diff --git a/.DS_Store b/.DS_Store index 9f9a6ce3..39a8a85c 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/.gitmodules b/.gitmodules index 6485e239..16b31eff 100644 --- a/.gitmodules +++ b/.gitmodules @@ -3,7 +3,7 @@ url = https://github.com/sqlcipher/sqlcipher.git [submodule "Signals"] path = Signals - url = https://github.com/peter-iakovlev/Signals.git +url=https://github.com/xingjun/Signals.git [submodule "MtProtoKit"] path = MtProtoKit - url = https://github.com/peter-iakovlev/MtProtoKit.git +url=https://github.com/xingjun/MtProtoKit.git diff --git a/ASCommon.m b/ASCommon.m index 4e596b6a..822a03ee 100644 --- a/ASCommon.m +++ b/ASCommon.m @@ -77,11 +77,11 @@ void TGLogToFilev(NSString *format, va_list args) { NSString *message = [[NSString alloc] initWithFormat:format arguments:args]; - BOOL result = [[NSProcessInfo processInfo].environment[@"console_logging"] boolValue]; + //BOOL result = [[NSProcessInfo processInfo].environment[@"console_logging"] boolValue]; - if(result) { + // if(result) { NSLog(@"%@", message); - } + // } dispatch_async(TGLogQueue(), ^ { diff --git a/MtProtoKit b/MtProtoKit index ba67798a..abd9e090 160000 --- a/MtProtoKit +++ b/MtProtoKit @@ -1 +1 @@ -Subproject commit ba67798afeec7944ef623ca195e348860ce3f45a +Subproject commit abd9e0902969ef3ca0c02c8e1d75b3618f393201 diff --git a/POPAnimator.mm b/POPAnimator.mm index 2addfba3..bb8dd541 100755 --- a/POPAnimator.mm +++ b/POPAnimator.mm @@ -462,8 +462,18 @@ - (void)_renderTime:(CFTimeInterval)time items:(std::list)it - (void)_renderTime:(CFTimeInterval)time item:(POPAnimatorItemRef)item { id obj = item->object; + POPAnimation *anim = item->animation; POPAnimationState *state = POPAnimationGetState(anim); + + + if([obj respondsToSelector:@selector(isHidden)] && [obj respondsToSelector:@selector(superview)] && [obj respondsToSelector:@selector(window)]) { + if([obj isHidden] || [obj superview] == nil || [obj window] == nil) { + [obj pop_removeAllAnimations]; + return; + } + } + if (nil == obj) { // object exists not; stop animating diff --git a/Signals b/Signals index 15243e33..c584b6bf 160000 --- a/Signals +++ b/Signals @@ -1 +1 @@ -Subproject commit 15243e33d7f595a3a062ebf6a3819e1987e66e1e +Subproject commit c584b6bf6bee4f17e9b63f68fc4ffb043665677a diff --git a/TGAnimationBlockDelegate.m b/TGAnimationBlockDelegate.m index c3215ee8..d4cee909 100644 --- a/TGAnimationBlockDelegate.m +++ b/TGAnimationBlockDelegate.m @@ -23,8 +23,21 @@ - (void)pop_animationDidStart:(POPAnimation *)anim { } -- (void)pop_animationDidStop:(POPAnimation *)anim finished:(BOOL)finished { - [self animationDidStop:nil finished:finished]; +- (void)pop_animationDidStop:(POPAnimation *)anim finished:(BOOL)flag { + CALayer *layer = _layer; + + if (flag) + { + if (_opacityOnCompletion != nil) + layer.opacity = [_opacityOnCompletion floatValue]; + } + if (_removeLayerOnCompletion) + [layer removeFromSuperlayer]; + + if (_completion) + _completion(flag); + + _completion = nil; } diff --git a/TGDatacenterWatchdogActor.m b/TGDatacenterWatchdogActor.m index 17d3a813..90d61719 100644 --- a/TGDatacenterWatchdogActor.m +++ b/TGDatacenterWatchdogActor.m @@ -158,7 +158,7 @@ - (void)processConfig:(TL_config *)config fromDatacenterId:(NSInteger)datacenter MTContext *context = [[MTNetwork instance] context]; setMaxChatUsers(config.chat_size_max-1); - setMaxBroadcastUsers(config.broadcast_size_max); + setMegagroupSizeMax(config.megagroup_size_max); #if TARGET_IPHONE_SIMULATOR NSMutableArray *dcOptions = [[NSMutableArray alloc] init]; diff --git a/TGModernAnimatedImagePlayer.h b/TGModernAnimatedImagePlayer.h index 00bd5e7a..5970523f 100644 --- a/TGModernAnimatedImagePlayer.h +++ b/TGModernAnimatedImagePlayer.h @@ -12,4 +12,6 @@ @property (nonatomic,assign) BOOL isPlaying; +-(NSImage *)poster; + @end diff --git a/TGModernAnimatedImagePlayer.m b/TGModernAnimatedImagePlayer.m index eb608c7f..0b07155f 100644 --- a/TGModernAnimatedImagePlayer.m +++ b/TGModernAnimatedImagePlayer.m @@ -81,4 +81,8 @@ - (void)pause _isPlaying = NO; } +-(NSImage *)poster { + return _image.posterImage; +} + @end diff --git a/TGShare/Info.plist b/TGShare/Info.plist index 687329fd..a5a19a54 100644 --- a/TGShare/Info.plist +++ b/TGShare/Info.plist @@ -9,7 +9,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - ru.keepcoder.Telegram.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName @@ -17,11 +17,11 @@ CFBundlePackageType XPC! CFBundleShortVersionString - 1.0 + 1.98 CFBundleSignature ???? CFBundleVersion - 1 + 33001 LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) NSExtension @@ -29,7 +29,22 @@ NSExtensionAttributes NSExtensionActivationRule - TRUEPREDICATE + + NSExtensionActivationSupportsAttachmentsWithMaxCount + 10 + NSExtensionActivationSupportsAttachmentsWithMinCount + 1 + NSExtensionActivationSupportsFileWithMaxCount + 10 + NSExtensionActivationSupportsImageWithMaxCount + 10 + NSExtensionActivationSupportsText + + NSExtensionActivationSupportsWebPageWithMaxCount + 1 + NSExtensionActivationSupportsWebURLWithMaxCount + 1 + NSExtensionPointIdentifier com.apple.share-services diff --git a/TGShare/ShareViewController.m b/TGShare/ShareViewController.m index 527c442c..e9d86392 100644 --- a/TGShare/ShareViewController.m +++ b/TGShare/ShareViewController.m @@ -85,6 +85,7 @@ @interface ShareViewController () @property (nonatomic,assign) BOOL isSearchActive; + @end @implementation ShareViewController @@ -273,13 +274,25 @@ -(void)loadNext { _isLocked = YES; - [TGS_RPCRequest sendRequest:[TLAPI_messages_getDialogs createWithOffset:(int)_items.count max_id:0 limit:100] successHandler:^(TGS_RPCRequest *request, TL_messages_dialogsSlice *response) { - + NSArray *items = [_tableView.list copy]; + + __block TGS_ConversationRowItem *rowItem = [items lastObject]; + + int date = 0; + + if([rowItem isKindOfClass:[TGS_ConversationRowItem class]]) { + date = rowItem.date; + } + + + [TGS_RPCRequest sendRequest:[TLAPI_messages_getDialogs createWithOffset_date:date offset_id:0 offset_peer:[TL_inputPeerEmpty create] limit:100] successHandler:^(TGS_RPCRequest *request, TL_messages_dialogsSlice *response) { NSMutableArray *items = [[NSMutableArray alloc] init]; [[response dialogs] enumerateObjectsUsingBlock:^(TLDialog *obj, NSUInteger idx, BOOL *stop) { + TLMessage *message = [[response.messages filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.n_id == %d",obj.top_message]] lastObject]; + TGS_ConversationRowItem *item; if([obj.peer isKindOfClass:[TL_peerChat class]]) { @@ -300,6 +313,8 @@ -(void)loadNext { item = [[TGS_ConversationRowItem alloc] initWithConversation:obj user:users[0]]; } } + + item.date = message.date; if(item) { [items addObject:item]; } diff --git a/TGShare/TGSEnterPasscodeView.m b/TGShare/TGSEnterPasscodeView.m index f327fc52..710bec6e 100644 --- a/TGShare/TGSEnterPasscodeView.m +++ b/TGShare/TGSEnterPasscodeView.m @@ -15,10 +15,12 @@ #import "TGS_MTNetwork.h" #import "TGImageView.h" #import "TGSImageObject.h" +#import "ShareViewController.h" @interface TGSEnterPasscodeView () @property (nonatomic,strong) NSSecureTextField *secureField; @property (nonatomic,strong) BTRButton *enterButton; @property (nonatomic,strong) TGImageView *avatar; +@property (nonatomic,strong) BTRButton *cancelButton; @end @implementation TGSEnterPasscodeView @@ -34,24 +36,24 @@ -(instancetype)initWithFrame:(NSRect)frameRect { - _avatar = [[TGImageView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)]; - - - [_avatar setCenterByView:self]; - - [_avatar setFrameOrigin:NSMakePoint(NSMinX(_avatar.frame), NSMinY(_avatar.frame) + 50)]; - - [self addSubview:_avatar]; - - TLUser *user = [ClassStore deserialize:[[TGSAppManager standartUserDefaults] objectForKey:@"selfUser"]]; - - TGSImageObject *imageObject = [[TGSImageObject alloc] initWithLocation:user.photo.photo_small]; - - imageObject.imageSize = NSMakeSize(100, 100); - - _avatar.object = imageObject; - - +// _avatar = [[TGImageView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)]; +// +// +// [_avatar setCenterByView:self]; +// +// [_avatar setFrameOrigin:NSMakePoint(NSMinX(_avatar.frame), NSMinY(_avatar.frame) + 50)]; +// +// [self addSubview:_avatar]; +// +// TLUser *user = [ClassStore deserialize:[[TGSAppManager standartUserDefaults] objectForKey:@"selfUser"]]; +// +// TGSImageObject *imageObject = [[TGSImageObject alloc] initWithLocation:user.photo.photo_small]; +// +// imageObject.imageSize = NSMakeSize(100, 100); +// +// _avatar.object = imageObject; +// +// self.backgroundColor = [NSColor whiteColor]; @@ -62,7 +64,7 @@ -(instancetype)initWithFrame:(NSRect)frameRect { [attrs appendString:NSLocalizedString(@"Passcode.EnterPlaceholder", nil) withColor:NSColorFromRGB(0xc8c8c8)]; - [attrs setAttributes:@{NSFontAttributeName:[NSFont fontWithName:@"HelveticaNeue" size:12]} range:attrs.range]; + [attrs setAttributes:@{NSFontAttributeName:TGSystemFont(12)} range:attrs.range]; [[self.secureField cell] setPlaceholderAttributedString:attrs]; @@ -93,12 +95,12 @@ -(instancetype)initWithFrame:(NSRect)frameRect { [self.secureField setAction:@selector(checkPassword)]; [self.secureField setTarget:self]; - [self.secureField setFont:[NSFont fontWithName:@"HelveticaNeue" size:14]]; + [self.secureField setFont:TGSystemFont(14)]; [self.secureField setTextColor:DARK_BLACK]; [self.secureField setCenterByView:self]; - [self.secureField setFrameOrigin:NSMakePoint(NSMinX(_secureField.frame), NSMinY(_secureField.frame) - 30)]; +// [self.secureField setFrameOrigin:NSMakePoint(NSMinX(_secureField.frame), NSMinY(_secureField.frame) - 30)]; [self addSubview:self.secureField]; @@ -121,6 +123,32 @@ -(instancetype)initWithFrame:(NSRect)frameRect { [self.enterButton setFrameOrigin:NSMakePoint(NSMaxX(self.secureField.frame) + 20, NSMinY(self.secureField.frame) + 3)]; [self addSubview:self.enterButton]; + + + + _cancelButton = [[BTRButton alloc] initWithFrame:NSMakeRect(NSWidth(_cancelButton.frame), 0, NSWidth(self.frame), 50)]; + + _cancelButton.layer.backgroundColor = [NSColor whiteColor].CGColor; + + [_cancelButton setTitleColor:LINK_COLOR forControlState:BTRControlStateNormal]; + + [_cancelButton setTitle:NSLocalizedString(@"Cancel", nil) forControlState:BTRControlStateNormal]; + + [_cancelButton addBlock:^(BTRControlEvents events) { + + [ShareViewController close]; + + + } forControlEvents:BTRControlEventClick]; + + [self addSubview:_cancelButton]; + + TMView *topSeparator = [[TMView alloc] initWithFrame:NSMakeRect(0, 49, NSWidth(self.frame), DIALOG_BORDER_WIDTH)]; + + topSeparator.backgroundColor = DIALOG_BORDER_COLOR; + + [self addSubview:topSeparator]; + } return self; diff --git a/TGShare/TGSKeychain.h b/TGShare/TGSKeychain.h new file mode 100644 index 00000000..3af01b87 --- /dev/null +++ b/TGShare/TGSKeychain.h @@ -0,0 +1,13 @@ +// +// TGSKeychain.h +// Telegram +// +// Created by keepcoder on 03.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TGKeychain.h" + +@interface TGSKeychain : TGKeychain + +@end diff --git a/TGShare/TGSKeychain.m b/TGShare/TGSKeychain.m new file mode 100644 index 00000000..7f6b46af --- /dev/null +++ b/TGShare/TGSKeychain.m @@ -0,0 +1,17 @@ +// +// TGSKeychain.m +// Telegram +// +// Created by keepcoder on 03.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TGSKeychain.h" + +@implementation TGSKeychain + +- (void)_storeKeychain:(NSString *)group { + +} + +@end diff --git a/TGShare/TGSModalSenderView.m b/TGShare/TGSModalSenderView.m index c032e543..bf063a3f 100644 --- a/TGShare/TGSModalSenderView.m +++ b/TGShare/TGSModalSenderView.m @@ -11,8 +11,8 @@ #import "ImageUtils.h" #import "NSViewCategory.h" #import "TGLinearProgressView.h" - - +#import "BTRButton.h" +#import "ShareViewController.h" @interface TGSModalSenderView () { @@ -32,7 +32,7 @@ @interface TGSModalSenderView () @property (nonatomic,strong) NSTextField *sharingTextField; - +@property (nonatomic,strong) BTRButton *cancelButton; @end @implementation TGSModalSenderView @@ -68,6 +68,38 @@ -(instancetype)initWithFrame:(NSRect)frameRect { [self addSubview:_containerView]; + _cancelButton = [[BTRButton alloc] initWithFrame:NSMakeRect(0, 0, NSWidth(_containerView.frame), 50)]; + + _cancelButton.layer.backgroundColor = [NSColor whiteColor].CGColor; + + [_cancelButton setTitleColor:LINK_COLOR forControlState:BTRControlStateNormal]; + + [_cancelButton setTitle:NSLocalizedString(@"Cancel", nil) forControlState:BTRControlStateNormal]; + + + weak(); + + [_cancelButton addBlock:^(BTRControlEvents events) { + + [weakSelf cleanup]; + + [ShareViewController close]; + + + } forControlEvents:BTRControlEventClick]; + + + TMView *topSeparator = [[TMView alloc] initWithFrame:NSMakeRect(0, 49, NSWidth(_containerView.frame), DIALOG_BORDER_WIDTH)]; + + topSeparator.backgroundColor = DIALOG_BORDER_COLOR; + + + + [self.containerView addSubview:_cancelButton]; + + [self.containerView addSubview:topSeparator]; + + _sharingTextField = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, NSWidth(_containerView.frame) - 20, 20)]; [_sharingTextField setCenterByView:_containerView]; @@ -94,6 +126,9 @@ -(instancetype)initWithFrame:(NSRect)frameRect { [_containerView addSubview:_progressView]; + + + } return self; @@ -115,14 +150,13 @@ -(void)sendItems:(NSArray *)shareItems rowItems:(NSArray *)rowItems completionHa _ts_count = (int) obj.attachments.count * (int) rowItems.count; - if(obj.attachments.count == 0 && obj.attributedContentText.length > 0) { + if(obj.attributedContentText.length > 0) { - _ts_count = 1 * (int) rowItems.count; + _ts_count+= 1 * (int) rowItems.count; [_rowItems enumerateObjectsUsingBlock:^(id rowItem, NSUInteger idx, BOOL *stop) { [self sendAsMessage:obj.attributedContentText.string rowItem:rowItem]; }]; - return; } @@ -200,7 +234,7 @@ -(void)performMediaRequest:(id)media rowItem:(TGS_ConversationRowItem *)rowItem _cs_count++; - id request = [TGS_RPCRequest sendRequest:[TLAPI_messages_sendMedia createWithFlags:0 peer:[self inputPeer:rowItem] reply_to_msg_id:0 media:media random_id:rand_long()] successHandler:^(id request, TLUpdates *response) { + id request = [TGS_RPCRequest sendRequest:[TLAPI_messages_sendMedia createWithFlags:0 peer:[self inputPeer:rowItem] reply_to_msg_id:0 media:media random_id:rand_long() reply_markup:nil] successHandler:^(id request, TLUpdates *response) { _sent_count++; @@ -289,7 +323,7 @@ -(void)sendAsMessage:(NSString *)message rowItem:(TGS_ConversationRowItem *)rowI [self updateProgress:30]; }]; - id request = [TGS_RPCRequest sendRequest:[TLAPI_messages_sendMessage createWithFlags:0 peer:[self inputPeer:rowItem] reply_to_msg_id:0 message:message random_id:rand_long()] successHandler:^(TGS_RPCRequest *request, id response) { + id request = [TGS_RPCRequest sendRequest:[TLAPI_messages_sendMessage createWithFlags:0 peer:[self inputPeer:rowItem] reply_to_msg_id:0 message:message random_id:rand_long() reply_markup:nil entities:nil] successHandler:^(TGS_RPCRequest *request, id response) { _cs_count++; @@ -315,15 +349,8 @@ -(id)inputPeer:(TGS_ConversationRowItem *)rowItem { input = [TL_inputPeerChat createWithChat_id:rowItem.chat.n_id]; } else { - if([rowItem.user isKindOfClass:[TL_userContact class]]) { - input = [TL_inputPeerContact createWithUser_id:rowItem.user.n_id]; - } else if([rowItem.user isKindOfClass:[TL_userDeleted class]] || [rowItem.user isKindOfClass:[TL_userEmpty class]]) { - input = [TL_inputPeerEmpty create]; - } else if([rowItem.user isKindOfClass:[TL_userForeign class]] || [rowItem.user isKindOfClass:[TL_userRequest class]]) { - input = [TL_inputPeerForeign createWithUser_id:rowItem.user.n_id access_hash:rowItem.user.access_hash]; - } else if([rowItem.user isKindOfClass:[TL_userSelf class]]) { - input = [TL_inputPeerSelf create]; - } + return [TL_inputPeerUser createWithUser_id:rowItem.user.n_id access_hash:rowItem.user.access_hash]; + } if(!input) return [TL_inputPeerEmpty create]; diff --git a/TGShare/TGS_ConversationRowItem.h b/TGShare/TGS_ConversationRowItem.h index 100545c9..b004f2c1 100644 --- a/TGShare/TGS_ConversationRowItem.h +++ b/TGShare/TGS_ConversationRowItem.h @@ -14,6 +14,7 @@ @property (nonatomic,strong,readonly) TLUser *user; @property (nonatomic,strong,readonly) TLChat *chat; +@property (nonatomic,assign) int date; @property (nonatomic,strong,readonly) NSAttributedString *name; diff --git a/TGShare/TGS_ConversationRowItem.m b/TGShare/TGS_ConversationRowItem.m index f03ee0d1..e367888e 100644 --- a/TGShare/TGS_ConversationRowItem.m +++ b/TGShare/TGS_ConversationRowItem.m @@ -11,6 +11,9 @@ #import "TMAttributedString.h" #import "TGS_MTNetwork.h" #import "TGDateUtils.h" + + + @implementation TGS_ConversationRowItem -(id)initWithConversation:(TLDialog *)conversation user:(TLUser *)user { @@ -37,6 +40,13 @@ -(id)initWithConversation:(TLDialog *)conversation chat:(TLChat *)chat { -(void)configure { NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] init]; + + if(!_user.first_name) + _user.first_name = @""; + + if(!_user.last_name) + _user.last_name = @""; + [attr appendString:_user ? [NSString stringWithFormat:@"%@ %@",_user.first_name, _user.last_name] : _chat.title withColor:NSColorFromRGB(0x000000)]; diff --git a/TGShare/TGS_MTNetwork.h b/TGShare/TGS_MTNetwork.h index f5bc2595..4274fef4 100644 --- a/TGShare/TGS_MTNetwork.h +++ b/TGShare/TGS_MTNetwork.h @@ -21,7 +21,7 @@ -(void)sendRequest:(TGS_RPCRequest *)request forDatacenter:(int)datacenterId; -(void)sendRandomRequest:(TGS_RPCRequest *)request; -(MTDatacenterAuthInfo *)authInfoForDatacenter:(int)dc_id; --(MTKeychain *)keyChain; +-(id)keyChain; -(void)successAuthForDatacenter:(int)dc_id; -(BOOL)isAuth; -(int)getTime; diff --git a/TGShare/TGS_MTNetwork.m b/TGShare/TGS_MTNetwork.m index 1d5bdadc..599b5158 100644 --- a/TGShare/TGS_MTNetwork.m +++ b/TGShare/TGS_MTNetwork.m @@ -10,7 +10,7 @@ #import #import "TGDatacenterWatchdogActor.h" #import "TGTimer.h" -#import "TGKeychain.h" +#import "TGSKeychain.h" #import "NSData+Extensions.h" #import "NSMutableData+Extension.h" @@ -20,6 +20,7 @@ #import "TLApi.h" #import "CMath.h" #import "TGSAppManager.h" +#import "TGSKeychain.h" @implementation MTRequest (LegacyTL) - (void)setBody:(TLApiObject *)body @@ -65,7 +66,7 @@ @interface TGS_MTNetwork () ASQueue *_queue; TGTimer *_globalTimer; NSMutableArray *_dispatchTimers; - TGKeychain *_keychain; + TGSKeychain *_keychain; } @end @@ -207,7 +208,7 @@ -(void)moveAndEncryptKeychain { if(isset) { - TGKeychain *keychain = [self nKeychain]; + TGSKeychain *keychain = [self nKeychain]; [keychain setNotEncryptedKeychain:YES]; @@ -229,8 +230,8 @@ -(MTQueue *)queue { return [_mtProto messageServiceQueue]; } --(TGKeychain *)nKeychain { - return [TGKeychain keychainWithName:@"ru.keepcoder.telegram"]; +-(TGSKeychain *)nKeychain { + return [TGSKeychain keychainWithName:@"ru.keepcoder.telegram"]; } @@ -238,7 +239,7 @@ -(void)updatePasscode:(NSData *)md5Hash { [_queue dispatchOnQueue:^{ - TGKeychain *keychain = (TGKeychain *)_keychain; + TGSKeychain *keychain = (TGSKeychain *)_keychain; [keychain updatePasscodeHash:md5Hash save:YES]; @@ -253,7 +254,7 @@ -(BOOL)checkPasscode:(NSData *)md5Hash { [_queue dispatchOnQueue:^{ - TGKeychain *keychain = (TGKeychain *)_keychain; + TGSKeychain *keychain = (TGSKeychain *)_keychain; result = [md5Hash isEqualToData:[keychain md5PasscodeHash]]; @@ -269,7 +270,7 @@ -(BOOL)passcodeIsEnabled { [_queue dispatchOnQueue:^{ - TGKeychain *keychain = (TGKeychain *)_keychain; + TGSKeychain *keychain = (TGSKeychain *)_keychain; result = [keychain passcodeIsEnabled]; @@ -280,7 +281,7 @@ -(BOOL)passcodeIsEnabled { } --(void)startWithKeychain:(TGKeychain *)keychain { +-(void)startWithKeychain:(TGSKeychain *)keychain { [_context setKeychain:keychain]; @@ -295,10 +296,9 @@ -(void)startWithKeychain:(TGKeychain *)keychain { _datacenterCount = 5; - NSString *address = @"149.154.175.50"; - - [_context setSeedAddressSetForDatacenterWithId:1 seedAddressSet:[[MTDatacenterAddressSet alloc] initWithAddressList:@[[[MTDatacenterAddress alloc] initWithIp:address port:443]]]]; + NSString *address = @"149.154.167.51"; + [_context setSeedAddressSetForDatacenterWithId:2 seedAddressSet:[[MTDatacenterAddressSet alloc] initWithAddressList:@[[[MTDatacenterAddress alloc] initWithIp:address port:443 preferForMedia:NO]]]]; } @@ -379,7 +379,7 @@ -(int)getUserId { return [[_keychain objectForKey:@"user_id" group:@"persistent"] intValue]; } --(MTKeychain *)keyChain { +-(id)keyChain { return _context.keychain; } diff --git a/TGShare/TGShare.entitlements b/TGShare/TGShare.entitlements index e74a9032..01168b97 100644 --- a/TGShare/TGShare.entitlements +++ b/TGShare/TGShare.entitlements @@ -4,17 +4,12 @@ com.apple.security.app-sandbox - com.apple.security.application-groups - - group.ru.keepcoder.Telegram - com.apple.security.files.user-selected.read-only com.apple.security.network.client keychain-access-groups - $(AppIdentifierPrefix)ru.keepcoder.Telegram.TGShare $(AppIdentifierPrefix)ru.keepcoder.Telegram diff --git a/TGShare/de.lproj/Localizable.strings b/TGShare/de.lproj/Localizable.strings index 767c3d44..2091b420 100644 Binary files a/TGShare/de.lproj/Localizable.strings and b/TGShare/de.lproj/Localizable.strings differ diff --git a/TGShare/en.lproj/Localizable.strings b/TGShare/en.lproj/Localizable.strings index e122cc0f..1ee39d32 100644 --- a/TGShare/en.lproj/Localizable.strings +++ b/TGShare/en.lproj/Localizable.strings @@ -7,7 +7,7 @@ */ "Search" = "Search"; "Passcode.EnterPlaceholder" = "Enter passcode"; -"NoAuthDescription" = "Sorry. You need login from main application to use share menu."; +"NoAuthDescription" = "Sorry. Please login to the Telegram application to use the sharing menu."; "Time.at" = "at"; "Time.last_seen" = "last seen"; diff --git a/TGShare/es.lproj/Localizable.strings b/TGShare/es.lproj/Localizable.strings index 767c3d44..991700da 100644 Binary files a/TGShare/es.lproj/Localizable.strings and b/TGShare/es.lproj/Localizable.strings differ diff --git a/TGShare/it.lproj/Localizable.strings b/TGShare/it.lproj/Localizable.strings index 767c3d44..84a7935e 100644 Binary files a/TGShare/it.lproj/Localizable.strings and b/TGShare/it.lproj/Localizable.strings differ diff --git a/TGShare/nl.lproj/Localizable.strings b/TGShare/nl.lproj/Localizable.strings index 767c3d44..f01da979 100644 Binary files a/TGShare/nl.lproj/Localizable.strings and b/TGShare/nl.lproj/Localizable.strings differ diff --git a/TGTimer.h b/TGTimer.h index 989ae320..479fbd1f 100644 --- a/TGTimer.h +++ b/TGTimer.h @@ -12,7 +12,12 @@ @property (nonatomic) NSTimeInterval timeoutDate; +@property (nonatomic,strong) id reservedObject; + - (id)initWithTimeout:(NSTimeInterval)timeout repeat:(bool)repeat completion:(dispatch_block_t)completion queue:(dispatch_queue_t)queue; + +- (id)initWithTimeout:(NSTimeInterval)timeout repeat:(bool)repeat completion:(dispatch_block_t)completion queue:(dispatch_queue_t)queue reservedObject:(id)object; + - (void)start; - (void)fireAndInvalidate; - (void)fire; diff --git a/TGTimer.m b/TGTimer.m index bc1295f0..f071491f 100644 --- a/TGTimer.m +++ b/TGTimer.m @@ -53,6 +53,14 @@ - (id)initWithTimeout:(NSTimeInterval)timeout repeat:(bool)repeat completion:(di return self; } +- (id)initWithTimeout:(NSTimeInterval)timeout repeat:(bool)repeat completion:(dispatch_block_t)completion queue:(dispatch_queue_t)queue reservedObject:(id)object { + if(self = [self initWithTimeout:timeout repeat:repeat completion:completion queue:queue]) { + _reservedObject = [object copy]; + } + + return self; +} + - (void)dealloc { if (_timer != nil) diff --git a/Telegram.entitlements b/Telegram.entitlements index 098ae523..8bc35006 100644 --- a/Telegram.entitlements +++ b/Telegram.entitlements @@ -20,5 +20,9 @@ com.apple.security.personal-information.location + keychain-access-groups + + $(AppIdentifierPrefix)ru.keepcoder.Telegram + diff --git a/Telegram.xcodeproj/project.pbxproj b/Telegram.xcodeproj/project.pbxproj index 53e96372..3846b401 100644 --- a/Telegram.xcodeproj/project.pbxproj +++ b/Telegram.xcodeproj/project.pbxproj @@ -21,7 +21,6 @@ 0A241A9D18AB176B00C32F45 /* MessageTableCellTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A241A9C18AB176B00C32F45 /* MessageTableCellTextView.m */; }; 0A241AA018AB2F5900C32F45 /* MessageTableCellPhotoView.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A241A9F18AB2F5900C32F45 /* MessageTableCellPhotoView.m */; }; 0A241AA318AB2FF200C32F45 /* MessageTableItemPhoto.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A241AA218AB2FF200C32F45 /* MessageTableItemPhoto.m */; }; - 0A241AA618AB60BA00C32F45 /* TMGLGif.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A241AA518AB60BA00C32F45 /* TMGLGif.m */; }; 0A241AAE18ACD39700C32F45 /* MessageTableCellVideoView.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A241AAD18ACD39700C32F45 /* MessageTableCellVideoView.m */; }; 0A241AB118ACD46700C32F45 /* MessageTableItemVideo.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A241AB018ACD46700C32F45 /* MessageTableItemVideo.m */; }; 0A2576A5181D09E500FB386C /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A2576A4181D09E500FB386C /* SystemConfiguration.framework */; }; @@ -154,7 +153,6 @@ 0AACA3F618B752C000621564 /* TMTextButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 0AACA3F518B752C000621564 /* TMTextButton.m */; }; 0AB43B8B18D2FBC400FB805A /* RegistrationViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0AB43B8A18D2FBC400FB805A /* RegistrationViewController.m */; }; 0AB43B9218D304C400FB805A /* RegistrationAvatarView.m in Sources */ = {isa = PBXBuildFile; fileRef = 0AB43B9118D304C400FB805A /* RegistrationAvatarView.m */; }; - 0AB43B9E18D43DC000FB805A /* TMGifImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 0AB43B9D18D43DC000FB805A /* TMGifImageView.m */; }; 0AB43BA518D44A1C00FB805A /* GifAnimationLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 0AB43BA418D44A1C00FB805A /* GifAnimationLayer.m */; }; 0AB43BA818D4D60B00FB805A /* MessageInputGrowingTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 0AB43BA718D4D60B00FB805A /* MessageInputGrowingTextView.m */; }; 0AB43BAB18D4F1FF00FB805A /* TMImagePicker.m in Sources */ = {isa = PBXBuildFile; fileRef = 0AB43BAA18D4F1FF00FB805A /* TMImagePicker.m */; }; @@ -212,20 +210,49 @@ 0AF4F4AA189D5C72004BA4DF /* MessageTableItemServiceMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = 0AF4F4A9189D5C72004BA4DF /* MessageTableItemServiceMessage.m */; }; 0AF4F4AD189D5CD5004BA4DF /* MessageTableCellServiceMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = 0AF4F4AC189D5CD5004BA4DF /* MessageTableCellServiceMessage.m */; }; 0AFE39FD18ED752D0014B525 /* MessageTableItemGif.m in Sources */ = {isa = PBXBuildFile; fileRef = 0AFE39FC18ED752D0014B525 /* MessageTableItemGif.m */; }; + 8AF787F21C57047600DC72E6 /* MtProtoKitMac.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C2D8261D1B6FA8A600434D37 /* MtProtoKitMac.framework */; }; + 8AF788921C570B6500DC72E6 /* SSignalKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C26E80171B7B748A003CC483 /* SSignalKit.framework */; }; C2002D0319990F10002A1915 /* BroadcastInfoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C2002D0219990F10002A1915 /* BroadcastInfoViewController.m */; }; C2002D0619994D7A002A1915 /* BroadcastInfoHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = C2002D0519994D7A002A1915 /* BroadcastInfoHeaderView.m */; }; C202D96718E9D67A0060238B /* TMClickTextFieldView.m in Sources */ = {isa = PBXBuildFile; fileRef = C202D96618E9D67A0060238B /* TMClickTextFieldView.m */; }; C20932241938BABF00DFF3EC /* AudioHistoryFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = C20932231938BABF00DFF3EC /* AudioHistoryFilter.m */; }; + C20A5E711B86290C007F4B49 /* TGWebpageGifObject.m in Sources */ = {isa = PBXBuildFile; fileRef = C20A5E701B86290C007F4B49 /* TGWebpageGifObject.m */; }; + C20A5E831B863979007F4B49 /* TGWebpageGifContainer.m in Sources */ = {isa = PBXBuildFile; fileRef = C20A5E821B863979007F4B49 /* TGWebpageGifContainer.m */; }; + C20A5E8F1B86404D007F4B49 /* DownloadCacheDocumentItem.m in Sources */ = {isa = PBXBuildFile; fileRef = C20A5E8E1B86404D007F4B49 /* DownloadCacheDocumentItem.m */; }; + C20A5EA71B86625F007F4B49 /* TGUpdateChannels.m in Sources */ = {isa = PBXBuildFile; fileRef = C20A5EA61B86625F007F4B49 /* TGUpdateChannels.m */; }; + C20A5EB31B871ABA007F4B49 /* TGUpdateChannelContainer.m in Sources */ = {isa = PBXBuildFile; fileRef = C20A5EB21B871ABA007F4B49 /* TGUpdateChannelContainer.m */; }; + C20A5EB61B873944007F4B49 /* TL_localMessage_old34.m in Sources */ = {isa = PBXBuildFile; fileRef = C20A5EB51B873944007F4B49 /* TL_localMessage_old34.m */; }; + C20A5EBA1B874890007F4B49 /* ChannelInfoHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = C20A5EB91B874890007F4B49 /* ChannelInfoHeaderView.m */; }; + C20A5EBD1B8748A3007F4B49 /* ChannelInfoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C20A5EBC1B8748A3007F4B49 /* ChannelInfoViewController.m */; }; + C20A5EC31B878E7C007F4B49 /* TL_channelConversation.m in Sources */ = {isa = PBXBuildFile; fileRef = C20A5EC21B878E7C007F4B49 /* TL_channelConversation.m */; }; + C20A5ECF1B8B67D7007F4B49 /* TL_conversation_old34.m in Sources */ = {isa = PBXBuildFile; fileRef = C20A5ECE1B8B67D7007F4B49 /* TL_conversation_old34.m */; }; + C20A5EDB1B8B7A81007F4B49 /* TGModernConversationHistoryController.m in Sources */ = {isa = PBXBuildFile; fileRef = C20A5EDA1B8B7A81007F4B49 /* TGModernConversationHistoryController.m */; }; + C20A5EDF1B8B8905007F4B49 /* TGObservableObject.m in Sources */ = {isa = PBXBuildFile; fileRef = C20A5EDE1B8B8905007F4B49 /* TGObservableObject.m */; }; + C20A5EE31B8CC19C007F4B49 /* TGDispatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = C20A5EE21B8CC19C007F4B49 /* TGDispatcher.m */; }; + C20A5EE61B8CC813007F4B49 /* TGEvent.m in Sources */ = {isa = PBXBuildFile; fileRef = C20A5EE51B8CC813007F4B49 /* TGEvent.m */; }; + C20A5EEC1B8CD8B8007F4B49 /* AddContactView.m in Sources */ = {isa = PBXBuildFile; fileRef = C20A5EE91B8CD8B8007F4B49 /* AddContactView.m */; }; + C20A5EED1B8CD8B9007F4B49 /* AddContactViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C20A5EEB1B8CD8B8007F4B49 /* AddContactViewController.m */; }; + C20A5EF01B8CD8CB007F4B49 /* TMBlueInputTextField.m in Sources */ = {isa = PBXBuildFile; fileRef = C20A5EEF1B8CD8CB007F4B49 /* TMBlueInputTextField.m */; }; + C20A5EF31B8CEE8E007F4B49 /* ChannelFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = C20A5EF21B8CEE8E007F4B49 /* ChannelFilter.m */; }; + C20A5F351B8F4579007F4B49 /* TGChannelsPolling.m in Sources */ = {isa = PBXBuildFile; fileRef = C20A5F341B8F4579007F4B49 /* TGChannelsPolling.m */; }; + C20A5F471B8F6863007F4B49 /* TGMessageHole.m in Sources */ = {isa = PBXBuildFile; fileRef = C20A5F461B8F6863007F4B49 /* TGMessageHole.m */; }; + C20A5F531B8F6CC3007F4B49 /* MessageTableItemHole.m in Sources */ = {isa = PBXBuildFile; fileRef = C20A5F521B8F6CC3007F4B49 /* MessageTableItemHole.m */; }; + C20A5F561B8F6CDD007F4B49 /* MessageTableCellHoleView.m in Sources */ = {isa = PBXBuildFile; fileRef = C20A5F551B8F6CDD007F4B49 /* MessageTableCellHoleView.m */; }; + C20A5F591B8F8B2B007F4B49 /* TGHistoryResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = C20A5F581B8F8B2B007F4B49 /* TGHistoryResponse.m */; }; + C20A5F5C1B90D815007F4B49 /* TGMessageGroupHole.m in Sources */ = {isa = PBXBuildFile; fileRef = C20A5F5B1B90D815007F4B49 /* TGMessageGroupHole.m */; }; + C20A5F5F1B9330CD007F4B49 /* ChannelImportantFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = C20A5F5E1B9330CD007F4B49 /* ChannelImportantFilter.m */; }; C20A7E5C19D7064D008844F2 /* TGDatacenterWatchdogActor.m in Sources */ = {isa = PBXBuildFile; fileRef = C20A7E5B19D7064D008844F2 /* TGDatacenterWatchdogActor.m */; }; C20A7E5F19D7069C008844F2 /* TGActor.m in Sources */ = {isa = PBXBuildFile; fileRef = C20A7E5E19D7069C008844F2 /* TGActor.m */; }; C20A7E6219D706D0008844F2 /* ASActor.m in Sources */ = {isa = PBXBuildFile; fileRef = C20A7E6119D706D0008844F2 /* ASActor.m */; }; C20A7E7519DAAF51008844F2 /* CoreText.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C20A7E7419DAAF51008844F2 /* CoreText.framework */; }; C20A7E7C19DC1379008844F2 /* TGCTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = C20A7E7B19DC1379008844F2 /* TGCTextView.m */; }; C20A7E7E19DC1816008844F2 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C20A7E7D19DC1816008844F2 /* CoreGraphics.framework */; }; - C20A7E8019DC1887008844F2 /* ImageIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C20A7E7F19DC1887008844F2 /* ImageIO.framework */; }; C20B228818E971D0007BCCD6 /* bitwise.c in Sources */ = {isa = PBXBuildFile; fileRef = C20B228418E971D0007BCCD6 /* bitwise.c */; }; C20B228918E971D0007BCCD6 /* framing.c in Sources */ = {isa = PBXBuildFile; fileRef = C20B228518E971D0007BCCD6 /* framing.c */; }; C20B228D18E98A2C007BCCD6 /* SettingsArchiver.m in Sources */ = {isa = PBXBuildFile; fileRef = C20B228C18E98A2C007BCCD6 /* SettingsArchiver.m */; }; + C20B82A11BD98EC700EF01AD /* TGPVDocumentsBehavior.m in Sources */ = {isa = PBXBuildFile; fileRef = C20B82A01BD98EC700EF01AD /* TGPVDocumentsBehavior.m */; }; + C20B82AD1BDA550600EF01AD /* TGChatHeadLockView.m in Sources */ = {isa = PBXBuildFile; fileRef = C20B82AC1BDA550600EF01AD /* TGChatHeadLockView.m */; }; + C20B82B01BDA975500EF01AD /* TGShareContactModalView.m in Sources */ = {isa = PBXBuildFile; fileRef = C20B82AF1BDA975500EF01AD /* TGShareContactModalView.m */; }; C20BA5DC1B0BB992001ECE22 /* TGSNoAuthModalView.m in Sources */ = {isa = PBXBuildFile; fileRef = C20BA5DB1B0BB992001ECE22 /* TGSNoAuthModalView.m */; }; C20BA5DF1B0BBE85001ECE22 /* TGSAppManager.m in Sources */ = {isa = PBXBuildFile; fileRef = C20BA5DE1B0BBE85001ECE22 /* TGSAppManager.m */; }; C20BA5E21B0BCC04001ECE22 /* TGSEnterPasscodeView.m in Sources */ = {isa = PBXBuildFile; fileRef = C20BA5E11B0BCC04001ECE22 /* TGSEnterPasscodeView.m */; }; @@ -236,6 +263,8 @@ C20D18EC1948A3F70095A906 /* NewMainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = C20D18EE1948A3F70095A906 /* NewMainMenu.xib */; }; C20D18F81948D1FE0095A906 /* SecretChatAccepter.m in Sources */ = {isa = PBXBuildFile; fileRef = C20D18F71948D1FE0095A906 /* SecretChatAccepter.m */; }; C20D190219542AB80095A906 /* SearchHistoryFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = C20D190119542AB80095A906 /* SearchHistoryFilter.m */; }; + C20F76E91BB994A6003A1E86 /* TGModernUserViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C20F76E81BB994A6003A1E86 /* TGModernUserViewController.m */; }; + C20F76ED1BBAC41A003A1E86 /* TGMessagesHintView.m in Sources */ = {isa = PBXBuildFile; fileRef = C20F76EC1BBAC41A003A1E86 /* TGMessagesHintView.m */; }; C2182BBE19589246002469CA /* TL_localMessageService.m in Sources */ = {isa = PBXBuildFile; fileRef = C2182BBD19589246002469CA /* TL_localMessageService.m */; }; C21C7B2C18D7044600253A7A /* MessageSenderItem.m in Sources */ = {isa = PBXBuildFile; fileRef = C21C7B2B18D7044600253A7A /* MessageSenderItem.m */; }; C21C7B2F18D7334D00253A7A /* MessageSenderSecretItem.m in Sources */ = {isa = PBXBuildFile; fileRef = C21C7B2E18D7334D00253A7A /* MessageSenderSecretItem.m */; }; @@ -269,14 +298,11 @@ C22019FC192CC82900C0E441 /* SelectUsersTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = C22019FB192CC82900C0E441 /* SelectUsersTableView.m */; }; C2201A00192CCB5C00C0E441 /* SelectUserItem.m in Sources */ = {isa = PBXBuildFile; fileRef = C22019FF192CCB5C00C0E441 /* SelectUserItem.m */; }; C2201A03192CCB6C00C0E441 /* SelectUserRowView.m in Sources */ = {isa = PBXBuildFile; fileRef = C2201A02192CCB6C00C0E441 /* SelectUserRowView.m */; }; - C2201A06192E488D00C0E441 /* AddContactView.m in Sources */ = {isa = PBXBuildFile; fileRef = C2201A05192E488D00C0E441 /* AddContactView.m */; }; - C2201A0A192E4AAA00C0E441 /* TMBlueInputTextField.m in Sources */ = {isa = PBXBuildFile; fileRef = C2201A09192E4AAA00C0E441 /* TMBlueInputTextField.m */; }; C2201A0D1934E6D600C0E441 /* DownloadPart.m in Sources */ = {isa = PBXBuildFile; fileRef = C2201A0C1934E6D600C0E441 /* DownloadPart.m */; }; C222773218FC2CA4002AA0F6 /* MessageTableItemUnreadMark.m in Sources */ = {isa = PBXBuildFile; fileRef = C222773118FC2CA4002AA0F6 /* MessageTableItemUnreadMark.m */; }; C222773518FC2DDA002AA0F6 /* MessageTableCellUnreadMarkView.m in Sources */ = {isa = PBXBuildFile; fileRef = C222773418FC2DDA002AA0F6 /* MessageTableCellUnreadMarkView.m */; }; C222774218FE8BB3002AA0F6 /* ChatHistoryController.m in Sources */ = {isa = PBXBuildFile; fileRef = C222774118FE8BB3002AA0F6 /* ChatHistoryController.m */; }; C222774E19093C8C002AA0F6 /* TMBottomScrollView.m in Sources */ = {isa = PBXBuildFile; fileRef = C222774D19093C8C002AA0F6 /* TMBottomScrollView.m */; }; - C2227752190E564B002AA0F6 /* OnlineNotificationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = C2227751190E564B002AA0F6 /* OnlineNotificationManager.m */; }; C2227759190E7309002AA0F6 /* TMTaskRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = C2227758190E7309002AA0F6 /* TMTaskRequest.m */; }; C222AB321A08FF2B00BEF907 /* PhotoCollectionTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = C222AB311A08FF2B00BEF907 /* PhotoCollectionTableView.m */; }; C222AB361A0901DC00BEF907 /* PhotoTableItem.m in Sources */ = {isa = PBXBuildFile; fileRef = C222AB351A0901DC00BEF907 /* PhotoTableItem.m */; }; @@ -299,10 +325,6 @@ C23298D718CF5FC7000826E5 /* QuickLook.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C23298D618CF5FC7000826E5 /* QuickLook.framework */; }; C23298DB18CF61AE000826E5 /* TMPreviewPhotoItem.m in Sources */ = {isa = PBXBuildFile; fileRef = C23298DA18CF61AE000826E5 /* TMPreviewPhotoItem.m */; }; C23298DE18CF61DD000826E5 /* TMMediaController.mm in Sources */ = {isa = PBXBuildFile; fileRef = C23298DD18CF61DD000826E5 /* TMMediaController.mm */; }; - C233FB2818B610E9008C9A96 /* NewConversationViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C233FB2718B610E9008C9A96 /* NewConversationViewController.m */; }; - C233FB2B18B6126C008C9A96 /* NewConversationTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = C233FB2A18B6126C008C9A96 /* NewConversationTableView.m */; }; - C233FB2E18B61415008C9A96 /* NewConversationRowItem.m in Sources */ = {isa = PBXBuildFile; fileRef = C233FB2D18B61415008C9A96 /* NewConversationRowItem.m */; }; - C233FB3118B61618008C9A96 /* NewConversationRowView.m in Sources */ = {isa = PBXBuildFile; fileRef = C233FB3018B61618008C9A96 /* NewConversationRowView.m */; }; C233FB3418B661B6008C9A96 /* TMCheckBox.m in Sources */ = {isa = PBXBuildFile; fileRef = C233FB3318B661B6008C9A96 /* TMCheckBox.m */; }; C235365919C8B4320044978E /* UserCardViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C235365819C8B4320044978E /* UserCardViewController.m */; }; C23536A819CB1A430044978E /* FFYDaemonController.m in Sources */ = {isa = PBXBuildFile; fileRef = C23536A719CB1A430044978E /* FFYDaemonController.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; @@ -357,6 +379,8 @@ C256E91718D22622008FFA04 /* DownloadDocumentItem.m in Sources */ = {isa = PBXBuildFile; fileRef = C256E91618D22622008FFA04 /* DownloadDocumentItem.m */; }; C256E91A18D24C4C008FFA04 /* DownloadAudioItem.m in Sources */ = {isa = PBXBuildFile; fileRef = C256E91918D24C4C008FFA04 /* DownloadAudioItem.m */; }; C256E91D18D25324008FFA04 /* TMPreviewAudioItem.m in Sources */ = {isa = PBXBuildFile; fileRef = C256E91C18D25324008FFA04 /* TMPreviewAudioItem.m */; }; + C25A57E01C072D1D0038169F /* ComposeActionStickersBehavior.m in Sources */ = {isa = PBXBuildFile; fileRef = C25A57DF1C072D1D0038169F /* ComposeActionStickersBehavior.m */; }; + C25A57EC1C0736D70038169F /* TGMovableTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = C25A57EB1C0736D70038169F /* TGMovableTableView.m */; }; C25F91B31977E115006868F3 /* TGImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = C25F91B21977E115006868F3 /* TGImageView.m */; }; C25F91B91977EB17006868F3 /* TGImageObject.m in Sources */ = {isa = PBXBuildFile; fileRef = C25F91B81977EB17006868F3 /* TGImageObject.m */; }; C25F91C4197858BF006868F3 /* LocationSenderItem.m in Sources */ = {isa = PBXBuildFile; fileRef = C25F91C3197858BF006868F3 /* LocationSenderItem.m */; }; @@ -405,6 +429,12 @@ C26976AC1A0C03610047E2C3 /* InstagramServiceDescription.m in Sources */ = {isa = PBXBuildFile; fileRef = C26976AB1A0C03610047E2C3 /* InstagramServiceDescription.m */; }; C26976B01A10CDED0047E2C3 /* TGPhotoViewer.m in Sources */ = {isa = PBXBuildFile; fileRef = C26976AF1A10CDED0047E2C3 /* TGPhotoViewer.m */; }; C26976B41A10E2110047E2C3 /* TGPVContainer.m in Sources */ = {isa = PBXBuildFile; fileRef = C26976B31A10E2110047E2C3 /* TGPVContainer.m */; }; + C26E80201B7B91A9003CC483 /* TGDatabaseRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = C26E801F1B7B91A9003CC483 /* TGDatabaseRequest.m */; }; + C26E80271B7D14E2003CC483 /* TL_localMessage_old32.m in Sources */ = {isa = PBXBuildFile; fileRef = C26E80261B7D14E2003CC483 /* TL_localMessage_old32.m */; }; + C26E802A1B7E00A1003CC483 /* TGRecentSearchRowItem.m in Sources */ = {isa = PBXBuildFile; fileRef = C26E80291B7E00A1003CC483 /* TGRecentSearchRowItem.m */; }; + C26E802D1B7E00C3003CC483 /* TGRecentSearchRowView.m in Sources */ = {isa = PBXBuildFile; fileRef = C26E802C1B7E00C3003CC483 /* TGRecentSearchRowView.m */; }; + C26E80301B7E106B003CC483 /* TGRecentSearchTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = C26E802F1B7E106B003CC483 /* TGRecentSearchTableView.m */; }; + C26E80341B8369B1003CC483 /* MtProtoKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C2D8261B1B6FA8A600434D37 /* MtProtoKit.framework */; }; C26F7EA21A4C32DB001D1AE2 /* TGAllStickersTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = C26F7EA11A4C32DB001D1AE2 /* TGAllStickersTableView.m */; }; C26F7EA81A56BEFE001D1AE2 /* SecretLayer20.m in Sources */ = {isa = PBXBuildFile; fileRef = C26F7EA71A56BEFE001D1AE2 /* SecretLayer20.m */; }; C26F7EAF1A56E5A1001D1AE2 /* AcceptKeySecretSenderItem.m in Sources */ = {isa = PBXBuildFile; fileRef = C26F7EAE1A56E5A1001D1AE2 /* AcceptKeySecretSenderItem.m */; }; @@ -428,7 +458,6 @@ C271525A19B637D200841C8A /* ComposeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C271525919B637D200841C8A /* ComposeViewController.m */; }; C271525E19B72F3400841C8A /* ComposeActionAddGroupMembersBehavior.m in Sources */ = {isa = PBXBuildFile; fileRef = C271525D19B72F3400841C8A /* ComposeActionAddGroupMembersBehavior.m */; }; C271526119B731DB00841C8A /* ComposeActionAddBroadcastMembersBehavior.m in Sources */ = {isa = PBXBuildFile; fileRef = C271526019B731DB00841C8A /* ComposeActionAddBroadcastMembersBehavior.m */; }; - C271526419B9ECCA00841C8A /* AddContactViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C271526319B9ECCA00841C8A /* AddContactViewController.m */; }; C273804E1B3B2F77000C479E /* MP3HistoryFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = C273804D1B3B2F77000C479E /* MP3HistoryFilter.m */; }; C273805C1B3D90DC000C479E /* TGAudioPlayerWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = C273805B1B3D90DC000C479E /* TGAudioPlayerWindow.m */; }; C274C3731AB83182000DFDE4 /* TGForwardContainer.m in Sources */ = {isa = PBXBuildFile; fileRef = C274C3721AB83182000DFDE4 /* TGForwardContainer.m */; }; @@ -455,8 +484,6 @@ C274C41F1ACC09B0000DFDE4 /* XCDYouTubeVideo.m in Sources */ = {isa = PBXBuildFile; fileRef = C274C4151ACC09B0000DFDE4 /* XCDYouTubeVideo.m */; }; C274C4201ACC09B0000DFDE4 /* XCDYouTubeVideoOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = C274C4181ACC09B0000DFDE4 /* XCDYouTubeVideoOperation.m */; }; C274C4221ACC09B0000DFDE4 /* XCDYouTubeVideoWebpage.m in Sources */ = {isa = PBXBuildFile; fileRef = C274C41C1ACC09B0000DFDE4 /* XCDYouTubeVideoWebpage.m */; }; - C274C4241ACC0D4D000DFDE4 /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C274C4231ACC0D4D000DFDE4 /* JavaScriptCore.framework */; }; - C274C42E1ACC5B3A000DFDE4 /* AVKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C274C42D1ACC5B3A000DFDE4 /* AVKit.framework */; }; C274C4401ACD8223000DFDE4 /* TGWebpageIGObject.m in Sources */ = {isa = PBXBuildFile; fileRef = C274C43F1ACD8223000DFDE4 /* TGWebpageIGObject.m */; }; C274C4471ACD99E7000DFDE4 /* TGWebpageTWObject.m in Sources */ = {isa = PBXBuildFile; fileRef = C274C4461ACD99E7000DFDE4 /* TGWebpageTWObject.m */; }; C274C44A1ACD9FF5000DFDE4 /* TGWebpageStandartObject.m in Sources */ = {isa = PBXBuildFile; fileRef = C274C4491ACD9FF5000DFDE4 /* TGWebpageStandartObject.m */; }; @@ -468,7 +495,6 @@ C2753DDC19E5A44300752BAF /* FLAnimatedImage.m in Sources */ = {isa = PBXBuildFile; fileRef = C2753DDB19E5A44300752BAF /* FLAnimatedImage.m */; }; C2753DDF19E5B24500752BAF /* TGModernAnimatedImagePlayer.m in Sources */ = {isa = PBXBuildFile; fileRef = C2753DDE19E5B24500752BAF /* TGModernAnimatedImagePlayer.m */; }; C276C7D3195C6C1B0037C4D7 /* ITProgressIndicator.m in Sources */ = {isa = PBXBuildFile; fileRef = C276C7D2195C6C1B0037C4D7 /* ITProgressIndicator.m */; }; - C277E2A418ABB44A00FFCA35 /* DialogsHistoryController.m in Sources */ = {isa = PBXBuildFile; fileRef = C277E2A318ABB44A00FFCA35 /* DialogsHistoryController.m */; }; C281C1781917D9C2007B160F /* DraggingControllerView.m in Sources */ = {isa = PBXBuildFile; fileRef = C281C1771917D9C2007B160F /* DraggingControllerView.m */; }; C281C17B1917D9D9007B160F /* DraggingItemView.m in Sources */ = {isa = PBXBuildFile; fileRef = C281C17A1917D9D9007B160F /* DraggingItemView.m */; }; C281C180191AA139007B160F /* TMPreviewChatPicture.m in Sources */ = {isa = PBXBuildFile; fileRef = C281C17F191AA139007B160F /* TMPreviewChatPicture.m */; }; @@ -477,6 +503,7 @@ C28261E219926C62004AC73E /* TL_peerBroadcast.m in Sources */ = {isa = PBXBuildFile; fileRef = C28261E119926C62004AC73E /* TL_peerBroadcast.m */; }; C28261E9199291EF004AC73E /* TL_broadcast.m in Sources */ = {isa = PBXBuildFile; fileRef = C28261E8199291EF004AC73E /* TL_broadcast.m */; }; C28261EC1992974C004AC73E /* BroadcastManager.m in Sources */ = {isa = PBXBuildFile; fileRef = C28261EB1992974C004AC73E /* BroadcastManager.m */; }; + C28C86771B98851300267C0B /* TGSKeychain.m in Sources */ = {isa = PBXBuildFile; fileRef = C28C86761B98851300267C0B /* TGSKeychain.m */; }; C291C7BC1836C39900ABBB50 /* Background.m in Sources */ = {isa = PBXBuildFile; fileRef = C291C7B91836C39900ABBB50 /* Background.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; C291C7BD1836C39900ABBB50 /* LBProgressBar.m in Sources */ = {isa = PBXBuildFile; fileRef = C291C7BB1836C39900ABBB50 /* LBProgressBar.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; C291C7C0183759EE00ABBB50 /* SSKeychainQuery.m in Sources */ = {isa = PBXBuildFile; fileRef = C291C7BF183759EE00ABBB50 /* SSKeychainQuery.m */; }; @@ -499,6 +526,9 @@ C297955F19EC587900BE893E /* SettingsSecurityViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C297955E19EC587900BE893E /* SettingsSecurityViewController.m */; }; C297FBA31832997B00714B3C /* SSKeychain.m in Sources */ = {isa = PBXBuildFile; fileRef = C297FBA21832997B00714B3C /* SSKeychain.m */; }; C297FBA618329F3500714B3C /* TGDcAuth.m in Sources */ = {isa = PBXBuildFile; fileRef = C297FBA518329F3500714B3C /* TGDcAuth.m */; }; + C2A2B4261BD01FC20083DA8A /* TGHeadChatPanel.m in Sources */ = {isa = PBXBuildFile; fileRef = C2A2B4251BD01FC20083DA8A /* TGHeadChatPanel.m */; }; + C2A2B42E1BD519870083DA8A /* TGHCMessagesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C2A2B42D1BD519870083DA8A /* TGHCMessagesViewController.m */; }; + C2A2B4311BD7C8DB0083DA8A /* TGModalForwardView.m in Sources */ = {isa = PBXBuildFile; fileRef = C2A2B4301BD7C8DB0083DA8A /* TGModalForwardView.m */; }; C2A3FB091A278E2700DE791B /* PhoneChangeController.m in Sources */ = {isa = PBXBuildFile; fileRef = C2A3FB081A278E2700DE791B /* PhoneChangeController.m */; }; C2A3FB0D1A28A6B200DE791B /* TGHashContact.m in Sources */ = {isa = PBXBuildFile; fileRef = C2A3FB0C1A28A6B200DE791B /* TGHashContact.m */; }; C2A5BFBE18DC80620021BE68 /* info.c in Sources */ = {isa = PBXBuildFile; fileRef = C2A5BFB318DC80620021BE68 /* info.c */; }; @@ -536,9 +566,23 @@ C2ACCE5F1ADD66A600ABEE78 /* TGConversationsTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = C2ACCE5E1ADD66A600ABEE78 /* TGConversationsTableView.m */; }; C2ACCE6B1AE10ED200ABEE78 /* TGRaceEmoji.m in Sources */ = {isa = PBXBuildFile; fileRef = C2ACCE6A1AE10ED200ABEE78 /* TGRaceEmoji.m */; }; C2ACCE6E1AE122A400ABEE78 /* EmojiButton.m in Sources */ = {isa = PBXBuildFile; fileRef = C2ACCE6D1AE122A400ABEE78 /* EmojiButton.m */; }; + C2B0DF771BA98E7C0023982C /* TL_localEmptyMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B0DF761BA98E7C0023982C /* TL_localEmptyMessage.m */; }; + C2B0DF831BA9B7840023982C /* ComposeActionAddChannelModeratorBehavior.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B0DF821BA9B7840023982C /* ComposeActionAddChannelModeratorBehavior.m */; }; + C2B0DF861BA9C59B0023982C /* ComposeConfirmModeratorViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B0DF851BA9C59B0023982C /* ComposeConfirmModeratorViewController.m */; }; + C2B0DF891BA9C6EC0023982C /* TGUserContainerView.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B0DF881BA9C6EC0023982C /* TGUserContainerView.m */; }; + C2B0DF8C1BA9CE290023982C /* TGUserContainerRowItem.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B0DF8B1BA9CE290023982C /* TGUserContainerRowItem.m */; }; + C2B0DF8F1BAAD9330023982C /* ComposeManagmentViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B0DF8E1BAAD9330023982C /* ComposeManagmentViewController.m */; }; + C2B0DF921BAAFD2E0023982C /* ComposeChannelParticipantsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B0DF911BAAFD2E0023982C /* ComposeChannelParticipantsViewController.m */; }; + C2B0DF991BAAFEFA0023982C /* TGModalDeleteChannelMessagesView.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B0DF981BAAFEFA0023982C /* TGModalDeleteChannelMessagesView.m */; }; + C2B0DF9C1BAB07DD0023982C /* ComposeActionBlackListBehavior.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B0DF9B1BAB07DD0023982C /* ComposeActionBlackListBehavior.m */; }; + C2B0DF9F1BAB13820023982C /* ComposeActionDeleteChannelMessagesBehavior.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B0DF9E1BAB13820023982C /* ComposeActionDeleteChannelMessagesBehavior.m */; }; + C2B0DFA21BAB34330023982C /* ComposeActionChannelMembersBehavior.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B0DFA11BAB34330023982C /* ComposeActionChannelMembersBehavior.m */; }; C2B325EE1A237A420012DE34 /* TLApiObject.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B325ED1A237A420012DE34 /* TLApiObject.m */; }; C2B326081A24F77E0012DE34 /* PhoneChangeAlertController.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B326071A24F77E0012DE34 /* PhoneChangeAlertController.m */; }; - C2BC529D1A695A270004A8FE /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C2BC529C1A695A270004A8FE /* IOKit.framework */; }; + C2B669861BA5571C004AF678 /* TGSettingsTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B669851BA5571C004AF678 /* TGSettingsTableView.m */; }; + C2B669891BA5591F004AF678 /* TGGeneralRowItem.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B669881BA5591F004AF678 /* TGGeneralRowItem.m */; }; + C2B6698C1BA570AF004AF678 /* ComposeCreateChannelUserNameStepViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B6698B1BA570AF004AF678 /* ComposeCreateChannelUserNameStepViewController.m */; }; + C2B6698F1BA575AE004AF678 /* TGChangeUserNameContainerView.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B6698E1BA575AE004AF678 /* TGChangeUserNameContainerView.m */; }; C2C1DC051A43345400BBCC63 /* MessageTableItemSticker.m in Sources */ = {isa = PBXBuildFile; fileRef = C2C1DC041A43345400BBCC63 /* MessageTableItemSticker.m */; }; C2C1DC0C1A43347800BBCC63 /* MessageTableCellStickerView.m in Sources */ = {isa = PBXBuildFile; fileRef = C2C1DC0B1A43347800BBCC63 /* MessageTableCellStickerView.m */; }; C2C1DC0F1A4336CE00BBCC63 /* TGStickerImageObject.m in Sources */ = {isa = PBXBuildFile; fileRef = C2C1DC0E1A4336CE00BBCC63 /* TGStickerImageObject.m */; }; @@ -579,9 +623,7 @@ C2CB5CFC1B4AB43800CD61DF /* TGPVDocumentContainer.m in Sources */ = {isa = PBXBuildFile; fileRef = C2CB5CFB1B4AB43800CD61DF /* TGPVDocumentContainer.m */; }; C2CB5D031B4AF9C000CD61DF /* TGPVDocumentObject.m in Sources */ = {isa = PBXBuildFile; fileRef = C2CB5D021B4AF9C000CD61DF /* TGPVDocumentObject.m */; }; C2CB5D411B4D697700CD61DF /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = C2CB5D401B4D697700CD61DF /* main.m */; }; - C2CB5D551B4D709000CD61DF /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C2CBF6741AFB6AFA006BF90A /* AppKit.framework */; }; C2CB5D5F1B4D871600CD61DF /* TGUpdater.m in Sources */ = {isa = PBXBuildFile; fileRef = C2CB5D5E1B4D871600CD61DF /* TGUpdater.m */; }; - C2CB5DA31B4DB18100CD61DF /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C2CBF67E1AFB6F13006BF90A /* Foundation.framework */; }; C2CB5DC51B4EAA4F00CD61DF /* NSObject+BObject.m in Sources */ = {isa = PBXBuildFile; fileRef = C2CB5DC41B4EAA4F00CD61DF /* NSObject+BObject.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; C2CB5DC81B4EAA6300CD61DF /* AJObject.m in Sources */ = {isa = PBXBuildFile; fileRef = C2CB5DC71B4EAA6300CD61DF /* AJObject.m */; }; C2CB5DCB1B4EAAAC00CD61DF /* AJUpdateObject.m in Sources */ = {isa = PBXBuildFile; fileRef = C2CB5DCA1B4EAAAC00CD61DF /* AJUpdateObject.m */; }; @@ -609,20 +651,10 @@ C2CBF6051AF90683006BF90A /* TGTimerTarget.m in Sources */ = {isa = PBXBuildFile; fileRef = C247015819839A4B007AB338 /* TGTimerTarget.m */; }; C2CBF6061AF90683006BF90A /* TGTimer.m in Sources */ = {isa = PBXBuildFile; fileRef = C2AA4EF618A8ED5500E20C68 /* TGTimer.m */; }; C2CBF6071AF906DC006BF90A /* TGKeychain.m in Sources */ = {isa = PBXBuildFile; fileRef = C2967B481AA9BF90003759B2 /* TGKeychain.m */; }; - C2CBF60C1AF90878006BF90A /* libsqlcipher.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C2E561031AF3726300B4CAF0 /* libsqlcipher.a */; }; - C2CBF60E1AF90882006BF90A /* libsqlite3.0.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = C2CBF60D1AF90881006BF90A /* libsqlite3.0.dylib */; }; - C2CBF60F1AF908B7006BF90A /* FMDatabase.m in Sources */ = {isa = PBXBuildFile; fileRef = CEAE5D59181ECDF100C17645 /* FMDatabase.m */; }; - C2CBF6101AF908B7006BF90A /* FMDatabaseAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = CEAE5D5B181ECDF100C17645 /* FMDatabaseAdditions.m */; }; - C2CBF6111AF908B7006BF90A /* FMDatabasePool.m in Sources */ = {isa = PBXBuildFile; fileRef = CEAE5D5D181ECDF100C17645 /* FMDatabasePool.m */; }; - C2CBF6121AF908B7006BF90A /* FMDatabaseQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = CEAE5D5F181ECDF100C17645 /* FMDatabaseQueue.m */; }; - C2CBF6131AF910E2006BF90A /* FMResultSet.m in Sources */ = {isa = PBXBuildFile; fileRef = CEAE5D62181ECDF100C17645 /* FMResultSet.m */; }; C2CBF6141AF910EF006BF90A /* TGTLSerialization.mm in Sources */ = {isa = PBXBuildFile; fileRef = C2CBF3D41AF38F6F006BF90A /* TGTLSerialization.mm */; }; C2CBF6151AF9113E006BF90A /* NSData+Extensions.m in Sources */ = {isa = PBXBuildFile; fileRef = CEF5C02717FFFEFE006CEE27 /* NSData+Extensions.m */; }; - C2CBF6171AF911A2006BF90A /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C2CBF6161AF911A2006BF90A /* SystemConfiguration.framework */; }; - C2CBF6191AF912A8006BF90A /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = C2CBF6181AF912A8006BF90A /* libz.dylib */; }; C2CBF61A1AF93A6C006BF90A /* SSKeychain.m in Sources */ = {isa = PBXBuildFile; fileRef = C297FBA21832997B00714B3C /* SSKeychain.m */; }; C2CBF61B1AF93A6C006BF90A /* SSKeychainQuery.m in Sources */ = {isa = PBXBuildFile; fileRef = C291C7BF183759EE00ABBB50 /* SSKeychainQuery.m */; }; - C2CBF64A1AFA5A23006BF90A /* MapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C2CBF6491AFA5A23006BF90A /* MapKit.framework */; }; C2CBF65B1AFAB075006BF90A /* NSMutableData+Extension.m in Sources */ = {isa = PBXBuildFile; fileRef = CECBC1681800D5E000AD98E6 /* NSMutableData+Extension.m */; }; C2CBF65C1AFB6834006BF90A /* TMView.m in Sources */ = {isa = PBXBuildFile; fileRef = 0AC7F478185DBA0800F90558 /* TMView.m */; }; C2CBF65D1AFB6881006BF90A /* TMTableView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0AC7F474185DA87A00F90558 /* TMTableView.mm */; }; @@ -647,17 +679,12 @@ C2CBF6711AFB6AE1006BF90A /* NSAttributedStringCategory.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A6D095C19535E8500A9AC64 /* NSAttributedStringCategory.m */; }; C2CBF6721AFB6AE1006BF90A /* NSAttributedString+RBLHTMLAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A9EDC1E1897BA0E0037E1BC /* NSAttributedString+RBLHTMLAdditions.m */; }; C2CBF6731AFB6AE1006BF90A /* NSAttributedString+Hyperlink.m in Sources */ = {isa = PBXBuildFile; fileRef = 0AA014591831140D00901B7A /* NSAttributedString+Hyperlink.m */; }; - C2CBF6751AFB6AFA006BF90A /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C2CBF6741AFB6AFA006BF90A /* AppKit.framework */; }; C2CBF6761AFB6B29006BF90A /* NSStringCategory.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A6D096C19535E8500A9AC64 /* NSStringCategory.m */; }; C2CBF6771AFB6B29006BF90A /* NSString+Extended.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A7EB71A183A873D00F02E04 /* NSString+Extended.m */; }; C2CBF6781AFB6B29006BF90A /* NSString+FindURLs.m in Sources */ = {isa = PBXBuildFile; fileRef = 0AA0145B1831140D00901B7A /* NSString+FindURLs.m */; }; C2CBF6791AFB6B29006BF90A /* NSString+Size.m in Sources */ = {isa = PBXBuildFile; fileRef = 0AEE20801820764900F348F2 /* NSString+Size.m */; }; C2CBF67A1AFB6B29006BF90A /* NSString+NSStringHexToBytes.m in Sources */ = {isa = PBXBuildFile; fileRef = CEF8EB8917FCA81000740D66 /* NSString+NSStringHexToBytes.m */; }; C2CBF67B1AFB6B2A006BF90A /* NSString+MD5.m in Sources */ = {isa = PBXBuildFile; fileRef = 0AF4061D18192B7E00160DB4 /* NSString+MD5.m */; }; - C2CBF67F1AFB6F13006BF90A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C2CBF67E1AFB6F13006BF90A /* Foundation.framework */; }; - C2CBF6811AFB6F18006BF90A /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C2CBF6801AFB6F18006BF90A /* Security.framework */; }; - C2CBF6831AFB6F33006BF90A /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C2CBF6821AFB6F33006BF90A /* AVFoundation.framework */; }; - C2CBF6851AFB6FE6006BF90A /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C2CBF6841AFB6FE6006BF90A /* QuartzCore.framework */; }; C2CBF6861AFB7082006BF90A /* TMScrollAnimation.m in Sources */ = {isa = PBXBuildFile; fileRef = 0AF4F496189A696A004BA4DF /* TMScrollAnimation.m */; }; C2CBF6891AFB73FE006BF90A /* TGS_ConversationRowItem.m in Sources */ = {isa = PBXBuildFile; fileRef = C2CBF6881AFB73FE006BF90A /* TGS_ConversationRowItem.m */; }; C2CBF68D1AFB7421006BF90A /* TGS_ConversationRowView.m in Sources */ = {isa = PBXBuildFile; fileRef = C2CBF68C1AFB7421006BF90A /* TGS_ConversationRowView.m */; }; @@ -669,7 +696,6 @@ C2CBF69E1AFB8141006BF90A /* DownloadItem.m in Sources */ = {isa = PBXBuildFile; fileRef = C256E91018D20BA8008FFA04 /* DownloadItem.m */; }; C2CBF69F1AFB817C006BF90A /* TMImageUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A0B09BB18B1823700F3FE1B /* TMImageUtils.m */; }; C2CBF6A01AFB817C006BF90A /* ImageUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = CEAE5CCF181B0D7600C17645 /* ImageUtils.m */; }; - C2CBF6A21AFB81A8006BF90A /* QuickLook.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C2CBF6A11AFB81A8006BF90A /* QuickLook.framework */; }; C2CBF6A41AFB8247006BF90A /* TGImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = C25F91B21977E115006868F3 /* TGImageView.m */; }; C2CBF6A61AFB835D006BF90A /* DownloadQueue.mm in Sources */ = {isa = PBXBuildFile; fileRef = CEB7ADE418128581005CB6A1 /* DownloadQueue.mm */; }; C2CBF6AD1AFB84DB006BF90A /* TGDownloadItem.m in Sources */ = {isa = PBXBuildFile; fileRef = C2CBF6AC1AFB84DB006BF90A /* TGDownloadItem.m */; }; @@ -686,7 +712,6 @@ C2CBF6CA1AFBC562006BF90A /* UploadOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = CED61A311825507400B2C5F4 /* UploadOperation.m */; }; C2CBF6CE1AFBC5C0006BF90A /* RPC.m in Sources */ = {isa = PBXBuildFile; fileRef = C2CBF6CD1AFBC5C0006BF90A /* RPC.m */; }; C2CBF6CF1AFBC5C0006BF90A /* RPC.m in Sources */ = {isa = PBXBuildFile; fileRef = C2CBF6CD1AFBC5C0006BF90A /* RPC.m */; }; - C2CBF6D01AFBC7B1006BF90A /* Crypto.m in Sources */ = {isa = PBXBuildFile; fileRef = CE4961C718034ACD000C3738 /* Crypto.m */; }; C2CBF6D11AFBC952006BF90A /* QueueManager.m in Sources */ = {isa = PBXBuildFile; fileRef = CE7E5657189AC5E30058C532 /* QueueManager.m */; }; C2CBF6D21AFBD2B5006BF90A /* mime-types.txt in Resources */ = {isa = PBXBuildFile; fileRef = C270C5B118A13FB9005D80E0 /* mime-types.txt */; }; C2CBF6D31AFBD764006BF90A /* NSViewCategory.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A6D097019535E8500A9AC64 /* NSViewCategory.m */; }; @@ -698,7 +723,29 @@ C2CBF6DB1AFBE662006BF90A /* NSTextFieldCategory.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A6D096E19535E8500A9AC64 /* NSTextFieldCategory.m */; }; C2CBF6DC1AFBE691006BF90A /* TMButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 0AD35DC81869B604007BA752 /* TMButton.m */; }; C2CBF6DE1AFBE812006BF90A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C2CBF6DD1AFBE812006BF90A /* Images.xcassets */; }; + C2CC41C41BA7FC450097E973 /* WeakReference.m in Sources */ = {isa = PBXBuildFile; fileRef = C2CC41C31BA7FC450097E973 /* WeakReference.m */; }; C2CD77C91A2C9E04000B4BA9 /* TGEnterPasswordPanel.m in Sources */ = {isa = PBXBuildFile; fileRef = C2CD77C81A2C9E04000B4BA9 /* TGEnterPasswordPanel.m */; }; + C2CE53C01BE2892E00BBEF5F /* ChatAdminsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C2CE53BF1BE2892E00BBEF5F /* ChatAdminsViewController.m */; }; + C2CE53C31BE295A000BBEF5F /* TGGeneralSearchRowView.m in Sources */ = {isa = PBXBuildFile; fileRef = C2CE53C21BE295A000BBEF5F /* TGGeneralSearchRowView.m */; }; + C2CE53C61BE7688900BBEF5F /* ComposeActionCreateMegaGroupBehavior.m in Sources */ = {isa = PBXBuildFile; fileRef = C2CE53C51BE7688900BBEF5F /* ComposeActionCreateMegaGroupBehavior.m */; }; + C2CE53CA1BE8C0DB00BBEF5F /* TGSProfileMediaRowView.m in Sources */ = {isa = PBXBuildFile; fileRef = C2CE53C91BE8C0DB00BBEF5F /* TGSProfileMediaRowView.m */; }; + C2CE53CD1BE8D96600BBEF5F /* TGSProfileMediaRowItem.m in Sources */ = {isa = PBXBuildFile; fileRef = C2CE53CC1BE8D96600BBEF5F /* TGSProfileMediaRowItem.m */; }; + C2CE53D01BE8E6F900BBEF5F /* TGProfileParamView.m in Sources */ = {isa = PBXBuildFile; fileRef = C2CE53CF1BE8E6F900BBEF5F /* TGProfileParamView.m */; }; + C2CE53D31BE8EC7B00BBEF5F /* TGProfileParamItem.m in Sources */ = {isa = PBXBuildFile; fileRef = C2CE53D21BE8EC7B00BBEF5F /* TGProfileParamItem.m */; }; + C2CE53D61BE905D800BBEF5F /* TGProfileHeaderRowView.m in Sources */ = {isa = PBXBuildFile; fileRef = C2CE53D51BE905D800BBEF5F /* TGProfileHeaderRowView.m */; }; + C2CE53D91BE9060500BBEF5F /* TGProfileHeaderRowItem.m in Sources */ = {isa = PBXBuildFile; fileRef = C2CE53D81BE9060500BBEF5F /* TGProfileHeaderRowItem.m */; }; + C2CE53DD1BE9275700BBEF5F /* ComposeActionInfoProfileBehavior.m in Sources */ = {isa = PBXBuildFile; fileRef = C2CE53DC1BE9275700BBEF5F /* ComposeActionInfoProfileBehavior.m */; }; + C2CE53E01BE938AC00BBEF5F /* TGModernChatInfoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C2CE53DF1BE938AC00BBEF5F /* TGModernChatInfoViewController.m */; }; + C2CE53E31BEA75B800BBEF5F /* TGModernChannelInfoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C2CE53E21BEA75B800BBEF5F /* TGModernChannelInfoViewController.m */; }; + C2CE53E61BEB4FAD00BBEF5F /* ComposeChangeChannelDescriptionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C2CE53E51BEB4FAD00BBEF5F /* ComposeChangeChannelDescriptionViewController.m */; }; + C2CE53E91BEB543A00BBEF5F /* TGGeneralInputTextRowView.m in Sources */ = {isa = PBXBuildFile; fileRef = C2CE53E81BEB543A00BBEF5F /* TGGeneralInputTextRowView.m */; }; + C2CE53EC1BEB5ACF00BBEF5F /* TGGeneralInputRowItem.m in Sources */ = {isa = PBXBuildFile; fileRef = C2CE53EB1BEB5ACF00BBEF5F /* TGGeneralInputRowItem.m */; }; + C2CE53EF1BEB748900BBEF5F /* ComposeActionChangeChannelAboutBehavior.m in Sources */ = {isa = PBXBuildFile; fileRef = C2CE53EE1BEB748900BBEF5F /* ComposeActionChangeChannelAboutBehavior.m */; }; + C2CE53F21BECC3A700BBEF5F /* MegagroupChatFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = C2CE53F11BECC3A700BBEF5F /* MegagroupChatFilter.m */; }; + C2CE53F51BECE46600BBEF5F /* MegagroupHistoryController.m in Sources */ = {isa = PBXBuildFile; fileRef = C2CE53F41BECE46600BBEF5F /* MegagroupHistoryController.m */; }; + C2CE53F81BED06BD00BBEF5F /* ChannelCommonFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = C2CE53F71BED06BD00BBEF5F /* ChannelCommonFilter.m */; }; + C2CE53FB1BF0AE3800BBEF5F /* CommonMediaHistoryFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = C2CE53FA1BF0AE3800BBEF5F /* CommonMediaHistoryFilter.m */; }; + C2CE53FE1BF0E43A00BBEF5F /* TGPhotoViewerBehavior.m in Sources */ = {isa = PBXBuildFile; fileRef = C2CE53FD1BF0E43A00BBEF5F /* TGPhotoViewerBehavior.m */; }; C2D235B91A2F2C5600765BA1 /* TGModernTypingManager.m in Sources */ = {isa = PBXBuildFile; fileRef = C2D235B81A2F2C5600765BA1 /* TGModernTypingManager.m */; }; C2D235BC1A2FA6F400765BA1 /* TGSendTypingManager.m in Sources */ = {isa = PBXBuildFile; fileRef = C2D235BB1A2FA6F400765BA1 /* TGSendTypingManager.m */; }; C2D4B7401AFCD36A0035B4E4 /* TGModalView.m in Sources */ = {isa = PBXBuildFile; fileRef = C2D4B73F1AFCD36A0035B4E4 /* TGModalView.m */; }; @@ -744,19 +791,20 @@ C2D51C381B25F5A8009327C0 /* TGStickerPackEmojiController.m in Sources */ = {isa = PBXBuildFile; fileRef = C2D51C371B25F5A8009327C0 /* TGStickerPackEmojiController.m */; }; C2D51C3E1B2618DE009327C0 /* TGTransformScrollView.m in Sources */ = {isa = PBXBuildFile; fileRef = C2D51C3D1B2618DE009327C0 /* TGTransformScrollView.m */; }; C2D5CE841B0B938B009F6419 /* SpacemanBlocks.h in Sources */ = {isa = PBXBuildFile; fileRef = CEA589441815827500462DF0 /* SpacemanBlocks.h */; }; + C2D777301BAEA30B00D451FD /* ComposeSettingupNewChannelViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C2D7772F1BAEA30B00D451FD /* ComposeSettingupNewChannelViewController.m */; }; C2D7C5B11B2B4FAF0042DC01 /* TGMenuItemPhoto.m in Sources */ = {isa = PBXBuildFile; fileRef = C2D7C5B01B2B4FAF0042DC01 /* TGMenuItemPhoto.m */; }; C2D7C5BE1B3091400042DC01 /* StartBotSenderItem.m in Sources */ = {isa = PBXBuildFile; fileRef = C2D7C5BD1B3091400042DC01 /* StartBotSenderItem.m */; }; - C2D825C31B664EC500434D37 /* Sparkle.framework in Copy Files (6 items) */ = {isa = PBXBuildFile; fileRef = C235364C19C88D620044978E /* Sparkle.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - C2D825C41B664EC500434D37 /* HockeySDK.framework in Copy Files (6 items) */ = {isa = PBXBuildFile; fileRef = C2082B7219C1E1C4000005E2 /* HockeySDK.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - C2D825C51B664ECA00434D37 /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C235364C19C88D620044978E /* Sparkle.framework */; }; - C2D825C61B664ECA00434D37 /* HockeySDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C2082B7219C1E1C4000005E2 /* HockeySDK.framework */; }; C2D825D61B67B22E00434D37 /* CacheSettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C2D825D51B67B22E00434D37 /* CacheSettingsViewController.m */; }; C2D825E01B690D7500434D37 /* NotificationSettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C2D825DF1B690D7500434D37 /* NotificationSettingsViewController.m */; }; C2D825E31B69155D00434D37 /* NotificationConversationRowItem.m in Sources */ = {isa = PBXBuildFile; fileRef = C2D825E21B69155D00434D37 /* NotificationConversationRowItem.m */; }; C2D825E61B6915B500434D37 /* NotificationConversationRowView.m in Sources */ = {isa = PBXBuildFile; fileRef = C2D825E51B6915B500434D37 /* NotificationConversationRowView.m */; }; C2D825EC1B6A700300434D37 /* TGEmbedModalView.m in Sources */ = {isa = PBXBuildFile; fileRef = C2D825EB1B6A700300434D37 /* TGEmbedModalView.m */; }; - C2D825EE1B6A711E00434D37 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C2D825ED1B6A711E00434D37 /* WebKit.framework */; }; - C2D826241B6FA8E800434D37 /* MtProtoKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C2D8261B1B6FA8A600434D37 /* MtProtoKit.framework */; }; + C2D8263B1B710E6400434D37 /* TGModernHistoryController.m in Sources */ = {isa = PBXBuildFile; fileRef = C2D8263A1B710E6400434D37 /* TGModernHistoryController.m */; }; + C2D8263F1B7110AB00434D37 /* TGConversation.m in Sources */ = {isa = PBXBuildFile; fileRef = C2D8263E1B7110AB00434D37 /* TGConversation.m */; }; + C2D826421B71155000434D37 /* TGDatabase.m in Sources */ = {isa = PBXBuildFile; fileRef = C2D826411B71155000434D37 /* TGDatabase.m */; }; + C2D826491B74FD5D00434D37 /* TGPVZoomControl.m in Sources */ = {isa = PBXBuildFile; fileRef = C2D826481B74FD5D00434D37 /* TGPVZoomControl.m */; }; + C2D8CFC31B84D3E200080775 /* ComposeActionCreateChannelBehavior.m in Sources */ = {isa = PBXBuildFile; fileRef = C2D8CFC21B84D3E200080775 /* ComposeActionCreateChannelBehavior.m */; }; + C2D8CFC61B84D73D00080775 /* ComposeCreateChannelViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C2D8CFC51B84D73D00080775 /* ComposeCreateChannelViewController.m */; }; C2D931401991140F00668F86 /* TGWindowArchiver.m in Sources */ = {isa = PBXBuildFile; fileRef = C2D9313F1991140F00668F86 /* TGWindowArchiver.m */; }; C2DE4FAB1AD08C34001EC26C /* TGWebpageArticle.m in Sources */ = {isa = PBXBuildFile; fileRef = C2DE4FAA1AD08C34001EC26C /* TGWebpageArticle.m */; }; C2DE4FAE1AD08C47001EC26C /* TGWebpageArticleContainer.m in Sources */ = {isa = PBXBuildFile; fileRef = C2DE4FAD1AD08C47001EC26C /* TGWebpageArticleContainer.m */; }; @@ -766,10 +814,23 @@ C2E40E2C19D58E3C0079046E /* PreferencePanes.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C2E40E2B19D58E3C0079046E /* PreferencePanes.framework */; }; C2E40E2E19D58E430079046E /* Quartz.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C2E40E2D19D58E430079046E /* Quartz.framework */; }; C2E40E3019D58E490079046E /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C2E40E2F19D58E490079046E /* Accelerate.framework */; }; - C2E40E3419D58E580079046E /* libstdc++.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = C2E40E3319D58E580079046E /* libstdc++.dylib */; }; C2E40E3519D58F160079046E /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A7C78FA1947E134001617DB /* OpenGL.framework */; }; C2E561041AF3729600B4CAF0 /* libsqlcipher.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C2E561031AF3726300B4CAF0 /* libsqlcipher.a */; }; + C2E5A0611BABF33C00C1BCA1 /* TL_localMessageService_old34.m in Sources */ = {isa = PBXBuildFile; fileRef = C2E5A0601BABF33C00C1BCA1 /* TL_localMessageService_old34.m */; }; + C2E5A0731BAC75C200C1BCA1 /* TGMessageViewSender.m in Sources */ = {isa = PBXBuildFile; fileRef = C2E5A0721BAC75C100C1BCA1 /* TGMessageViewSender.m */; }; + C2ED28041BFF7F0E00F19531 /* TGReportChannelModalView.m in Sources */ = {isa = PBXBuildFile; fileRef = C2ED28031BFF7F0E00F19531 /* TGReportChannelModalView.m */; }; C2ED357D18D9FECB00D0027C /* CAProgressLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = C2ED357C18D9FECB00D0027C /* CAProgressLayer.m */; }; + C2F07E0F1BBD7CD900B3DB39 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C2F07E0E1BBD7CD900B3DB39 /* IOKit.framework */; }; + C2F07E111BBD7CEF00B3DB39 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C2F07E101BBD7CEF00B3DB39 /* WebKit.framework */; }; + C2F07E131BBD7CFA00B3DB39 /* MapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C2F07E121BBD7CFA00B3DB39 /* MapKit.framework */; }; + C2F07E151BBD7D3B00B3DB39 /* AVKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C2F07E141BBD7D3B00B3DB39 /* AVKit.framework */; }; + C2F07E171BBD7D5300B3DB39 /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C2F07E161BBD7D5300B3DB39 /* JavaScriptCore.framework */; }; + C2F07E191BBD7D9300B3DB39 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = C2F07E181BBD7D9300B3DB39 /* libz.tbd */; }; + C2F07E1B1BBD7E0E00B3DB39 /* libsqlite3.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = C2F07E1A1BBD7E0E00B3DB39 /* libsqlite3.tbd */; }; + C2F07E1D1BBDBABF00B3DB39 /* ImageIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C2F07E1C1BBDBABF00B3DB39 /* ImageIO.framework */; }; + C2F07E1F1BBDBACD00B3DB39 /* libstdc++.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = C2F07E1E1BBDBACD00B3DB39 /* libstdc++.tbd */; }; + C2F07E251BC02F6200B3DB39 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A2576A4181D09E500FB386C /* SystemConfiguration.framework */; }; + C2F07E281BC02FC500B3DB39 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = C2F07E181BBD7D9300B3DB39 /* libz.tbd */; }; C2F3995F190E7692006B36F7 /* ReadHistroryTask.m in Sources */ = {isa = PBXBuildFile; fileRef = C2F3995E190E7692006B36F7 /* ReadHistroryTask.m */; }; C2F39967190FD1D6006B36F7 /* ASHandle.m in Sources */ = {isa = PBXBuildFile; fileRef = C2F39965190FD1D6006B36F7 /* ASHandle.m */; }; C2F3996E190FD1FC006B36F7 /* SGraphListNode.m in Sources */ = {isa = PBXBuildFile; fileRef = C2F39969190FD1FC006B36F7 /* SGraphListNode.m */; }; @@ -787,7 +848,13 @@ C2FA78E91923CB76001A9D1B /* DocumentHistoryFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = C2FA78E81923CB76001A9D1B /* DocumentHistoryFilter.m */; }; C2FA78EC1923CBA1001A9D1B /* PhotoHistoryFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = C2FA78EB1923CBA1001A9D1B /* PhotoHistoryFilter.m */; }; C2FA78EF1924D934001A9D1B /* NoMessagesView.m in Sources */ = {isa = PBXBuildFile; fileRef = C2FA78EE1924D934001A9D1B /* NoMessagesView.m */; }; - CE05837E17FD80AD0029EFCB /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CE05837D17FD80AD0029EFCB /* libz.dylib */; }; + C2FB6C921C05F08200B066A4 /* Sparkle.framework in Copy Files (6 items) */ = {isa = PBXBuildFile; fileRef = C235364C19C88D620044978E /* Sparkle.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + C2FB6C931C05F08200B066A4 /* HockeySDK.framework in Copy Files (6 items) */ = {isa = PBXBuildFile; fileRef = C2082B7219C1E1C4000005E2 /* HockeySDK.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + C2FB6C941C05F08600B066A4 /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C235364C19C88D620044978E /* Sparkle.framework */; }; + C2FB6C951C05F08600B066A4 /* HockeySDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C2082B7219C1E1C4000005E2 /* HockeySDK.framework */; }; + C2FF82A31B99C7CE00DE2455 /* TGForceChannelUpdate.m in Sources */ = {isa = PBXBuildFile; fileRef = C2FF82A21B99C7CE00DE2455 /* TGForceChannelUpdate.m */; }; + C2FF82E81B9F28DA00DE2455 /* ChannelHistoryController.m in Sources */ = {isa = PBXBuildFile; fileRef = C2FF82E71B9F28D900DE2455 /* ChannelHistoryController.m */; }; + C2FF82EB1BA0796400DE2455 /* ChannelsManager.m in Sources */ = {isa = PBXBuildFile; fileRef = C2FF82EA1BA0796400DE2455 /* ChannelsManager.m */; }; CE05838017FDB68C0029EFCB /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CE05837F17FDB68C0029EFCB /* CoreFoundation.framework */; }; CE0AC51D18BE0EE70031658A /* TL_destructMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = CE0AC51C18BE0EE70031658A /* TL_destructMessage.m */; }; CE23C38218C717D200AA6C78 /* MessageTableItemAudio.m in Sources */ = {isa = PBXBuildFile; fileRef = CE23C38118C717D200AA6C78 /* MessageTableItemAudio.m */; }; @@ -823,7 +890,6 @@ CEAE5D65181ECDF100C17645 /* FMDatabasePool.m in Sources */ = {isa = PBXBuildFile; fileRef = CEAE5D5D181ECDF100C17645 /* FMDatabasePool.m */; }; CEAE5D66181ECDF100C17645 /* FMDatabaseQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = CEAE5D5F181ECDF100C17645 /* FMDatabaseQueue.m */; }; CEAE5D68181ECDF100C17645 /* FMResultSet.m in Sources */ = {isa = PBXBuildFile; fileRef = CEAE5D62181ECDF100C17645 /* FMResultSet.m */; }; - CEAE5D6A181ED1BF00C17645 /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CEAE5D69181ED1BF00C17645 /* libsqlite3.dylib */; }; CEAE5D6D181EEFF000C17645 /* TLPeer+Extensions.m in Sources */ = {isa = PBXBuildFile; fileRef = CEAE5D6C181EEFF000C17645 /* TLPeer+Extensions.m */; }; CEB09E5C17DAFC250055F150 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEB09E5B17DAFC250055F150 /* Cocoa.framework */; }; CEB09E6817DAFC250055F150 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = CEB09E6717DAFC250055F150 /* main.m */; }; @@ -832,7 +898,6 @@ CEB0A1E417DB03AA0055F150 /* AsyncUdpSocket.m in Sources */ = {isa = PBXBuildFile; fileRef = CEB0A14C17DB03A90055F150 /* AsyncUdpSocket.m */; }; CEB0A23317DB03D40055F150 /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEB0A23217DB03D40055F150 /* CoreServices.framework */; }; CEB0A23517DB03E00055F150 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEB0A23417DB03E00055F150 /* Security.framework */; }; - CEB0A25117DB09C10055F150 /* TGInitializer.m in Sources */ = {isa = PBXBuildFile; fileRef = CEB0A25017DB09C10055F150 /* TGInitializer.m */; }; CEB0D71618E0CBB000457D08 /* libopus.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C2A5BF9D18DC800E0021BE68 /* libopus.a */; }; CEB0D72418E3770D00457D08 /* TMWindowTitleView.m in Sources */ = {isa = PBXBuildFile; fileRef = CEB0D72318E3770D00457D08 /* TMWindowTitleView.m */; }; CEB26161180C91F900378932 /* RpcErrorParser.m in Sources */ = {isa = PBXBuildFile; fileRef = CEB26160180C91F900378932 /* RpcErrorParser.m */; }; @@ -850,30 +915,43 @@ CEC6A8F018C90A69002EC18F /* DatacenterArchiver.m in Sources */ = {isa = PBXBuildFile; fileRef = CEC6A8EF18C90A69002EC18F /* DatacenterArchiver.m */; }; CEC8B88A1832108A00283E53 /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = CEC8B8891832108A00283E53 /* Reachability.m */; }; CECBC15618008B3300AD98E6 /* CMath.c in Sources */ = {isa = PBXBuildFile; fileRef = CECBC15518008B3300AD98E6 /* CMath.c */; }; - CECBC1661800CA2400AD98E6 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEB09E6017DAFC250055F150 /* Foundation.framework */; }; CECBC1691800D5E000AD98E6 /* NSMutableData+Extension.m in Sources */ = {isa = PBXBuildFile; fileRef = CECBC1681800D5E000AD98E6 /* NSMutableData+Extension.m */; }; CEF5C02817FFFEFE006CEE27 /* NSData+Extensions.m in Sources */ = {isa = PBXBuildFile; fileRef = CEF5C02717FFFEFE006CEE27 /* NSData+Extensions.m */; }; CEF8EB8A17FCA81000740D66 /* NSString+NSStringHexToBytes.m in Sources */ = {isa = PBXBuildFile; fileRef = CEF8EB8917FCA81000740D66 /* NSString+NSStringHexToBytes.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ - C2D825FD1B6F9E8300434D37 /* PBXContainerItemProxy */ = { + 8AF787EC1C57031900DC72E6 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; - containerPortal = C2D825F11B6F9E8200434D37 /* SSignalKit.xcodeproj */; + containerPortal = C26E80101B7B748A003CC483 /* SSignalKit.xcodeproj */; proxyType = 2; - remoteGlobalIDString = D0445DD81A7C2CA500267924; - remoteInfo = SSignalKit; + remoteGlobalIDString = D0085B221B282B9800EAF753; + remoteInfo = SwiftSignalKit; }; - C2D825FF1B6F9E8300434D37 /* PBXContainerItemProxy */ = { + 8AF787EE1C57031900DC72E6 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; - containerPortal = C2D825F11B6F9E8200434D37 /* SSignalKit.xcodeproj */; + containerPortal = C26E80101B7B748A003CC483 /* SSignalKit.xcodeproj */; proxyType = 2; - remoteGlobalIDString = D0445E5C1A7C446000267924; - remoteInfo = SSignalKitStatic; + remoteGlobalIDString = D0085B2C1B282B9800EAF753; + remoteInfo = SwiftSignalKitTests; }; - C2D826011B6F9E8300434D37 /* PBXContainerItemProxy */ = { + 8AF787F31C5704BD00DC72E6 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; - containerPortal = C2D825F11B6F9E8200434D37 /* SSignalKit.xcodeproj */; + containerPortal = C2D826131B6FA8A600434D37 /* MtProtoKit.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = D079AB961AF39B8000076F59; + remoteInfo = MtProtoKitMac; + }; + C26E80161B7B748A003CC483 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = C26E80101B7B748A003CC483 /* SSignalKit.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = D0445DD81A7C2CA500267924; + remoteInfo = SSignalKit; + }; + C26E801A1B7B748A003CC483 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = C26E80101B7B748A003CC483 /* SSignalKit.xcodeproj */; proxyType = 2; remoteGlobalIDString = D0445DE31A7C2CA500267924; remoteInfo = SSignalKitTests; @@ -899,13 +977,6 @@ remoteGlobalIDString = D0D2250B1B4D817B0085E26D; remoteInfo = MtProtoKitDynamic; }; - C2D826201B6FA8A600434D37 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = C2D826131B6FA8A600434D37 /* MtProtoKit.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = D0D225151B4D817B0085E26D; - remoteInfo = MtProtoKitDynamicTests; - }; C2E561021AF3726300B4CAF0 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = C2E560FD1AF3726300B4CAF0 /* sqlcipher.xcodeproj */; @@ -922,8 +993,8 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( - C2D825C31B664EC500434D37 /* Sparkle.framework in Copy Files (6 items) */, - C2D825C41B664EC500434D37 /* HockeySDK.framework in Copy Files (6 items) */, + C2FB6C921C05F08200B066A4 /* Sparkle.framework in Copy Files (6 items) */, + C2FB6C931C05F08200B066A4 /* HockeySDK.framework in Copy Files (6 items) */, ); name = "Copy Files (6 items)"; runOnlyForDeploymentPostprocessing = 0; @@ -977,8 +1048,6 @@ 0A241A9F18AB2F5900C32F45 /* MessageTableCellPhotoView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MessageTableCellPhotoView.m; sourceTree = ""; }; 0A241AA118AB2FF200C32F45 /* MessageTableItemPhoto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageTableItemPhoto.h; sourceTree = ""; }; 0A241AA218AB2FF200C32F45 /* MessageTableItemPhoto.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MessageTableItemPhoto.m; sourceTree = ""; }; - 0A241AA418AB60BA00C32F45 /* TMGLGif.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TMGLGif.h; sourceTree = ""; }; - 0A241AA518AB60BA00C32F45 /* TMGLGif.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TMGLGif.m; sourceTree = ""; }; 0A241AAC18ACD39700C32F45 /* MessageTableCellVideoView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageTableCellVideoView.h; sourceTree = ""; }; 0A241AAD18ACD39700C32F45 /* MessageTableCellVideoView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MessageTableCellVideoView.m; sourceTree = ""; }; 0A241AAF18ACD46700C32F45 /* MessageTableItemVideo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageTableItemVideo.h; sourceTree = ""; }; @@ -1251,8 +1320,6 @@ 0AB43B8A18D2FBC400FB805A /* RegistrationViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RegistrationViewController.m; sourceTree = ""; }; 0AB43B9018D304C400FB805A /* RegistrationAvatarView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegistrationAvatarView.h; sourceTree = ""; }; 0AB43B9118D304C400FB805A /* RegistrationAvatarView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RegistrationAvatarView.m; sourceTree = ""; }; - 0AB43B9C18D43DC000FB805A /* TMGifImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TMGifImageView.h; sourceTree = ""; }; - 0AB43B9D18D43DC000FB805A /* TMGifImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TMGifImageView.m; sourceTree = ""; }; 0AB43BA318D44A1C00FB805A /* GifAnimationLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GifAnimationLayer.h; sourceTree = ""; }; 0AB43BA418D44A1C00FB805A /* GifAnimationLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GifAnimationLayer.m; sourceTree = ""; }; 0AB43BA618D4D60B00FB805A /* MessageInputGrowingTextView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageInputGrowingTextView.h; sourceTree = ""; }; @@ -1380,6 +1447,56 @@ C2082B7219C1E1C4000005E2 /* HockeySDK.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = HockeySDK.framework; sourceTree = ""; }; C20932221938BABF00DFF3EC /* AudioHistoryFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioHistoryFilter.h; sourceTree = ""; }; C20932231938BABF00DFF3EC /* AudioHistoryFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AudioHistoryFilter.m; sourceTree = ""; }; + C20A5E6F1B86290C007F4B49 /* TGWebpageGifObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGWebpageGifObject.h; sourceTree = ""; }; + C20A5E701B86290C007F4B49 /* TGWebpageGifObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGWebpageGifObject.m; sourceTree = ""; }; + C20A5E811B863979007F4B49 /* TGWebpageGifContainer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGWebpageGifContainer.h; sourceTree = ""; }; + C20A5E821B863979007F4B49 /* TGWebpageGifContainer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGWebpageGifContainer.m; sourceTree = ""; }; + C20A5E8D1B86404D007F4B49 /* DownloadCacheDocumentItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DownloadCacheDocumentItem.h; sourceTree = ""; }; + C20A5E8E1B86404D007F4B49 /* DownloadCacheDocumentItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DownloadCacheDocumentItem.m; sourceTree = ""; }; + C20A5EA51B86625F007F4B49 /* TGUpdateChannels.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGUpdateChannels.h; sourceTree = ""; }; + C20A5EA61B86625F007F4B49 /* TGUpdateChannels.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGUpdateChannels.m; sourceTree = ""; }; + C20A5EB11B871ABA007F4B49 /* TGUpdateChannelContainer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGUpdateChannelContainer.h; sourceTree = ""; }; + C20A5EB21B871ABA007F4B49 /* TGUpdateChannelContainer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGUpdateChannelContainer.m; sourceTree = ""; }; + C20A5EB41B873944007F4B49 /* TL_localMessage_old34.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TL_localMessage_old34.h; sourceTree = ""; }; + C20A5EB51B873944007F4B49 /* TL_localMessage_old34.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TL_localMessage_old34.m; sourceTree = ""; }; + C20A5EB81B874890007F4B49 /* ChannelInfoHeaderView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChannelInfoHeaderView.h; sourceTree = ""; }; + C20A5EB91B874890007F4B49 /* ChannelInfoHeaderView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChannelInfoHeaderView.m; sourceTree = ""; }; + C20A5EBB1B8748A3007F4B49 /* ChannelInfoViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChannelInfoViewController.h; sourceTree = ""; }; + C20A5EBC1B8748A3007F4B49 /* ChannelInfoViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChannelInfoViewController.m; sourceTree = ""; }; + C20A5EC11B878E7B007F4B49 /* TL_channelConversation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TL_channelConversation.h; sourceTree = ""; }; + C20A5EC21B878E7C007F4B49 /* TL_channelConversation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TL_channelConversation.m; sourceTree = ""; }; + C20A5ECD1B8B67D7007F4B49 /* TL_conversation_old34.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TL_conversation_old34.h; sourceTree = ""; }; + C20A5ECE1B8B67D7007F4B49 /* TL_conversation_old34.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TL_conversation_old34.m; sourceTree = ""; }; + C20A5ED91B8B7A81007F4B49 /* TGModernConversationHistoryController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGModernConversationHistoryController.h; sourceTree = ""; }; + C20A5EDA1B8B7A81007F4B49 /* TGModernConversationHistoryController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGModernConversationHistoryController.m; sourceTree = ""; }; + C20A5EDD1B8B8905007F4B49 /* TGObservableObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGObservableObject.h; sourceTree = ""; }; + C20A5EDE1B8B8905007F4B49 /* TGObservableObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGObservableObject.m; sourceTree = ""; }; + C20A5EE11B8CC19C007F4B49 /* TGDispatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGDispatcher.h; sourceTree = ""; }; + C20A5EE21B8CC19C007F4B49 /* TGDispatcher.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGDispatcher.m; sourceTree = ""; }; + C20A5EE41B8CC813007F4B49 /* TGEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGEvent.h; sourceTree = ""; }; + C20A5EE51B8CC813007F4B49 /* TGEvent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGEvent.m; sourceTree = ""; }; + C20A5EE81B8CD8B8007F4B49 /* AddContactView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AddContactView.h; sourceTree = ""; }; + C20A5EE91B8CD8B8007F4B49 /* AddContactView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AddContactView.m; sourceTree = ""; }; + C20A5EEA1B8CD8B8007F4B49 /* AddContactViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AddContactViewController.h; sourceTree = ""; }; + C20A5EEB1B8CD8B8007F4B49 /* AddContactViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AddContactViewController.m; sourceTree = ""; }; + C20A5EEE1B8CD8CB007F4B49 /* TMBlueInputTextField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TMBlueInputTextField.h; sourceTree = ""; }; + C20A5EEF1B8CD8CB007F4B49 /* TMBlueInputTextField.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TMBlueInputTextField.m; sourceTree = ""; }; + C20A5EF11B8CEE8E007F4B49 /* ChannelFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChannelFilter.h; sourceTree = ""; }; + C20A5EF21B8CEE8E007F4B49 /* ChannelFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChannelFilter.m; sourceTree = ""; }; + C20A5F331B8F4579007F4B49 /* TGChannelsPolling.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGChannelsPolling.h; sourceTree = ""; }; + C20A5F341B8F4579007F4B49 /* TGChannelsPolling.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGChannelsPolling.m; sourceTree = ""; }; + C20A5F451B8F6863007F4B49 /* TGMessageHole.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGMessageHole.h; sourceTree = ""; }; + C20A5F461B8F6863007F4B49 /* TGMessageHole.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGMessageHole.m; sourceTree = ""; }; + C20A5F511B8F6CC3007F4B49 /* MessageTableItemHole.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageTableItemHole.h; sourceTree = ""; }; + C20A5F521B8F6CC3007F4B49 /* MessageTableItemHole.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MessageTableItemHole.m; sourceTree = ""; }; + C20A5F541B8F6CDD007F4B49 /* MessageTableCellHoleView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageTableCellHoleView.h; sourceTree = ""; }; + C20A5F551B8F6CDD007F4B49 /* MessageTableCellHoleView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MessageTableCellHoleView.m; sourceTree = ""; }; + C20A5F571B8F8B2B007F4B49 /* TGHistoryResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGHistoryResponse.h; sourceTree = ""; }; + C20A5F581B8F8B2B007F4B49 /* TGHistoryResponse.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGHistoryResponse.m; sourceTree = ""; }; + C20A5F5A1B90D815007F4B49 /* TGMessageGroupHole.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGMessageGroupHole.h; sourceTree = ""; }; + C20A5F5B1B90D815007F4B49 /* TGMessageGroupHole.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGMessageGroupHole.m; sourceTree = ""; }; + C20A5F5D1B9330CD007F4B49 /* ChannelImportantFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChannelImportantFilter.h; sourceTree = ""; }; + C20A5F5E1B9330CD007F4B49 /* ChannelImportantFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChannelImportantFilter.m; sourceTree = ""; }; C20A7E5A19D7064D008844F2 /* TGDatacenterWatchdogActor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGDatacenterWatchdogActor.h; sourceTree = ""; }; C20A7E5B19D7064D008844F2 /* TGDatacenterWatchdogActor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGDatacenterWatchdogActor.m; sourceTree = ""; }; C20A7E5D19D7069C008844F2 /* TGActor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGActor.h; sourceTree = ""; }; @@ -1390,13 +1507,18 @@ C20A7E7A19DC1379008844F2 /* TGCTextView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGCTextView.h; sourceTree = ""; }; C20A7E7B19DC1379008844F2 /* TGCTextView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGCTextView.m; sourceTree = ""; }; C20A7E7D19DC1816008844F2 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; - C20A7E7F19DC1887008844F2 /* ImageIO.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ImageIO.framework; path = System/Library/Frameworks/ImageIO.framework; sourceTree = SDKROOT; }; C20B228418E971D0007BCCD6 /* bitwise.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bitwise.c; sourceTree = ""; }; C20B228518E971D0007BCCD6 /* framing.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = framing.c; sourceTree = ""; }; C20B228618E971D0007BCCD6 /* ogg.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ogg.h; sourceTree = ""; }; C20B228718E971D0007BCCD6 /* os_types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = os_types.h; sourceTree = ""; }; C20B228B18E98A2C007BCCD6 /* SettingsArchiver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingsArchiver.h; sourceTree = ""; }; C20B228C18E98A2C007BCCD6 /* SettingsArchiver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SettingsArchiver.m; sourceTree = ""; }; + C20B829F1BD98EC700EF01AD /* TGPVDocumentsBehavior.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGPVDocumentsBehavior.h; sourceTree = ""; }; + C20B82A01BD98EC700EF01AD /* TGPVDocumentsBehavior.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGPVDocumentsBehavior.m; sourceTree = ""; }; + C20B82AB1BDA550600EF01AD /* TGChatHeadLockView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGChatHeadLockView.h; sourceTree = ""; }; + C20B82AC1BDA550600EF01AD /* TGChatHeadLockView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGChatHeadLockView.m; sourceTree = ""; }; + C20B82AE1BDA975500EF01AD /* TGShareContactModalView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGShareContactModalView.h; sourceTree = ""; }; + C20B82AF1BDA975500EF01AD /* TGShareContactModalView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGShareContactModalView.m; sourceTree = ""; }; C20BA5DA1B0BB992001ECE22 /* TGSNoAuthModalView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGSNoAuthModalView.h; sourceTree = ""; }; C20BA5DB1B0BB992001ECE22 /* TGSNoAuthModalView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGSNoAuthModalView.m; sourceTree = ""; }; C20BA5DD1B0BBE85001ECE22 /* TGSAppManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGSAppManager.h; sourceTree = ""; }; @@ -1413,13 +1535,16 @@ C20D1891193E09C00095A906 /* TMBlueAddButtonView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TMBlueAddButtonView.h; sourceTree = ""; }; C20D1892193E09C00095A906 /* TMBlueAddButtonView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TMBlueAddButtonView.m; sourceTree = ""; }; C20D18B11945BE890095A906 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = ""; }; - C20D18ED1948A3F70095A906 /* ru */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = ru; path = ru.lproj/NewMainMenu.xib; sourceTree = ""; }; C20D18F31948A3FB0095A906 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/NewMainMenu.xib; sourceTree = ""; }; C20D18F51948A4970095A906 /* es */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = es; path = es.lproj/NewMainMenu.xib; sourceTree = ""; }; C20D18F61948D1FE0095A906 /* SecretChatAccepter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SecretChatAccepter.h; sourceTree = ""; }; C20D18F71948D1FE0095A906 /* SecretChatAccepter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SecretChatAccepter.m; sourceTree = ""; }; C20D190019542AB80095A906 /* SearchHistoryFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SearchHistoryFilter.h; sourceTree = ""; }; C20D190119542AB80095A906 /* SearchHistoryFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SearchHistoryFilter.m; sourceTree = ""; }; + C20F76E71BB994A6003A1E86 /* TGModernUserViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGModernUserViewController.h; sourceTree = ""; }; + C20F76E81BB994A6003A1E86 /* TGModernUserViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGModernUserViewController.m; sourceTree = ""; }; + C20F76EB1BBAC41A003A1E86 /* TGMessagesHintView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGMessagesHintView.h; sourceTree = ""; }; + C20F76EC1BBAC41A003A1E86 /* TGMessagesHintView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGMessagesHintView.m; sourceTree = ""; }; C2182BBC19589246002469CA /* TL_localMessageService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TL_localMessageService.h; sourceTree = ""; }; C2182BBD19589246002469CA /* TL_localMessageService.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TL_localMessageService.m; sourceTree = ""; }; C21C7B2A18D7044600253A7A /* MessageSenderItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageSenderItem.h; sourceTree = ""; }; @@ -1486,10 +1611,6 @@ C22019FF192CCB5C00C0E441 /* SelectUserItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SelectUserItem.m; sourceTree = ""; }; C2201A01192CCB6C00C0E441 /* SelectUserRowView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SelectUserRowView.h; sourceTree = ""; }; C2201A02192CCB6C00C0E441 /* SelectUserRowView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SelectUserRowView.m; sourceTree = ""; }; - C2201A04192E488D00C0E441 /* AddContactView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AddContactView.h; sourceTree = ""; }; - C2201A05192E488D00C0E441 /* AddContactView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AddContactView.m; sourceTree = ""; }; - C2201A08192E4AAA00C0E441 /* TMBlueInputTextField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TMBlueInputTextField.h; sourceTree = ""; }; - C2201A09192E4AAA00C0E441 /* TMBlueInputTextField.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TMBlueInputTextField.m; sourceTree = ""; }; C2201A0B1934E6D600C0E441 /* DownloadPart.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DownloadPart.h; sourceTree = ""; }; C2201A0C1934E6D600C0E441 /* DownloadPart.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DownloadPart.m; sourceTree = ""; }; C222773018FC2CA4002AA0F6 /* MessageTableItemUnreadMark.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageTableItemUnreadMark.h; sourceTree = ""; }; @@ -1500,8 +1621,6 @@ C222774118FE8BB3002AA0F6 /* ChatHistoryController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChatHistoryController.m; sourceTree = ""; }; C222774C19093C8C002AA0F6 /* TMBottomScrollView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TMBottomScrollView.h; sourceTree = ""; }; C222774D19093C8C002AA0F6 /* TMBottomScrollView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TMBottomScrollView.m; sourceTree = ""; }; - C2227750190E564B002AA0F6 /* OnlineNotificationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OnlineNotificationManager.h; sourceTree = ""; }; - C2227751190E564B002AA0F6 /* OnlineNotificationManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OnlineNotificationManager.m; sourceTree = ""; }; C2227757190E7309002AA0F6 /* TMTaskRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TMTaskRequest.h; sourceTree = ""; }; C2227758190E7309002AA0F6 /* TMTaskRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TMTaskRequest.m; sourceTree = ""; }; C222775C190E7403002AA0F6 /* ITaskRequest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ITaskRequest.h; sourceTree = ""; }; @@ -1547,14 +1666,6 @@ C23298DA18CF61AE000826E5 /* TMPreviewPhotoItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TMPreviewPhotoItem.m; sourceTree = ""; }; C23298DC18CF61DD000826E5 /* TMMediaController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TMMediaController.h; sourceTree = ""; }; C23298DD18CF61DD000826E5 /* TMMediaController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TMMediaController.mm; sourceTree = ""; }; - C233FB2618B610E9008C9A96 /* NewConversationViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NewConversationViewController.h; sourceTree = ""; }; - C233FB2718B610E9008C9A96 /* NewConversationViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NewConversationViewController.m; sourceTree = ""; }; - C233FB2918B6126C008C9A96 /* NewConversationTableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NewConversationTableView.h; sourceTree = ""; }; - C233FB2A18B6126C008C9A96 /* NewConversationTableView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NewConversationTableView.m; sourceTree = ""; }; - C233FB2C18B61415008C9A96 /* NewConversationRowItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NewConversationRowItem.h; sourceTree = ""; }; - C233FB2D18B61415008C9A96 /* NewConversationRowItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NewConversationRowItem.m; sourceTree = ""; }; - C233FB2F18B61618008C9A96 /* NewConversationRowView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NewConversationRowView.h; sourceTree = ""; }; - C233FB3018B61618008C9A96 /* NewConversationRowView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NewConversationRowView.m; sourceTree = ""; }; C233FB3218B661B6008C9A96 /* TMCheckBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TMCheckBox.h; sourceTree = ""; }; C233FB3318B661B6008C9A96 /* TMCheckBox.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TMCheckBox.m; sourceTree = ""; }; C235364C19C88D620044978E /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Sparkle.framework; sourceTree = ""; }; @@ -1670,6 +1781,10 @@ C256E91918D24C4C008FFA04 /* DownloadAudioItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DownloadAudioItem.m; sourceTree = ""; }; C256E91B18D25324008FFA04 /* TMPreviewAudioItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TMPreviewAudioItem.h; sourceTree = ""; }; C256E91C18D25324008FFA04 /* TMPreviewAudioItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TMPreviewAudioItem.m; sourceTree = ""; }; + C25A57DE1C072D1D0038169F /* ComposeActionStickersBehavior.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ComposeActionStickersBehavior.h; sourceTree = ""; }; + C25A57DF1C072D1D0038169F /* ComposeActionStickersBehavior.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ComposeActionStickersBehavior.m; sourceTree = ""; }; + C25A57EA1C0736D70038169F /* TGMovableTableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGMovableTableView.h; sourceTree = ""; }; + C25A57EB1C0736D70038169F /* TGMovableTableView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGMovableTableView.m; sourceTree = ""; }; C25F91B11977E115006868F3 /* TGImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGImageView.h; sourceTree = ""; }; C25F91B21977E115006868F3 /* TGImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGImageView.m; sourceTree = ""; }; C25F91B71977EB17006868F3 /* TGImageObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGImageObject.h; sourceTree = ""; }; @@ -1779,6 +1894,17 @@ C26976AF1A10CDED0047E2C3 /* TGPhotoViewer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGPhotoViewer.m; sourceTree = ""; }; C26976B21A10E2110047E2C3 /* TGPVContainer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGPVContainer.h; sourceTree = ""; }; C26976B31A10E2110047E2C3 /* TGPVContainer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGPVContainer.m; sourceTree = ""; }; + C26E80101B7B748A003CC483 /* SSignalKit.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = SSignalKit.xcodeproj; path = Signals/SSignalKit.xcodeproj; sourceTree = ""; }; + C26E801E1B7B91A9003CC483 /* TGDatabaseRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGDatabaseRequest.h; sourceTree = ""; }; + C26E801F1B7B91A9003CC483 /* TGDatabaseRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGDatabaseRequest.m; sourceTree = ""; }; + C26E80251B7D14E2003CC483 /* TL_localMessage_old32.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TL_localMessage_old32.h; sourceTree = ""; }; + C26E80261B7D14E2003CC483 /* TL_localMessage_old32.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TL_localMessage_old32.m; sourceTree = ""; }; + C26E80281B7E00A1003CC483 /* TGRecentSearchRowItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGRecentSearchRowItem.h; sourceTree = ""; }; + C26E80291B7E00A1003CC483 /* TGRecentSearchRowItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGRecentSearchRowItem.m; sourceTree = ""; }; + C26E802B1B7E00C3003CC483 /* TGRecentSearchRowView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGRecentSearchRowView.h; sourceTree = ""; }; + C26E802C1B7E00C3003CC483 /* TGRecentSearchRowView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGRecentSearchRowView.m; sourceTree = ""; }; + C26E802E1B7E106B003CC483 /* TGRecentSearchTableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGRecentSearchTableView.h; sourceTree = ""; }; + C26E802F1B7E106B003CC483 /* TGRecentSearchTableView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGRecentSearchTableView.m; sourceTree = ""; }; C26F7E9C1A4B1EEB001D1AE2 /* nl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nl; path = nl.lproj/InfoPlist.strings; sourceTree = ""; }; C26F7E9D1A4B1EEB001D1AE2 /* nl */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = nl; path = nl.lproj/NewMainMenu.xib; sourceTree = ""; }; C26F7E9E1A4B1EEB001D1AE2 /* nl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nl; path = nl.lproj/Localizable.strings; sourceTree = ""; }; @@ -1826,8 +1952,6 @@ C271525D19B72F3400841C8A /* ComposeActionAddGroupMembersBehavior.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ComposeActionAddGroupMembersBehavior.m; sourceTree = ""; }; C271525F19B731DB00841C8A /* ComposeActionAddBroadcastMembersBehavior.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ComposeActionAddBroadcastMembersBehavior.h; sourceTree = ""; }; C271526019B731DB00841C8A /* ComposeActionAddBroadcastMembersBehavior.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ComposeActionAddBroadcastMembersBehavior.m; sourceTree = ""; }; - C271526219B9ECCA00841C8A /* AddContactViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AddContactViewController.h; sourceTree = ""; }; - C271526319B9ECCA00841C8A /* AddContactViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AddContactViewController.m; sourceTree = ""; }; C273804C1B3B2F77000C479E /* MP3HistoryFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MP3HistoryFilter.h; sourceTree = ""; }; C273804D1B3B2F77000C479E /* MP3HistoryFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MP3HistoryFilter.m; sourceTree = ""; }; C273805B1B3D90DC000C479E /* TGAudioPlayerWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGAudioPlayerWindow.m; sourceTree = ""; }; @@ -1883,8 +2007,6 @@ C274C4181ACC09B0000DFDE4 /* XCDYouTubeVideoOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XCDYouTubeVideoOperation.m; sourceTree = ""; }; C274C41B1ACC09B0000DFDE4 /* XCDYouTubeVideoWebpage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XCDYouTubeVideoWebpage.h; sourceTree = ""; }; C274C41C1ACC09B0000DFDE4 /* XCDYouTubeVideoWebpage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XCDYouTubeVideoWebpage.m; sourceTree = ""; }; - C274C4231ACC0D4D000DFDE4 /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/JavaScriptCore.framework; sourceTree = DEVELOPER_DIR; }; - C274C42D1ACC5B3A000DFDE4 /* AVKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVKit.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/AVKit.framework; sourceTree = DEVELOPER_DIR; }; C274C43E1ACD8223000DFDE4 /* TGWebpageIGObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGWebpageIGObject.h; sourceTree = ""; }; C274C43F1ACD8223000DFDE4 /* TGWebpageIGObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGWebpageIGObject.m; sourceTree = ""; }; C274C4451ACD99E7000DFDE4 /* TGWebpageTWObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGWebpageTWObject.h; sourceTree = ""; }; @@ -1908,8 +2030,6 @@ C276C7D1195C6C1B0037C4D7 /* ITProgressIndicator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ITProgressIndicator.h; sourceTree = ""; }; C276C7D2195C6C1B0037C4D7 /* ITProgressIndicator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ITProgressIndicator.m; sourceTree = ""; }; C277E2A118AAA69B00FFCA35 /* MessagesDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MessagesDelegate.h; sourceTree = ""; }; - C277E2A218ABB44A00FFCA35 /* DialogsHistoryController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DialogsHistoryController.h; sourceTree = ""; }; - C277E2A318ABB44A00FFCA35 /* DialogsHistoryController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DialogsHistoryController.m; sourceTree = ""; }; C281C1761917D9C2007B160F /* DraggingControllerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DraggingControllerView.h; sourceTree = ""; }; C281C1771917D9C2007B160F /* DraggingControllerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DraggingControllerView.m; sourceTree = ""; }; C281C1791917D9D9007B160F /* DraggingItemView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DraggingItemView.h; sourceTree = ""; }; @@ -1926,6 +2046,8 @@ C28261E8199291EF004AC73E /* TL_broadcast.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TL_broadcast.m; sourceTree = ""; }; C28261EA1992974C004AC73E /* BroadcastManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BroadcastManager.h; sourceTree = ""; }; C28261EB1992974C004AC73E /* BroadcastManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BroadcastManager.m; sourceTree = ""; }; + C28C86751B98851300267C0B /* TGSKeychain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGSKeychain.h; sourceTree = ""; }; + C28C86761B98851300267C0B /* TGSKeychain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGSKeychain.m; sourceTree = ""; }; C291C7B81836C39900ABBB50 /* Background.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Background.h; sourceTree = ""; }; C291C7B91836C39900ABBB50 /* Background.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Background.m; sourceTree = ""; }; C291C7BA1836C39900ABBB50 /* LBProgressBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LBProgressBar.h; sourceTree = ""; }; @@ -1969,6 +2091,12 @@ C297FBA21832997B00714B3C /* SSKeychain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SSKeychain.m; sourceTree = ""; }; C297FBA418329F3500714B3C /* TGDcAuth.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGDcAuth.h; sourceTree = ""; }; C297FBA518329F3500714B3C /* TGDcAuth.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGDcAuth.m; sourceTree = ""; }; + C2A2B4241BD01FC20083DA8A /* TGHeadChatPanel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGHeadChatPanel.h; sourceTree = ""; }; + C2A2B4251BD01FC20083DA8A /* TGHeadChatPanel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGHeadChatPanel.m; sourceTree = ""; }; + C2A2B42C1BD519870083DA8A /* TGHCMessagesViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGHCMessagesViewController.h; sourceTree = ""; }; + C2A2B42D1BD519870083DA8A /* TGHCMessagesViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGHCMessagesViewController.m; sourceTree = ""; }; + C2A2B42F1BD7C8DB0083DA8A /* TGModalForwardView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGModalForwardView.h; sourceTree = ""; }; + C2A2B4301BD7C8DB0083DA8A /* TGModalForwardView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGModalForwardView.m; sourceTree = ""; }; C2A3FB071A278E2700DE791B /* PhoneChangeController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PhoneChangeController.h; sourceTree = ""; }; C2A3FB081A278E2700DE791B /* PhoneChangeController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PhoneChangeController.m; sourceTree = ""; }; C2A3FB0B1A28A6B200DE791B /* TGHashContact.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGHashContact.h; sourceTree = ""; }; @@ -2043,12 +2171,41 @@ C2ACCE6A1AE10ED200ABEE78 /* TGRaceEmoji.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGRaceEmoji.m; sourceTree = ""; }; C2ACCE6C1AE122A400ABEE78 /* EmojiButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EmojiButton.h; sourceTree = ""; }; C2ACCE6D1AE122A400ABEE78 /* EmojiButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EmojiButton.m; sourceTree = ""; }; + C2B0DF751BA98E7C0023982C /* TL_localEmptyMessage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TL_localEmptyMessage.h; sourceTree = ""; }; + C2B0DF761BA98E7C0023982C /* TL_localEmptyMessage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TL_localEmptyMessage.m; sourceTree = ""; }; + C2B0DF811BA9B7840023982C /* ComposeActionAddChannelModeratorBehavior.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ComposeActionAddChannelModeratorBehavior.h; sourceTree = ""; }; + C2B0DF821BA9B7840023982C /* ComposeActionAddChannelModeratorBehavior.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ComposeActionAddChannelModeratorBehavior.m; sourceTree = ""; }; + C2B0DF841BA9C59B0023982C /* ComposeConfirmModeratorViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ComposeConfirmModeratorViewController.h; sourceTree = ""; }; + C2B0DF851BA9C59B0023982C /* ComposeConfirmModeratorViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ComposeConfirmModeratorViewController.m; sourceTree = ""; }; + C2B0DF871BA9C6EC0023982C /* TGUserContainerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGUserContainerView.h; sourceTree = ""; }; + C2B0DF881BA9C6EC0023982C /* TGUserContainerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGUserContainerView.m; sourceTree = ""; }; + C2B0DF8A1BA9CE290023982C /* TGUserContainerRowItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGUserContainerRowItem.h; sourceTree = ""; }; + C2B0DF8B1BA9CE290023982C /* TGUserContainerRowItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGUserContainerRowItem.m; sourceTree = ""; }; + C2B0DF8D1BAAD9330023982C /* ComposeManagmentViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ComposeManagmentViewController.h; sourceTree = ""; }; + C2B0DF8E1BAAD9330023982C /* ComposeManagmentViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ComposeManagmentViewController.m; sourceTree = ""; }; + C2B0DF901BAAFD2E0023982C /* ComposeChannelParticipantsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ComposeChannelParticipantsViewController.h; sourceTree = ""; }; + C2B0DF911BAAFD2E0023982C /* ComposeChannelParticipantsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ComposeChannelParticipantsViewController.m; sourceTree = ""; }; + C2B0DF971BAAFEFA0023982C /* TGModalDeleteChannelMessagesView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGModalDeleteChannelMessagesView.h; sourceTree = ""; }; + C2B0DF981BAAFEFA0023982C /* TGModalDeleteChannelMessagesView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGModalDeleteChannelMessagesView.m; sourceTree = ""; }; + C2B0DF9A1BAB07DD0023982C /* ComposeActionBlackListBehavior.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ComposeActionBlackListBehavior.h; sourceTree = ""; }; + C2B0DF9B1BAB07DD0023982C /* ComposeActionBlackListBehavior.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ComposeActionBlackListBehavior.m; sourceTree = ""; }; + C2B0DF9D1BAB13820023982C /* ComposeActionDeleteChannelMessagesBehavior.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ComposeActionDeleteChannelMessagesBehavior.h; sourceTree = ""; }; + C2B0DF9E1BAB13820023982C /* ComposeActionDeleteChannelMessagesBehavior.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ComposeActionDeleteChannelMessagesBehavior.m; sourceTree = ""; }; + C2B0DFA01BAB34330023982C /* ComposeActionChannelMembersBehavior.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ComposeActionChannelMembersBehavior.h; sourceTree = ""; }; + C2B0DFA11BAB34330023982C /* ComposeActionChannelMembersBehavior.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ComposeActionChannelMembersBehavior.m; sourceTree = ""; }; C2B1730B19A3BF43003FBA23 /* Application.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Application.h; sourceTree = ""; }; C2B325EC1A237A420012DE34 /* TLApiObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TLApiObject.h; sourceTree = ""; }; C2B325ED1A237A420012DE34 /* TLApiObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TLApiObject.m; sourceTree = ""; }; C2B326061A24F77E0012DE34 /* PhoneChangeAlertController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PhoneChangeAlertController.h; sourceTree = ""; }; C2B326071A24F77E0012DE34 /* PhoneChangeAlertController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PhoneChangeAlertController.m; sourceTree = ""; }; - C2BC529C1A695A270004A8FE /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/IOKit.framework; sourceTree = DEVELOPER_DIR; }; + C2B669841BA5571C004AF678 /* TGSettingsTableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGSettingsTableView.h; sourceTree = ""; }; + C2B669851BA5571C004AF678 /* TGSettingsTableView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGSettingsTableView.m; sourceTree = ""; }; + C2B669871BA5591F004AF678 /* TGGeneralRowItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGGeneralRowItem.h; sourceTree = ""; }; + C2B669881BA5591F004AF678 /* TGGeneralRowItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGGeneralRowItem.m; sourceTree = ""; }; + C2B6698A1BA570AF004AF678 /* ComposeCreateChannelUserNameStepViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ComposeCreateChannelUserNameStepViewController.h; sourceTree = ""; }; + C2B6698B1BA570AF004AF678 /* ComposeCreateChannelUserNameStepViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ComposeCreateChannelUserNameStepViewController.m; sourceTree = ""; }; + C2B6698D1BA575AE004AF678 /* TGChangeUserNameContainerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGChangeUserNameContainerView.h; sourceTree = ""; }; + C2B6698E1BA575AE004AF678 /* TGChangeUserNameContainerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGChangeUserNameContainerView.m; sourceTree = ""; }; C2C1DC031A43345400BBCC63 /* MessageTableItemSticker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageTableItemSticker.h; sourceTree = ""; }; C2C1DC041A43345400BBCC63 /* MessageTableItemSticker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MessageTableItemSticker.m; sourceTree = ""; }; C2C1DC0A1A43347800BBCC63 /* MessageTableCellStickerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageTableCellStickerView.h; sourceTree = ""; }; @@ -2136,8 +2293,6 @@ C2CB5D401B4D697700CD61DF /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; C2CB5D5D1B4D871600CD61DF /* TGUpdater.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGUpdater.h; sourceTree = ""; }; C2CB5D5E1B4D871600CD61DF /* TGUpdater.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGUpdater.m; sourceTree = ""; }; - C2CB5DA11B4DB14F00CD61DF /* libstdc++.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = "libstdc++.dylib"; path = "Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/lib/libstdc++.dylib"; sourceTree = DEVELOPER_DIR; }; - C2CB5DA41B4DB18700CD61DF /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Cocoa.framework; sourceTree = DEVELOPER_DIR; }; C2CB5DC31B4EAA4F00CD61DF /* NSObject+BObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSObject+BObject.h"; sourceTree = ""; }; C2CB5DC41B4EAA4F00CD61DF /* NSObject+BObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSObject+BObject.m"; sourceTree = ""; }; C2CB5DC61B4EAA6300CD61DF /* AJObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AJObject.h; sourceTree = ""; }; @@ -2163,24 +2318,14 @@ C2CBF5E71AF7CBD9006BF90A /* TGS_RPCRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGS_RPCRequest.m; sourceTree = ""; }; C2CBF5F01AF8DA5C006BF90A /* ClassStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClassStore.h; sourceTree = ""; }; C2CBF5F11AF8DA5C006BF90A /* ClassStore.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ClassStore.m; sourceTree = ""; }; - C2CBF60D1AF90881006BF90A /* libsqlite3.0.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libsqlite3.0.dylib; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/lib/libsqlite3.0.dylib; sourceTree = DEVELOPER_DIR; }; - C2CBF6161AF911A2006BF90A /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/SystemConfiguration.framework; sourceTree = DEVELOPER_DIR; }; - C2CBF6181AF912A8006BF90A /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/lib/libz.dylib; sourceTree = DEVELOPER_DIR; }; - C2CBF6491AFA5A23006BF90A /* MapKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MapKit.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/MapKit.framework; sourceTree = DEVELOPER_DIR; }; - C2CBF6741AFB6AFA006BF90A /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/AppKit.framework; sourceTree = DEVELOPER_DIR; }; C2CBF67C1AFB6B6D006BF90A /* TGShare.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGShare.pch; sourceTree = ""; }; C2CBF67D1AFB6BE1006BF90A /* TGHeader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGHeader.h; sourceTree = ""; }; - C2CBF67E1AFB6F13006BF90A /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; }; - C2CBF6801AFB6F18006BF90A /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Security.framework; sourceTree = DEVELOPER_DIR; }; - C2CBF6821AFB6F33006BF90A /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/AVFoundation.framework; sourceTree = DEVELOPER_DIR; }; - C2CBF6841AFB6FE6006BF90A /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/QuartzCore.framework; sourceTree = DEVELOPER_DIR; }; C2CBF6871AFB73FE006BF90A /* TGS_ConversationRowItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGS_ConversationRowItem.h; sourceTree = ""; }; C2CBF6881AFB73FE006BF90A /* TGS_ConversationRowItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGS_ConversationRowItem.m; sourceTree = ""; }; C2CBF68B1AFB7421006BF90A /* TGS_ConversationRowView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGS_ConversationRowView.h; sourceTree = ""; }; C2CBF68C1AFB7421006BF90A /* TGS_ConversationRowView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGS_ConversationRowView.m; sourceTree = ""; }; C2CBF6961AFB7EFE006BF90A /* CFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFunctions.h; sourceTree = ""; }; C2CBF6971AFB7EFE006BF90A /* CFunctions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CFunctions.m; sourceTree = ""; }; - C2CBF6A11AFB81A8006BF90A /* QuickLook.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuickLook.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/QuickLook.framework; sourceTree = DEVELOPER_DIR; }; C2CBF6AB1AFB84DB006BF90A /* TGDownloadItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGDownloadItem.h; sourceTree = ""; }; C2CBF6AC1AFB84DB006BF90A /* TGDownloadItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGDownloadItem.m; sourceTree = ""; }; C2CBF6AF1AFB8584006BF90A /* TGSDownloadItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGSDownloadItem.h; sourceTree = ""; }; @@ -2202,8 +2347,52 @@ C2CBF6D51AFBDB6F006BF90A /* TGLinearProgressView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGLinearProgressView.h; sourceTree = ""; }; C2CBF6D61AFBDB6F006BF90A /* TGLinearProgressView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGLinearProgressView.m; sourceTree = ""; }; C2CBF6DD1AFBE812006BF90A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; + C2CC41C21BA7FC450097E973 /* WeakReference.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeakReference.h; sourceTree = ""; }; + C2CC41C31BA7FC450097E973 /* WeakReference.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WeakReference.m; sourceTree = ""; }; C2CD77C71A2C9E04000B4BA9 /* TGEnterPasswordPanel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGEnterPasswordPanel.h; sourceTree = ""; }; C2CD77C81A2C9E04000B4BA9 /* TGEnterPasswordPanel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGEnterPasswordPanel.m; sourceTree = ""; }; + C2CE53BE1BE2892E00BBEF5F /* ChatAdminsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChatAdminsViewController.h; sourceTree = ""; }; + C2CE53BF1BE2892E00BBEF5F /* ChatAdminsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChatAdminsViewController.m; sourceTree = ""; }; + C2CE53C11BE295A000BBEF5F /* TGGeneralSearchRowView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGGeneralSearchRowView.h; sourceTree = ""; }; + C2CE53C21BE295A000BBEF5F /* TGGeneralSearchRowView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGGeneralSearchRowView.m; sourceTree = ""; }; + C2CE53C41BE7688900BBEF5F /* ComposeActionCreateMegaGroupBehavior.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ComposeActionCreateMegaGroupBehavior.h; sourceTree = ""; }; + C2CE53C51BE7688900BBEF5F /* ComposeActionCreateMegaGroupBehavior.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ComposeActionCreateMegaGroupBehavior.m; sourceTree = ""; }; + C2CE53C81BE8C0DB00BBEF5F /* TGSProfileMediaRowView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGSProfileMediaRowView.h; sourceTree = ""; }; + C2CE53C91BE8C0DB00BBEF5F /* TGSProfileMediaRowView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGSProfileMediaRowView.m; sourceTree = ""; }; + C2CE53CB1BE8D96600BBEF5F /* TGSProfileMediaRowItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGSProfileMediaRowItem.h; sourceTree = ""; }; + C2CE53CC1BE8D96600BBEF5F /* TGSProfileMediaRowItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGSProfileMediaRowItem.m; sourceTree = ""; }; + C2CE53CE1BE8E6F900BBEF5F /* TGProfileParamView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGProfileParamView.h; sourceTree = ""; }; + C2CE53CF1BE8E6F900BBEF5F /* TGProfileParamView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGProfileParamView.m; sourceTree = ""; }; + C2CE53D11BE8EC7B00BBEF5F /* TGProfileParamItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGProfileParamItem.h; sourceTree = ""; }; + C2CE53D21BE8EC7B00BBEF5F /* TGProfileParamItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGProfileParamItem.m; sourceTree = ""; }; + C2CE53D41BE905D800BBEF5F /* TGProfileHeaderRowView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGProfileHeaderRowView.h; sourceTree = ""; }; + C2CE53D51BE905D800BBEF5F /* TGProfileHeaderRowView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGProfileHeaderRowView.m; sourceTree = ""; }; + C2CE53D71BE9060500BBEF5F /* TGProfileHeaderRowItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGProfileHeaderRowItem.h; sourceTree = ""; }; + C2CE53D81BE9060500BBEF5F /* TGProfileHeaderRowItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGProfileHeaderRowItem.m; sourceTree = ""; }; + C2CE53DB1BE9275700BBEF5F /* ComposeActionInfoProfileBehavior.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ComposeActionInfoProfileBehavior.h; sourceTree = ""; }; + C2CE53DC1BE9275700BBEF5F /* ComposeActionInfoProfileBehavior.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ComposeActionInfoProfileBehavior.m; sourceTree = ""; }; + C2CE53DE1BE938AC00BBEF5F /* TGModernChatInfoViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGModernChatInfoViewController.h; sourceTree = ""; }; + C2CE53DF1BE938AC00BBEF5F /* TGModernChatInfoViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGModernChatInfoViewController.m; sourceTree = ""; }; + C2CE53E11BEA75B800BBEF5F /* TGModernChannelInfoViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGModernChannelInfoViewController.h; sourceTree = ""; }; + C2CE53E21BEA75B800BBEF5F /* TGModernChannelInfoViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGModernChannelInfoViewController.m; sourceTree = ""; }; + C2CE53E41BEB4FAD00BBEF5F /* ComposeChangeChannelDescriptionViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ComposeChangeChannelDescriptionViewController.h; sourceTree = ""; }; + C2CE53E51BEB4FAD00BBEF5F /* ComposeChangeChannelDescriptionViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ComposeChangeChannelDescriptionViewController.m; sourceTree = ""; }; + C2CE53E71BEB543A00BBEF5F /* TGGeneralInputTextRowView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGGeneralInputTextRowView.h; sourceTree = ""; }; + C2CE53E81BEB543A00BBEF5F /* TGGeneralInputTextRowView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGGeneralInputTextRowView.m; sourceTree = ""; }; + C2CE53EA1BEB5ACF00BBEF5F /* TGGeneralInputRowItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGGeneralInputRowItem.h; sourceTree = ""; }; + C2CE53EB1BEB5ACF00BBEF5F /* TGGeneralInputRowItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGGeneralInputRowItem.m; sourceTree = ""; }; + C2CE53ED1BEB748900BBEF5F /* ComposeActionChangeChannelAboutBehavior.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ComposeActionChangeChannelAboutBehavior.h; sourceTree = ""; }; + C2CE53EE1BEB748900BBEF5F /* ComposeActionChangeChannelAboutBehavior.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ComposeActionChangeChannelAboutBehavior.m; sourceTree = ""; }; + C2CE53F01BECC3A700BBEF5F /* MegagroupChatFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MegagroupChatFilter.h; sourceTree = ""; }; + C2CE53F11BECC3A700BBEF5F /* MegagroupChatFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MegagroupChatFilter.m; sourceTree = ""; }; + C2CE53F31BECE46600BBEF5F /* MegagroupHistoryController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MegagroupHistoryController.h; sourceTree = ""; }; + C2CE53F41BECE46600BBEF5F /* MegagroupHistoryController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MegagroupHistoryController.m; sourceTree = ""; }; + C2CE53F61BED06BD00BBEF5F /* ChannelCommonFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChannelCommonFilter.h; sourceTree = ""; }; + C2CE53F71BED06BD00BBEF5F /* ChannelCommonFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChannelCommonFilter.m; sourceTree = ""; }; + C2CE53F91BF0AE3800BBEF5F /* CommonMediaHistoryFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonMediaHistoryFilter.h; sourceTree = ""; }; + C2CE53FA1BF0AE3800BBEF5F /* CommonMediaHistoryFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CommonMediaHistoryFilter.m; sourceTree = ""; }; + C2CE53FC1BF0E43A00BBEF5F /* TGPhotoViewerBehavior.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGPhotoViewerBehavior.h; sourceTree = ""; }; + C2CE53FD1BF0E43A00BBEF5F /* TGPhotoViewerBehavior.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGPhotoViewerBehavior.m; sourceTree = ""; }; C2D235B71A2F2C5600765BA1 /* TGModernTypingManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGModernTypingManager.h; sourceTree = ""; }; C2D235B81A2F2C5600765BA1 /* TGModernTypingManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGModernTypingManager.m; sourceTree = ""; }; C2D235BA1A2FA6F400765BA1 /* TGSendTypingManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGSendTypingManager.h; sourceTree = ""; }; @@ -2296,6 +2485,8 @@ C2D51C371B25F5A8009327C0 /* TGStickerPackEmojiController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGStickerPackEmojiController.m; sourceTree = ""; }; C2D51C3C1B2618DE009327C0 /* TGTransformScrollView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGTransformScrollView.h; sourceTree = ""; }; C2D51C3D1B2618DE009327C0 /* TGTransformScrollView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGTransformScrollView.m; sourceTree = ""; }; + C2D7772E1BAEA30B00D451FD /* ComposeSettingupNewChannelViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ComposeSettingupNewChannelViewController.h; sourceTree = ""; }; + C2D7772F1BAEA30B00D451FD /* ComposeSettingupNewChannelViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ComposeSettingupNewChannelViewController.m; sourceTree = ""; }; C2D7C5AF1B2B4FAF0042DC01 /* TGMenuItemPhoto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGMenuItemPhoto.h; sourceTree = ""; }; C2D7C5B01B2B4FAF0042DC01 /* TGMenuItemPhoto.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGMenuItemPhoto.m; sourceTree = ""; }; C2D7C5BC1B3091400042DC01 /* StartBotSenderItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StartBotSenderItem.h; sourceTree = ""; }; @@ -2310,9 +2501,19 @@ C2D825E51B6915B500434D37 /* NotificationConversationRowView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NotificationConversationRowView.m; sourceTree = ""; }; C2D825EA1B6A700300434D37 /* TGEmbedModalView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGEmbedModalView.h; sourceTree = ""; }; C2D825EB1B6A700300434D37 /* TGEmbedModalView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGEmbedModalView.m; sourceTree = ""; }; - C2D825ED1B6A711E00434D37 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/WebKit.framework; sourceTree = DEVELOPER_DIR; }; - C2D825F11B6F9E8200434D37 /* SSignalKit.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = SSignalKit.xcodeproj; path = Signals/SSignalKit.xcodeproj; sourceTree = ""; }; C2D826131B6FA8A600434D37 /* MtProtoKit.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = MtProtoKit.xcodeproj; path = MtProtoKit/MtProtoKit.xcodeproj; sourceTree = ""; }; + C2D826391B710E6400434D37 /* TGModernHistoryController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGModernHistoryController.h; sourceTree = ""; }; + C2D8263A1B710E6400434D37 /* TGModernHistoryController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGModernHistoryController.m; sourceTree = ""; }; + C2D8263D1B7110AB00434D37 /* TGConversation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGConversation.h; sourceTree = ""; }; + C2D8263E1B7110AB00434D37 /* TGConversation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGConversation.m; sourceTree = ""; }; + C2D826401B71155000434D37 /* TGDatabase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGDatabase.h; sourceTree = ""; }; + C2D826411B71155000434D37 /* TGDatabase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGDatabase.m; sourceTree = ""; }; + C2D826471B74FD5D00434D37 /* TGPVZoomControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGPVZoomControl.h; sourceTree = ""; }; + C2D826481B74FD5D00434D37 /* TGPVZoomControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGPVZoomControl.m; sourceTree = ""; }; + C2D8CFC11B84D3E200080775 /* ComposeActionCreateChannelBehavior.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ComposeActionCreateChannelBehavior.h; sourceTree = ""; }; + C2D8CFC21B84D3E200080775 /* ComposeActionCreateChannelBehavior.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ComposeActionCreateChannelBehavior.m; sourceTree = ""; }; + C2D8CFC41B84D73D00080775 /* ComposeCreateChannelViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ComposeCreateChannelViewController.h; sourceTree = ""; }; + C2D8CFC51B84D73D00080775 /* ComposeCreateChannelViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ComposeCreateChannelViewController.m; sourceTree = ""; }; C2D9313E1991140F00668F86 /* TGWindowArchiver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGWindowArchiver.h; sourceTree = ""; }; C2D9313F1991140F00668F86 /* TGWindowArchiver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGWindowArchiver.m; sourceTree = ""; }; C2DE4FA91AD08C34001EC26C /* TGWebpageArticle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGWebpageArticle.h; sourceTree = ""; }; @@ -2328,10 +2529,25 @@ C2E40E2D19D58E430079046E /* Quartz.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quartz.framework; path = System/Library/Frameworks/Quartz.framework; sourceTree = SDKROOT; }; C2E40E2F19D58E490079046E /* Accelerate.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Accelerate.framework; path = System/Library/Frameworks/Accelerate.framework; sourceTree = SDKROOT; }; C2E40E3119D58E500079046E /* OpenCL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenCL.framework; path = System/Library/Frameworks/OpenCL.framework; sourceTree = SDKROOT; }; - C2E40E3319D58E580079046E /* libstdc++.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = "libstdc++.dylib"; path = "usr/lib/libstdc++.dylib"; sourceTree = SDKROOT; }; C2E560FD1AF3726300B4CAF0 /* sqlcipher.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = sqlcipher.xcodeproj; path = sqlcipher/sqlcipher.xcodeproj; sourceTree = ""; }; + C2E5A05F1BABF33C00C1BCA1 /* TL_localMessageService_old34.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TL_localMessageService_old34.h; sourceTree = ""; }; + C2E5A0601BABF33C00C1BCA1 /* TL_localMessageService_old34.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TL_localMessageService_old34.m; sourceTree = ""; }; + C2E5A0711BAC75C100C1BCA1 /* TGMessageViewSender.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGMessageViewSender.h; sourceTree = ""; }; + C2E5A0721BAC75C100C1BCA1 /* TGMessageViewSender.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGMessageViewSender.m; sourceTree = ""; }; + C2ED28021BFF7F0E00F19531 /* TGReportChannelModalView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGReportChannelModalView.h; sourceTree = ""; }; + C2ED28031BFF7F0E00F19531 /* TGReportChannelModalView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGReportChannelModalView.m; sourceTree = ""; }; C2ED357B18D9FECB00D0027C /* CAProgressLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CAProgressLayer.h; sourceTree = ""; }; C2ED357C18D9FECB00D0027C /* CAProgressLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CAProgressLayer.m; sourceTree = ""; }; + C2F07E0E1BBD7CD900B3DB39 /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = System/Library/Frameworks/IOKit.framework; sourceTree = SDKROOT; }; + C2F07E101BBD7CEF00B3DB39 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; }; + C2F07E121BBD7CFA00B3DB39 /* MapKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MapKit.framework; path = System/Library/Frameworks/MapKit.framework; sourceTree = SDKROOT; }; + C2F07E141BBD7D3B00B3DB39 /* AVKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVKit.framework; path = System/Library/Frameworks/AVKit.framework; sourceTree = SDKROOT; }; + C2F07E161BBD7D5300B3DB39 /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; }; + C2F07E181BBD7D9300B3DB39 /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; }; + C2F07E1A1BBD7E0E00B3DB39 /* libsqlite3.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libsqlite3.tbd; path = usr/lib/libsqlite3.tbd; sourceTree = SDKROOT; }; + C2F07E1C1BBDBABF00B3DB39 /* ImageIO.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ImageIO.framework; path = System/Library/Frameworks/ImageIO.framework; sourceTree = SDKROOT; }; + C2F07E1E1BBDBACD00B3DB39 /* libstdc++.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libstdc++.tbd"; path = "usr/lib/libstdc++.tbd"; sourceTree = SDKROOT; }; + C2F07E231BC0210600B3DB39 /* libcommonCrypto.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libcommonCrypto.tbd; path = usr/lib/system/libcommonCrypto.tbd; sourceTree = SDKROOT; }; C2F3995D190E7692006B36F7 /* ReadHistroryTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReadHistroryTask.h; sourceTree = ""; }; C2F3995E190E7692006B36F7 /* ReadHistroryTask.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ReadHistroryTask.m; sourceTree = ""; }; C2F39964190FD1D6006B36F7 /* ASHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASHandle.h; sourceTree = ""; }; @@ -2367,7 +2583,12 @@ C2FA78EB1923CBA1001A9D1B /* PhotoHistoryFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PhotoHistoryFilter.m; sourceTree = ""; }; C2FA78ED1924D934001A9D1B /* NoMessagesView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NoMessagesView.h; sourceTree = ""; }; C2FA78EE1924D934001A9D1B /* NoMessagesView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NoMessagesView.m; sourceTree = ""; }; - CE05837D17FD80AD0029EFCB /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; }; + C2FF82A11B99C7CE00DE2455 /* TGForceChannelUpdate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGForceChannelUpdate.h; sourceTree = ""; }; + C2FF82A21B99C7CE00DE2455 /* TGForceChannelUpdate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGForceChannelUpdate.m; sourceTree = ""; }; + C2FF82E61B9F28D900DE2455 /* ChannelHistoryController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChannelHistoryController.h; sourceTree = ""; }; + C2FF82E71B9F28D900DE2455 /* ChannelHistoryController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChannelHistoryController.m; sourceTree = ""; }; + C2FF82E91BA0796400DE2455 /* ChannelsManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChannelsManager.h; sourceTree = ""; }; + C2FF82EA1BA0796400DE2455 /* ChannelsManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChannelsManager.m; sourceTree = ""; }; CE05837F17FDB68C0029EFCB /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; }; CE0AC51B18BE0EE70031658A /* TL_destructMessage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TL_destructMessage.h; sourceTree = ""; }; CE0AC51C18BE0EE70031658A /* TL_destructMessage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TL_destructMessage.m; sourceTree = ""; }; @@ -2375,7 +2596,6 @@ CE23C38118C717D200AA6C78 /* MessageTableItemAudio.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MessageTableItemAudio.m; sourceTree = ""; }; CE29CA791801355200803E22 /* libcrypto.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libcrypto.a; sourceTree = ""; }; CE29CA7A1801355200803E22 /* libssl.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libssl.a; sourceTree = ""; }; - CE46A25A1854C05900D6EF14 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/Localizable.strings; sourceTree = ""; }; CE46A25B1854C09A00D6EF14 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; CE4961C618034ACD000C3738 /* Crypto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Crypto.h; sourceTree = ""; }; CE4961C718034ACD000C3738 /* Crypto.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Crypto.m; sourceTree = ""; }; @@ -2437,14 +2657,10 @@ CEAE5D5F181ECDF100C17645 /* FMDatabaseQueue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FMDatabaseQueue.m; sourceTree = ""; }; CEAE5D61181ECDF100C17645 /* FMResultSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FMResultSet.h; sourceTree = ""; }; CEAE5D62181ECDF100C17645 /* FMResultSet.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FMResultSet.m; sourceTree = ""; }; - CEAE5D69181ED1BF00C17645 /* libsqlite3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libsqlite3.dylib; path = usr/lib/libsqlite3.dylib; sourceTree = SDKROOT; }; CEAE5D6B181EEFF000C17645 /* TLPeer+Extensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "TLPeer+Extensions.h"; sourceTree = ""; }; CEAE5D6C181EEFF000C17645 /* TLPeer+Extensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "TLPeer+Extensions.m"; sourceTree = ""; }; CEB09E5817DAFC250055F150 /* Telegram.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Telegram.app; sourceTree = BUILT_PRODUCTS_DIR; }; CEB09E5B17DAFC250055F150 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; - CEB09E5E17DAFC250055F150 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; - CEB09E5F17DAFC250055F150 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; }; - CEB09E6017DAFC250055F150 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; CEB09E6317DAFC250055F150 /* Telegraph-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Telegraph-Info.plist"; sourceTree = ""; }; CEB09E6717DAFC250055F150 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; CEB09E6917DAFC250055F150 /* Telegraph-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Telegraph-Prefix.pch"; sourceTree = ""; }; @@ -2456,8 +2672,6 @@ CEB0A14C17DB03A90055F150 /* AsyncUdpSocket.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AsyncUdpSocket.m; sourceTree = ""; }; CEB0A23217DB03D40055F150 /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = System/Library/Frameworks/CoreServices.framework; sourceTree = SDKROOT; }; CEB0A23417DB03E00055F150 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; - CEB0A24F17DB09C10055F150 /* TGInitializer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGInitializer.h; sourceTree = ""; }; - CEB0A25017DB09C10055F150 /* TGInitializer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGInitializer.m; sourceTree = ""; }; CEB0D72218E3770D00457D08 /* TMWindowTitleView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TMWindowTitleView.h; sourceTree = ""; }; CEB0D72318E3770D00457D08 /* TMWindowTitleView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TMWindowTitleView.m; sourceTree = ""; }; CEB2615F180C91F900378932 /* RpcErrorParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RpcErrorParser.h; sourceTree = ""; }; @@ -2489,7 +2703,6 @@ CEC8B8891832108A00283E53 /* Reachability.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Reachability.m; sourceTree = ""; }; CECBC15418008B2700AD98E6 /* CMath.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CMath.h; sourceTree = ""; }; CECBC15518008B3300AD98E6 /* CMath.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CMath.c; sourceTree = ""; }; - CECBC1571800C2A900AD98E6 /* libcommonCrypto.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libcommonCrypto.dylib; path = usr/lib/system/libcommonCrypto.dylib; sourceTree = SDKROOT; }; CECBC1671800D5E000AD98E6 /* NSMutableData+Extension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSMutableData+Extension.h"; sourceTree = ""; }; CECBC1681800D5E000AD98E6 /* NSMutableData+Extension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSMutableData+Extension.m"; sourceTree = ""; }; CED61A301825507400B2C5F4 /* UploadOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UploadOperation.h; sourceTree = ""; }; @@ -2506,8 +2719,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - C2CB5DA31B4DB18100CD61DF /* Foundation.framework in Frameworks */, - C2CB5D551B4D709000CD61DF /* AppKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2515,16 +2726,9 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - C2CBF6A21AFB81A8006BF90A /* QuickLook.framework in Frameworks */, - C2CBF6851AFB6FE6006BF90A /* QuartzCore.framework in Frameworks */, - C2CBF6831AFB6F33006BF90A /* AVFoundation.framework in Frameworks */, - C2CBF6811AFB6F18006BF90A /* Security.framework in Frameworks */, - C2CBF67F1AFB6F13006BF90A /* Foundation.framework in Frameworks */, - C2CBF6751AFB6AFA006BF90A /* AppKit.framework in Frameworks */, - C2CBF6191AF912A8006BF90A /* libz.dylib in Frameworks */, - C2CBF6171AF911A2006BF90A /* SystemConfiguration.framework in Frameworks */, - C2CBF60E1AF90882006BF90A /* libsqlite3.0.dylib in Frameworks */, - C2CBF60C1AF90878006BF90A /* libsqlcipher.a in Frameworks */, + C2F07E281BC02FC500B3DB39 /* libz.tbd in Frameworks */, + C2F07E251BC02F6200B3DB39 /* SystemConfiguration.framework in Frameworks */, + C26E80341B8369B1003CC483 /* MtProtoKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2532,45 +2736,45 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - C2D826241B6FA8E800434D37 /* MtProtoKit.framework in Frameworks */, - C2D825EE1B6A711E00434D37 /* WebKit.framework in Frameworks */, - C2CBF64A1AFA5A23006BF90A /* MapKit.framework in Frameworks */, + 8AF788921C570B6500DC72E6 /* SSignalKit.framework in Frameworks */, + 8AF787F21C57047600DC72E6 /* MtProtoKitMac.framework in Frameworks */, + C2FB6C941C05F08600B066A4 /* Sparkle.framework in Frameworks */, + C2FB6C951C05F08600B066A4 /* HockeySDK.framework in Frameworks */, + C2F07E191BBD7D9300B3DB39 /* libz.tbd in Frameworks */, + C2F07E1F1BBDBACD00B3DB39 /* libstdc++.tbd in Frameworks */, + C2F07E1D1BBDBABF00B3DB39 /* ImageIO.framework in Frameworks */, + 0A2576A5181D09E500FB386C /* SystemConfiguration.framework in Frameworks */, + C2F07E1B1BBD7E0E00B3DB39 /* libsqlite3.tbd in Frameworks */, + CEB7AE05181419E5005CB6A1 /* QuartzCore.framework in Frameworks */, + C23298D718CF5FC7000826E5 /* QuickLook.framework in Frameworks */, + C2F07E171BBD7D5300B3DB39 /* JavaScriptCore.framework in Frameworks */, + 0AB8F2BB1948BCF30074E4E7 /* AVFoundation.framework in Frameworks */, + C2F07E151BBD7D3B00B3DB39 /* AVKit.framework in Frameworks */, + CEB09E5C17DAFC250055F150 /* Cocoa.framework in Frameworks */, + C2F07E131BBD7CFA00B3DB39 /* MapKit.framework in Frameworks */, + C2F07E111BBD7CEF00B3DB39 /* WebKit.framework in Frameworks */, + C2F07E0F1BBD7CD900B3DB39 /* IOKit.framework in Frameworks */, C2E561041AF3729600B4CAF0 /* libsqlcipher.a in Frameworks */, - C274C42E1ACC5B3A000DFDE4 /* AVKit.framework in Frameworks */, - C274C4241ACC0D4D000DFDE4 /* JavaScriptCore.framework in Frameworks */, - C2BC529D1A695A270004A8FE /* IOKit.framework in Frameworks */, - C20A7E8019DC1887008844F2 /* ImageIO.framework in Frameworks */, C2E40E3519D58F160079046E /* OpenGL.framework in Frameworks */, C20A7E7E19DC1816008844F2 /* CoreGraphics.framework in Frameworks */, C20A7E7519DAAF51008844F2 /* CoreText.framework in Frameworks */, - C2E40E3419D58E580079046E /* libstdc++.dylib in Frameworks */, C2C8AB0C1A3F3BC900C857D6 /* libwebpdemux.a in Frameworks */, C2E40E3019D58E490079046E /* Accelerate.framework in Frameworks */, C2E40E2E19D58E430079046E /* Quartz.framework in Frameworks */, C2E40E2C19D58E3C0079046E /* PreferencePanes.framework in Frameworks */, C2E40E2A19D58E370079046E /* CoreMedia.framework in Frameworks */, CEB0A23317DB03D40055F150 /* CoreServices.framework in Frameworks */, - 0AB8F2BB1948BCF30074E4E7 /* AVFoundation.framework in Frameworks */, C2A5C02518E300E70021BE68 /* CoreAudio.framework in Frameworks */, C2A5C01818E1AB980021BE68 /* AudioToolbox.framework in Frameworks */, C2A5BFFA18E02D8F0021BE68 /* AudioUnit.framework in Frameworks */, - C23298D718CF5FC7000826E5 /* QuickLook.framework in Frameworks */, - CEAE5D6A181ED1BF00C17645 /* libsqlite3.dylib in Frameworks */, C2C8AB0D1A3F3BC900C857D6 /* libwebpmux.a in Frameworks */, - 0A2576A5181D09E500FB386C /* SystemConfiguration.framework in Frameworks */, 0A13B82A18199C1A00E06702 /* AddressBook.framework in Frameworks */, - CEB7AE05181419E5005CB6A1 /* QuartzCore.framework in Frameworks */, - CECBC1661800CA2400AD98E6 /* Foundation.framework in Frameworks */, CE29CA7C1801355200803E22 /* libssl.a in Frameworks */, CE29CA7B1801355200803E22 /* libcrypto.a in Frameworks */, C2C8AB0B1A3F3BC900C857D6 /* libwebp.a in Frameworks */, CE05838017FDB68C0029EFCB /* CoreFoundation.framework in Frameworks */, - CE05837E17FD80AD0029EFCB /* libz.dylib in Frameworks */, CEB0A23517DB03E00055F150 /* Security.framework in Frameworks */, - CEB09E5C17DAFC250055F150 /* Cocoa.framework in Frameworks */, CEB0D71618E0CBB000457D08 /* libopus.a in Frameworks */, - C2D825C51B664ECA00434D37 /* Sparkle.framework in Frameworks */, - C2D825C61B664ECA00434D37 /* HockeySDK.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2590,6 +2794,8 @@ 0ACF9E3B19235F42001F9E1E /* SearchLoadMoreItem.m */, C274C3AA1AC083AA000DFDE4 /* SearchHashtagItem.h */, C274C3AB1AC083AA000DFDE4 /* SearchHashtagItem.m */, + C26E80281B7E00A1003CC483 /* TGRecentSearchRowItem.h */, + C26E80291B7E00A1003CC483 /* TGRecentSearchRowItem.m */, ); name = tableItems; sourceTree = ""; @@ -2637,6 +2843,8 @@ 0A004F5018748E0B009A0C27 /* tableItems */, 0A4B0A79186EED080016D80F /* SearchViewController.h */, 0A4B0A7A186EED080016D80F /* SearchViewController.m */, + C26E802E1B7E106B003CC483 /* TGRecentSearchTableView.h */, + C26E802F1B7E106B003CC483 /* TGRecentSearchTableView.m */, ); name = search; sourceTree = ""; @@ -2783,6 +2991,8 @@ C268C19B19F12EFA007F836A /* MessageTableItemAudioDocument.m */, C2C1DC031A43345400BBCC63 /* MessageTableItemSticker.h */, C2C1DC041A43345400BBCC63 /* MessageTableItemSticker.m */, + C20A5F511B8F6CC3007F4B49 /* MessageTableItemHole.h */, + C20A5F521B8F6CC3007F4B49 /* MessageTableItemHole.m */, ); name = items; sourceTree = ""; @@ -2820,6 +3030,8 @@ C2233DA41A07EE4B0056594F /* MessageTableCellSocialView.m */, C2C1DC0A1A43347800BBCC63 /* MessageTableCellStickerView.h */, C2C1DC0B1A43347800BBCC63 /* MessageTableCellStickerView.m */, + C20A5F541B8F6CDD007F4B49 /* MessageTableCellHoleView.h */, + C20A5F551B8F6CDD007F4B49 /* MessageTableCellHoleView.m */, ); name = cells; sourceTree = ""; @@ -2963,6 +3175,8 @@ 0AA01439182CF2BE00901B7A /* user/сhats info */ = { isa = PBXGroup; children = ( + C20F76E61BB99438003A1E86 /* modern */, + C20A5EB71B874850007F4B49 /* channels */, C2200B7018F43A4200F28803 /* help */, C2002CFC19990EE2002A1915 /* broadcast */, 0AA7E1C018CCF0740064EFC7 /* chatinfo */, @@ -3102,6 +3316,8 @@ C268C1AF19F6B1F7007F836A /* SearchMessageTableItem.m */, C274C3AD1AC0842D000DFDE4 /* SearchHashtagCellView.h */, C274C3AE1AC0842D000DFDE4 /* SearchHashtagCellView.m */, + C26E802B1B7E00C3003CC483 /* TGRecentSearchRowView.h */, + C26E802C1B7E00C3003CC483 /* TGRecentSearchRowView.m */, ); name = tableCells; sourceTree = ""; @@ -3167,10 +3383,6 @@ 0AC7F476185DAA7F00F90558 /* TMElements.h */, 0A6758F0189672F600F4487D /* TMFastQueue.h */, 0A6758F1189672F600F4487D /* TMFastQueue.mm */, - 0AB43B9C18D43DC000FB805A /* TMGifImageView.h */, - 0AB43B9D18D43DC000FB805A /* TMGifImageView.m */, - 0A241AA418AB60BA00C32F45 /* TMGLGif.h */, - 0A241AA518AB60BA00C32F45 /* TMGLGif.m */, 0A67588918928F1A00F4487D /* TMGrowingTextView.h */, 0A67588A18928F1A00F4487D /* TMGrowingTextView.m */, 0A9EDC101896FE010037E1BC /* TMHyperlinkTextField.h */, @@ -3246,6 +3458,8 @@ C2AC8DB31A7BF13000655B9D /* TGSearchRowItem.m */, C2CBF6D51AFBDB6F006BF90A /* TGLinearProgressView.h */, C2CBF6D61AFBDB6F006BF90A /* TGLinearProgressView.m */, + C2CE53C11BE295A000BBEF5F /* TGGeneralSearchRowView.h */, + C2CE53C21BE295A000BBEF5F /* TGGeneralSearchRowView.m */, ); name = elements; sourceTree = ""; @@ -3272,6 +3486,8 @@ 0AEE20821821340200F348F2 /* messages */ = { isa = PBXGroup; children = ( + C2A2B4271BD01FC70083DA8A /* head-chats */, + C20F76EA1BBAC191003A1E86 /* hint-view */, C2D51C091B21FA44009327C0 /* botcommands */, C2D51B9C1B17A6A3009327C0 /* popuphelps */, C2C85B7A1AE5315D00FBEABD /* image-attach */, @@ -3334,6 +3550,37 @@ name = helps; sourceTree = ""; }; + C20A5EB71B874850007F4B49 /* channels */ = { + isa = PBXGroup; + children = ( + C20A5EB81B874890007F4B49 /* ChannelInfoHeaderView.h */, + C20A5EB91B874890007F4B49 /* ChannelInfoHeaderView.m */, + C20A5EBB1B8748A3007F4B49 /* ChannelInfoViewController.h */, + C20A5EBC1B8748A3007F4B49 /* ChannelInfoViewController.m */, + ); + name = channels; + sourceTree = ""; + }; + C20A5EDC1B8B820F007F4B49 /* conversations */ = { + isa = PBXGroup; + children = ( + C20A5ED91B8B7A81007F4B49 /* TGModernConversationHistoryController.h */, + C20A5EDA1B8B7A81007F4B49 /* TGModernConversationHistoryController.m */, + ); + name = conversations; + sourceTree = ""; + }; + C20A5EE01B8CC185007F4B49 /* dispatcher */ = { + isa = PBXGroup; + children = ( + C20A5EE11B8CC19C007F4B49 /* TGDispatcher.h */, + C20A5EE21B8CC19C007F4B49 /* TGDispatcher.m */, + C20A5EE41B8CC813007F4B49 /* TGEvent.h */, + C20A5EE51B8CC813007F4B49 /* TGEvent.m */, + ); + name = dispatcher; + sourceTree = ""; + }; C20B228318E971D0007BCCD6 /* ogg */ = { isa = PBXGroup; children = ( @@ -3365,6 +3612,30 @@ name = help; sourceTree = ""; }; + C20F76E61BB99438003A1E86 /* modern */ = { + isa = PBXGroup; + children = ( + C2CE53DA1BE9274200BBEF5F /* compose */, + C2CE53C71BE8C00500BBEF5F /* elements */, + C20F76E71BB994A6003A1E86 /* TGModernUserViewController.h */, + C20F76E81BB994A6003A1E86 /* TGModernUserViewController.m */, + C2CE53DE1BE938AC00BBEF5F /* TGModernChatInfoViewController.h */, + C2CE53DF1BE938AC00BBEF5F /* TGModernChatInfoViewController.m */, + C2CE53E11BEA75B800BBEF5F /* TGModernChannelInfoViewController.h */, + C2CE53E21BEA75B800BBEF5F /* TGModernChannelInfoViewController.m */, + ); + name = modern; + sourceTree = ""; + }; + C20F76EA1BBAC191003A1E86 /* hint-view */ = { + isa = PBXGroup; + children = ( + C20F76EB1BBAC41A003A1E86 /* TGMessagesHintView.h */, + C20F76EC1BBAC41A003A1E86 /* TGMessagesHintView.m */, + ); + name = "hint-view"; + sourceTree = ""; + }; C21C7B2518D7041700253A7A /* sender */ = { isa = PBXGroup; children = ( @@ -3464,6 +3735,12 @@ C21D482F19ACC41E000F06E1 /* contacts */ = { isa = PBXGroup; children = ( + C20A5EEE1B8CD8CB007F4B49 /* TMBlueInputTextField.h */, + C20A5EEF1B8CD8CB007F4B49 /* TMBlueInputTextField.m */, + C20A5EE81B8CD8B8007F4B49 /* AddContactView.h */, + C20A5EE91B8CD8B8007F4B49 /* AddContactView.m */, + C20A5EEA1B8CD8B8007F4B49 /* AddContactViewController.h */, + C20A5EEB1B8CD8B8007F4B49 /* AddContactViewController.m */, C21D483019ACC436000F06E1 /* ContactsViewController.h */, C21D483119ACC436000F06E1 /* ContactsViewController.m */, ); @@ -3473,6 +3750,7 @@ C21D484619AF3C0E000F06E1 /* compose */ = { isa = PBXGroup; children = ( + C2D8CFC01B84D2F300080775 /* channels */, C226CC791B341CC80042C5D8 /* add_to_group */, C2D51C021B21F02D009327C0 /* select_groups */, C22019FD192CCB4000C0E441 /* select_users */, @@ -3506,6 +3784,18 @@ C24435871A1E018100F9BB38 /* ComposeActionCustomBehavior.m */, C226CC801B3427390042C5D8 /* ComposeActionAddUserToGroupBehavior.h */, C226CC811B3427390042C5D8 /* ComposeActionAddUserToGroupBehavior.m */, + C2D8CFC11B84D3E200080775 /* ComposeActionCreateChannelBehavior.h */, + C2D8CFC21B84D3E200080775 /* ComposeActionCreateChannelBehavior.m */, + C2B0DF811BA9B7840023982C /* ComposeActionAddChannelModeratorBehavior.h */, + C2B0DF821BA9B7840023982C /* ComposeActionAddChannelModeratorBehavior.m */, + C2B0DF9A1BAB07DD0023982C /* ComposeActionBlackListBehavior.h */, + C2B0DF9B1BAB07DD0023982C /* ComposeActionBlackListBehavior.m */, + C2B0DF9D1BAB13820023982C /* ComposeActionDeleteChannelMessagesBehavior.h */, + C2B0DF9E1BAB13820023982C /* ComposeActionDeleteChannelMessagesBehavior.m */, + C2B0DFA01BAB34330023982C /* ComposeActionChannelMembersBehavior.h */, + C2B0DFA11BAB34330023982C /* ComposeActionChannelMembersBehavior.m */, + C2CE53C41BE7688900BBEF5F /* ComposeActionCreateMegaGroupBehavior.h */, + C2CE53C51BE7688900BBEF5F /* ComposeActionCreateMegaGroupBehavior.m */, ); name = behavior; sourceTree = ""; @@ -3532,6 +3822,8 @@ C23536C519D453720044978E /* EncryptedKeyViewController.m */, C2C85BA21AEEB82100FBEABD /* ChatExportLinkViewController.h */, C2C85BA31AEEB82100FBEABD /* ChatExportLinkViewController.m */, + C2CE53BE1BE2892E00BBEF5F /* ChatAdminsViewController.h */, + C2CE53BF1BE2892E00BBEF5F /* ChatAdminsViewController.m */, ); name = help; sourceTree = ""; @@ -3549,19 +3841,6 @@ name = select_users; sourceTree = ""; }; - C2201A07192E4A5B00C0E441 /* addcontact */ = { - isa = PBXGroup; - children = ( - C2201A04192E488D00C0E441 /* AddContactView.h */, - C2201A05192E488D00C0E441 /* AddContactView.m */, - C2201A08192E4AAA00C0E441 /* TMBlueInputTextField.h */, - C2201A09192E4AAA00C0E441 /* TMBlueInputTextField.m */, - C271526219B9ECCA00841C8A /* AddContactViewController.h */, - C271526319B9ECCA00841C8A /* AddContactViewController.m */, - ); - name = addcontact; - sourceTree = ""; - }; C222775A190E734C002AA0F6 /* taskrequest */ = { isa = PBXGroup; children = ( @@ -3634,22 +3913,6 @@ name = qlmedia; sourceTree = ""; }; - C233FB2518B60F43008C9A96 /* deprecated */ = { - isa = PBXGroup; - children = ( - C2201A07192E4A5B00C0E441 /* addcontact */, - C233FB2618B610E9008C9A96 /* NewConversationViewController.h */, - C233FB2718B610E9008C9A96 /* NewConversationViewController.m */, - C233FB2918B6126C008C9A96 /* NewConversationTableView.h */, - C233FB2A18B6126C008C9A96 /* NewConversationTableView.m */, - C233FB2C18B61415008C9A96 /* NewConversationRowItem.h */, - C233FB2D18B61415008C9A96 /* NewConversationRowItem.m */, - C233FB2F18B61618008C9A96 /* NewConversationRowView.h */, - C233FB3018B61618008C9A96 /* NewConversationRowView.m */, - ); - name = deprecated; - sourceTree = ""; - }; C235365219C8B40F0044978E /* exportcrard */ = { isa = PBXGroup; children = ( @@ -3703,6 +3966,10 @@ C247C47F18C0D0E800726C91 /* TGUpdateState.m */, C247C48118C0D38600726C91 /* TGUpdateContainer.h */, C247C48218C0D38600726C91 /* TGUpdateContainer.m */, + C20A5EA51B86625F007F4B49 /* TGUpdateChannels.h */, + C20A5EA61B86625F007F4B49 /* TGUpdateChannels.m */, + C20A5EB11B871ABA007F4B49 /* TGUpdateChannelContainer.h */, + C20A5EB21B871ABA007F4B49 /* TGUpdateChannelContainer.m */, ); name = tgupdates; sourceTree = ""; @@ -3772,6 +4039,8 @@ C256E91918D24C4C008FFA04 /* DownloadAudioItem.m */, C2CBF6AB1AFB84DB006BF90A /* TGDownloadItem.h */, C2CBF6AC1AFB84DB006BF90A /* TGDownloadItem.m */, + C20A5E8D1B86404D007F4B49 /* DownloadCacheDocumentItem.h */, + C20A5E8E1B86404D007F4B49 /* DownloadCacheDocumentItem.m */, ); name = download_items; sourceTree = ""; @@ -3808,6 +4077,8 @@ children = ( C268C13B19EEB580007F836A /* UserNameViewController.h */, C268C13C19EEB580007F836A /* UserNameViewController.m */, + C2B6698D1BA575AE004AF678 /* TGChangeUserNameContainerView.h */, + C2B6698E1BA575AE004AF678 /* TGChangeUserNameContainerView.m */, ); name = username; sourceTree = ""; @@ -3917,10 +4188,23 @@ C26976B31A10E2110047E2C3 /* TGPVContainer.m */, C2C6D9671A124F70001EF8A2 /* TGPVControls.h */, C2C6D9681A124F70001EF8A2 /* TGPVControls.m */, + C2D826471B74FD5D00434D37 /* TGPVZoomControl.h */, + C2D826481B74FD5D00434D37 /* TGPVZoomControl.m */, ); name = elements; sourceTree = ""; }; + C26E80111B7B748A003CC483 /* Products */ = { + isa = PBXGroup; + children = ( + C26E80171B7B748A003CC483 /* SSignalKit.framework */, + C26E801B1B7B748A003CC483 /* SSignalKitTests.xctest */, + 8AF787ED1C57031900DC72E6 /* SwiftSignalKit.framework */, + 8AF787EF1C57031900DC72E6 /* SwiftSignalKitTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; C26F7E9F1A4C32BA001D1AE2 /* emoji */ = { isa = PBXGroup; children = ( @@ -3965,6 +4249,20 @@ C24F87961A002F7E00EC962E /* TL_secretServiceMessage.m */, C2D51BFF1B21D942009327C0 /* TL_messageActionBotDescription.h */, C2D51C001B21D942009327C0 /* TL_messageActionBotDescription.m */, + C26E80251B7D14E2003CC483 /* TL_localMessage_old32.h */, + C26E80261B7D14E2003CC483 /* TL_localMessage_old32.m */, + C20A5EB41B873944007F4B49 /* TL_localMessage_old34.h */, + C20A5EB51B873944007F4B49 /* TL_localMessage_old34.m */, + C20A5EC11B878E7B007F4B49 /* TL_channelConversation.h */, + C20A5EC21B878E7C007F4B49 /* TL_channelConversation.m */, + C20A5ECD1B8B67D7007F4B49 /* TL_conversation_old34.h */, + C20A5ECE1B8B67D7007F4B49 /* TL_conversation_old34.m */, + C2FF82A11B99C7CE00DE2455 /* TGForceChannelUpdate.h */, + C2FF82A21B99C7CE00DE2455 /* TGForceChannelUpdate.m */, + C2B0DF751BA98E7C0023982C /* TL_localEmptyMessage.h */, + C2B0DF761BA98E7C0023982C /* TL_localEmptyMessage.m */, + C2E5A05F1BABF33C00C1BCA1 /* TL_localMessageService_old34.h */, + C2E5A0601BABF33C00C1BCA1 /* TL_localMessageService_old34.m */, ); name = constructors; sourceTree = ""; @@ -4001,6 +4299,10 @@ children = ( C271524F19B5C8AC00841C8A /* TMProgressModalView.h */, C271525019B5C8AC00841C8A /* TMProgressModalView.m */, + C2B0DF871BA9C6EC0023982C /* TGUserContainerView.h */, + C2B0DF881BA9C6EC0023982C /* TGUserContainerView.m */, + C2B0DF8A1BA9CE290023982C /* TGUserContainerRowItem.h */, + C2B0DF8B1BA9CE290023982C /* TGUserContainerRowItem.m */, ); name = help; sourceTree = ""; @@ -4106,6 +4408,8 @@ C274C44C1ACDA00A000DFDE4 /* TGWebpageStandartContainer.m */, C2DE4FAC1AD08C47001EC26C /* TGWebpageArticleContainer.h */, C2DE4FAD1AD08C47001EC26C /* TGWebpageArticleContainer.m */, + C20A5E811B863979007F4B49 /* TGWebpageGifContainer.h */, + C20A5E821B863979007F4B49 /* TGWebpageGifContainer.m */, ); name = views; sourceTree = ""; @@ -4125,6 +4429,8 @@ C274C4491ACD9FF5000DFDE4 /* TGWebpageStandartObject.m */, C2DE4FA91AD08C34001EC26C /* TGWebpageArticle.h */, C2DE4FAA1AD08C34001EC26C /* TGWebpageArticle.m */, + C20A5E6F1B86290C007F4B49 /* TGWebpageGifObject.h */, + C20A5E701B86290C007F4B49 /* TGWebpageGifObject.m */, ); name = objects; sourceTree = ""; @@ -4219,6 +4525,14 @@ C297955719EC29EA00BE893E /* GeneralSettingsRowView.m */, C297955919EC36F100BE893E /* GeneralSettingsBlockHeaderView.h */, C297955A19EC36F100BE893E /* GeneralSettingsBlockHeaderView.m */, + C2B669841BA5571C004AF678 /* TGSettingsTableView.h */, + C2B669851BA5571C004AF678 /* TGSettingsTableView.m */, + C2B669871BA5591F004AF678 /* TGGeneralRowItem.h */, + C2B669881BA5591F004AF678 /* TGGeneralRowItem.m */, + C2CE53E71BEB543A00BBEF5F /* TGGeneralInputTextRowView.h */, + C2CE53E81BEB543A00BBEF5F /* TGGeneralInputTextRowView.m */, + C2CE53EA1BEB5ACF00BBEF5F /* TGGeneralInputRowItem.h */, + C2CE53EB1BEB5ACF00BBEF5F /* TGGeneralInputRowItem.m */, ); name = general; sourceTree = ""; @@ -4243,6 +4557,19 @@ name = security; sourceTree = ""; }; + C2A2B4271BD01FC70083DA8A /* head-chats */ = { + isa = PBXGroup; + children = ( + C2A2B4241BD01FC20083DA8A /* TGHeadChatPanel.h */, + C2A2B4251BD01FC20083DA8A /* TGHeadChatPanel.m */, + C2A2B42C1BD519870083DA8A /* TGHCMessagesViewController.h */, + C2A2B42D1BD519870083DA8A /* TGHCMessagesViewController.m */, + C20B82AB1BDA550600EF01AD /* TGChatHeadLockView.h */, + C20B82AC1BDA550600EF01AD /* TGChatHeadLockView.m */, + ); + name = "head-chats"; + sourceTree = ""; + }; C2A3FB0A1A28A68300DE791B /* contacts */ = { isa = PBXGroup; children = ( @@ -4483,6 +4810,15 @@ name = collection; sourceTree = ""; }; + C2B0DF961BAAFEC40023982C /* modalsettings */ = { + isa = PBXGroup; + children = ( + C2B0DF971BAAFEFA0023982C /* TGModalDeleteChannelMessagesView.h */, + C2B0DF981BAAFEFA0023982C /* TGModalDeleteChannelMessagesView.m */, + ); + name = modalsettings; + sourceTree = ""; + }; C2B325EB1A23741E0012DE34 /* serialization */ = { isa = PBXGroup; children = ( @@ -4565,6 +4901,10 @@ C267526F1A13D9F600152D9A /* TGPVUserBehavior.m */, C26752751A15099A00152D9A /* TGPVEmptyBehavior.h */, C26752761A15099A00152D9A /* TGPVEmptyBehavior.m */, + C20B829F1BD98EC700EF01AD /* TGPVDocumentsBehavior.h */, + C20B82A01BD98EC700EF01AD /* TGPVDocumentsBehavior.m */, + C2CE53FC1BF0E43A00BBEF5F /* TGPhotoViewerBehavior.h */, + C2CE53FD1BF0E43A00BBEF5F /* TGPhotoViewerBehavior.m */, ); name = behavior; sourceTree = ""; @@ -4724,6 +5064,8 @@ C2CBF5E41AF7CB42006BF90A /* TGS_MTNetwork.m */, C2CBF5E61AF7CBD9006BF90A /* TGS_RPCRequest.h */, C2CBF5E71AF7CBD9006BF90A /* TGS_RPCRequest.m */, + C28C86751B98851300267C0B /* TGSKeychain.h */, + C28C86761B98851300267C0B /* TGSKeychain.m */, ); name = protocol; sourceTree = ""; @@ -4779,13 +5121,52 @@ name = password; sourceTree = ""; }; + C2CE53C71BE8C00500BBEF5F /* elements */ = { + isa = PBXGroup; + children = ( + C2CE53C81BE8C0DB00BBEF5F /* TGSProfileMediaRowView.h */, + C2CE53C91BE8C0DB00BBEF5F /* TGSProfileMediaRowView.m */, + C2CE53CB1BE8D96600BBEF5F /* TGSProfileMediaRowItem.h */, + C2CE53CC1BE8D96600BBEF5F /* TGSProfileMediaRowItem.m */, + C2CE53CE1BE8E6F900BBEF5F /* TGProfileParamView.h */, + C2CE53CF1BE8E6F900BBEF5F /* TGProfileParamView.m */, + C2CE53D11BE8EC7B00BBEF5F /* TGProfileParamItem.h */, + C2CE53D21BE8EC7B00BBEF5F /* TGProfileParamItem.m */, + C2CE53D41BE905D800BBEF5F /* TGProfileHeaderRowView.h */, + C2CE53D51BE905D800BBEF5F /* TGProfileHeaderRowView.m */, + C2CE53D71BE9060500BBEF5F /* TGProfileHeaderRowItem.h */, + C2CE53D81BE9060500BBEF5F /* TGProfileHeaderRowItem.m */, + ); + name = elements; + sourceTree = ""; + }; + C2CE53DA1BE9274200BBEF5F /* compose */ = { + isa = PBXGroup; + children = ( + C2CE53DB1BE9275700BBEF5F /* ComposeActionInfoProfileBehavior.h */, + C2CE53DC1BE9275700BBEF5F /* ComposeActionInfoProfileBehavior.m */, + C2CE53E41BEB4FAD00BBEF5F /* ComposeChangeChannelDescriptionViewController.h */, + C2CE53E51BEB4FAD00BBEF5F /* ComposeChangeChannelDescriptionViewController.m */, + C2CE53ED1BEB748900BBEF5F /* ComposeActionChangeChannelAboutBehavior.h */, + C2CE53EE1BEB748900BBEF5F /* ComposeActionChangeChannelAboutBehavior.m */, + ); + name = compose; + sourceTree = ""; + }; C2D4B73A1AFCD35F0035B4E4 /* modal */ = { isa = PBXGroup; children = ( + C2A2B42F1BD7C8DB0083DA8A /* TGModalForwardView.h */, + C2A2B4301BD7C8DB0083DA8A /* TGModalForwardView.m */, + C2B0DF961BAAFEC40023982C /* modalsettings */, C2D4B73E1AFCD36A0035B4E4 /* TGModalView.h */, C2D4B73F1AFCD36A0035B4E4 /* TGModalView.m */, C2D4B7411AFCD3B80035B4E4 /* TGStickerPackModalView.h */, C2D4B7421AFCD3B80035B4E4 /* TGStickerPackModalView.m */, + C20B82AE1BDA975500EF01AD /* TGShareContactModalView.h */, + C20B82AF1BDA975500EF01AD /* TGShareContactModalView.m */, + C2ED28021BFF7F0E00F19531 /* TGReportChannelModalView.h */, + C2ED28031BFF7F0E00F19531 /* TGReportChannelModalView.m */, ); name = modal; sourceTree = ""; @@ -4971,25 +5352,48 @@ name = notifications; sourceTree = ""; }; - C2D825F21B6F9E8200434D37 /* Products */ = { + C2D826141B6FA8A600434D37 /* Products */ = { isa = PBXGroup; children = ( - C2D825FE1B6F9E8300434D37 /* SSignalKit.framework */, - C2D826001B6F9E8300434D37 /* libSSignalKitStatic.a */, - C2D826021B6F9E8300434D37 /* SSignalKitTests.xctest */, + C2D8261B1B6FA8A600434D37 /* MtProtoKit.framework */, + C2D8261D1B6FA8A600434D37 /* MtProtoKitMac.framework */, + C2D8261F1B6FA8A600434D37 /* MtProtoKitDynamic.framework */, ); name = Products; sourceTree = ""; }; - C2D826141B6FA8A600434D37 /* Products */ = { + C2D8262F1B71011200434D37 /* modern */ = { isa = PBXGroup; children = ( - C2D8261B1B6FA8A600434D37 /* MtProtoKit.framework */, - C2D8261D1B6FA8A600434D37 /* MtProtoKitMac.framework */, - C2D8261F1B6FA8A600434D37 /* MtProtoKitDynamic.framework */, - C2D826211B6FA8A600434D37 /* MtProtoKitDynamicTests.xctest */, + C2D826391B710E6400434D37 /* TGModernHistoryController.h */, + C2D8263A1B710E6400434D37 /* TGModernHistoryController.m */, + C2D8263D1B7110AB00434D37 /* TGConversation.h */, + C2D8263E1B7110AB00434D37 /* TGConversation.m */, + C2D826401B71155000434D37 /* TGDatabase.h */, + C2D826411B71155000434D37 /* TGDatabase.m */, + C26E801E1B7B91A9003CC483 /* TGDatabaseRequest.h */, + C26E801F1B7B91A9003CC483 /* TGDatabaseRequest.m */, ); - name = Products; + name = modern; + sourceTree = ""; + }; + C2D8CFC01B84D2F300080775 /* channels */ = { + isa = PBXGroup; + children = ( + C2D8CFC41B84D73D00080775 /* ComposeCreateChannelViewController.h */, + C2D8CFC51B84D73D00080775 /* ComposeCreateChannelViewController.m */, + C2B6698A1BA570AF004AF678 /* ComposeCreateChannelUserNameStepViewController.h */, + C2B6698B1BA570AF004AF678 /* ComposeCreateChannelUserNameStepViewController.m */, + C2B0DF841BA9C59B0023982C /* ComposeConfirmModeratorViewController.h */, + C2B0DF851BA9C59B0023982C /* ComposeConfirmModeratorViewController.m */, + C2B0DF8D1BAAD9330023982C /* ComposeManagmentViewController.h */, + C2B0DF8E1BAAD9330023982C /* ComposeManagmentViewController.m */, + C2B0DF901BAAFD2E0023982C /* ComposeChannelParticipantsViewController.h */, + C2B0DF911BAAFD2E0023982C /* ComposeChannelParticipantsViewController.m */, + C2D7772E1BAEA30B00D451FD /* ComposeSettingupNewChannelViewController.h */, + C2D7772F1BAEA30B00D451FD /* ComposeSettingupNewChannelViewController.m */, + ); + name = channels; sourceTree = ""; }; C2DE4FB21AD43EBC001EC26C /* h */ = { @@ -5014,6 +5418,10 @@ children = ( C2F429C31B00C88B00C2CE4E /* TGStickersSettingsViewController.h */, C2F429C41B00C88B00C2CE4E /* TGStickersSettingsViewController.m */, + C25A57DE1C072D1D0038169F /* ComposeActionStickersBehavior.h */, + C25A57DF1C072D1D0038169F /* ComposeActionStickersBehavior.m */, + C25A57EA1C0736D70038169F /* TGMovableTableView.h */, + C25A57EB1C0736D70038169F /* TGMovableTableView.m */, ); name = stickers; sourceTree = ""; @@ -5039,6 +5447,16 @@ C273804D1B3B2F77000C479E /* MP3HistoryFilter.m */, C240B1B61B627B3700912248 /* SharedLinksHistoryFilter.h */, C240B1B71B627B3700912248 /* SharedLinksHistoryFilter.m */, + C20A5EF11B8CEE8E007F4B49 /* ChannelFilter.h */, + C20A5EF21B8CEE8E007F4B49 /* ChannelFilter.m */, + C20A5F5D1B9330CD007F4B49 /* ChannelImportantFilter.h */, + C20A5F5E1B9330CD007F4B49 /* ChannelImportantFilter.m */, + C2CE53F01BECC3A700BBEF5F /* MegagroupChatFilter.h */, + C2CE53F11BECC3A700BBEF5F /* MegagroupChatFilter.m */, + C2CE53F61BED06BD00BBEF5F /* ChannelCommonFilter.h */, + C2CE53F71BED06BD00BBEF5F /* ChannelCommonFilter.m */, + C2CE53F91BF0AE3800BBEF5F /* CommonMediaHistoryFilter.h */, + C2CE53FA1BF0AE3800BBEF5F /* CommonMediaHistoryFilter.m */, ); name = filter; sourceTree = ""; @@ -5088,6 +5506,8 @@ C28261EB1992974C004AC73E /* BroadcastManager.m */, C2D51B961B179D91009327C0 /* FullUsersManager.h */, C2D51B971B179D91009327C0 /* FullUsersManager.m */, + C2FF82E91BA0796400DE2455 /* ChannelsManager.h */, + C2FF82EA1BA0796400DE2455 /* ChannelsManager.m */, ); name = managers; sourceTree = ""; @@ -5128,8 +5548,8 @@ CEB09E4F17DAFC240055F150 = { isa = PBXGroup; children = ( + C26E80101B7B748A003CC483 /* SSignalKit.xcodeproj */, C2D826131B6FA8A600434D37 /* MtProtoKit.xcodeproj */, - C2D825F11B6F9E8200434D37 /* SSignalKit.xcodeproj */, C2E560FD1AF3726300B4CAF0 /* sqlcipher.xcodeproj */, C2D4B7681AFCE8F80035B4E4 /* YapDatabase */, C2AA4EBB18A8ECC800E20C68 /* external */, @@ -5156,26 +5576,18 @@ CEB09E5A17DAFC250055F150 /* Frameworks */ = { isa = PBXGroup; children = ( - C2D825ED1B6A711E00434D37 /* WebKit.framework */, - C2CB5DA41B4DB18700CD61DF /* Cocoa.framework */, - C2CB5DA11B4DB14F00CD61DF /* libstdc++.dylib */, - C2CBF6A11AFB81A8006BF90A /* QuickLook.framework */, - C2CBF6841AFB6FE6006BF90A /* QuartzCore.framework */, - C2CBF6821AFB6F33006BF90A /* AVFoundation.framework */, - C2CBF6801AFB6F18006BF90A /* Security.framework */, - C2CBF67E1AFB6F13006BF90A /* Foundation.framework */, - C2CBF6741AFB6AFA006BF90A /* AppKit.framework */, - C2CBF6491AFA5A23006BF90A /* MapKit.framework */, - C2CBF6181AF912A8006BF90A /* libz.dylib */, - C2CBF6161AF911A2006BF90A /* SystemConfiguration.framework */, - C2CBF60D1AF90881006BF90A /* libsqlite3.0.dylib */, - C274C42D1ACC5B3A000DFDE4 /* AVKit.framework */, - C274C4231ACC0D4D000DFDE4 /* JavaScriptCore.framework */, - C2BC529C1A695A270004A8FE /* IOKit.framework */, - C20A7E7F19DC1887008844F2 /* ImageIO.framework */, + C2F07E231BC0210600B3DB39 /* libcommonCrypto.tbd */, + C2F07E1E1BBDBACD00B3DB39 /* libstdc++.tbd */, + C2F07E1C1BBDBABF00B3DB39 /* ImageIO.framework */, + C2F07E1A1BBD7E0E00B3DB39 /* libsqlite3.tbd */, + C2F07E181BBD7D9300B3DB39 /* libz.tbd */, + C2F07E161BBD7D5300B3DB39 /* JavaScriptCore.framework */, + C2F07E141BBD7D3B00B3DB39 /* AVKit.framework */, + C2F07E121BBD7CFA00B3DB39 /* MapKit.framework */, + C2F07E101BBD7CEF00B3DB39 /* WebKit.framework */, + C2F07E0E1BBD7CD900B3DB39 /* IOKit.framework */, C20A7E7D19DC1816008844F2 /* CoreGraphics.framework */, C20A7E7419DAAF51008844F2 /* CoreText.framework */, - C2E40E3319D58E580079046E /* libstdc++.dylib */, C2E40E3119D58E500079046E /* OpenCL.framework */, C2E40E2F19D58E490079046E /* Accelerate.framework */, C2E40E2D19D58E430079046E /* Quartz.framework */, @@ -5197,16 +5609,12 @@ CE29CA7A1801355200803E22 /* libssl.a */, CEB0A23417DB03E00055F150 /* Security.framework */, CEB0A23217DB03D40055F150 /* CoreServices.framework */, - CEAE5D69181ED1BF00C17645 /* libsqlite3.dylib */, 0A2576A4181D09E500FB386C /* SystemConfiguration.framework */, 0A13B82918199C1A00E06702 /* AddressBook.framework */, CEB7AE04181419E5005CB6A1 /* QuartzCore.framework */, - CECBC1571800C2A900AD98E6 /* libcommonCrypto.dylib */, CE05837F17FDB68C0029EFCB /* CoreFoundation.framework */, - CE05837D17FD80AD0029EFCB /* libz.dylib */, CEB09E5B17DAFC250055F150 /* Cocoa.framework */, C235369919CB1A100044978E /* Foundation.framework */, - CEB09E5D17DAFC250055F150 /* Other Frameworks */, 0AA7E1D118CD392A0064EFC7 /* UIImageView+AFNetworking.h */, 0AA7E1D218CD392A0064EFC7 /* UIImageView+AFNetworking.m */, 0AA7E1D718CD3BCB0064EFC7 /* AFImageRequestOperation.h */, @@ -5215,16 +5623,6 @@ name = Frameworks; sourceTree = ""; }; - CEB09E5D17DAFC250055F150 /* Other Frameworks */ = { - isa = PBXGroup; - children = ( - CEB09E5E17DAFC250055F150 /* AppKit.framework */, - CEB09E5F17DAFC250055F150 /* CoreData.framework */, - CEB09E6017DAFC250055F150 /* Foundation.framework */, - ); - name = "Other Frameworks"; - sourceTree = ""; - }; CEB09E6117DAFC250055F150 /* Telegram */ = { isa = PBXGroup; children = ( @@ -5306,8 +5704,6 @@ C22C7F2918B2163F007C4D17 /* MTNetwork.m */, 0ABACDA5181ADB0500EF43DB /* MTProto */, CEB2579A180B54CB006770DF /* rpc_error */, - CEB0A24F17DB09C10055F150 /* TGInitializer.h */, - CEB0A25017DB09C10055F150 /* TGInitializer.m */, C22520E318B2801D00049558 /* MTConnection.h */, C22520E418B2801D00049558 /* MTConnection.m */, CEC6A8EE18C90A69002EC18F /* DatacenterArchiver.h */, @@ -5348,7 +5744,6 @@ 0A2F5AD5181A8FAC005045A5 /* controllers */, 0AB6A51C18290D200015920A /* login */, 0AEE20821821340200F348F2 /* messages */, - C233FB2518B60F43008C9A96 /* deprecated */, 0AEE207F1820762700F348F2 /* NSString+Size.h */, 0AEE20801820764900F348F2 /* NSString+Size.m */, 0A4B0A78186EEA0C0016D80F /* search */, @@ -5385,6 +5780,10 @@ children = ( C297FBA418329F3500714B3C /* TGDcAuth.h */, C297FBA518329F3500714B3C /* TGDcAuth.m */, + C20A5F451B8F6863007F4B49 /* TGMessageHole.h */, + C20A5F461B8F6863007F4B49 /* TGMessageHole.m */, + C20A5F5A1B90D815007F4B49 /* TGMessageGroupHole.h */, + C20A5F5B1B90D815007F4B49 /* TGMessageGroupHole.m */, ); name = entities; sourceTree = ""; @@ -5392,6 +5791,8 @@ CEB2615B180C5B9B00378932 /* logic */ = { isa = PBXGroup; children = ( + C20A5EE01B8CC185007F4B49 /* dispatcher */, + C2D8262F1B71011200434D37 /* modern */, C2CB5D5C1B4D870D00CD61DF /* updater */, C24F877C19FE92D700EC962E /* modernencryptedchats */, C222775A190E734C002AA0F6 /* taskrequest */, @@ -5406,14 +5807,14 @@ CEB7ADF01812E31F005CB6A1 /* ImageCache.m */, CEACBA7F181FD76300AB11D1 /* Notification.h */, CEACBA80181FD76300AB11D1 /* Notification.m */, - C2227750190E564B002AA0F6 /* OnlineNotificationManager.h */, - C2227751190E564B002AA0F6 /* OnlineNotificationManager.m */, C20D18F61948D1FE0095A906 /* SecretChatAccepter.h */, C20D18F71948D1FE0095A906 /* SecretChatAccepter.m */, C26752781A1A7CEF00152D9A /* TGCache.h */, C26752791A1A7CEF00152D9A /* TGCache.m */, C2967B171A9B75B4003759B2 /* TGPasslock.h */, C2967B181A9B75B4003759B2 /* TGPasslock.m */, + C2E5A0711BAC75C100C1BCA1 /* TGMessageViewSender.h */, + C2E5A0721BAC75C100C1BCA1 /* TGMessageViewSender.m */, ); name = logic; sourceTree = ""; @@ -5442,19 +5843,26 @@ CEB7ADF21812F899005CB6A1 /* message_controllers */ = { isa = PBXGroup; children = ( + C20A5EDC1B8B820F007F4B49 /* conversations */, C2FA78D819237996001A9D1B /* filter */, CEB7AE0618143E35005CB6A1 /* MessageSender.h */, CEB7AE0718143E35005CB6A1 /* MessageSender.m */, C2C725D81860E05200094EC7 /* EncryptedParams.h */, C2C725D91860E05200094EC7 /* EncryptedParams.m */, - C277E2A218ABB44A00FFCA35 /* DialogsHistoryController.h */, - C277E2A318ABB44A00FFCA35 /* DialogsHistoryController.m */, C282485018BBB67200131533 /* SelfDestructionController.h */, C282485118BBB67200131533 /* SelfDestructionController.m */, C282485318BBB7FB00131533 /* Destructor.h */, C282485418BBB7FB00131533 /* Destructor.m */, C222774018FE8BB3002AA0F6 /* ChatHistoryController.h */, C222774118FE8BB3002AA0F6 /* ChatHistoryController.m */, + C20A5F331B8F4579007F4B49 /* TGChannelsPolling.h */, + C20A5F341B8F4579007F4B49 /* TGChannelsPolling.m */, + C20A5F571B8F8B2B007F4B49 /* TGHistoryResponse.h */, + C20A5F581B8F8B2B007F4B49 /* TGHistoryResponse.m */, + C2FF82E61B9F28D900DE2455 /* ChannelHistoryController.h */, + C2FF82E71B9F28D900DE2455 /* ChannelHistoryController.m */, + C2CE53F31BECE46600BBEF5F /* MegagroupHistoryController.h */, + C2CE53F41BECE46600BBEF5F /* MegagroupHistoryController.m */, ); name = message_controllers; sourceTree = ""; @@ -5519,6 +5927,10 @@ C2531F531964412700F7D7A2 /* NSTextView+EmojiExtension.m */, C2CBF6961AFB7EFE006BF90A /* CFunctions.h */, C2CBF6971AFB7EFE006BF90A /* CFunctions.m */, + C20A5EDD1B8B8905007F4B49 /* TGObservableObject.h */, + C20A5EDE1B8B8905007F4B49 /* TGObservableObject.m */, + C2CC41C21BA7FC450097E973 /* WeakReference.h */, + C2CC41C31BA7FC450097E973 /* WeakReference.m */, ); name = utils; sourceTree = ""; @@ -5574,6 +5986,7 @@ buildRules = ( ); dependencies = ( + 8AF787F41C5704BD00DC72E6 /* PBXTargetDependency */, ); name = Telegram; productName = TelegramTest; @@ -5586,7 +5999,7 @@ CEB09E5017DAFC240055F150 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0600; + LastUpgradeCheck = 0700; ORGANIZATIONNAME = keepcoder; TargetAttributes = { C2CB5D3D1B4D697700CD61DF = { @@ -5597,7 +6010,7 @@ DevelopmentTeam = 6N38VWS5BX; SystemCapabilities = { com.apple.ApplicationGroups.Mac = { - enabled = 1; + enabled = 0; }; com.apple.Keychain = { enabled = 1; @@ -5617,7 +6030,7 @@ enabled = 0; }; com.apple.Keychain = { - enabled = 0; + enabled = 1; }; com.apple.Mac = { enabled = 0; @@ -5639,7 +6052,6 @@ knownRegions = ( en, English, - ru, es, de, fi, @@ -5664,8 +6076,8 @@ ProjectRef = C2E560FD1AF3726300B4CAF0 /* sqlcipher.xcodeproj */; }, { - ProductGroup = C2D825F21B6F9E8200434D37 /* Products */; - ProjectRef = C2D825F11B6F9E8200434D37 /* SSignalKit.xcodeproj */; + ProductGroup = C26E80111B7B748A003CC483 /* Products */; + ProjectRef = C26E80101B7B748A003CC483 /* SSignalKit.xcodeproj */; }, ); projectRoot = ""; @@ -5678,25 +6090,32 @@ /* End PBXProject section */ /* Begin PBXReferenceProxy section */ - C2D825FE1B6F9E8300434D37 /* SSignalKit.framework */ = { + 8AF787ED1C57031900DC72E6 /* SwiftSignalKit.framework */ = { isa = PBXReferenceProxy; fileType = wrapper.framework; - path = SSignalKit.framework; - remoteRef = C2D825FD1B6F9E8300434D37 /* PBXContainerItemProxy */; + path = SwiftSignalKit.framework; + remoteRef = 8AF787EC1C57031900DC72E6 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - C2D826001B6F9E8300434D37 /* libSSignalKitStatic.a */ = { + 8AF787EF1C57031900DC72E6 /* SwiftSignalKitTests.xctest */ = { isa = PBXReferenceProxy; - fileType = archive.ar; - path = libSSignalKitStatic.a; - remoteRef = C2D825FF1B6F9E8300434D37 /* PBXContainerItemProxy */; + fileType = wrapper.cfbundle; + path = SwiftSignalKitTests.xctest; + remoteRef = 8AF787EE1C57031900DC72E6 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - C2D826021B6F9E8300434D37 /* SSignalKitTests.xctest */ = { + C26E80171B7B748A003CC483 /* SSignalKit.framework */ = { + isa = PBXReferenceProxy; + fileType = wrapper.framework; + path = SSignalKit.framework; + remoteRef = C26E80161B7B748A003CC483 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + C26E801B1B7B748A003CC483 /* SSignalKitTests.xctest */ = { isa = PBXReferenceProxy; fileType = wrapper.cfbundle; path = SSignalKitTests.xctest; - remoteRef = C2D826011B6F9E8300434D37 /* PBXContainerItemProxy */; + remoteRef = C26E801A1B7B748A003CC483 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; C2D8261B1B6FA8A600434D37 /* MtProtoKit.framework */ = { @@ -5720,13 +6139,6 @@ remoteRef = C2D8261E1B6FA8A600434D37 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - C2D826211B6FA8A600434D37 /* MtProtoKitDynamicTests.xctest */ = { - isa = PBXReferenceProxy; - fileType = wrapper.cfbundle; - path = MtProtoKitDynamicTests.xctest; - remoteRef = C2D826201B6FA8A600434D37 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; C2E561031AF3726300B4CAF0 /* libsqlcipher.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; @@ -5813,7 +6225,6 @@ C2CBF6D41AFBD8B1006BF90A /* TMAnimations.m in Sources */, C2CBF6D31AFBD764006BF90A /* NSViewCategory.m in Sources */, C2CBF6D11AFBC952006BF90A /* QueueManager.m in Sources */, - C2CBF6D01AFBC7B1006BF90A /* Crypto.m in Sources */, C2CBF6CA1AFBC562006BF90A /* UploadOperation.m in Sources */, C2CBF6BC1AFB8B1E006BF90A /* DownloadPart.m in Sources */, C2CBF6A61AFB835D006BF90A /* DownloadQueue.mm in Sources */, @@ -5844,6 +6255,7 @@ C2CBF6891AFB73FE006BF90A /* TGS_ConversationRowItem.m in Sources */, C2CBF6661AFB6A91006BF90A /* BTRImageView.m in Sources */, C2CBF6671AFB6A91006BF90A /* BTRLabel.m in Sources */, + C28C86771B98851300267C0B /* TGSKeychain.m in Sources */, C2CBF6B11AFB8584006BF90A /* TGSDownloadItem.m in Sources */, C2CBF6681AFB6A91006BF90A /* BTRPopUpButton.m in Sources */, C2CBF6D81AFBDB6F006BF90A /* TGLinearProgressView.m in Sources */, @@ -5868,11 +6280,6 @@ C2CBF61B1AF93A6C006BF90A /* SSKeychainQuery.m in Sources */, C2CBF6151AF9113E006BF90A /* NSData+Extensions.m in Sources */, C2CBF6141AF910EF006BF90A /* TGTLSerialization.mm in Sources */, - C2CBF6131AF910E2006BF90A /* FMResultSet.m in Sources */, - C2CBF60F1AF908B7006BF90A /* FMDatabase.m in Sources */, - C2CBF6101AF908B7006BF90A /* FMDatabaseAdditions.m in Sources */, - C2CBF6111AF908B7006BF90A /* FMDatabasePool.m in Sources */, - C2CBF6121AF908B7006BF90A /* FMDatabaseQueue.m in Sources */, C2CBF6071AF906DC006BF90A /* TGKeychain.m in Sources */, C2CBF6051AF90683006BF90A /* TGTimerTarget.m in Sources */, C2CBF6061AF90683006BF90A /* TGTimer.m in Sources */, @@ -5911,6 +6318,7 @@ C271523F19B0936C00841C8A /* TokenItem.m in Sources */, 0A59068218AA32C8002ED7BA /* BTRView.m in Sources */, CEACBA81181FD76300AB11D1 /* Notification.m in Sources */, + C20A5F471B8F6863007F4B49 /* TGMessageHole.m in Sources */, C2CB5CFC1B4AB43800CD61DF /* TGPVDocumentContainer.m in Sources */, 0A6D099219535E8500A9AC64 /* NSStringCategory.m in Sources */, 0AB8F2B61948778F0074E4E7 /* TMAudioRecorder.m in Sources */, @@ -5918,16 +6326,22 @@ C2D4B8761AFCE8FA0035B4E4 /* YapDatabase.m in Sources */, 0AA3F3A818BDF54F00D383F1 /* TMStatusTextField.m in Sources */, C2FA78EF1924D934001A9D1B /* NoMessagesView.m in Sources */, + C2B0DF861BA9C59B0023982C /* ComposeConfirmModeratorViewController.m in Sources */, 0A9EDC4A1897BA0E0037E1BC /* CAAnimation+RBLBlockAdditions.m in Sources */, C2D51B981B179D91009327C0 /* FullUsersManager.m in Sources */, C2AA4EB918A8D23A00E20C68 /* TL_localMessage.m in Sources */, C2753DCB19DEBE6500752BAF /* TGMultipleSelectTextView.m in Sources */, + C20A5EF31B8CEE8E007F4B49 /* ChannelFilter.m in Sources */, C2CB5CF61B4AB40C00CD61DF /* TGPVPhotoContainer.m in Sources */, + C2B0DF9C1BAB07DD0023982C /* ComposeActionBlackListBehavior.m in Sources */, C2F3995F190E7692006B36F7 /* ReadHistroryTask.m in Sources */, C25F91C4197858BF006868F3 /* LocationSenderItem.m in Sources */, CEAE5CCA1818811000C17645 /* NSDate-Utilities.m in Sources */, C2D4B8661AFCE8F90035B4E4 /* YapDatabaseConnectionState.m in Sources */, + C2CE53E01BE938AC00BBEF5F /* TGModernChatInfoViewController.m in Sources */, + C2E5A0611BABF33C00C1BCA1 /* TL_localMessageService_old34.m in Sources */, C28261E9199291EF004AC73E /* TL_broadcast.m in Sources */, + C2CE53F21BECC3A700BBEF5F /* MegagroupChatFilter.m in Sources */, 0AAAE59218CA271600A2F9F1 /* MessagesBottomView.m in Sources */, C248F3BF19BE03F600BF658E /* opusenc.c in Sources */, C2233DB21A0818910056594F /* MessageCellDescriptionView.m in Sources */, @@ -5954,20 +6368,24 @@ C268C18819F0519C007F836A /* POPAnimationExtras.mm in Sources */, CEB09E6F17DAFC250055F150 /* AppDelegate.m in Sources */, 0A59068018AA32C8002ED7BA /* BTRSecureTextField.m in Sources */, + C2D8CFC61B84D73D00080775 /* ComposeCreateChannelViewController.m in Sources */, CEB26165180C928A00378932 /* RpcError.m in Sources */, 0A6D098D19535E8500A9AC64 /* NSEventCategory.m in Sources */, C274C44D1ACDA00A000DFDE4 /* TGWebpageStandartContainer.m in Sources */, C24F877619FE7CAB00EC962E /* SecretLayer1.m in Sources */, C282485518BBB7FB00131533 /* Destructor.m in Sources */, 0AACA3F618B752C000621564 /* TMTextButton.m in Sources */, + C20A5EBA1B874890007F4B49 /* ChannelInfoHeaderView.m in Sources */, 0AEE20811820764900F348F2 /* NSString+Size.m in Sources */, 0AD35DC618698CDB007BA752 /* _TMSearchTextField.m in Sources */, C2D4B8651AFCE8F90035B4E4 /* YapDatabaseConnectionDefaults.m in Sources */, + C20A5EE31B8CC19C007F4B49 /* TGDispatcher.m in Sources */, 0AF4F4AA189D5C72004BA4DF /* MessageTableItemServiceMessage.m in Sources */, 0AB8F6551862DD87000E6FF3 /* TMImageView.m in Sources */, 0A6D099919535E8500A9AC64 /* TLChatFullCategory.m in Sources */, 0A9EDC551897BA0E0037E1BC /* NSView+RBLViewControllerAdditions.m in Sources */, CEAE5D63181ECDF100C17645 /* FMDatabase.m in Sources */, + C20A5EB61B873944007F4B49 /* TL_localMessage_old34.m in Sources */, CE23C38218C717D200AA6C78 /* MessageTableItemAudio.m in Sources */, C297955B19EC36F100BE893E /* GeneralSettingsBlockHeaderView.m in Sources */, C2D4B7401AFCD36A0035B4E4 /* TGModalView.m in Sources */, @@ -5988,11 +6406,14 @@ 0AF4F4AD189D5CD5004BA4DF /* MessageTableCellServiceMessage.m in Sources */, CEAE5D68181ECDF100C17645 /* FMResultSet.m in Sources */, C2FA78E61923CB6A001A9D1B /* VideoHistoryFilter.m in Sources */, + C2B0DF9F1BAB13820023982C /* ComposeActionDeleteChannelMessagesBehavior.m in Sources */, C268C18C19F0519C007F836A /* POPBasicAnimation.mm in Sources */, C2AC8D971A76889100655B9D /* TGOpacityViewController.m in Sources */, 0A4B0A7B186EED080016D80F /* SearchViewController.m in Sources */, C222AB321A08FF2B00BEF907 /* PhotoCollectionTableView.m in Sources */, + C2CE53D31BE8EC7B00BBEF5F /* TGProfileParamItem.m in Sources */, C248F3E319BE08A800BF658E /* flac.c in Sources */, + C2D777301BAEA30B00D451FD /* ComposeSettingupNewChannelViewController.m in Sources */, 0AB8501E1875AC38001A796C /* TMRowItem.m in Sources */, C21D482E19ACB7CD000F06E1 /* AccountSettingsViewController.m in Sources */, C2C1DC1D1A443CCB00BBCC63 /* StickersPanelView.m in Sources */, @@ -6007,12 +6428,13 @@ 0A9EDC571897BA0E0037E1BC /* RBLExpandingContainerView.m in Sources */, C271525A19B637D200841C8A /* ComposeViewController.m in Sources */, C22421D119EBCFBC0030078A /* BlockedUserRowView.m in Sources */, + C20A5E831B863979007F4B49 /* TGWebpageGifContainer.m in Sources */, + C2A2B42E1BD519870083DA8A /* TGHCMessagesViewController.m in Sources */, 0A613C1D18AD96A9004096DD /* MessageTableCellDocumentView.m in Sources */, CEAE5D6D181EEFF000C17645 /* TLPeer+Extensions.m in Sources */, 0A6D098919535E8500A9AC64 /* NSArrayCategory.m in Sources */, C222AB391A0901F500BEF907 /* PhotoTableItemView.m in Sources */, C2227759190E7309002AA0F6 /* TMTaskRequest.m in Sources */, - 0A241AA618AB60BA00C32F45 /* TMGLGif.m in Sources */, C21D484C19AF64A5000F06E1 /* ComposeAction.m in Sources */, 0A6D098F19535E8500A9AC64 /* NSImageViewCategory.m in Sources */, C248F3D119BE046C00BF658E /* picture.c in Sources */, @@ -6027,18 +6449,17 @@ C21D485619B07A21000F06E1 /* ComposeActionSecretChatBehavior.m in Sources */, C222AB361A0901DC00BEF907 /* PhotoTableItem.m in Sources */, C274C37C1AB831A3000DFDE4 /* TGForwardObject.m in Sources */, + C2CE53FE1BF0E43A00BBEF5F /* TGPhotoViewerBehavior.m in Sources */, C2967B461AA8684E003759B2 /* TGReplayMessage.m in Sources */, 0AF4F497189A696A004BA4DF /* TMScrollAnimation.m in Sources */, C291C7BC1836C39900ABBB50 /* Background.m in Sources */, C2936945197E6B5700DD9680 /* MessageTableHeaderItem.m in Sources */, C291C7C0183759EE00ABBB50 /* SSKeychainQuery.m in Sources */, C2C85BA71AF10B6500FBEABD /* TGCaptionView.m in Sources */, - C2201A06192E488D00C0E441 /* AddContactView.m in Sources */, C256E8F818D0A70B008FFA04 /* TMPreviewUserPicture.m in Sources */, C24F878819FFFFEB00EC962E /* SetTTLSenderItem.m in Sources */, C2233DA51A07EE4B0056594F /* MessageTableCellSocialView.m in Sources */, C2FA78E91923CB76001A9D1B /* DocumentHistoryFilter.m in Sources */, - 0AB43B9E18D43DC000FB805A /* TMGifImageView.m in Sources */, C24435881A1E018100F9BB38 /* ComposeActionCustomBehavior.m in Sources */, C21C7B5318D8991D00253A7A /* SecretSenderItem.m in Sources */, C274C3D01AC57201000DFDE4 /* TGPasswosdMainViewController.m in Sources */, @@ -6055,13 +6476,13 @@ C202D96718E9D67A0060238B /* TMClickTextFieldView.m in Sources */, C268C18719F0519C007F836A /* POPAnimationEvent.mm in Sources */, C240B1B81B627B3700912248 /* SharedLinksHistoryFilter.m in Sources */, - C277E2A418ABB44A00FFCA35 /* DialogsHistoryController.m in Sources */, C21C7B3E18D777B300253A7A /* DocumentSenderItem.m in Sources */, 0AA0A98718B160CF00836E83 /* TMAvatarImageView.m in Sources */, 0A697E86191624AD003469CB /* TMCircleLayer.m in Sources */, C297955819EC29EA00BE893E /* GeneralSettingsRowView.m in Sources */, 0AB43BA818D4D60B00FB805A /* MessageInputGrowingTextView.m in Sources */, C248F3E419BE08A800BF658E /* lpc.c in Sources */, + C2CE53EC1BEB5ACF00BBEF5F /* TGGeneralInputRowItem.m in Sources */, C2A5BFF318E02BAB0021BE68 /* TGAudioPlayer.m in Sources */, C23298CA18CF1A34000826E5 /* TL_conversation.m in Sources */, 0A9EDC5F1897BA0E0037E1BC /* RBLTableView.m in Sources */, @@ -6072,11 +6493,15 @@ C2AC8DB11A7BF0A600655B9D /* TGSearchRowView.m in Sources */, C2753DD219E4282000752BAF /* SearchMessagesView.m in Sources */, 0A7517D2193A053A0088C806 /* TGSwipeRedView.m in Sources */, + C2B0DF831BA9B7840023982C /* ComposeActionAddChannelModeratorBehavior.m in Sources */, C24435921A1E1C7E00F9BB38 /* PrivacyUserListItemView.m in Sources */, C2544E8A1A8128A8006E44DF /* TGSharedMediaCap.m in Sources */, + C25A57E01C072D1D0038169F /* ComposeActionStickersBehavior.m in Sources */, C2C1DC0F1A4336CE00BBCC63 /* TGStickerImageObject.m in Sources */, + C20F76E91BB994A6003A1E86 /* TGModernUserViewController.m in Sources */, 0AB43BC618D8A4AC00FB805A /* NSColor+CNGridViewPalette.m in Sources */, C274C4471ACD99E7000DFDE4 /* TGWebpageTWObject.m in Sources */, + C2B0DFA21BAB34330023982C /* ComposeActionChannelMembersBehavior.m in Sources */, C26976B41A10E2110047E2C3 /* TGPVContainer.m in Sources */, CEAE5D2E181E4C6F00C17645 /* TLFileLocation+Extensions.m in Sources */, C244358B1A1E159900F9BB38 /* PrivacyUserListController.m in Sources */, @@ -6093,12 +6518,16 @@ C268C19F19F13721007F836A /* MessagetableCellAudioController.m in Sources */, C274C3AC1AC083AA000DFDE4 /* SearchHashtagItem.m in Sources */, 0AAAE56F18C7821900A2F9F1 /* UserInfoShortButtonView.m in Sources */, + C2CE53E61BEB4FAD00BBEF5F /* ComposeChangeChannelDescriptionViewController.m in Sources */, C2C6D9661A111B3E001EF8A2 /* TGPhotoViewerItem.m in Sources */, C2D4B8681AFCE8F90035B4E4 /* YapDatabaseManager.m in Sources */, + C2CE53DD1BE9275700BBEF5F /* ComposeActionInfoProfileBehavior.m in Sources */, + C2D8CFC31B84D3E200080775 /* ComposeActionCreateChannelBehavior.m in Sources */, 0ADA319C19469D16002BAEDB /* EmojiViewController.m in Sources */, C2967B431AA4CFA9003759B2 /* TGMentionPopup.m in Sources */, C26976B01A10CDED0047E2C3 /* TGPhotoViewer.m in Sources */, C268C19419F0519C007F836A /* POPSpringAnimation.mm in Sources */, + C2A2B4311BD7C8DB0083DA8A /* TGModalForwardView.m in Sources */, C268C14319F01AE3007F836A /* TMLoaderView.m in Sources */, C2D51BE41B21C67B009327C0 /* EMInMemoryImageCache.m in Sources */, C233FB3418B661B6008C9A96 /* TMCheckBox.m in Sources */, @@ -6110,16 +6539,17 @@ 0AA0145F1831140D00901B7A /* NSString+FindURLs.m in Sources */, 0A9EDC601897BA0E0037E1BC /* RBLView.m in Sources */, C20D190219542AB80095A906 /* SearchHistoryFilter.m in Sources */, - C233FB2B18B6126C008C9A96 /* NewConversationTableView.m in Sources */, C2D4B8721AFCE8FA0035B4E4 /* YapDatabaseQuery.m in Sources */, C2D825D61B67B22E00434D37 /* CacheSettingsViewController.m in Sources */, C20D1893193E09C00095A906 /* TMBlueAddButtonView.m in Sources */, + C2CE53D61BE905D800BBEF5F /* TGProfileHeaderRowView.m in Sources */, C2CBF5F21AF8DA5C006BF90A /* ClassStore.m in Sources */, 0AA0145E1831140D00901B7A /* NSAttributedString+Hyperlink.m in Sources */, C2967B191A9B75B4003759B2 /* TGPasslock.m in Sources */, CEB0A1E317DB03AA0055F150 /* AsyncSocket.m in Sources */, CEF5C02817FFFEFE006CEE27 /* NSData+Extensions.m in Sources */, C2967B1C1A9B9710003759B2 /* TGPasscodeSettingsViewController.m in Sources */, + C2D826421B71155000434D37 /* TGDatabase.m in Sources */, C222773218FC2CA4002AA0F6 /* MessageTableItemUnreadMark.m in Sources */, C2F429D81B04E33F00C2CE4E /* TGProgressIndicator.m in Sources */, C24BCB73186A2711000902BE /* NSNumber+NumberFormatter.m in Sources */, @@ -6134,15 +6564,18 @@ C26F7EC91A602CB3001D1AE2 /* ExternalDocumentSecretSenderItem.m in Sources */, C2CBAEE118F6D617008DF862 /* PreviewObject.m in Sources */, CEA46CFB182A590B007209A6 /* TypingController.m in Sources */, + C2FF82E81B9F28DA00DE2455 /* ChannelHistoryController.m in Sources */, C2531F721965DE5F00F7D7A2 /* ConnectionStatusViewControllerView.m in Sources */, C2C2491F19EBC699006BB1AB /* BlockedUsersViewController.m in Sources */, C2D51C381B25F5A8009327C0 /* TGStickerPackEmojiController.m in Sources */, + C2D8263F1B7110AB00434D37 /* TGConversation.m in Sources */, C240B1B51B627A3300912248 /* TGSharedLinksTableView.m in Sources */, C268C1AD19F6B0A3007F836A /* SearchMessageCellView.m in Sources */, C21C7B3818D769B100253A7A /* VideoSenderItem.m in Sources */, C2689F6F18B3B96300272CD4 /* TGUpdateMessageService.m in Sources */, C2FA78D61922641D001A9D1B /* TMCollectionPageController.m in Sources */, 0A073FD218BF953300BAA928 /* TMTextView.m in Sources */, + C2FF82EB1BA0796400DE2455 /* ChannelsManager.m in Sources */, C24F878B1A00002700EC962E /* DeleteRandomMessagesSenderItem.m in Sources */, C276C7D3195C6C1B0037C4D7 /* ITProgressIndicator.m in Sources */, C274C4051ACBFF33000DFDE4 /* TGWebpageContainer.m in Sources */, @@ -6171,10 +6604,12 @@ CE7E5654189AC25C0058C532 /* UploadQueue.m in Sources */, C274C3D31AC585C1000DFDE4 /* TGPasswordSetViewController.m in Sources */, C2C6D96D1A12650B001EF8A2 /* TGPVMediaBehavior.m in Sources */, + C20A5EC31B878E7C007F4B49 /* TL_channelConversation.m in Sources */, C28261EC1992974C004AC73E /* BroadcastManager.m in Sources */, C268C13D19EEB580007F836A /* UserNameViewController.m in Sources */, 0ACDB13E18CF5535009FE910 /* СountriesManager.m in Sources */, C20B228D18E98A2C007BCCD6 /* SettingsArchiver.m in Sources */, + C20B82B01BDA975500EF01AD /* TGShareContactModalView.m in Sources */, C2CBF6981AFB7EFE006BF90A /* CFunctions.m in Sources */, C2C85B731AE52E8D00FBEABD /* TGImageAttachmentsController.m in Sources */, C268C18519F0519C007F836A /* POPAnimatableProperty.mm in Sources */, @@ -6200,6 +6635,10 @@ C2A5BFD418DDB1EE0021BE68 /* ASQueue.m in Sources */, 0AA7E1C618CCF1D60064EFC7 /* ChatInfoHeaderView.m in Sources */, CEA589471815ADBD00462DF0 /* TGDownloadOperation.m in Sources */, + C2A2B4261BD01FC20083DA8A /* TGHeadChatPanel.m in Sources */, + C2CE53FB1BF0AE3800BBEF5F /* CommonMediaHistoryFilter.m in Sources */, + C26E80301B7E106B003CC483 /* TGRecentSearchTableView.m in Sources */, + C2B0DF891BA9C6EC0023982C /* TGUserContainerView.m in Sources */, 0AB43BB518D89C5700FB805A /* TMSearchImage.m in Sources */, CEC8B88A1832108A00283E53 /* Reachability.m in Sources */, C247C48318C0D38600726C91 /* TGUpdateContainer.m in Sources */, @@ -6216,6 +6655,7 @@ 0A67588E1892A7D600F4487D /* TMScrollView.m in Sources */, C2D4B9291AFCEA1D0035B4E4 /* YapDatabaseExtensionConnection.m in Sources */, C2D51C0C1B21FA5F009327C0 /* TGBotCommandsKeyboard.m in Sources */, + C26E802A1B7E00A1003CC483 /* TGRecentSearchRowItem.m in Sources */, 0AB8500F18756FAD001A796C /* SearchSeparatorTableCell.m in Sources */, 0A7C78C71947701A001617DB /* TMMenuController.m in Sources */, C2C85B8A1AE9269B00FBEABD /* TGModalSetCaptionView.m in Sources */, @@ -6225,7 +6665,6 @@ CEC22DF51827B454008817D0 /* MessagesUtils.m in Sources */, 0A9EDC541897BA0E0037E1BC /* NSView+RBLAnimationAdditions.m in Sources */, 0A6D099819535E8500A9AC64 /* TLEncryptedChatCategory.m in Sources */, - C233FB2E18B61415008C9A96 /* NewConversationRowItem.m in Sources */, C248F3D019BE046C00BF658E /* opus_header.c in Sources */, C2A5BFFD18E03D150021BE68 /* MessageTableCellAudioView.m in Sources */, 0A5F0FFE18DC300A00CCFA60 /* ChatParticipantRowView.m in Sources */, @@ -6245,12 +6684,14 @@ C2967B101A94C0BC003759B2 /* TGAttachImageElement.m in Sources */, C2D4B8731AFCE8FA0035B4E4 /* YapMurmurHash.m in Sources */, C268C18A19F0519C007F836A /* POPAnimationTracer.mm in Sources */, + C20A5E8F1B86404D007F4B49 /* DownloadCacheDocumentItem.m in Sources */, 0AA3F3A218BCD61600D383F1 /* UserInfoViewController.m in Sources */, C2A3FB091A278E2700DE791B /* PhoneChangeController.m in Sources */, C26F7EA21A4C32DB001D1AE2 /* TGAllStickersTableView.m in Sources */, CEB7ADF11812E31F005CB6A1 /* ImageCache.m in Sources */, 0A5F0FF818DC0F5C00CCFA60 /* ChatInfoNotificationView.m in Sources */, 0AC7F475185DA87A00F90558 /* TMTableView.mm in Sources */, + C2D8263B1B710E6400434D37 /* TGModernHistoryController.m in Sources */, C268C19C19F12EFA007F836A /* MessageTableItemAudioDocument.m in Sources */, C24F87971A002F7E00EC962E /* TL_secretServiceMessage.m in Sources */, 0ACDB13218CF28DC009FE910 /* NewLoginViewController.m in Sources */, @@ -6259,14 +6700,19 @@ C274C3E81ACAB97D000DFDE4 /* TGNotifyViewController.m in Sources */, 0AB43BC318D8A4AC00FB805A /* CNGridView.m in Sources */, 0A6D098E19535E8500A9AC64 /* NSImageCategory.m in Sources */, + C2CE53E91BEB543A00BBEF5F /* TGGeneralInputTextRowView.m in Sources */, C2D825EC1B6A700300434D37 /* TGEmbedModalView.m in Sources */, C274C3D91AC5A683000DFDE4 /* TGPasswordEmailViewController.m in Sources */, + C2CE53E31BEA75B800BBEF5F /* TGModernChannelInfoViewController.m in Sources */, 0A6D099419535E8500A9AC64 /* NSViewCategory.m in Sources */, C2F429C51B00C88B00C2CE4E /* TGStickersSettingsViewController.m in Sources */, + C20A5F561B8F6CDD007F4B49 /* MessageTableCellHoleView.m in Sources */, 0A7EB71B183A873D00F02E04 /* NSString+Extended.m in Sources */, C226CC7C1B341CED0042C5D8 /* ComposeChooseGroupViewController.m in Sources */, 0A241A9D18AB176B00C32F45 /* MessageTableCellTextView.m in Sources */, CECBC15618008B3300AD98E6 /* CMath.c in Sources */, + C20A5EF01B8CD8CB007F4B49 /* TMBlueInputTextField.m in Sources */, + C2E5A0731BAC75C200C1BCA1 /* TGMessageViewSender.m in Sources */, 0AB4789818E304B100DF283B /* ChatAvatarImageView.m in Sources */, C281C1781917D9C2007B160F /* DraggingControllerView.m in Sources */, C24F877719FE7CAB00EC962E /* SecretLayer17.m in Sources */, @@ -6274,6 +6720,7 @@ C247015919839A4B007AB338 /* TGTimerTarget.m in Sources */, C2CBF6CE1AFBC5C0006BF90A /* RPC.m in Sources */, 0AAAE57D18C8CBB600A2F9F1 /* TMAnimations.m in Sources */, + C2CE53EF1BEB748900BBEF5F /* ComposeActionChangeChannelAboutBehavior.m in Sources */, C2201A0D1934E6D600C0E441 /* DownloadPart.m in Sources */, C274C41E1ACC09B0000DFDE4 /* XCDYouTubePlayerScript.m in Sources */, C2AC8DAE1A77E51F00655B9D /* TGSharedMediaFileThumbnailView.m in Sources */, @@ -6303,10 +6750,14 @@ 0AAAE57218C78E4400A2F9F1 /* UserInfoParamsView.m in Sources */, C2DE4FAE1AD08C47001EC26C /* TGWebpageArticleContainer.m in Sources */, C2AA4F0E18A8EDCB00E20C68 /* NSObject+TGLock.m in Sources */, + C2D826491B74FD5D00434D37 /* TGPVZoomControl.m in Sources */, + C20A5EDB1B8B7A81007F4B49 /* TGModernConversationHistoryController.m in Sources */, C271525419B61E5700841C8A /* ComposeActionBroadcastBehavior.m in Sources */, C2D51BFA1B21C707009327C0 /* TGAudioRowItem.m in Sources */, C270D2F11A1CD8BA00522FB0 /* PrivacyViewController.m in Sources */, + C2B669861BA5571C004AF678 /* TGSettingsTableView.m in Sources */, C24F878519FEA70200EC962E /* UpgradeLayerSenderItem.m in Sources */, + C20A5F591B8F8B2B007F4B49 /* TGHistoryResponse.m in Sources */, C2D4B86D1AFCE8FA0035B4E4 /* YapRowidSet.mm in Sources */, C21C7B4F18D8410700253A7A /* ShareContactSenterItem.m in Sources */, C2233DAC1A07F2460056594F /* YoutubeServiceDescription.m in Sources */, @@ -6314,11 +6765,13 @@ C268C19119F0519C007F836A /* POPLayerExtras.mm in Sources */, 0A4A1A1F189FFAE400D756CD /* MessageTableItemTyping.m in Sources */, C274C3FC1ACBF765000DFDE4 /* TGWebpageIGContainer.m in Sources */, + C2B6698C1BA570AF004AF678 /* ComposeCreateChannelUserNameStepViewController.m in Sources */, C20A7E6219D706D0008844F2 /* ASActor.m in Sources */, 0A9EDC4F1897BA0E0037E1BC /* NSFont+RBLFallbackAdditions.m in Sources */, 0A6D099319535E8500A9AC64 /* NSTextFieldCategory.m in Sources */, 0A6B6E331903FED1005291FE /* ITSwitch.m in Sources */, 0AF4F49E189AA378004BA4DF /* TMTypingObject.m in Sources */, + C2CE53F81BED06BD00BBEF5F /* ChannelCommonFilter.m in Sources */, C26F7EB21A56E5B0001D1AE2 /* RequestKeySecretSenderItem.m in Sources */, 0AB43BB018D84FA200FB805A /* TMImagesSearchController.m in Sources */, C2531F541964412700F7D7A2 /* NSTextView+EmojiExtension.m in Sources */, @@ -6328,13 +6781,13 @@ 0ABACDA8181ADB1E00EF43DB /* SerializedData.m in Sources */, CE4CC6EA1829B4DF00B532CC /* WhiteTitleButton.m in Sources */, C23223D21A024CC600E476E2 /* TGSecretInAction.m in Sources */, - C2201A0A192E4AAA00C0E441 /* TMBlueInputTextField.m in Sources */, C24435811A1D1B9900F9BB38 /* PrivacyArchiver.m in Sources */, 0AA7E1C318CCF08D0064EFC7 /* ChatInfoViewController.m in Sources */, C22421CA19EBCFA80030078A /* BlockedUserRowItem.m in Sources */, 0A6D098B19535E8500A9AC64 /* NSBezierPathCategory.m in Sources */, CEA5894C181673E500462DF0 /* NS(Attributed)String+Geometrics.m in Sources */, 0A59068518AA32C8002ED7BA /* NSImage+BTRImageAdditions.m in Sources */, + C20B82A11BD98EC700EF01AD /* TGPVDocumentsBehavior.m in Sources */, C268C19219F0519C007F836A /* POPMath.mm in Sources */, C2CBF6D71AFBDB6F006BF90A /* TGLinearProgressView.m in Sources */, C2AC8DB41A7BF13000655B9D /* TGSearchRowItem.m in Sources */, @@ -6353,10 +6806,12 @@ C21C7B3B18D769E400253A7A /* SenderItem.m in Sources */, C273805C1B3D90DC000C479E /* TGAudioPlayerWindow.m in Sources */, 0AE2E3F41867263C004926A7 /* TMSearchTextField.m in Sources */, + C2CE53D01BE8E6F900BBEF5F /* TGProfileParamView.m in Sources */, C2C1DC131A433C3900BBCC63 /* DownloadStickerItem.m in Sources */, CE7E5658189AC5E30058C532 /* QueueManager.m in Sources */, C2D4B86E1AFCE8FA0035B4E4 /* YapTouch.m in Sources */, C2201A03192CCB6C00C0E441 /* SelectUserRowView.m in Sources */, + C2CE53C61BE7688900BBEF5F /* ComposeActionCreateMegaGroupBehavior.m in Sources */, C2A5BFC118DC80620021BE68 /* stream.c in Sources */, 0AB7927E182587E500B3E2A1 /* UploadOperation.m in Sources */, 0AB43B9218D304C400FB805A /* RegistrationAvatarView.m in Sources */, @@ -6374,16 +6829,19 @@ C248F3D719BE070D00BF658E /* audio-in.c in Sources */, 0A0B09BC18B1823700F3FE1B /* TMImageUtils.m in Sources */, C2ED357D18D9FECB00D0027C /* CAProgressLayer.m in Sources */, + C26E80201B7B91A9003CC483 /* TGDatabaseRequest.m in Sources */, 0A241AA018AB2F5900C32F45 /* MessageTableCellPhotoView.m in Sources */, C23536A819CB1A430044978E /* FFYDaemonController.m in Sources */, C2D51B9F1B17A6BD009327C0 /* TGHelpPopup.m in Sources */, 0AB43BC518D8A4AC00FB805A /* CNGridViewItemLayout.m in Sources */, C26976AC1A0C03610047E2C3 /* InstagramServiceDescription.m in Sources */, 0AB43BC718D8A4AC00FB805A /* NSView+CNGridView.m in Sources */, + C20A5EDF1B8B8905007F4B49 /* TGObservableObject.m in Sources */, C2D4B8701AFCE8FA0035B4E4 /* YapCache.m in Sources */, C270D2F91A1CE12000522FB0 /* PrivacySettingsViewController.m in Sources */, 0A613C2318AD9924004096DD /* MessageTableCellContactView.m in Sources */, C268C14019EFF70E007F836A /* GLView.m in Sources */, + C26E80271B7D14E2003CC483 /* TL_localMessage_old32.m in Sources */, 0A9EDC511897BA0E0037E1BC /* NSObject+RBObjectSizzlingAdditions.m in Sources */, C2201A00192CCB5C00C0E441 /* SelectUserItem.m in Sources */, C26976A51A0AB3B80047E2C3 /* PhotoCollectionImageObject.m in Sources */, @@ -6401,35 +6859,45 @@ C2CB5DC51B4EAA4F00CD61DF /* NSObject+BObject.m in Sources */, C2F429D21B04D37C00C2CE4E /* TGUIMainThreadGuard.m in Sources */, 0A08D1D4181B1F8C005F7C13 /* TLClassStore.m in Sources */, + C2B0DF921BAAFD2E0023982C /* ComposeChannelParticipantsViewController.m in Sources */, + C20A5EEC1B8CD8B8007F4B49 /* AddContactView.m in Sources */, C2002D0619994D7A002A1915 /* BroadcastInfoHeaderView.m in Sources */, C2DE4FB51AD43ED0001EC26C /* TGArticleImageObject.m in Sources */, C2200B7A18F5557600F28803 /* TL_outDocument.m in Sources */, 0A59067B18AA32C8002ED7BA /* BTRImage.m in Sources */, + C20A5EBD1B8748A3007F4B49 /* ChannelInfoViewController.m in Sources */, C2FA78CC191BEA29001A9D1B /* TMPreviewCollectionPhotoItem.m in Sources */, 0A9EDC561897BA0E0037E1BC /* RBLClipView.m in Sources */, C2531F5D196572BA00F7D7A2 /* TMSharedMediaButton.m in Sources */, C274C4021ACBF7A5000DFDE4 /* TGWebpageObject.m in Sources */, + C2B0DF991BAAFEFA0023982C /* TGModalDeleteChannelMessagesView.m in Sources */, C256E91418D21A96008FFA04 /* DownloadPhotoItem.m in Sources */, 0A59068618AA32C8002ED7BA /* NSView+BTRAdditions.m in Sources */, C2CB5CEF1B467D5A00CD61DF /* TGSplitView.m in Sources */, + C20A5F5F1B9330CD007F4B49 /* ChannelImportantFilter.m in Sources */, C26752811A1CA7CC00152D9A /* TMAvaImageObject.m in Sources */, C274C3C91AC48F6B000DFDE4 /* TGSessionRowitem.m in Sources */, C2DE4FB11AD2E5D6001EC26C /* TGWebpageAttach.m in Sources */, + C2CE53C31BE295A000BBEF5F /* TGGeneralSearchRowView.m in Sources */, 0A9EDC501897BA0E0037E1BC /* NSImage+RBLResizableImageAdditions.m in Sources */, C2182BBE19589246002469CA /* TL_localMessageService.m in Sources */, 0AB8F64E1861B07C000E6FF3 /* TMRowView.m in Sources */, C2753DDF19E5B24500752BAF /* TGModernAnimatedImagePlayer.m in Sources */, - C233FB2818B610E9008C9A96 /* NewConversationViewController.m in Sources */, 0A073FCF18BF65F500BAA928 /* TMNavigationBar.m in Sources */, C2D825E61B6915B500434D37 /* NotificationConversationRowView.m in Sources */, C256E91D18D25324008FFA04 /* TMPreviewAudioItem.m in Sources */, + C20A5F531B8F6CC3007F4B49 /* MessageTableItemHole.m in Sources */, + C2B6698F1BA575AE004AF678 /* TGChangeUserNameContainerView.m in Sources */, C281C180191AA139007B160F /* TMPreviewChatPicture.m in Sources */, + C20A5ECF1B8B67D7007F4B49 /* TL_conversation_old34.m in Sources */, 0A2F5AD8181A8FC6005045A5 /* NSContactsPopover.m in Sources */, CEAE5D25181C407600C17645 /* MessagesManager.m in Sources */, C222774E19093C8C002AA0F6 /* TMBottomScrollView.m in Sources */, C25F91F0197D374F006868F3 /* TimeObserver.m in Sources */, 0ACF9E3C19235F42001F9E1E /* SearchLoadMoreItem.m in Sources */, + C2CE53D91BE9060500BBEF5F /* TGProfileHeaderRowItem.m in Sources */, 0AF4061E18192B7E00160DB4 /* NSString+MD5.m in Sources */, + C20A5EB31B871ABA007F4B49 /* TGUpdateChannelContainer.m in Sources */, 0AA0A98418B140FF00836E83 /* CAAvatarLayer.m in Sources */, C256E8FB18D0A742008FFA04 /* TMMediaUserPictureController.mm in Sources */, CE4D06AE1811CAAD00207C34 /* BFImage.m in Sources */, @@ -6447,6 +6915,7 @@ C25F91B91977EB17006868F3 /* TGImageObject.m in Sources */, C2CBF6BF1AFB8BAB006BF90A /* ImageObject.m in Sources */, C2A5BFBE18DC80620021BE68 /* info.c in Sources */, + C20A5EED1B8CD8B9007F4B49 /* AddContactViewController.m in Sources */, C2531F5A1964548100F7D7A2 /* MessagesTopInfoView.m in Sources */, C2D4B86B1AFCE8F90035B4E4 /* YapMemoryTable.m in Sources */, C256E91118D20BA8008FFA04 /* DownloadItem.m in Sources */, @@ -6474,11 +6943,13 @@ C20D188B193CBC230095A906 /* AudioSenderItem.m in Sources */, C20D18F81948D1FE0095A906 /* SecretChatAccepter.m in Sources */, C2B325EE1A237A420012DE34 /* TLApiObject.m in Sources */, + C20F76ED1BBAC41A003A1E86 /* TGMessagesHintView.m in Sources */, C274C44A1ACD9FF5000DFDE4 /* TGWebpageStandartObject.m in Sources */, C248F3CF19BE046C00BF658E /* diag_range.c in Sources */, 0A59067818AA32C8002ED7BA /* BTRButton.m in Sources */, C2D51BFE1B21D762009327C0 /* ComposeChatPickerViewController.m in Sources */, C26F7EBB1A5ED66E001D1AE2 /* AbortKeySecretSenderItem.m in Sources */, + C2CE53CA1BE8C0DB00BBEF5F /* TGSProfileMediaRowView.m in Sources */, C268C1B019F6B1F7007F836A /* SearchMessageTableItem.m in Sources */, CEC22DF81827CC10008817D0 /* FullChatManager.m in Sources */, C2D51C3E1B2618DE009327C0 /* TGTransformScrollView.m in Sources */, @@ -6491,6 +6962,7 @@ 0A9EDC4C1897BA0E0037E1BC /* NSApplication+RBLBlockAdditions.m in Sources */, C2ACCE561ADD2A0600ABEE78 /* TGConversationsViewController.m in Sources */, C2FA78EC1923CBA1001A9D1B /* PhotoHistoryFilter.m in Sources */, + C2FF82A31B99C7CE00DE2455 /* TGForceChannelUpdate.m in Sources */, C2C1DC2C1A44942E00BBCC63 /* StickerSenderItem.m in Sources */, C274C4221ACC09B0000DFDE4 /* XCDYouTubeVideoWebpage.m in Sources */, C244358F1A1E1C6C00F9BB38 /* PrivacyUserListItem.m in Sources */, @@ -6501,10 +6973,9 @@ CEB7ADE518128581005CB6A1 /* DownloadQueue.mm in Sources */, 0A6758881892798500F4487D /* SJExpandingTextView.m in Sources */, 0A6D099019535E8500A9AC64 /* NSMenuCategory.m in Sources */, - C2227752190E564B002AA0F6 /* OnlineNotificationManager.m in Sources */, 0AB8F2AF194866050074E4E7 /* MapPanel.m in Sources */, - C233FB3118B61618008C9A96 /* NewConversationRowView.m in Sources */, C268C18619F0519C007F836A /* POPAnimation.mm in Sources */, + C2CE53F51BECE46600BBEF5F /* MegagroupHistoryController.m in Sources */, C2B326081A24F77E0012DE34 /* PhoneChangeAlertController.m in Sources */, C297955119EC267200BE893E /* GeneralSettingsViewController.m in Sources */, CE84549A18244F1600E73DF7 /* TelegramWindow.m in Sources */, @@ -6515,27 +6986,35 @@ C256E90918D201CD008FFA04 /* TMPreviewVideoItem.m in Sources */, C2D51BFB1B21C707009327C0 /* TGAudioRowView.m in Sources */, 0AB43BA518D44A1C00FB805A /* GifAnimationLayer.m in Sources */, + C2B669891BA5591F004AF678 /* TGGeneralRowItem.m in Sources */, C268C18F19F0519C007F836A /* POPDecayAnimation.mm in Sources */, 0A9C56A218CB0D66005B5049 /* TMBackButton.m in Sources */, C2002D0319990F10002A1915 /* BroadcastInfoViewController.m in Sources */, C268C19919F12B66007F836A /* MessageTablecellAudioDocumentView.m in Sources */, C2C6D9691A124F70001EF8A2 /* TGPVControls.m in Sources */, + C20A5EA71B86625F007F4B49 /* TGUpdateChannels.m in Sources */, + C26E802D1B7E00C3003CC483 /* TGRecentSearchRowView.m in Sources */, + C2CE53CD1BE8D96600BBEF5F /* TGSProfileMediaRowItem.m in Sources */, C256E91A18D24C4C008FFA04 /* DownloadAudioItem.m in Sources */, CEAE5CD0181B0D7600C17645 /* ImageUtils.m in Sources */, - C271526419B9ECCA00841C8A /* AddContactViewController.m in Sources */, CEA589431815704E00462DF0 /* SharedManager.m in Sources */, 0AA7E1D318CD392A0064EFC7 /* UIImageView+AFNetworking.m in Sources */, + C20A5EE61B8CC813007F4B49 /* TGEvent.m in Sources */, + C2B0DF8F1BAAD9330023982C /* ComposeManagmentViewController.m in Sources */, C2A3FB0D1A28A6B200DE791B /* TGHashContact.m in Sources */, C20A7E5F19D7069C008844F2 /* TGActor.m in Sources */, C2200B6018EDD1E200F28803 /* AboutViewControllerWindowController.m in Sources */, C2D931401991140F00668F86 /* TGWindowArchiver.m in Sources */, + C2B0DF771BA98E7C0023982C /* TL_localEmptyMessage.m in Sources */, C2D4B7431AFCD3B80035B4E4 /* TGStickerPackModalView.m in Sources */, 0AC9FD431868DF5B00F7E95C /* TMNineImage.m in Sources */, + C20A5F351B8F4579007F4B49 /* TGChannelsPolling.m in Sources */, C282485218BBB67200131533 /* SelfDestructionController.m in Sources */, C281C17B1917D9D9007B160F /* DraggingItemView.m in Sources */, C2FA78D3191CDBF6001A9D1B /* ProfileSharedMediaView.m in Sources */, C2F39967190FD1D6006B36F7 /* ASHandle.m in Sources */, C2AA4F0618A8ED5500E20C68 /* TGObserverProxy.m in Sources */, + C2B0DF8C1BA9CE290023982C /* TGUserContainerRowItem.m in Sources */, 0A9EDC121896FE010037E1BC /* TMHyperlinkTextField.m in Sources */, C2D4B8671AFCE8F90035B4E4 /* YapDatabaseLogging.m in Sources */, C23298DE18CF61DD000826E5 /* TMMediaController.mm in Sources */, @@ -6552,17 +7031,22 @@ C2D4B8791AFCE8FA0035B4E4 /* YapDatabaseTransaction.m in Sources */, C2FA78DF1923A3BB001A9D1B /* PhotoVideoHistoryFilter.m in Sources */, 0ACDB13B18CF45A5009FE910 /* LoginCountrySelectorView.m in Sources */, + C25A57EC1C0736D70038169F /* TGMovableTableView.m in Sources */, + C2ED28041BFF7F0E00F19531 /* TGReportChannelModalView.m in Sources */, C2AA5D35187597680026EA1F /* LoopingUtils.m in Sources */, C24F87941A0015BD00EC962E /* TGSecretAction.m in Sources */, 0A613C1A18AD7E49004096DD /* MessageTableCellGeoView.m in Sources */, + C20A5E711B86290C007F4B49 /* TGWebpageGifObject.m in Sources */, C2CD77C91A2C9E04000B4BA9 /* TGEnterPasswordPanel.m in Sources */, 0A9EDC5C1897BA0E0037E1BC /* RBLShadowedTextFieldCell.m in Sources */, C270C5B018A13F9F005D80E0 /* FileUtils.m in Sources */, + C20A5F5C1B90D815007F4B49 /* TGMessageGroupHole.m in Sources */, C2D4B86C1AFCE8F90035B4E4 /* YapNull.m in Sources */, C2200B7618F43B3300F28803 /* EncryptedKeyWindow.m in Sources */, C268C18919F0519C007F836A /* POPAnimationRuntime.mm in Sources */, C2C8AB101A3F508300C857D6 /* TLDocument+Extension.m in Sources */, C268C19319F0519C007F836A /* POPPropertyAnimation.mm in Sources */, + C2CC41C41BA7FC450097E973 /* WeakReference.m in Sources */, 0A13B82D1819C27500E06702 /* NSArray+BlockFiltering.m in Sources */, C297955F19EC587900BE893E /* SettingsSecurityViewController.m in Sources */, C2C85B841AE57D0100FBEABD /* TGAttachObject.m in Sources */, @@ -6571,7 +7055,7 @@ 0A4A1A2218A153F800D756CD /* MessageTableItemDocument.m in Sources */, C21C7B2C18D7044600253A7A /* MessageSenderItem.m in Sources */, 0A62CC8A181EFC1C0098720C /* Telegram.m in Sources */, - CEB0A25117DB09C10055F150 /* TGInitializer.m in Sources */, + C2CE53C01BE2892E00BBEF5F /* ChatAdminsViewController.m in Sources */, C2753DDC19E5A44300752BAF /* FLAnimatedImage.m in Sources */, C2CB5CF21B467D5A00CD61DF /* TGViewController.m in Sources */, C2233DA91A07EF060056594F /* MessageTableItemSocial.m in Sources */, @@ -6581,12 +7065,21 @@ 0A6D098819535E8500A9AC64 /* NSAlertCategory.m in Sources */, C2CBF6B71AFB860D006BF90A /* DownloadOperation.m in Sources */, C2D51BF91B21C707009327C0 /* TGAudioProgressView.m in Sources */, + C20B82AD1BDA550600EF01AD /* TGChatHeadLockView.m in Sources */, C26F7EC21A5EFB54001D1AE2 /* SecretLayer23.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ +/* Begin PBXTargetDependency section */ + 8AF787F41C5704BD00DC72E6 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = MtProtoKitMac; + targetProxy = 8AF787F31C5704BD00DC72E6 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + /* Begin PBXVariantGroup section */ 0A9EDC191897BA0E0037E1BC /* InfoPlist.strings */ = { isa = PBXVariantGroup; @@ -6613,7 +7106,6 @@ C20D18EE1948A3F70095A906 /* NewMainMenu.xib */ = { isa = PBXVariantGroup; children = ( - C20D18ED1948A3F70095A906 /* ru */, C20D18F31948A3FB0095A906 /* en */, C20D18F51948A4970095A906 /* es */, C2002D13199E9ADA002A1915 /* de */, @@ -6626,7 +7118,6 @@ CE46A2571854B68F00D6EF14 /* Localizable.strings */ = { isa = PBXVariantGroup; children = ( - CE46A25A1854C05900D6EF14 /* ru */, CE46A25B1854C09A00D6EF14 /* en */, C20D18B11945BE890095A906 /* es */, C2002D14199E9ADA002A1915 /* de */, @@ -6721,7 +7212,7 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - ./MtProtoKit, + "./MtProtoKit/**", ); INFOPLIST_FILE = TGShare/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @executable_path/../../../../Frameworks"; @@ -6729,10 +7220,12 @@ MTL_ENABLE_DEBUG_INFO = YES; OTHER_CODE_SIGN_FLAGS = ""; "OTHER_CODE_SIGN_FLAGS[sdk=*]" = "--deep"; + PRODUCT_BUNDLE_IDENTIFIER = "ru.keepcoder.Telegram.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - PROVISIONING_PROFILE = "9b5f6bc3-32b1-4737-bbea-c772320d3813"; + PROVISIONING_PROFILE = "1c746dc7-fbd8-40fe-8897-361d3f52bd07"; SDKROOT = macosx; SKIP_INSTALL = YES; + USER_HEADER_SEARCH_PATHS = "./MtProtoKit/**"; }; name = Debug; }; @@ -6746,6 +7239,7 @@ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_UNREACHABLE_CODE = YES; CODE_SIGN_ENTITLEMENTS = TGShare/TGShare.entitlements; + CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=macosx*]" = ""; COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; @@ -6762,7 +7256,7 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - ./MtProtoKit, + "./MtProtoKit/**", ); INFOPLIST_FILE = TGShare/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @executable_path/../../../../Frameworks"; @@ -6770,10 +7264,12 @@ MTL_ENABLE_DEBUG_INFO = NO; OTHER_CODE_SIGN_FLAGS = ""; "OTHER_CODE_SIGN_FLAGS[sdk=*]" = "--deep"; + PRODUCT_BUNDLE_IDENTIFIER = "ru.keepcoder.Telegram.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - PROVISIONING_PROFILE = "9b5f6bc3-32b1-4737-bbea-c772320d3813"; + PROVISIONING_PROFILE = "1c746dc7-fbd8-40fe-8897-361d3f52bd07"; SDKROOT = macosx; SKIP_INSTALL = YES; + USER_HEADER_SEARCH_PATHS = "./MtProtoKit/**"; }; name = Release; }; @@ -6790,6 +7286,7 @@ CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_OBJC_EXCEPTIONS = YES; @@ -6807,7 +7304,7 @@ MACOSX_DEPLOYMENT_TARGET = 10.7; ONLY_ACTIVE_ARCH = YES; PROVISIONING_PROFILE = ""; - SDKROOT = macosx10.9; + SDKROOT = macosx; }; name = Debug; }; @@ -6834,7 +7331,7 @@ GCC_WARN_UNUSED_VARIABLE = YES; MACOSX_DEPLOYMENT_TARGET = 10.7; PROVISIONING_PROFILE = ""; - SDKROOT = macosx10.9; + SDKROOT = macosx; }; name = Release; }; @@ -6843,6 +7340,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = Telegram.entitlements; + CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=macosx*]" = ""; COMBINE_HIDPI_IMAGES = YES; FRAMEWORK_SEARCH_PATHS = ( @@ -6855,11 +7353,13 @@ ); GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "TelegramTest/Telegraph-Prefix.pch"; + GCC_WARN_UNDECLARED_SELECTOR = YES; HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, ./sqlcipher/sr, - ./MtProtoKit/, + "./MtProtoKit/**", + "./Signals/**", ); INFOPLIST_FILE = "TelegramTest/Telegraph-Info.plist"; LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks @executable_path/../Frameworks"; @@ -6867,16 +7367,20 @@ "$(inherited)", "$(PROJECT_DIR)", "$(PROJECT_DIR)/libwebp-0.4.2-mac-10.8/lib", + "$(SDKROOT)/usr/lib/system", ); MACOSX_DEPLOYMENT_TARGET = 10.8; OTHER_CFLAGS = "-DSQLITE_HAS_CODEC"; "OTHER_CODE_SIGN_FLAGS[sdk=*]" = "--deep"; - OTHER_LDFLAGS = ""; - "OTHER_LDFLAGS[arch=*]" = ""; + OTHER_LDFLAGS = ( + "$(OTHER_LDFLAGS)", + "-ObjC", + ); + PRODUCT_BUNDLE_IDENTIFIER = ru.keepcoder.Telegram; PRODUCT_NAME = Telegram; PROVISIONING_PROFILE = ""; SDKROOT = macosx; - USER_HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/libwebp-0.4.2-mac-10.8/include"; + USER_HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/libwebp-0.4.2-mac-10.8/include ./MtProtoKit/**"; VALIDATE_PRODUCT = NO; WRAPPER_EXTENSION = app; }; @@ -6887,6 +7391,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = Telegram.entitlements; + CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=macosx*]" = ""; COMBINE_HIDPI_IMAGES = YES; FRAMEWORK_SEARCH_PATHS = ( @@ -6899,11 +7404,13 @@ ); GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "TelegramTest/Telegraph-Prefix.pch"; + GCC_WARN_UNDECLARED_SELECTOR = YES; HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, ./sqlcipher/sr, - ./MtProtoKit/, + "./MtProtoKit/**", + "./Signals/**", ); INFOPLIST_FILE = "TelegramTest/Telegraph-Info.plist"; LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks @executable_path/../Frameworks"; @@ -6911,16 +7418,20 @@ "$(inherited)", "$(PROJECT_DIR)", "$(PROJECT_DIR)/libwebp-0.4.2-mac-10.8/lib", + "$(SDKROOT)/usr/lib/system", ); MACOSX_DEPLOYMENT_TARGET = 10.8; OTHER_CFLAGS = "-DSQLITE_HAS_CODEC"; "OTHER_CODE_SIGN_FLAGS[sdk=*]" = "--deep"; - OTHER_LDFLAGS = ""; - "OTHER_LDFLAGS[arch=*]" = ""; + OTHER_LDFLAGS = ( + "$(OTHER_LDFLAGS)", + "-ObjC", + ); + PRODUCT_BUNDLE_IDENTIFIER = ru.keepcoder.Telegram; PRODUCT_NAME = Telegram; PROVISIONING_PROFILE = ""; SDKROOT = macosx; - USER_HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/libwebp-0.4.2-mac-10.8/include"; + USER_HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/libwebp-0.4.2-mac-10.8/include ./MtProtoKit/**"; VALIDATE_PRODUCT = NO; WRAPPER_EXTENSION = app; }; diff --git a/Telegram.xcodeproj/project.xcworkspace/xcshareddata/Telegram.xcscmblueprint b/Telegram.xcodeproj/project.xcworkspace/xcshareddata/Telegram.xcscmblueprint new file mode 100644 index 00000000..260ca0e9 --- /dev/null +++ b/Telegram.xcodeproj/project.xcworkspace/xcshareddata/Telegram.xcscmblueprint @@ -0,0 +1,44 @@ +{ + "DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "4A5BEE4DFE7777AFD5504E71EF990A207EDDC37A", + "DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : { + + }, + "DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : { + "7EC1C8EA9643E5D9E5CFB7785E6B7386F88D4D5C" : 0, + "4A5BEE4DFE7777AFD5504E71EF990A207EDDC37A" : 0, + "E860E73EA92362394DE531098D73ED96B22811B3" : 0, + "55011AEBD444630C0E9DF47BD2E18FDBBDCC285D" : 0 + }, + "DVTSourceControlWorkspaceBlueprintIdentifierKey" : "ABCC6397-1AF7-49D7-9751-8C02D795855C", + "DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : { + "7EC1C8EA9643E5D9E5CFB7785E6B7386F88D4D5C" : "osx-cipher\/MtProtoKit\/", + "4A5BEE4DFE7777AFD5504E71EF990A207EDDC37A" : "osx-cipher\/", + "E860E73EA92362394DE531098D73ED96B22811B3" : "osx-cipher\/Signals\/", + "55011AEBD444630C0E9DF47BD2E18FDBBDCC285D" : "osx-cipher\/sqlcipher\/" + }, + "DVTSourceControlWorkspaceBlueprintNameKey" : "Telegram", + "DVTSourceControlWorkspaceBlueprintVersion" : 204, + "DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "Telegram.xcodeproj", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [ + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/overtake\/telegramosx.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "4A5BEE4DFE7777AFD5504E71EF990A207EDDC37A" + }, + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/sqlcipher\/sqlcipher.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "55011AEBD444630C0E9DF47BD2E18FDBBDCC285D" + }, + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/iakovlev-peter\/MtProtoKit.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "7EC1C8EA9643E5D9E5CFB7785E6B7386F88D4D5C" + }, + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/peter-iakovlev\/Signals", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "E860E73EA92362394DE531098D73ED96B22811B3" + } + ] +} \ No newline at end of file diff --git a/Telegram.xcodeproj/project.xcworkspace/xcuserdata/mikhailfilimonov.xcuserdatad/xcdebugger/Expressions.xcexplist b/Telegram.xcodeproj/project.xcworkspace/xcuserdata/mikhailfilimonov.xcuserdatad/xcdebugger/Expressions.xcexplist index 09a97235..991fea22 100644 --- a/Telegram.xcodeproj/project.xcworkspace/xcuserdata/mikhailfilimonov.xcuserdatad/xcdebugger/Expressions.xcexplist +++ b/Telegram.xcodeproj/project.xcworkspace/xcuserdata/mikhailfilimonov.xcuserdatad/xcdebugger/Expressions.xcexplist @@ -3,865 +3,3000 @@ version = "1.0"> + contextName = "-[MessagesBottomView checkMentionsOrTags]:MessagesBottomView.m"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + contextName = "__40-[PhoneChangeConfirmController loadView]_block_invoke_2:PhoneChangeConfirmController.m"> + contextName = "-[TLAPI_account_updatePasswordSettings getData]:TLApi.m"> + + + + + + - - + value = "_updateState.pts"> + contextName = "-[ChatHistoryController filterAndAdd:isLates:]:ChatHistoryController.m"> + contextName = "-[TMButton drawRect:]:TMButton.m"> + + + value = "self.list"> + contextName = "-[Storage loadChannelMessages:min_id:max_id:minDate:maxDate:limit:filterMask:important:]:Storage.m"> + value = "botHole"> + value = "topHole"> + value = "messages"> - - - - + contextName = "__63-[TGUpdateChannels failUpdateWithChannelId:limit:withCallback:]_block_invoke:TGUpdateChannels.m"> - - + value = "conversation"> - - + contextName = "-[MessageTableCellContainerView scrollWheel:]:MessageTableCellContainerView.m"> + value = "theEvent.clickCount"> - - + contextName = "-[TMAvatarImageView rebuild:]:TMAvatarImageView.m"> + value = "self.type"> - - - - - - - - + value = "self.chat"> + + + + + contextName = "__88-[Storage loadChannelMessages:min_id:max_id:minDate:maxDate:limit:filterMask:important:]_block_invoke:Storage.m"> + value = "min"> + + + + + contextName = "-[TGUpdateChannels addStatefullUpdate:]:TGUpdateChannels.m"> + value = "self.pts"> + contextName = "__41-[TGAllStickersTableView performLoadSet:]_block_invoke:TGAllStickersTableView.m"> + contextName = "__42-[TGSModalSenderView sendAsMedia:rowItem:]_block_invoke_2:TGSModalSenderView.m"> + + - - + value = "object.media.document"> + contextName = "__44-[TGChannelsLoader loadNext:result:onQueue:]_block_invoke_2:TGModernConversationHistoryController.m"> + value = "channel"> + + + contextName = "-[ChatHistoryController max_id]:ChatHistoryController.m"> + contextName = "__27-[Storage saveUpdateState:]_block_invoke:Storage.m"> + contextName = "-[TGImageObject initDownloadItem]:TGImageObject.m"> + contextName = "+[TGWebpageObject objectForWebpage:]:TGWebpageObject.m"> + contextName = "-[PhotoCollectionImageView checkAction]:PhotoCollectionImageView.m"> + + + + + contextName = "-[DocumentSenderItem initWithPath:forConversation:]:DocumentSenderItem.m"> + + + + + contextName = "-[ChannelHistoryController loadAroundMessagesWithSelectHandler:prevLimit:nextLimit:prevResult:nextResult:]:ChannelHistoryController.m"> + + + + + contextName = "__89-[MessagesViewController showMessage:fromMsg:animated:selectText:switchDiscussion:flags:]_block_invoke:MessagesViewController.m"> + + + + + contextName = "__81-[Storage loadMessages:localMaxId:limit:next:maxDate:filterMask:completeHandler:]_block_invoke:Storage.m"> + contextName = "__59-[TGAllStickersTableView performLoadSet:allSets:hash:save:]_block_invoke_2:TGAllStickersTableView.m"> + contextName = "__34-[SenderItem removeEventListener:]_block_invoke:SenderItem.m"> + value = "_listeners"> + contextName = "__56-[DocumentHistoryFilter remoteRequest:peer_id:callback:]_block_invoke:DocumentHistoryFilter.m"> + contextName = "-[DownloadVideoItem setDownloadState:]:DownloadVideoItem.m"> + contextName = "-[TMNavigationController pushViewController:animated:]:TMNavigationController.m"> + value = "oldViewController"> + contextName = "-[TGPhotoViewer show:user:]:TGPhotoViewer.m"> + contextName = "__57-[MessagesManager notifyMessage:update_real_date:notify:]_block_invoke:MessagesManager.m"> + value = "message.chat.isMegagroup"> + contextName = "__42-[NewContactsManager importCloudContacts:]_block_invoke_2:NewContactsManager.m"> + + + value = ""> + + + + + contextName = "__38-[TGAttachObject prepareImage:orData:]_block_invoke:TGAttachObject.m"> + + + value = "photoSize"> + contextName = "__23-[DownloadItem notify:]_block_invoke_2:DownloadItem.m"> + contextName = "-[ComposeActionCreateChannelBehavior showAddingCompose]:ComposeActionCreateChannelBehavior.m"> + + + + + contextName = "-[MessageTableCellPhotoView setItem:]:MessageTableCellPhotoView.m"> + value = "item.imageSize"> + + + contextName = "-[Storage lastMessageAroundMinId:important:isTop:]:Storage.m"> + + + + + contextName = "-[MessageTableItem initWithObject:]:MessageTableItem.m"> + value = "object.from_id"> + value = "self.user "> - - + contextName = "-[Storage parseDialogs:dialogs:messages:]:Storage.m"> + contextName = "+[EncryptedParams findAndCreate:]:EncryptedParams.m"> + contextName = "-[FullChatManager loadFullChatByChatId:force:isChannel:callback:]:FullChatManager.m"> + value = "isChannel"> + contextName = "-[TGSharedLinksTableView didChangeUpdateWebpage:]:TGSharedLinksTableView.m"> + contextName = "__57-[TGModernChannelInfoViewController loadNextParticipants]_block_invoke173:TGModernChannelInfoViewController.m"> + contextName = "__55-[FullChatManager loadFullChatByChatId:force:callback:]_block_invoke:FullChatManager.m"> + contextName = "__51-[TGStickersSettingsViewController viewWillAppear:]_block_invoke:TGStickersSettingsViewController.m"> + contextName = "-[TGUpdateMessageService processMessage:]:TGUpdateMessageService.m"> + contextName = "-[TGModernChannelInfoViewController configure]:TGModernChannelInfoViewController.m"> + value = "_chat.isAdmin"> + value = "_chat.isManager"> + value = "_chat.isCreator"> + contextName = "__44-[TGChannelsPolling setCurrentConversation:]_block_invoke:TGChannelsPolling.m"> + contextName = "__44-[TMCollectionPageController convertedRows:]_block_invoke:TMCollectionPageController.m"> + value = "items"> + contextName = "__63-[CommonMediaHistoryFilter remoteRequest:max_id:hole:callback:]_block_invoke:CommonMediaHistoryFilter.m"> + + + value = "self.filter"> + + + + + + + contextName = "__23-[DownloadItem notify:]_block_invoke_3:DownloadItem.m"> + contextName = "__57-[Storage deleteChannelMessagesMessages:completeHandler:]_block_invoke:Storage.m"> + contextName = "-[DialogsManager checkBotKeyboard:forMessage:notify:]:DialogsManager.m"> + + + + + value = "item.message.n_id"> + + + + + + + contextName = "-[TGStickerPackRowView redrawRow]:TGStickersSettingsViewController.m"> + contextName = "-[TGWebpageStandartObject initWithWebPage:]:TGWebpageStandartObject.m"> + contextName = "__34-[ChatsManager add:withCustomKey:]_block_invoke:ChatsManager.m"> + contextName = "+[MessageTableItem socialClass:]:MessageTableItem.m"> + value = "range"> + + + contextName = "__30-[TGAllStickersTableView load]_block_invoke:TGAllStickersTableView.m"> + value = "sort"> + contextName = "-[NSAttributedString(Category) coreTextSizeForTextFieldForWidth:withPaths:]:NSAttributedStringCategory.m"> + value = "origins"> - - - - + contextName = "__46-[TGModernChannelInfoViewController configure]_block_invoke_2143:TGModernChannelInfoViewController.m"> + value = "action.result.singleObject"> + contextName = "__52-[ComposeChannelParticipantsViewController loadNext]_block_invoke_2103:ComposeChannelParticipantsViewController.m"> + + + + + contextName = "-[TGProccessUpdates applyUpdate:]:TGProccessUpdates.m"> + contextName = "-[TGModernEncryptedUpdates proccessMessage:withLayer:params:conversation:]:TGModernEncryptedUpdates.m"> + contextName = "__56-[TGModernConversationHistoryController performLoadNext]_block_invoke_2:TGModernConversationHistoryController.m"> + contextName = "__56-[TGModernConversationHistoryController performLoadNext]_block_invoke55:TGModernConversationHistoryController.m"> + contextName = "__56-[TGModernConversationHistoryController performLoadNext]_block_invoke63:TGModernConversationHistoryController.m"> + contextName = "-[SenderItem removeAllListeners]:SenderItem.m"> + value = "self.listeners"> + contextName = "-[ChatHistoryController filterAndAdd:acceptToFilters:]:ChatHistoryController.m"> - - + value = "items"> - - - - + contextName = "-[Storage searchDialogsByPeers:needMessages:searchString:completeHandler:]:Storage.m"> - - - - - - + value = "peers"> - - - - + contextName = "-[TGStickerPackEmojiController drawWithStickers:]:TGStickerPackEmojiController.m"> + contextName = "-[MessageSenderItem parseEntities:nextLocation:entities:]:MessageSenderItem.m"> + + + + + contextName = "__46-[TMCollectionPageController setConversation:]_block_invoke:TMCollectionPageController.m"> + contextName = "-[ChatHistoryController pollingDidSaidTooLongWithTopMessage:minMsg:]:ChatHistoryController.m"> + value = "topMsg"> + contextName = "-[TGUpdateMessageService processMessages:]:TGUpdateMessageService.m"> + contextName = "__40-[TMCollectionPageController loadRemote]_block_invoke_2:TMCollectionPageController.m"> + contextName = "-[MessagesViewController resendItem:]:MessagesViewController.m"> + value = "self.messages"> + contextName = "__22-[Storage open:queue:]_block_invoke_2:Storage.m"> - - - - + value = "encryptionKey"> + contextName = "-[TL_initConnection getData:]:TLAPIAdd.m"> + contextName = "__52-[ChannelFilter remoteRequest:max_id:hole:callback:]_block_invoke:ChannelFilter.m"> + value = "response.messages"> + contextName = "__32-[Storage insertSecretInAction:]_block_invoke:Storage.m"> + + + value = "listeners"> + contextName = "-[TMTableView initialize]:TMTableView.mm"> - - + value = "self.frame"> - - + contextName = "-[TMTableView numberOfRowsInTableView:]:TMTableView.mm"> + contextName = "-[HistoryFilter remoteRequest:max_id:hole:callback:]:HistoryFilter.m"> - - + value = "self.selectAllItems"> + contextName = "__58-[TGModernEncryptedUpdates dequeueInActions:conversation:]_block_invoke:TGModernEncryptedUpdates.m"> - - - - + contextName = "-[Storage loadChannelMessages:localMaxId:limit:next:maxDate:filterMask:]:Storage.m"> + contextName = "__41-[TGPVMediaBehavior loadRemote:callback:]_block_invoke:TGPVMediaBehavior.m"> - - - - + contextName = "__27-[TGPhotoViewer show:user:]_block_invoke:TGPhotoViewer.m"> + contextName = "__48-[MessageTableCellContainerView onStateChanged:]_block_invoke:MessageTableCellContainerView.m"> + + + value = "self.navigationViewController"> + contextName = "-[MessageTypingView redrawByArray:]:MessageTypingView.m"> + contextName = "__41-[GeneralSettingsViewController loadView]_block_invoke153:GeneralSettingsViewController.m"> + contextName = "__81-[Storage loadImportantChannelMessages:localMaxId:limit:next:maxDate:filterMask:]_block_invoke:Storage.m"> + value = "msg.flags"> - - - - + value = "messages"> + contextName = "-[ChatHistoryController setFilter:]:ChatHistoryController.m"> - - + value = "item.message.n_id"> + contextName = "__44-[StickersPanelView showAndSearch:animated:]_block_invoke:StickersPanelView.m"> + + + value = "f"> + contextName = "__35-[TGUpdateChannels proccessUpdate:]_block_invoke283:TGUpdateChannels.m"> + value = "chat"> + contextName = "__39-[AppDelegate initializeKeyDownHandler]_block_invoke_2399:AppDelegate.m"> + value = "incomingEvent.responder"> + contextName = "__33-[VideoSenderItem performRequest]_block_invoke:VideoSenderItem.m"> + value = "size"> + contextName = "-[PreviewObject initWithMsdId:media:peer_id:]:PreviewObject.m"> + contextName = "__50-[TGAllStickersTableView loadSetsIfNeeded:n_hash:]_block_invoke277:TGAllStickersTableView.m"> - - - - - - + value = "removed"> + contextName = "__open_card_block_invoke_2:FileUtils.m"> + contextName = "__42-[NewContactsManager importCloudContacts:]_block_invoke123:NewContactsManager.m"> + + - - - - + value = "exception"> + contextName = "__33-[PhoneChangeController loadView]_block_invoke_2:PhoneChangeController.m"> + contextName = "-[QueueManager add:]:QueueManager.m"> + value = "self.queue.operationCount"> + contextName = "-[TGCTextView open_link:itsReal:]:TGCTextView.m"> + value = "item.message"> + contextName = "-[TGDownloadOperation load:]:TGDownloadOperation.m"> + contextName = "-[MessageTableCell setItem:]:MessageTableCell.m"> + value = "item.messageSender"> - - - - + contextName = "prettysize:ImageUtils.m"> + value = "img.representations"> - - - - + value = "[imageRep pixelsWide]"> + contextName = "-[ImageAttachSenderItem didEndUploading]:ImageAttachSenderItem.m"> + contextName = "-[TL_conversation chat]:TL_conversation.m"> + + + value = "self.type"> + contextName = "-[DialogSwipeTableControll mouseDown:]:DialogSwipeTableControll.m"> + value = "self.tableView.selectedRow"> + contextName = "main:main.m"> + + + value = "self.mainWindow"> + + + + + value = "peer.peer_id"> + contextName = "-[TelegramSerialization serializeMessage:]:TelegramSerialization.m"> + contextName = "-[MessagesTopInfoView setConversation:]:MessagesTopInfoView.m"> + value = "user.n_id"> + contextName = "-[MessageReplyContainer update]:MessageReplyContainer.m"> + value = "_replyObject.replyHeaderHeight"> + contextName = "-[DialogTableView initWithFrame:]:DialogTableView.m"> + value = "frame"> - - + contextName = "__41-[NewContactsManager remoteCheckContacts]_block_invoke:NewContactsManager.m"> + contextName = "-[MessageTableItemPhoto initWithObject:]:MessageTableItemPhoto.m"> - - + value = "self.cachePhoto"> + value = "object"> - - + contextName = "-[TGPVContainer runAnimation:]:TGPVContainer.m"> + value = "self.layer"> + contextName = "-[DialogsViewController loadView]:DialogsViewController.mm"> + + + + + contextName = "__49-[TGPasswosdMainViewController rebuildController]_block_invoke_4235:TGPasswosdMainViewController.m"> + contextName = "-[TGAudioPlayerListView setSelectedId:]:TGAudioPlayerListView.m"> + value = "[self.tableView rectOfRow:selectedIdx]"> + contextName = "-[MessagesViewController scrollViewDocumentOffsetChangingNotificationHandler:]:MessagesViewController.m"> + value = "self.historyController.nextState"> + contextName = "__23-[FullChatManager add:]_block_invoke:FullChatManager.m"> + + + value = "self.isProccessing"> + + + contextName = "__57-[MessagesViewController loadhistory:toEnd:prev:isFirst:]_block_invoke:MessagesViewController.m"> + value = "_historyController.selectLimit"> + + + + - - - - + contextName = "__39-[AppDelegate initializeKeyDownHandler]_block_invoke298:AppDelegate.m"> + contextName = "__40-[ImageAttachSenderItem didEndUploading]_block_invoke156:ImageAttachSenderItem.m"> + contextName = "__42-[NewContactsManager importCloudContacts:]_block_invoke122:NewContactsManager.m"> + contextName = "-[MessageTableItemText initWithObject:]:MessageTableItemText.m"> + contextName = "-[ChannelImportantFilter storageRequest:state:]:ChannelImportantFilter.m"> - - + value = "self.controller.min_id"> @@ -869,475 +3004,408 @@ contextName = "__95-[TGPasswosdMainViewController setPassword:current_pswd_hash:email:hint:flags:successCallback:]_block_invoke314:TGPasswosdMainViewController.m"> - - - - - - - - - - - - - - - - - - + contextName = "-[TGPhotoViewer performNextItem]:TGPhotoViewer.m"> + contextName = "-[TGReplyObject initWithReplyMessage:]:TGReplyObject.m"> + value = "_replyThumb.imageSize"> + contextName = "__32-[NewContactsManager fullReload]_block_invoke_2:NewContactsManager.m"> + contextName = "__39-[ChannelFilter fillGroupHoles:bottom:]_block_invoke168:ChannelFilter.m"> + contextName = "__31-[SecretChatAccepter proccess:]_block_invoke_2:SecretChatAccepter.m"> + contextName = "-[MessageTableItemText makeSizeByWidth:]:MessageTableItemText.m"> + value = "[NSThread currentThread]"> + contextName = "__42-[Storage insertMessages:completeHandler:]_block_invoke:Storage.m"> + value = "message.n_id"> - - - - + contextName = "__39-[DialogsManager deleteChannelMessags:]_block_invoke_2:DialogsManager.m"> + contextName = "__57-[TGModernChannelInfoViewController loadNextParticipants]_block_invoke:TGModernChannelInfoViewController.m"> + value = "_chat.chatFull.participants.participants"> + contextName = "-[TGImageObject _didDownloadImage:]:TGImageObject.m"> + + + + + + + value = "theEvent.keyCode"> + value = "self.listSelectedElementHash"> - - + contextName = "-[TL_conversation updateNotifySettings:]:TL_conversation.m"> + contextName = "__56-[TGModernConversationHistoryController performLoadNext]_block_invoke_2207:TGModernConversationHistoryController.m"> + contextName = "-[TGUpdateChannels proccessStatefullUpdate:]:TGUpdateChannels.m"> + value = "hole"> - - - - + contextName = "-[ChatHistoryController prevState]:ChatHistoryController.m"> + value = "filter.prevState"> + contextName = "__39-[ChatAvatarImageView updateChatPhoto:]_block_invoke_2211:ChatAvatarImageView.m"> + contextName = "__add_sticker_pack_by_name_block_invoke:FileUtils.m"> + contextName = "__57-[MessagesManager markAllInConversation:max_id:callback:]_block_invoke:MessagesManager.m"> + contextName = "__45-[Storage fillLastMessagesWithConversations:]_block_invoke_2:Storage.m"> + value = "obj.top_message"> + + + + + contextName = "-[TL_localMessage save:]:TL_localMessage.m"> + value = "self.n_id"> + contextName = "+[TMInAppLinks parseUrlAndDo:]:TMInAppLinks.m"> + contextName = "-[TGHeadChatPanel initializeHeadChatPanel]:TGHeadChatPanel.m"> + value = "self.contentView"> + contextName = "-[SelectUsersTableView ready]:SelectUsersTableView.m"> + value = "items"> - - - - + contextName = "__42-[NewContactsManager importCloudContacts:]_block_invoke_3:NewContactsManager.m"> + contextName = "__29-[RPCRequest completeHandler]_block_invoke:RPCRequest.m"> - - + value = "self"> - - + contextName = "-[MessageSenderItem initWithMessage:forConversation:]:MessageSenderItem.m"> + contextName = "__36-[TGPVMediaBehavior convertObjects:]_block_invoke:TGPVMediaBehavior.m"> + contextName = "-[ReadHistroryTask loop:]:ReadHistroryTask.m"> + contextName = "__38-[TGEnterPasswordPanel initWithFrame:]_block_invoke_8:TGEnterPasswordPanel.m"> + contextName = "+[SearchItem hash:]:SearchItem.m"> + contextName = "-[TGCTextView calcSelectedRange]:TGCTextView.m"> + + + + + contextName = "+[TMAvatarImageView text:]:TMAvatarImageView.m"> + contextName = "__30-[Storage insertMessagesHole:]_block_invoke:Storage.m"> + contextName = "__56-[TGModernConversationHistoryController performLoadNext]_block_invoke_260:TGModernConversationHistoryController.m"> - - - - + value = "response"> + contextName = "-[UserInfoViewController setUser:conversation:]:UserInfoViewController.m"> + value = "conversation.type"> + value = "conversation"> - - - - - - + contextName = "-[SelectUserRowView redrawRow]:SelectUserRowView.m"> + value = "[self rowItem].table"> - - - - - - + value = "[[self rowItem].table selectLimit]"> + contextName = "__42-[MessageTableCellStickerView contextMenu]_block_invoke73:MessageTableCellStickerView.m"> + contextName = "__37-[TGAllStickersTableView reloadData:]_block_invoke:TGAllStickersTableView.m"> + value = "stickers"> + value = "array"> - - + contextName = "__34-[TGDocumentsController loadNext:]_block_invoke:TGDocumentsMediaTableView.m"> + value = "result"> + contextName = "__31-[TGPhotoViewer indexOfObject:]_block_invoke:TGPhotoViewer.m"> + value = "self.list"> - - - - - - - - + contextName = "-[MessageSenderItem initWithMessage:forConversation:noWebpage:additionFlags:]:MessageSenderItem.m"> + value = "self.message.message"> - - + contextName = "__51-[NewContactsManager importCloudContacts:callback:]_block_invoke_2115:NewContactsManager.m"> + value = "abset.count"> + contextName = "-[MessageTableCellServiceMessage setItem:]:MessageTableCellServiceMessage.m"> + + + + + contextName = "__52-[ChatHistoryController notificationReceiveMessage:]_block_invoke:ChatHistoryController.m"> + + + + + contextName = "__47-[TGPVMediaBehavior loadRemote:limit:callback:]_block_invoke:TGPVMediaBehavior.m"> + contextName = "-[ImageAttachSenderItem performRequest]:ImageAttachSenderItem.m"> + contextName = "-[TGModernConversationHistoryController performLoadNext]:TGModernConversationHistoryController.m"> + value = "conversation.lastMessage.date"> + contextName = "__46-[TGPhotoViewer show:conversation:isReversed:]_block_invoke_2:TGPhotoViewer.m"> + contextName = "-[TGModernChatInfoViewController checkSupergroup]:TGModernChatInfoViewController.m"> + value = "self.participantsRange"> + contextName = "-[AccountSettingsViewController defaultContainerView]:AccountSettingsViewController.m"> + value = "currentY"> + contextName = "-[ChatsManager add:withCustomKey:]:ChatsManager.m"> + + - - + value = "isCleared"> + contextName = "__42-[TGDocumentsMediaTableView remoteSearch:]_block_invoke:TGDocumentsMediaTableView.m"> + + + + + + + value = "path"> + contextName = "-[TGReplyObject updateObject]:TGReplyObject.m"> + value = "_replyThumb.imageSize"> + value = "replyText"> + value = "photoSize.h"> - - - - + contextName = "-[TGMessagesHintView performSelected]:TGMessagesHintView.m"> + value = "_choiceHandler"> + contextName = "-[ZipArchive addFileToZip:newname:]:ZipArchive.mm"> + value = "file"> - - + contextName = "__37-[MessagesViewController sendMessage]_block_invoke:MessagesViewController.m"> + contextName = "__43-[TMCircularProgress setProgress:animated:]_block_invoke:TMCircularProgress.m"> + value = "self.isHidden"> + contextName = "-[MessagesViewController tableView:viewForTableColumn:row:]:MessagesViewController.m"> + value = "item"> + contextName = "__43-[SearchViewController remoteGlobalSearch:]_block_invoke:SearchViewController.m"> + + + value = "_filters"> - - - - - - + contextName = "-[TMMenuItemView click]:TMMenuController.m"> + value = "self.item.target"> + + - - @@ -1356,711 +3424,796 @@ + contextName = "__17-[MTNetwork init]_block_invoke:MTNetwork.m"> + contextName = "__41-[Storage lastGroupHole:cornerId:bottom:]_block_invoke:Storage.m"> + value = "cornerId"> - - + contextName = "__42-[NewContactsManager remoteCheckContacts:]_block_invoke:NewContactsManager.m"> - - + value = "fv"> + contextName = "-[DialogsManager createDialogForMessage:]:DialogsManager.m"> + + + + + + - - + value = "strongSelf.fullChat.chat_photo"> + contextName = "-[TGPasswosdMainViewController viewWillAppear:]:TGPasswosdMainViewController.m"> + contextName = "-[TGWebpageObject initWithWebPage:]:TGWebpageObject.m"> + contextName = "-[PhotoTableItemView redrawRow]:PhotoTableItemView.m"> + contextName = "-[MessageTableCellGifView playAnimation]:MessageTableCellGifView.m"> + + + + + contextName = "-[ChatAvatarImageView progressContainer]:ChatAvatarImageView.m"> + + + + + contextName = "-[TGPVContainer setCurrentViewerItem:]:TGPVContainer.m"> + value = "msg"> + contextName = "__47-[ChatHistoryController pollingDidSaidTooLong:]_block_invoke:ChatHistoryController.m"> + value = "self.filter.botHole.max_id"> + contextName = "-[TGRecentSearchTableView loadRecentSearchItems]:TGRecentSearchTableView.m"> + + + value = "obj"> + contextName = "-[MessagesViewController loadView]:MessagesViewController.m"> + value = "self.table"> + value = "self.view.bounds"> + + + contextName = "__59-[TGStickersSettingsViewController tableViewDidChangeOrder]_block_invoke_2:TGStickersSettingsViewController.m"> + contextName = "-[DeleteRandomMessagesSenderItem performRequest]:DeleteRandomMessagesSenderItem.m"> + contextName = "-[TGSendingAction perform]:TGSendTypingManager.m"> + contextName = "-[TGPVContainer initWithFrame:]:TGPVContainer.m"> + + + value = "image.size"> + contextName = "__45-[TGMediaCounterLoader loadWithConversation:]_block_invoke_2:TGSProfileMediaRowView.m"> + + + value = "message"> + value = "self.user"> + + + + + value = "_controller.server_min_id"> + contextName = "-[MessagesTableView mouseDragged:]:MessagesTableView.m"> + + + + + contextName = "-[RightViewController didChangedLayout]:RightViewController.m"> + value = "self.navigationViewController.viewControllerStack"> + contextName = "__41-[UsersManager add:withCustomKey:update:]_block_invoke:UsersManager.m"> + + + + + + + + + + + + + contextName = "-[ImageSenderItem initWithImage:forConversation:]:ImageSenderItem.m"> + contextName = "-[MessageTableCellTextView pop_animationDidReachToValue:]:MessageTableCellTextView.m"> + contextName = "__32+[TGSecretAction _resendActions]_block_invoke_2:TGSecretAction.m"> + contextName = "-[TGPasslockModalView checkPassword]:TGPasslockModalView.m"> - - + value = "self.secureField.stringValue"> + contextName = "__33+[DownloadQueue addAndStartItem:]_block_invoke:DownloadQueue.mm"> + value = "operation.item.n_id"> + contextName = "-[TGAudioPlayerWindow setMouseInWindow:]:TGAudioPlayerWindow.m"> - - + value = "_currentItem"> + contextName = "-[TL_userFull unserialize:]:MTProto.m"> + contextName = "-[ChatHistoryController windowBecomeNotification:]:ChatHistoryController.m"> + value = "[[NSApp mainWindow]"> + contextName = "__31-[TGPhotoViewer insertObjects:]_block_invoke:TGPhotoViewer.m"> + value = "previewObject.msg_id"> + contextName = "__24-[TGCTextView drawRect:]_block_invoke:TGCTextView.m"> + value = "mark"> - - + contextName = "-[MessageTableCellAudioView setCellState:]:MessageTableCellAudioView.m"> + value = "self.item.state"> - - - - - - - - - - + contextName = "-[TMBackButton updateBackButton]:TMBackButton.m"> + + + + + + + contextName = "__40+[TGSecretAction dequeAllStorageActions]_block_invoke_2:TGSecretAction.m"> + contextName = "-[MessagesViewController showMessage:fromMsg:animated:selectText:switchDiscussion:flags:]:MessagesViewController.m"> + contextName = "-[TGModernEncryptedUpdates proccess1Layer:params:conversation:encryptedMessage:]:TGModernEncryptedUpdates.m"> + contextName = "__45-[TGPVUserBehavior load:next:limit:callback:]_block_invoke:TGPVUserBehavior.m"> + contextName = "-[TGConversationsViewController tableViewSelectionDidChange:]:TGConversationsViewController.m"> + value = "self.selectedItem"> - - + contextName = "-[TGWebpageGifObject initWithWebPage:]:TGWebpageGifObject.m"> + value = "_imageObject.imageSize "> - - + contextName = "-[MessagesViewController updateScrollBtn]:MessagesViewController.m"> + + + + + contextName = "__38-[YoutubeServiceDescription loadInfo:]_block_invoke:YoutubeServiceDescription.m"> + + + + + contextName = "__26-[Storage insertMessages:]_block_invoke:Storage.m"> + value = "messages"> + contextName = "-[DownloadItem initWithObject:]:DownloadItem.m"> + + + + + contextName = "-[TGModalView show:animated:]:TGModalView.m"> + value = "self.containerSize"> + contextName = "-[ComposeActionGroupBehavior centerTitle]:ComposeActionGroupBehavior.m"> + + + + + contextName = "__54-[ComposeActionAddGroupMembersBehavior composeDidDone]_block_invoke:ComposeActionAddGroupMembersBehavior.m"> + contextName = "-[DownloadItem findAndFillAfterInit]:DownloadItem.m"> + + + + + contextName = "__36-[DownloadOperation start:selector:]_block_invoke:DownloadOperation.m"> + contextName = "-[MessageSenderItem parseEntities:entities:]:MessageSenderItem.m"> + contextName = "__35-[TGPVImageObject initDownloadItem]_block_invoke:TGPVImageObject.m"> + contextName = "__48-[TGModernTypingManager userTypingNotification:]_block_invoke:TGModernTypingManager.m"> + contextName = "__50-[MessagesManager notifyMessage:update_real_date:]_block_invoke:MessagesManager.m"> + + + + + contextName = "+[TGHashtagPopup show:view:ofRect:callback:]:TGHashtagPopup.m"> + contextName = "__30-[MTNetwork constructRequest:]_block_invoke_4:MTNetwork.m"> + + + + + contextName = "__29-[TGModalView show:animated:]_block_invoke91:TGModalView.m"> + + + + + contextName = "-[TL_localMessage peer]:TL_localMessage.m"> + contextName = "__56-[TGStickersSettingsViewController reloadDataWithPacks:]_block_invoke:TGStickersSettingsViewController.m"> + contextName = "-[MainViewController loadView]:MainViewController.m"> + value = "self.view.window"> + contextName = "-[MessageTableItemAudioDocument regenerate]:MessageTableItemAudioDocument.m"> + contextName = "-[TGCTextView drawRect:]:TGCTextView.m"> + value = "self.marks"> + + + contextName = "-[TMCollectionPageController convertedRows:]:TMCollectionPageController.m"> + contextName = "-[ComposeActionCreateChannelBehavior composeDidDone]:ComposeActionCreateChannelBehavior.m"> + contextName = "-[TGProccessUpdates uptodateWithConnectionState:]:TGProccessUpdates.m"> + + + value = "response"> - - + contextName = "open_user_by_name:FileUtils.m"> + contextName = "-[TMTableView tableViewSelectionDidChange:]:TMTableView.mm"> + value = "self.selectedRow"> - - - - + contextName = "-[MessageSenderItem performRequest]:MessageSenderItem.m"> + contextName = "_POPAnimationState::setDelegate(objc_object*):POPAnimationInternal.h"> + + + + + contextName = "-[MTNetwork sendRequest:]:MTNetwork.m"> + contextName = "-[AppDelegate application:continueUserActivity:restorationHandler:]:AppDelegate.m"> + value = "text"> + + + contextName = "-[DialogsManager updateTop:needUpdate:update_real_date:]:DialogsManager.m"> + contextName = "__37-[SearchViewController remoteSearch:]_block_invoke:SearchViewController.m"> + contextName = "__44-[TGSModalSenderView sendAsMessage:rowItem:]_block_invoke257:TGSModalSenderView.m"> - - - - + contextName = "-[Storage selectChannelsWithMaxDate:]:Storage.m"> + contextName = "-[TMGrowingTextView validateUserInterfaceItem:]:TMGrowingTextView.m"> + value = "[anItem action];"> + contextName = "-[MessageTableItemVideo rebuildImageObject]:MessageTableItemVideo.m"> + contextName = "__34-[TGWebpageYTContainer mouseDown:]_block_invoke:TGWebpageYTContainer.m"> + contextName = "__51-[ChatHistoryController notificationDeleteMessage:]_block_invoke_2:ChatHistoryController.m"> + contextName = "-[TGImageView setObject:]:TGImageView.m"> + value = "self.image"> + contextName = "__31-[TGAllStickersTableView load:]_block_invoke226:TGAllStickersTableView.m"> + contextName = "__41-[UsersManager add:withCustomKey:update:]_block_invoke_3:UsersManager.m"> - - - - + contextName = "__31-[TGAllStickersTableView load:]_block_invoke212:TGAllStickersTableView.m"> + contextName = "__87-[Storage loadImportantChannelMessages:min_id:max_id:minDate:maxDate:limit:filterMask:]_block_invoke:Storage.m"> + value = "min"> - - - - + value = "max"> + + + contextName = "-[ComposePickerViewController viewWillAppear:]:ComposePickerViewController.m"> + value = "self.action.filter"> + + + contextName = "__46-[Storage lastMessageForPeer:completeHandler:]_block_invoke:Storage.m"> + contextName = "-[TGStickersSettingsViewController reloadDataWithPacks:]:TGStickersSettingsViewController.m"> + value = "packs"> + contextName = "__24-[TGCTextView drawRect:]_block_invoke_2:TGCTextView.m"> + value = "startSelectPosition"> + value = "runBounds.size.height"> - - - - + contextName = "-[TGProccessUpdates init]:TGProccessUpdates.m"> + contextName = "-[MessageTableCellContainerView updateDownloadState]:MessageTableCellContainerView.m"> + value = "self.item.downloadListener"> + value = "self.item.downloadItem"> + contextName = "-[MessageTableCellVideoView open]:MessageTableCellVideoView.m"> + value = "self.item.message.media.video"> + contextName = "__47-[MessagesViewController sendMessage:callback:]_block_invoke_2:MessagesViewController.m"> + + + value = "self.isHidden"> + contextName = "-[TGStickersSettingsViewController viewWillAppear:]:TGStickersSettingsViewController.m"> + contextName = "-[TelegramSerialization parseMessage:responseParsingBlock:]:TelegramSerialization.m"> + contextName = "-[MessageTableItemText updateLinkAttributesByMessageEntities]:MessageTableItemText.m"> + value = "self.message.entities"> + contextName = "__37-[TGAllStickersTableView reloadData:]_block_invoke_2:TGAllStickersTableView.m"> + + + value = "encryptionKey"> + contextName = "-[ForwardSenterItem initWithMessages:forConversation:additionFlags:]:ForwardSenterItem.m"> + + + value = "max_id"> + + + contextName = "__40-[TMCollectionPageController reloadData]_block_invoke:TMCollectionPageController.m"> + contextName = "__37-[SearchViewController remoteSearch:]_block_invoke546:SearchViewController.m"> + + + value = "chat.n_id"> + contextName = "-[RBLPopover showRelativeToRect:ofView:preferredEdge:]:RBLPopover.m"> - - - - + value = "self.contentViewController.view"> + contextName = "__35-[ForwardSenterItem performRequest]_block_invoke106:ForwardSenterItem.m"> + contextName = "+[RPCRequest sendRequest:successHandler:errorHandler:]:RPCRequest.m"> + + + value = "_descField.isHidden"> + contextName = "-[ChatAvatarImageView mouseDown:]:ChatAvatarImageView.m"> + value = "self.chat.chatFull"> + + + + + + + contextName = "__36-[StartBotSenderItem performRequest]_block_invoke:StartBotSenderItem.m"> + contextName = "__33-[DialogsManager updateReadList:]_block_invoke_2:DialogsManager.m"> + value = "message.dialog.last_marked_message"> - - - - + value = "message.n_id"> + contextName = "-[ChannelFilter fillGroupHoles:bottom:]:ChannelFilter.m"> + contextName = "__38-[ChatAdminsViewController reloadData]_block_invoke_2:ChatAdminsViewController.m"> + contextName = "__53-[DialogsHistoryController loadlocal:limit:callback:]_block_invoke_2:DialogsHistoryController.m"> + contextName = "-[TelegramFirstController validateMenuItem:]:TelegramFirstController.m"> + value = "menuItem.action"> - - - - + contextName = "__31-[TGProccessUpdates addUpdate:]_block_invoke:TGProccessUpdates.m"> + value = "shortMessage.seq"> + contextName = "-[TGProccessUpdates updateShort:]:TGProccessUpdates.m"> + contextName = "-[UserInfoShortButtonView setRightContainer:]:UserInfoShortButtonView.m"> + value = "_currentRightController.frame"> + contextName = "-[LeftViewController updateSize]:LeftViewController.m"> + value = "self.tabViewController.currentController"> + contextName = "-[AccountSettingsViewController updateUserName]:AccountSettingsViewController.m"> + value = "self.userNameTextField.attributedStringValue"> + value = "[UsersManager currentUser].userNameTitle"> + + + + + value = "self.prevState"> + value = "self.nextState"> + + + + + value = "self.conversation.chat.type "> + contextName = "__59-[SharedLinksHistoryFilter remoteRequest:peer_id:callback:]_block_invoke:SharedLinksHistoryFilter.m"> + contextName = "__57-[MessagesViewController loadhistory:toEnd:prev:isFirst:]_block_invoke_2:MessagesViewController.m"> + value = "result"> + + + + + + @@ -2073,824 +4226,888 @@ + contextName = "-[ConnectionStatusViewControllerView show:]:ConnectionStatusViewControllerView.m"> + + + contextName = "-[TGStickerPackModalView setStickerPack:]:TGStickerPackModalView.m"> + + + + - - - - - - + value = ""> + contextName = "-[MTTcpTransport initWithDelegate:context:datacenterId:address:]:MTTcpTransport.m"> + + + + + + + + + + + + + + + + - - + value = "self.chat"> + contextName = "__49-[TGProccessUpdates uptodateWithConnectionState:]_block_invoke:TGProccessUpdates.m"> + value = "request"> + + + contextName = "-[DeleteRandomMessagesSenderItem initWithConversation:random_ids:]:DeleteRandomMessagesSenderItem.m"> + + + + + + + value = "self.disallowUsersAction"> - - + contextName = "-[MessagesViewController setCurrentConversation:withJump:historyFilter:force:]:MessagesViewController.m"> + value = "dialog.type"> + value = "dialog.chat"> - - + contextName = "__29-[TMAvatarImageView rebuild:]_block_invoke:TMAvatarImageView.m"> + + + + + contextName = "__50-[TGAllStickersTableView loadSetsIfNeeded:n_hash:]_block_invoke266:TGAllStickersTableView.m"> + contextName = "-[ChatHistoryController removeAllItems]:ChatHistoryController.m"> + + + + + contextName = "+[EmojiViewController reloadStickers]:EmojiViewController.m"> + value = "[self instance].stickersTableView.stickers"> + contextName = "-[MessageTableCellContainerView checkActionState:]:MessageTableCellContainerView.m"> + + + + + contextName = "__54-[DialogsHistoryController loadremote:limit:callback:]_block_invoke:DialogsHistoryController.m"> + value = "offset"> + contextName = "__47-[NSString(NSString_FindURLs) locationsOfLinks]_block_invoke:NSString+FindURLs.m"> + + + + + value = "self.params"> + contextName = "-[TGModernEncryptedUpdates proccessServiceMessage:withLayer:]:TGModernEncryptedUpdates.m"> + contextName = "-[Storage createAndCheckDatabase:]:Storage.m"> + value = "encryptedDatabasePath"> + value = "encryptionKey"> + contextName = "-[MainWindow windowWillResize:toSize:]:MainWindow.m"> + value = "self.minSize"> + contextName = "__47-[NewLoginViewController getSMSCodeSendRequest]_block_invoke:NewLoginViewController.m"> + contextName = "__37-[TGUpdateChannels addWaitingUpdate:]_block_invoke79:TGUpdateChannels.m"> + contextName = "-[NSString(NSString_FindURLs) locationsOfLinks:]:NSString+FindURLs.m"> + + + + + contextName = "-[TGProccessUpdates processUpdates:stateSeq:]:TGProccessUpdates.m"> + contextName = "-[ComposeViewController viewWillAppear:]:ComposeViewController.m"> + contextName = "__63-[TGUpdateChannels failUpdateWithChannelId:limit:withCallback:]_block_invoke_2:TGUpdateChannels.m"> + + + value = "items"> + + + + + value = "localStickers"> + contextName = "__67-[TGProccessUpdates addStatefullUpdate:seq:pts:date:qts:pts_count:]_block_invoke:TGProccessUpdates.m"> + contextName = "__47-[SelectUsersTableView remoteSearchByUserName:]_block_invoke:SelectUsersTableView.m"> - - + value = "self.items"> - - + contextName = "-[ChatHistoryController pollingDidSaidTooLong:]:ChatHistoryController.m"> + value = "self.min_id"> + value = "self.max_id"> + + + contextName = "__join_group_by_hash_block_invoke_3:FileUtils.m"> + contextName = "-[ComposeViewController updateActionNavigation]:ComposeViewController.m"> + value = "self.action.behavior.doneTitle"> + + + + - - + contextName = "__28-[TGDownloadOperation load:]_block_invoke169:TGDownloadOperation.m"> + value = "error"> + contextName = "+[MessagesUtils serviceMessage:forAction:]:MessagesUtils.m"> + value = "message.isChannelMessage"> - - + contextName = "-[ChannelImportantFilter remoteRequest:max_id:hole:callback:]:ChannelImportantFilter.m"> + contextName = "-[TGConversationTableItem needUpdateMessage:]:TGConversationTableItem.m"> + value = "self.conversation"> + contextName = "__52-[ChatHistoryController notificationReceiveMessage:]_block_invoke_3:ChatHistoryController.m"> + contextName = "__69-[ChannelHistoryController request:anotherSource:sync:selectHandler:]_block_invoke_2:ChannelHistoryController.m"> - - + value = "chat.dialog"> - - - - - - - - - - - - + contextName = "-[ComposeBroadcastTableItemView redrawRow]:ComposeBroadcastListViewController.m"> + contextName = "__66-[ChatHistoryController request:anotherSource:sync:selectHandler:]_block_invoke289:ChatHistoryController.m"> + contextName = "__83-[MessagesViewController showMessage:fromMsg:animated:selectText:switchDiscussion:]_block_invoke:MessagesViewController.m"> + value = "msg.isImportantMessage"> - - - - + contextName = "__31-[ChannelInfoHeaderView reload]_block_invoke_2:ChannelInfoHeaderView.m"> + contextName = "+[SenderItem sendingDequeue]:SenderItem.m"> + contextName = "-[TL_localMessage serialize:]:TL_localMessage.m"> + contextName = "__30-[TMAudioRecorder stopRecord:]_block_invoke:TMAudioRecorder.m"> + + + + + contextName = "__45-[ComposeActionGroupBehavior createGroupChat]_block_invoke:ComposeActionGroupBehavior.m"> + contextName = "__79-[TGPasswosdMainViewController setPassword:current_pswd_hash:email:hint:flags:]_block_invoke237:TGPasswosdMainViewController.m"> + contextName = "-[TGPVImageObject _didDownloadImage:]:TGPVImageObject.m"> + value = "item.isRemoteLoaded"> + value = "self.imageSize"> + contextName = "-[TGRaceEmoji initWithFrame:emoji:]:TGRaceEmoji.m"> + contextName = "__51-[NewContactsManager importCloudContacts:callback:]_block_invoke:NewContactsManager.m"> + value = "importedSet.count"> + + + + + + + + + contextName = "-[TGProccessUpdates updateDifference:updateConnectionState:]:TGProccessUpdates.m"> + + + value = "self.frame"> + contextName = "-[ContactsViewController selectionDidChange:item:]:ContactsViewController.m"> + contextName = "-[TLUser(Category) rebuildType]:TLUserCategory.m"> - - - - + contextName = "__85-[MessagesViewController showMessage:fromMsgId:animated:selectText:switchDiscussion:]_block_invoke_2:MessagesViewController.m"> + contextName = "__40-[TGChannelsPolling launchTimer:repeat:]_block_invoke_2:TGChannelsPolling.m"> + contextName = "__58-[TGModernEncryptedUpdates dequeueInActions:conversation:]_block_invoke_2:TGModernEncryptedUpdates.m"> + + + value = "action"> - - + contextName = "-[ComposePickerViewController selectTableDidChangedItem:]:ComposePickerViewController.m"> + contextName = "-[MessageTableItem buildHeaderAndSaveToCache]:MessageTableItem.m"> + value = "self.message.from_id"> + contextName = "-[TGWebpageAttach didUpdateWebpage:]:TGWebpageAttach.m"> + + + value = "state->repeatForever"> + + + contextName = "-[MessageTableItemDocument initWithObject:]:MessageTableItemDocument.m"> + value = "self.thumbObject.imageSize"> + + - - + contextName = "-[MessageTableCellWebPageView setItem:]:MessageTableCellWebPageView.m"> + contextName = "-[TL_conversation blockedText]:TL_conversation.m"> + value = "self.chat"> + + + contextName = "__35-[TGUpdateChannels proccessUpdate:]_block_invoke_5:TGUpdateChannels.m"> + + + + + contextName = "__39-[ChatExportLinkViewController rebuild]_block_invoke:ChatExportLinkViewController.m"> + contextName = "-[TGUpdateChannels conversationWithChannelId:]:TGUpdateChannels.m"> + contextName = "__54-[DialogsHistoryController loadremote:limit:callback:]_block_invoke_2:DialogsHistoryController.m"> + value = "response"> + contextName = "-[TGUser(Category) rebuildNames]:TGUserCategory.m"> + value = "self.type"> + contextName = "__86-[Storage loadMessages:min_id:max_id:minDate:maxDate:limit:next:filterMask:isChannel:]_block_invoke_2:Storage.m"> + value = "next"> - - - - + contextName = "__52-[HistoryFilter remoteRequest:max_id:hole:callback:]_block_invoke:HistoryFilter.m"> - - + value = "request"> - - - - - - + contextName = "__66-[ChatHistoryController request:anotherSource:sync:selectHandler:]_block_invoke_2274:ChatHistoryController.m"> + + + + + contextName = "__55-[Storage deleteMessagesWithRandomIds:completeHandler:]_block_invoke:Storage.m"> + value = "messages"> + contextName = "__45-[SelfDestructionController didReadMessages:]_block_invoke:SelfDestructionController.m"> + contextName = "-[TGAllStickersTableView stickersHash:]:TGAllStickersTableView.m"> + contextName = "__28-[Storage importedContacts:]_block_invoke:Storage.m"> + contextName = "-[TGConversationTableCell setItem:]:TGConversationTableCell.m"> + value = "stateImage"> + contextName = "-[DownloadOperation load]:DownloadOperation.m"> + + + value = "self.message.randomId"> - - - - + contextName = "-[SearchViewController searchByString:]:SearchViewController.m"> - - + value = "searchUsers"> + value = "searchChats"> + value = "searchString"> - - - - + contextName = "__31-[TGAllStickersTableView load:]_block_invoke:TGAllStickersTableView.m"> - - - - + contextName = "-[ChatAvatarImageView updateWithConversation:]:ChatAvatarImageView.m"> + contextName = "-[TMCollectionPageController addNextItems:]:TMCollectionPageController.m"> + + + value = "item.text"> + contextName = "__22-[Storage open:queue:]_block_invoke:Storage.m"> + value = "encryptionKey"> + contextName = "__26-[Storage insertMessages:]_block_invoke692:Storage.m"> + value = "mask"> + contextName = "-[PrivacyArchiver rules]:PrivacyArchiver.m"> + + + value = "action.users"> + contextName = "__35-[TGPVUserBehavior convertObjects:]_block_invoke:TGPVUserBehavior.m"> + contextName = "-[TGConversationsViewController selectionDidChange:item:]:TGConversationsViewController.m"> + value = "appWindow()"> + + - - + contextName = "__35-[ForwardSenterItem performRequest]_block_invoke_2:ForwardSenterItem.m"> + value = "response.updates"> + contextName = "-[TL_localMessage unserialize:]:TL_localMessage.m"> + contextName = "+[MessagesManager defaultMessage:]:MessagesManager.m"> + contextName = "__39-[Storage allChannels:deliveryOnQueue:]_block_invoke:Storage.m"> + value = "topMessage"> + value = "serializedMessage"> - - - - + value = "messages"> + contextName = "-[GeneralSettingsViewController loadView]:GeneralSettingsViewController.m"> + + - - + value = "range"> + value = "self.message.message"> + value = "self.message"> + contextName = "-[TGModernChatInfoViewController changeEditable:]:TGModernChatInfoViewController.m"> + value = "_tableView.defaultAnimation"> + contextName = "-[TGConversationsViewController insertAll:]:TGConversationsViewController.m"> + value = "self.chat.isDeactivated"> + + + + + value = "self.action"> + contextName = "__60-[ComposeChannelParticipantsViewController kickParticipant:]_block_invoke:ComposeChannelParticipantsViewController.m"> + contextName = "__35-[TGPVMediaBehavior load:callback:]_block_invoke_2:TGPVMediaBehavior.m"> + value = "self"> + contextName = "__48-[NotificationSettingsViewController insertAll:]_block_invoke:NotificationSettingsViewController.m"> + contextName = "-[MessageTableCellGifView setItem:]:MessageTableCellGifView.m"> + contextName = "-[ConversationTableItem updateLastMessage]:ConversationTableItem.m"> - - + value = "self.lastMessage.message"> + contextName = "-[SearchViewController showSearchResults:]:SearchViewController.m"> + contextName = "-[TGModernEncryptedUpdates proccess17Layer:params:conversation:]:TGModernEncryptedUpdates.m"> + + + + + + + value = "anItem.action"> + contextName = "-[HistoryFilter proccessAndGetHoleWithHole:next:messages:]:HistoryFilter.m"> + contextName = "__41-[TMSharedMediaButton loadCount:peer_id:]_block_invoke:TMSharedMediaButton.m"> + value = "self.type"> + + + + + value = "font"> + value = "offset"> + contextName = "__40-[TGStickerPackModalView initWithFrame:]_block_invoke56:TGStickerPackModalView.m"> + contextName = "+[NSString(NSString_FindURLs) textCheckingResultsForText:highlightMentionsAndTags:highlightCommands:]:NSString+FindURLs.m"> + contextName = "-[MessageTableItemGif initWithObject:]:MessageTableItemGif.m"> + + + value = "self.type & SearchTypeGlobalUsers"> + + + + - - + contextName = "__52-[ChatHistoryController notificationReceiveMessage:]_block_invoke_2:ChatHistoryController.m"> + value = "res"> + + + contextName = "-[MessageTableCellVideoView setItem:]:MessageTableCellVideoView.m"> + value = "item.imageObject"> + contextName = "-[MessageReplyContainer mouseUp:]:MessageReplyContainer.m"> + value = "_replyObject.replyMessage"> - - + contextName = "-[TGSharedLinkRowView setItem:]:TGSharedLinkRowView.m"> - - + value = "self.isEditable"> - - - - - - - - + contextName = "+[SharedManager proccessGlobalResponse:]:SharedManager.m"> + contextName = "-[MessagesViewController showMessage:fromMsg:animated:selectText:switchDiscussion:]:MessagesViewController.m"> + value = "message.hole"> + contextName = "-[UserInfoContainerView buildTTLTitle]:UserInfoContainerView.m"> + + + value = "_context"> + contextName = "__67-[MessageTableCellTextView _didChangeBackgroundColorWithAnimation:]_block_invoke_3:MessageTableCellTextView.m"> + + + value = "self.controller"> + contextName = "-[TGUpdater initWithVersion:token:url:]:TGUpdater.m"> - - + value = "version"> + contextName = "-[TGConversationTableItem initWithConversation:]:TGConversationTableItem.m"> + contextName = "__39-[TGPhotoViewer convertPreviewObjects:]_block_invoke:TGPhotoViewer.m"> + + + value = "self.messageKeys"> + + + + + + + + + + + + + contextName = "-[SettingsWindowController awakeFromNib]:SettingsWindowController.m"> - - + value = "self.window.contentView "> + + diff --git a/Telegram.xcodeproj/xcuserdata/XingJunsPro.xcuserdatad/xcschemes/TGShare.xcscheme b/Telegram.xcodeproj/xcuserdata/XingJunsPro.xcuserdatad/xcschemes/TGShare.xcscheme new file mode 100644 index 00000000..dbe3050c --- /dev/null +++ b/Telegram.xcodeproj/xcuserdata/XingJunsPro.xcuserdatad/xcschemes/TGShare.xcscheme @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Telegram.xcodeproj/xcuserdata/XingJunsPro.xcuserdatad/xcschemes/Telegram.xcscheme b/Telegram.xcodeproj/xcuserdata/XingJunsPro.xcuserdatad/xcschemes/Telegram.xcscheme new file mode 100644 index 00000000..7b26f38b --- /dev/null +++ b/Telegram.xcodeproj/xcuserdata/XingJunsPro.xcuserdatad/xcschemes/Telegram.xcscheme @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Telegram.xcodeproj/xcuserdata/XingJunsPro.xcuserdatad/xcschemes/Updater.xcscheme b/Telegram.xcodeproj/xcuserdata/XingJunsPro.xcuserdatad/xcschemes/Updater.xcscheme new file mode 100644 index 00000000..98186059 --- /dev/null +++ b/Telegram.xcodeproj/xcuserdata/XingJunsPro.xcuserdatad/xcschemes/Updater.xcscheme @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Telegram.xcodeproj/xcuserdata/XingJunsPro.xcuserdatad/xcschemes/xcschememanagement.plist b/Telegram.xcodeproj/xcuserdata/XingJunsPro.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 00000000..91a56ab5 --- /dev/null +++ b/Telegram.xcodeproj/xcuserdata/XingJunsPro.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,42 @@ + + + + + SchemeUserState + + TGShare.xcscheme + + orderHint + 1 + + Telegram.xcscheme + + orderHint + 0 + + Updater.xcscheme + + orderHint + 2 + + + SuppressBuildableAutocreation + + C2CB5D3D1B4D697700CD61DF + + primary + + + C2CBF3B51AF38426006BF90A + + primary + + + CEB09E5717DAFC250055F150 + + primary + + + + + diff --git a/Telegram.xcodeproj/xcuserdata/mikhailfilimonov.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/Telegram.xcodeproj/xcuserdata/mikhailfilimonov.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index 7258765d..a275e6a1 100644 --- a/Telegram.xcodeproj/xcuserdata/mikhailfilimonov.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/Telegram.xcodeproj/xcuserdata/mikhailfilimonov.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -3,19 +3,83 @@ type = "1" version = "2.0"> + + + + + + + + + + + + + + + + diff --git a/Telegram.xcodeproj/xcuserdata/mikhailfilimonov.xcuserdatad/xcschemes/AppStore.xcscheme b/Telegram.xcodeproj/xcuserdata/mikhailfilimonov.xcuserdatad/xcschemes/AppStore.xcscheme index 958a9da7..8ffbeeef 100644 --- a/Telegram.xcodeproj/xcuserdata/mikhailfilimonov.xcuserdatad/xcschemes/AppStore.xcscheme +++ b/Telegram.xcodeproj/xcuserdata/mikhailfilimonov.xcuserdatad/xcschemes/AppStore.xcscheme @@ -1,6 +1,6 @@ + shouldUseLaunchSchemeArgsEnv = "YES"> @@ -38,17 +38,21 @@ ReferencedContainer = "container:Telegram.xcodeproj"> + + - + - + + shouldUseLaunchSchemeArgsEnv = "YES"> @@ -38,17 +38,21 @@ ReferencedContainer = "container:Telegram.xcodeproj"> + + - + - + + shouldUseLaunchSchemeArgsEnv = "YES"> + + @@ -54,10 +57,10 @@ diff --git a/Telegram.xcodeproj/xcuserdata/mikhailfilimonov.xcuserdatad/xcschemes/TGShare.xcscheme b/Telegram.xcodeproj/xcuserdata/mikhailfilimonov.xcuserdatad/xcschemes/TGShare.xcscheme index a8f80df0..942eb3f4 100644 --- a/Telegram.xcodeproj/xcuserdata/mikhailfilimonov.xcuserdatad/xcschemes/TGShare.xcscheme +++ b/Telegram.xcodeproj/xcuserdata/mikhailfilimonov.xcuserdatad/xcschemes/TGShare.xcscheme @@ -1,6 +1,6 @@ + shouldUseLaunchSchemeArgsEnv = "YES"> @@ -53,15 +53,18 @@ ReferencedContainer = "container:Telegram.xcodeproj"> + + + shouldUseLaunchSchemeArgsEnv = "YES"> @@ -47,15 +47,18 @@ ReferencedContainer = "container:Telegram.xcodeproj"> + + diff --git a/Telegram.xcodeproj/xcuserdata/mikhailfilimonov.xcuserdatad/xcschemes/Updater.xcscheme b/Telegram.xcodeproj/xcuserdata/mikhailfilimonov.xcuserdatad/xcschemes/Updater.xcscheme index 34dc2a18..24ad9a59 100644 --- a/Telegram.xcodeproj/xcuserdata/mikhailfilimonov.xcuserdatad/xcschemes/Updater.xcscheme +++ b/Telegram.xcodeproj/xcuserdata/mikhailfilimonov.xcuserdatad/xcschemes/Updater.xcscheme @@ -1,6 +1,6 @@ @@ -37,10 +37,10 @@ + shouldUseLaunchSchemeArgsEnv = "YES"> @@ -56,27 +56,30 @@ + + @@ -86,16 +89,16 @@ diff --git a/Telegram.xcodeproj/xcuserdata/mikhailfilimonov.xcuserdatad/xcschemes/debug.xcscheme b/Telegram.xcodeproj/xcuserdata/mikhailfilimonov.xcuserdatad/xcschemes/debug.xcscheme index 68f7b352..1c308f86 100644 --- a/Telegram.xcodeproj/xcuserdata/mikhailfilimonov.xcuserdatad/xcschemes/debug.xcscheme +++ b/Telegram.xcodeproj/xcuserdata/mikhailfilimonov.xcuserdatad/xcschemes/debug.xcscheme @@ -1,6 +1,6 @@ + shouldUseLaunchSchemeArgsEnv = "YES"> @@ -38,15 +38,18 @@ ReferencedContainer = "container:Telegram.xcodeproj"> + + @@ -74,10 +77,10 @@ diff --git a/Telegram.xcodeproj/xcuserdata/user.xcuserdatad/xcschemes/TGShare.xcscheme b/Telegram.xcodeproj/xcuserdata/user.xcuserdatad/xcschemes/TGShare.xcscheme new file mode 100644 index 00000000..963cd949 --- /dev/null +++ b/Telegram.xcodeproj/xcuserdata/user.xcuserdatad/xcschemes/TGShare.xcscheme @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Telegram.xcodeproj/xcuserdata/user.xcuserdatad/xcschemes/Updater.xcscheme b/Telegram.xcodeproj/xcuserdata/user.xcuserdatad/xcschemes/Updater.xcscheme new file mode 100644 index 00000000..271346c8 --- /dev/null +++ b/Telegram.xcodeproj/xcuserdata/user.xcuserdatad/xcschemes/Updater.xcscheme @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Telegram.xcodeproj/xcuserdata/user.xcuserdatad/xcschemes/xcschememanagement.plist b/Telegram.xcodeproj/xcuserdata/user.xcuserdatad/xcschemes/xcschememanagement.plist index 71d86ca2..2372a22d 100644 --- a/Telegram.xcodeproj/xcuserdata/user.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/Telegram.xcodeproj/xcuserdata/user.xcuserdatad/xcschemes/xcschememanagement.plist @@ -5,6 +5,11 @@ SchemeUserState TGKeeper.xcscheme + + orderHint + 1 + + TGShare.xcscheme orderHint 3 @@ -12,12 +17,17 @@ Telegram.xcscheme orderHint - 2 + 0 + + Updater.xcscheme + + orderHint + 4 debug.xcscheme orderHint - 6 + 2 SuppressBuildableAutocreation @@ -27,6 +37,16 @@ primary + C2CB5D3D1B4D697700CD61DF + + primary + + + C2CBF3B51AF38426006BF90A + + primary + + CEB09E5717DAFC250055F150 primary diff --git a/Telegram.xcodeproj/xcuserdata/zhishui.xcuserdatad/xcschemes/TGShare.xcscheme b/Telegram.xcodeproj/xcuserdata/zhishui.xcuserdatad/xcschemes/TGShare.xcscheme new file mode 100644 index 00000000..2e29067d --- /dev/null +++ b/Telegram.xcodeproj/xcuserdata/zhishui.xcuserdatad/xcschemes/TGShare.xcscheme @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Telegram.xcodeproj/xcuserdata/zhishui.xcuserdatad/xcschemes/Telegram.xcscheme b/Telegram.xcodeproj/xcuserdata/zhishui.xcuserdatad/xcschemes/Telegram.xcscheme new file mode 100644 index 00000000..f18dbbed --- /dev/null +++ b/Telegram.xcodeproj/xcuserdata/zhishui.xcuserdatad/xcschemes/Telegram.xcscheme @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Telegram.xcodeproj/xcuserdata/zhishui.xcuserdatad/xcschemes/Updater.xcscheme b/Telegram.xcodeproj/xcuserdata/zhishui.xcuserdatad/xcschemes/Updater.xcscheme new file mode 100644 index 00000000..d0efbd8e --- /dev/null +++ b/Telegram.xcodeproj/xcuserdata/zhishui.xcuserdatad/xcschemes/Updater.xcscheme @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Telegram.xcodeproj/xcuserdata/zhishui.xcuserdatad/xcschemes/xcschememanagement.plist b/Telegram.xcodeproj/xcuserdata/zhishui.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 00000000..91a56ab5 --- /dev/null +++ b/Telegram.xcodeproj/xcuserdata/zhishui.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,42 @@ + + + + + SchemeUserState + + TGShare.xcscheme + + orderHint + 1 + + Telegram.xcscheme + + orderHint + 0 + + Updater.xcscheme + + orderHint + 2 + + + SuppressBuildableAutocreation + + C2CB5D3D1B4D697700CD61DF + + primary + + + C2CBF3B51AF38426006BF90A + + primary + + + CEB09E5717DAFC250055F150 + + primary + + + + + diff --git a/TelegramTest/.DS_Store b/TelegramTest/.DS_Store index 5bcfa84e..b2bf559a 100644 Binary files a/TelegramTest/.DS_Store and b/TelegramTest/.DS_Store differ diff --git a/TelegramTest/ASQueue.m b/TelegramTest/ASQueue.m index d8eccefb..20e484b4 100644 --- a/TelegramTest/ASQueue.m +++ b/TelegramTest/ASQueue.m @@ -112,80 +112,80 @@ - (void)dispatchOnQueue:(dispatch_block_t)block synchronous:(bool)synchronous if (_isMainQueue) { if ([NSThread isMainThread]) { - @try { + // @try { block(); - } - @catch (NSException *exception) { - MTLog(@"fatal error: %@",[exception callStackSymbols]); + // } + // @catch (NSException *exception) { + // MTLog(@"fatal error: %@",[exception callStackSymbols]); #ifdef TGDEBUG - [self alertUserWithCrash:exception]; + // [self alertUserWithCrash:exception]; #endif - } + // } } else if (synchronous) dispatch_sync(_queue, ^{ - @try { + // @try { block(); - } - @catch (NSException *exception) { - MTLog(@"fatal error: %@",[exception callStackSymbols]); + // } + // @catch (NSException *exception) { + // MTLog(@"fatal error: %@",[exception callStackSymbols]); #ifdef TGDEBUG - [self alertUserWithCrash:exception]; + // [self alertUserWithCrash:exception]; #endif - } + // } }); else dispatch_async(_queue, ^{ - @try { + // @try { block(); - } - @catch (NSException *exception) { - MTLog(@"fatal error: %@",[exception callStackSymbols]); + // } + // @catch (NSException *exception) { + // MTLog(@"fatal error: %@",[exception callStackSymbols]); #ifdef TGDEBUG - [self alertUserWithCrash:exception]; + // [self alertUserWithCrash:exception]; #endif - } + // } }); } else { if (dispatch_get_current_queue() == self.nativeQueue) - @try { + // @try { block(); - } - @catch (NSException *exception) { - MTLog(@"fatal error: %@",[exception callStackSymbols]); + // } + // @catch (NSException *exception) { + // MTLog(@"fatal error: %@",[exception callStackSymbols]); #ifdef TGDEBUG - [self alertUserWithCrash:exception]; + // [self alertUserWithCrash:exception]; #endif - } + // } else if (synchronous) dispatch_sync(_queue, ^{ - @try { + // @try { block(); - } - @catch (NSException *exception) { - MTLog(@"fatal error: %@",[exception callStackSymbols]); + // } + // @catch (NSException *exception) { + // MTLog(@"fatal error: %@",[exception callStackSymbols]); #ifdef TGDEBUG - [self alertUserWithCrash:exception]; + // [self alertUserWithCrash:exception]; #endif - } + // } }); else dispatch_async(_queue, ^{ - @try { + // @try { block(); - } - @catch (NSException *exception) { - MTLog(@"fatal error: %@",[exception callStackSymbols]); + // } + // @catch (NSException *exception) { + // MTLog(@"fatal error: %@",[exception callStackSymbols]); #ifdef TGDEBUG - [self alertUserWithCrash:exception]; + // [self alertUserWithCrash:exception]; #endif - } + // } }); } } @@ -194,6 +194,8 @@ - (void)dispatchOnQueue:(dispatch_block_t)block synchronous:(bool)synchronous -(void)alertUserWithCrash:(NSException *)crash { +#ifdef TGDEBUG + [ASQueue dispatchOnMainQueue:^{ NSAlert *alert = [[NSAlert alloc] init]; [alert setAlertStyle:NSInformationalAlertStyle]; @@ -206,11 +208,15 @@ -(void)alertUserWithCrash:(NSException *)crash { [alert addButtonWithTitle:@"Ignore ;("]; [alert beginSheetModalForWindow:[[NSApp delegate] mainWindow] modalDelegate:self didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) contextInfo:(__bridge void *)(crash)]; }]; + +#endif } - (void)alertDidEnd:(NSAlert *)alert returnCode:(int)returnCode contextInfo:(void *)contextInfo { + #ifdef TGDEBUG + if(returnCode == 1000) { NSException *crash = (__bridge NSException *)(contextInfo); @throw crash; @@ -218,6 +224,8 @@ - (void)alertDidEnd:(NSAlert *)alert returnCode:(int)returnCode contextInfo:(voi [Telegram sendLogs]; } + #endif + } @end diff --git a/TelegramTest/AboutViewController.m b/TelegramTest/AboutViewController.m index 60b99bfd..33a1d938 100644 --- a/TelegramTest/AboutViewController.m +++ b/TelegramTest/AboutViewController.m @@ -60,7 +60,7 @@ -(void)loadView { TMTextField *version = [TMTextField defaultTextField]; [version setStringValue:[NSString stringWithFormat:@"Version %@",API_VERSION]]; - [version setFont:[NSFont fontWithName:@"HelveticaNeue" size:12]]; + [version setFont:TGSystemFont(12)]; [version setSelectable:YES]; [version sizeToFit]; diff --git a/TelegramTest/AccountSettingsViewController.m b/TelegramTest/AccountSettingsViewController.m index 81f45d2b..12bc15d5 100644 --- a/TelegramTest/AccountSettingsViewController.m +++ b/TelegramTest/AccountSettingsViewController.m @@ -76,6 +76,7 @@ @interface AccountSettingsViewController () @property (nonatomic,strong) UserInfoShortButtonView *privacy; @property (nonatomic,strong) UserInfoShortButtonView *blockedUsers; @property (nonatomic,strong) UserInfoShortButtonView *generalSettings; +@property (nonatomic,strong) UserInfoShortButtonView *notificationSettings; @property (nonatomic,strong) UserInfoShortButtonView *userName; @property (nonatomic,strong) UserInfoShortButtonView *phoneNumber; @@ -161,7 +162,7 @@ -(void)loadView { [header setStringValue:NSLocalizedString(@"Settings", nil)]; - [header setFont:[NSFont fontWithName:@"HelveticaNeue" size:15]]; + [header setFont:TGSystemFont(15)]; [header setTextColor:DARK_BLACK]; [header sizeToFit]; @@ -356,7 +357,7 @@ -(void)updateUserName { self.userNameTextField.attributedStringValue = attr; - attr = [[NSMutableAttributedString alloc] initWithString:[UsersManager currentUser].phoneWithFormat attributes:@{NSFontAttributeName:[NSFont fontWithName:@"HelveticaNeue" size:14]}]; + attr = [[NSMutableAttributedString alloc] initWithString:[UsersManager currentUser].phoneWithFormat attributes:@{NSFontAttributeName:TGSystemFont(14)}]; [attr addAttribute:NSForegroundColorAttributeName value:self.selectedController == self.phoneNumber ? NSColorFromRGB(0xffffff) : GRAY_TEXT_COLOR range:attr.range]; self.phoneNumberTextField.attributedStringValue = attr; @@ -375,6 +376,11 @@ -(void)willChangedController:(TMViewController *)controller { return; } + if([controller isKindOfClass:[NotificationSettingsViewController class]]) { + [self selectController:self.notificationSettings]; + return; + } + if([controller isKindOfClass:[BlockedUsersViewController class]]) { [self selectController:self.blockedUsers]; return; @@ -496,7 +502,7 @@ -(void)setState:(AccountSettingsState)state animated:(BOOL)animated { [self.lastNameView.textView setStringValue:[UsersManager currentUser].last_name]; - int height = defaultY + NSHeight(self.defaultView.frame); + int height = defaultY + NSHeight(self.defaultView.frame) + 43; [self.topContainer setFrame:NSMakeRect(0, 0, NSWidth(self.view.frame) - DIALOG_BORDER_WIDTH, NSHeight(self.topContainer.frame))]; @@ -560,8 +566,32 @@ -(NSView *)defaultContainerView { [container addSubview:self.generalSettings]; + currentY+=38; + + self.notificationSettings = [UserInfoShortButtonView buttonWithText:NSLocalizedString(@"Notifications",nil) tapBlock:^{ + + if([Telegram rightViewController].navigationViewController.isLocked) + { + //NSBeep(); + return; + } + + [[Telegram rightViewController] showNotificationSettingsViewController]; + + }]; + + [self.notificationSettings setFrame:NSMakeRect(0, currentY, NSWidth(self.view.frame) - 0, 38)]; + + [self.notificationSettings.textButton setFrameSize:NSMakeSize(NSWidth(self.notificationSettings.frame), NSHeight(self.notificationSettings.textButton.frame))]; + [self.notificationSettings.textButton setFrameOrigin:NSMakePoint(20, NSMinY(self.notificationSettings.textButton.frame))]; + + + [container addSubview:self.notificationSettings]; + + + + - // currentY+=38; self.blockedUsers = [UserInfoShortButtonView buttonWithText:NSLocalizedString(@"Account.BlockedUsers",nil) tapBlock:^{ @@ -746,7 +776,8 @@ -(NSView *)defaultContainerView { [dialog save]; } - [[Telegram rightViewController] showByDialog:dialog sender:self]; + [appWindow().navigationController showMessagesViewController:dialog]; + }; @@ -785,10 +816,10 @@ -(NSView *)defaultContainerView { [container addSubview:self.askQuestion]; - self.phoneNumber.autoresizingMask = self.phoneNumber.textButton.autoresizingMask = self.privacy.autoresizingMask = self.privacy.textButton.autoresizingMask = self.askQuestion.autoresizingMask = self.faq.autoresizingMask = self.about.autoresizingMask = self.blockedUsers.autoresizingMask = self.blockedUsers.textButton.autoresizingMask = self.updatePhotoButton.autoresizingMask = self.updatePhotoButton.textButton.autoresizingMask = self.nameTextField.autoresizingMask = NSViewWidthSizable; + self.notificationSettings.autoresizingMask = self.phoneNumber.autoresizingMask = self.phoneNumber.textButton.autoresizingMask = self.privacy.autoresizingMask = self.privacy.textButton.autoresizingMask = self.askQuestion.autoresizingMask = self.faq.autoresizingMask = self.about.autoresizingMask = self.blockedUsers.autoresizingMask = self.blockedUsers.textButton.autoresizingMask = self.updatePhotoButton.autoresizingMask = self.updatePhotoButton.textButton.autoresizingMask = self.nameTextField.autoresizingMask = NSViewWidthSizable; - self.phoneNumber.textButton.textColor = self.privacy.textButton.textColor = self.askQuestion.textButton.textColor = self.faq.textButton.textColor = self.about.textButton.textColor = self.blockedUsers.textButton.textColor = self.userName.textButton.textColor = self.generalSettings.textButton.textColor = DARK_BLACK; + self.notificationSettings.textButton.textColor = self.phoneNumber.textButton.textColor = self.privacy.textButton.textColor = self.askQuestion.textButton.textColor = self.faq.textButton.textColor = self.about.textButton.textColor = self.blockedUsers.textButton.textColor = self.userName.textButton.textColor = self.generalSettings.textButton.textColor = DARK_BLACK; [container setAutoresizingMask:NSViewWidthSizable]; @@ -803,6 +834,8 @@ -(NSView *)defaultContainerView { self.askQuestion.rightContainer = imageViewWithImage(image_ArrowGrey()); self.privacy.rightContainer = imageViewWithImage(image_ArrowGrey()); self.phoneNumber.rightContainer = imageViewWithImage(image_ArrowGrey()); + self.notificationSettings.rightContainer = imageViewWithImage(image_ArrowGrey()); + self.userName.rightContainerOffset = NSMakePoint(-10, 0); self.blockedUsers.rightContainerOffset = NSMakePoint(-10, 0); @@ -812,6 +845,7 @@ -(NSView *)defaultContainerView { self.askQuestion.rightContainerOffset = NSMakePoint(-10, 0); self.privacy.rightContainerOffset = NSMakePoint(-10, 0); self.phoneNumber.rightContainerOffset = NSMakePoint(-10, 0); + self.notificationSettings.rightContainerOffset = NSMakePoint(-10, 0); [self.userName setSelectedColor:BLUE_COLOR_SELECT]; [self.blockedUsers setSelectedColor:BLUE_COLOR_SELECT]; @@ -821,7 +855,7 @@ -(NSView *)defaultContainerView { [self.askQuestion setSelectedColor:BLUE_COLOR_SELECT]; [self.privacy setSelectedColor:BLUE_COLOR_SELECT]; [self.phoneNumber setSelectedColor:BLUE_COLOR_SELECT]; - + [self.notificationSettings setSelectedColor:BLUE_COLOR_SELECT]; return container; } @@ -899,8 +933,8 @@ -(NSView *)editContainerView { [self.lastNameView.textView setTarget:self]; [self.lastNameView.textView setAction:@selector(enterClick)]; - [self.firstNameView.textView setFont:[NSFont fontWithName:@"HelveticaNeue" size:14]]; - [self.lastNameView.textView setFont:[NSFont fontWithName:@"HelveticaNeue" size:14]]; + [self.firstNameView.textView setFont:TGSystemFont(14)]; + [self.lastNameView.textView setFont:TGSystemFont(14)]; [self.firstNameView.textView setAlignment:NSLeftTextAlignment]; [self.lastNameView.textView setAlignment:NSLeftTextAlignment]; diff --git a/TelegramTest/AddContactView.m b/TelegramTest/AddContactView.m index eb73d8ba..01469aed 100644 --- a/TelegramTest/AddContactView.m +++ b/TelegramTest/AddContactView.m @@ -78,8 +78,8 @@ - (id)initWithFrame:(NSRect)frame [self.lastNameView.textView setTarget:self]; [self.lastNameView.textView setAction:@selector(enterClick)]; - [self.firstNameView.textView setFont:[NSFont fontWithName:@"HelveticaNeue" size:14]]; - [self.lastNameView.textView setFont:[NSFont fontWithName:@"HelveticaNeue" size:14]]; + [self.firstNameView.textView setFont:TGSystemFont(14)]; + [self.lastNameView.textView setFont:TGSystemFont(14)]; [self.firstNameView.textView setAlignment:NSLeftTextAlignment]; [self.lastNameView.textView setAlignment:NSLeftTextAlignment]; @@ -94,21 +94,21 @@ - (id)initWithFrame:(NSRect)frame self.phoneNumberView = [[UserInfoShortTextEditView alloc] initWithFrame:NSMakeRect(100, 115 + offsetY, frame.size.width-200, 35)]; - self.phoneNumberView.textView.font = [NSFont fontWithName:@"HelveticaNeue" size:13]; + self.phoneNumberView.textView.font = TGSystemFont(13); - NSAttributedString *phoneViewPlaceHolder = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"AddContact.PhoneNumberPlaceholder", nil) attributes:@{NSFontAttributeName:[NSFont fontWithName:@"HelveticaNeue" size:13], NSForegroundColorAttributeName:GRAY_TEXT_COLOR}]; + NSAttributedString *phoneViewPlaceHolder = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"AddContact.PhoneNumberPlaceholder", nil) attributes:@{NSFontAttributeName:TGSystemFont(13), NSForegroundColorAttributeName:GRAY_TEXT_COLOR}]; [self.phoneNumberView.textView.cell setPlaceholderAttributedString:phoneViewPlaceHolder]; - NSAttributedString *firstNameViewPlaceHolder = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"AddContact.FirstNamePlaceholder", nil) attributes:@{NSFontAttributeName:[NSFont fontWithName:@"HelveticaNeue" size:13], NSForegroundColorAttributeName:GRAY_TEXT_COLOR}]; + NSAttributedString *firstNameViewPlaceHolder = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"AddContact.FirstNamePlaceholder", nil) attributes:@{NSFontAttributeName:TGSystemFont(13), NSForegroundColorAttributeName:GRAY_TEXT_COLOR}]; [self.phoneNumberView.textView.cell setPlaceholderAttributedString:phoneViewPlaceHolder]; - NSAttributedString *lastNameViewPlaceHolder = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"AddContact.LastNamePlaceholder", nil) attributes:@{NSFontAttributeName:[NSFont fontWithName:@"HelveticaNeue" size:13], NSForegroundColorAttributeName:GRAY_TEXT_COLOR}]; + NSAttributedString *lastNameViewPlaceHolder = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"AddContact.LastNamePlaceholder", nil) attributes:@{NSFontAttributeName:TGSystemFont(13), NSForegroundColorAttributeName:GRAY_TEXT_COLOR}]; [self.phoneNumberView.textView.cell setPlaceholderAttributedString:phoneViewPlaceHolder]; @@ -140,6 +140,9 @@ - (id)initWithFrame:(NSRect)frame return self; } +-(void)enterClick { + +} - (void)actionAddContact { @@ -164,26 +167,13 @@ - (void)actionAddContact { if(isAdd) { - TLDialog *dialog = user.dialog; + TL_conversation *dialog = user.dialog; if(dialog) { - [[Telegram sharedInstance] showMessagesFromDialog:dialog sender:self]; - } else { - [[Storage manager] dialogByPeer:user.n_id completeHandler:^(TLDialog *dialog, TLMessage *message) { - - if(dialog) { - [[DialogsManager sharedManager] add:@[dialog]]; - } else { - dialog = [[DialogsManager sharedManager] createDialogForUser:user]; - } - - if(message) - [[MessagesManager sharedManager] add:@[message]]; - - [[Telegram sharedInstance] showMessagesFromDialog:dialog sender:self]; - }]; + [appWindow().navigationController showMessagesViewController:dialog]; } + } else { alert(NSLocalizedString(@"AddContact.NotRegistredTitle",nil), NSLocalizedString(@"AddContact.NotRegistredDescription",nil)); } diff --git a/TelegramTest/AddContactViewController.m b/TelegramTest/AddContactViewController.m index 8ea0cf63..f05a9721 100644 --- a/TelegramTest/AddContactViewController.m +++ b/TelegramTest/AddContactViewController.m @@ -77,21 +77,21 @@ -(void)loadView { self.phoneNumberView = [[UserInfoShortTextEditView alloc] initWithFrame:NSMakeRect(100, 115 + offsetY, self.view.frame.size.width-200, 35)]; - self.phoneNumberView.textView.font = [NSFont fontWithName:@"HelveticaNeue" size:13]; + self.phoneNumberView.textView.font = TGSystemFont(13); - NSAttributedString *phoneViewPlaceHolder = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"AddContact.PhoneNumberPlaceholder", nil) attributes:@{NSFontAttributeName:[NSFont fontWithName:@"HelveticaNeue" size:13], NSForegroundColorAttributeName:GRAY_TEXT_COLOR}]; + NSAttributedString *phoneViewPlaceHolder = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"AddContact.PhoneNumberPlaceholder", nil) attributes:@{NSFontAttributeName:TGSystemFont(13), NSForegroundColorAttributeName:GRAY_TEXT_COLOR}]; [self.phoneNumberView.textView.cell setPlaceholderAttributedString:phoneViewPlaceHolder]; - NSAttributedString *firstNameViewPlaceHolder = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"AddContact.FirstNamePlaceholder", nil) attributes:@{NSFontAttributeName:[NSFont fontWithName:@"HelveticaNeue" size:13], NSForegroundColorAttributeName:GRAY_TEXT_COLOR}]; + NSAttributedString *firstNameViewPlaceHolder = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"AddContact.FirstNamePlaceholder", nil) attributes:@{NSFontAttributeName:TGSystemFont(13), NSForegroundColorAttributeName:GRAY_TEXT_COLOR}]; [self.phoneNumberView.textView.cell setPlaceholderAttributedString:phoneViewPlaceHolder]; - NSAttributedString *lastNameViewPlaceHolder = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"AddContact.LastNamePlaceholder", nil) attributes:@{NSFontAttributeName:[NSFont fontWithName:@"HelveticaNeue" size:13], NSForegroundColorAttributeName:GRAY_TEXT_COLOR}]; + NSAttributedString *lastNameViewPlaceHolder = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"AddContact.LastNamePlaceholder", nil) attributes:@{NSFontAttributeName:TGSystemFont(13), NSForegroundColorAttributeName:GRAY_TEXT_COLOR}]; [self.phoneNumberView.textView.cell setPlaceholderAttributedString:phoneViewPlaceHolder]; @@ -111,8 +111,8 @@ -(void)loadView { [self.lastNameView.textView setTarget:self]; [self.lastNameView.textView setAction:@selector(enterClick:)]; - [self.firstNameView.textView setFont:[NSFont fontWithName:@"HelveticaNeue" size:14]]; - [self.lastNameView.textView setFont:[NSFont fontWithName:@"HelveticaNeue" size:14]]; + [self.firstNameView.textView setFont:TGSystemFont(14)]; + [self.lastNameView.textView setFont:TGSystemFont(14)]; [self.firstNameView.textView setAlignment:NSLeftTextAlignment]; [self.lastNameView.textView setAlignment:NSLeftTextAlignment]; @@ -170,23 +170,9 @@ - (void)actionAddContact { if(isAdd) { - TLDialog *dialog = user.dialog; + TL_conversation *dialog = user.dialog; if(dialog) { - [[Telegram sharedInstance] showMessagesFromDialog:dialog sender:self]; - } else { - [[Storage manager] dialogByPeer:user.n_id completeHandler:^(TLDialog *dialog, TLMessage *message) { - - if(dialog) { - [[DialogsManager sharedManager] add:@[dialog]]; - } else { - dialog = [[DialogsManager sharedManager] createDialogForUser:user]; - } - - if(message) - [[MessagesManager sharedManager] add:@[message]]; - - [[Telegram sharedInstance] showMessagesFromDialog:dialog sender:self]; - }]; + [appWindow().navigationController showMessagesViewController:dialog]; } diff --git a/TelegramTest/AppDelegate.h b/TelegramTest/AppDelegate.h index b4a415b8..6a1f72af 100644 --- a/TelegramTest/AppDelegate.h +++ b/TelegramTest/AppDelegate.h @@ -7,7 +7,6 @@ // #import -#import "TGInitializer.h" #import "NSContactsPopover.h" #ifdef TGDEBUG @@ -22,8 +21,6 @@ @class Telegram; -@protocol NSUserNotificationCenterDelegate -@end @interface AppDelegate : NSObject diff --git a/TelegramTest/AppDelegate.m b/TelegramTest/AppDelegate.m index f8a46596..e1010028 100644 --- a/TelegramTest/AppDelegate.m +++ b/TelegramTest/AppDelegate.m @@ -26,7 +26,6 @@ #import "SelfDestructionController.h" #import "TGProccessUpdates.h" #import "TMMediaController.h" -#import "DialogsHistoryController.h" #import "SettingsWindowController.h" #import "TGTimer.h" #import "NSString+Extended.h" @@ -51,6 +50,8 @@ #import "MessagesBottomView.h" #import "TGAudioPlayerWindow.h" #import "TGUpdater.h" +#import "TGHeadChatPanel.h" +#import "NSArrayCategory.h" @interface NSUserNotification(For107) @property (nonatomic, strong) NSAttributedString *response; @@ -101,9 +102,7 @@ static void TGTelegramLoggingFunction(NSString *format, va_list args) - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { - - - + MTLogSetLoggingFunction(&TGTelegramLoggingFunction); NSAppleEventManager *appleEventManager = [NSAppleEventManager sharedAppleEventManager]; @@ -165,7 +164,8 @@ - (void)userNotificationCenter:(NSUserNotificationCenter *)center didActivateNot return; } - [[Telegram sharedInstance] showMessagesFromDialog:dialog sender:self]; + [self.mainWindow.navigationController showMessagesViewController:dialog]; + @@ -174,11 +174,11 @@ - (void)userNotificationCenter:(NSUserNotificationCenter *)center didActivateNot dispatch_async(dispatch_get_main_queue(), ^{ - TL_localMessage *msg = [[MessagesManager sharedManager] find:[[userInfo objectForKey:@"msg_id"] intValue]]; + TL_localMessage *msg = [[Storage manager] messageById:[[userInfo objectForKey:@"msg_id"] intValue] inChannel:dialog.type == DialogTypeChannel ? dialog.peer_id : 0]; if(dialog.type == DialogTypeChat) { - if(msg) [[Telegram rightViewController].messagesViewController addReplayMessage:msg animated:NO]; - + if(msg) + [[Telegram rightViewController].messagesViewController addReplayMessage:msg animated:NO]; } [[Telegram rightViewController].messagesViewController sendMessage:userResponse forConversation:dialog]; @@ -257,8 +257,6 @@ - (void)showMainApplicationWindowForCrashManager:(id)crashManager { [SharedManager sharedManager]; - [Storage manager]; - [self initializeUpdater]; [self initializeKeyDownHandler]; @@ -411,9 +409,20 @@ - (void)initializeKeyDownHandler { return [[NSEvent alloc] init]; } + if(![result.window isKindOfClass:NSClassFromString(@"TGHeadChatPanel")]) { + if([result.window isKindOfClass:[NSPanel class]]) { + [result.window cancelOperation:nil]; + } else { + [result.window close]; + } + } - [result.window close]; - + else + { + TGHeadChatPanel *panel = (TGHeadChatPanel *) result.window; + + [panel back]; + } return result; @@ -448,6 +457,16 @@ - (void)initializeKeyDownHandler { return [[NSEvent alloc] init]; } + if(incomingEvent.keyCode == 24 || incomingEvent.keyCode == 69) { + [TGPhotoViewer increaseZoom]; + return [[NSEvent alloc] init]; + } + + if(incomingEvent.keyCode == 27 || incomingEvent.keyCode == 78) { + [TGPhotoViewer decreaseZoom]; + return [[NSEvent alloc] init]; + } + return result; } @@ -456,7 +475,7 @@ - (void)initializeKeyDownHandler { return result; - id responder = self.mainWindow.firstResponder; + id responder = incomingEvent.window.firstResponder; if(incomingEvent.keyCode == 48) { @@ -498,16 +517,19 @@ - (void)initializeKeyDownHandler { } else if(incomingEvent.keyCode == 53) { + + if([responder isKindOfClass:[NSTextView class]] && [((NSTextView *)responder).superview.superview isKindOfClass:NSClassFromString(@"_TMSearchTextField")]) { + [[Telegram leftViewController] resignFirstResponder]; + return [[NSEvent alloc] init]; + } + if([Telegram rightViewController].navigationViewController.currentController == [Telegram rightViewController].currentEmptyController && ![responder isKindOfClass:NSClassFromString(@"_NSPopoverWindow")]) { if(![responder isKindOfClass:[NSTextView class]] || ![((NSTextView *)responder).superview.superview isKindOfClass:NSClassFromString(@"_TMSearchTextField")]) { [[Telegram leftViewController] becomeFirstResponder]; return [[NSEvent alloc] init]; - } else if([((NSTextView *)responder).superview.superview isKindOfClass:NSClassFromString(@"_TMSearchTextField")]) { - [((NSTextView *)responder) setString:@""]; - [((NSTextView *)responder) didChangeText]; - } + } return incomingEvent; } @@ -677,7 +699,6 @@ - (void)initializeKeyDownHandler { } } - return result; } @@ -693,23 +714,23 @@ - (void)initializeKeyDownHandler { id block3 = ^(NSEvent *incomingEvent) { - if([self.mainWindow.firstResponder class] == [SelectTextManager class]) { // hard fix for osx events bug + if([appWindow().firstResponder class] == [SelectTextManager class]) { // hard fix for osx events bug - NSPoint mouseLoc = [[Telegram rightViewController].messagesViewController.table.scrollView convertPoint:[incomingEvent locationInWindow] fromView:nil]; + NSPoint mouseLoc = [appWindow().navigationController.messagesViewController.table.scrollView convertPoint:[incomingEvent locationInWindow] fromView:nil]; - BOOL isInside = [[Telegram rightViewController].messagesViewController.table.scrollView mouse:mouseLoc inRect:[Telegram rightViewController].messagesViewController.table.scrollView.bounds]; + BOOL isInside = [appWindow().navigationController.messagesViewController.table.scrollView mouse:mouseLoc inRect:appWindow().navigationController.messagesViewController.table.scrollView.bounds]; if(isInside) { - [[Telegram rightViewController].messagesViewController.table mouseDragged:incomingEvent]; + [appWindow().navigationController.messagesViewController.table mouseDragged:incomingEvent]; return [[NSEvent alloc] init]; } } - + return incomingEvent; }; @@ -717,6 +738,10 @@ - (void)initializeKeyDownHandler { } + + + + - (void)windowDidChangeBackingProperties:(NSNotification *)notification { } @@ -733,6 +758,8 @@ -(NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender } + + -(void)initializeSounds { // playSentMessage(NO); } @@ -746,8 +773,14 @@ - (void)applicationDidBecomeActive:(NSNotification *)notification { [TGPasslock appIncomeActive]; - if(![TMViewController isModalActive]) + if(![TMViewController isModalActive]) { + + if([Telegram isSingleLayout] && [[Telegram rightViewController].navigationViewController.currentController isKindOfClass:[StandartViewController class]]) + return; + [[Telegram rightViewController] becomeFirstResponder]; + } + else [[TMViewController modalView] becomeFirstResponder]; } @@ -851,13 +884,18 @@ - (void)logoutWithForce:(BOOL)force { [TGAudioPlayerWindow hide]; - [[Storage manager] drop:^{ + [[MTNetwork instance] drop]; + + [Storage drop]; + + [Storage open:^{ + + [[MTNetwork instance] initConnectionWithId:-1]; [TGCache clear]; [TGModernTypingManager drop]; [SharedManager drop]; [[MTNetwork instance] startNetwork]; - [[MTNetwork instance] drop]; [Telegram drop]; [TMViewController hidePasslock]; [MessageSender drop]; @@ -867,26 +905,34 @@ - (void)logoutWithForce:(BOOL)force { [self initializeLoginWindow]; }]; - }]; + + }]; }; + if([[MTNetwork instance] isAuth] && !force) { [TMViewController showModalProgress]; - - dispatch_block_t clearCache = ^ { + dispatch_block_t clearCache = ^ { [RPCRequest sendRequest:[TLAPI_auth_logOut create] successHandler:^(RPCRequest *request, id response) { - block(); + [[Storage manager] drop:^{ + block(); + }]; + } errorHandler:^(RPCRequest *request, RpcError *error) { [TMViewController hideModalProgress]; confirm(NSLocalizedString(@"Auth.CantLogout", nil), NSLocalizedString(@"Auth.ForceLogout", nil), ^ { - [self logoutWithForce:YES]; + + [[Storage manager] drop:^{ + [self logoutWithForce:YES]; + }]; + },nil); } timeout:5]; @@ -994,9 +1040,7 @@ - (BOOL)application:(NSApplication *)application int peerId = [userInfo[@"peer"][@"id"] intValue]; NSString *text = userInfo[@"text"]; - - NSString *username = userInfo[@"peer"][@"username"]; - + TLPeer *peer; if([peerType isEqualToString:@"group"]) { @@ -1019,7 +1063,7 @@ - (BOOL)application:(NSApplication *)application [[DialogsManager sharedManager] add:@[conversation]]; - [[Telegram rightViewController] showByDialog:conversation sender:self]; + [self.mainWindow.navigationController showMessagesViewController:conversation]; [[Telegram rightViewController].messagesViewController setStringValueToTextField:text]; diff --git a/TelegramTest/AudioHistoryFilter.h b/TelegramTest/AudioHistoryFilter.h index f3bfb52e..5f112940 100644 --- a/TelegramTest/AudioHistoryFilter.h +++ b/TelegramTest/AudioHistoryFilter.h @@ -7,7 +7,7 @@ // #import "HistoryFilter.h" - -@interface AudioHistoryFilter : HistoryFilter +#import "CommonMediaHistoryFilter.h" +@interface AudioHistoryFilter : CommonMediaHistoryFilter @end diff --git a/TelegramTest/AudioHistoryFilter.m b/TelegramTest/AudioHistoryFilter.m index 4de35e02..4d47f980 100644 --- a/TelegramTest/AudioHistoryFilter.m +++ b/TelegramTest/AudioHistoryFilter.m @@ -10,15 +10,6 @@ #import "ChatHistoryController.h" @implementation AudioHistoryFilter -static NSMutableDictionary * messageItems; -static NSMutableDictionary * messageKeys; - --(id)initWithController:(ChatHistoryController *)controller { - if(self = [super initWithController:controller]) { - } - - return self; -} -(int)type { return HistoryFilterAudio; @@ -28,87 +19,8 @@ +(int)type { return HistoryFilterAudio; } -- (NSMutableDictionary *)messageKeys:(int)peer_id { - return [[self class] messageKeys:peer_id]; -} - -- (NSMutableArray *)messageItems:(int)peer_id { - return [[self class] messageItems:peer_id]; -} - -+ (NSMutableDictionary *)messageKeys:(int)peer_id { - - __block NSMutableDictionary *keys; - [ASQueue dispatchOnStageQueue:^{ - - keys = messageKeys[@(peer_id)]; - - if(!keys) - { - keys = [[NSMutableDictionary alloc] init]; - messageKeys[@(peer_id)] = keys; - } - - } synchronous:YES]; - - return keys; -} - -+ (NSMutableArray *)messageItems:(int)peer_id { - __block NSMutableArray *items; - - [ASQueue dispatchOnStageQueue:^{ - - items = messageItems[@(peer_id)]; - - if(!items) - { - items = [[NSMutableArray alloc] init]; - messageItems[@(peer_id)] = items; - } - - } synchronous:YES]; - - - - return items; -} - - -+(void)drop { - [ASQueue dispatchOnStageQueue:^{ - [messageKeys removeAllObjects]; - [messageItems removeAllObjects]; - }]; -} - - -+(void)initialize { - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - messageItems = [[NSMutableDictionary alloc] init]; - messageKeys = [[NSMutableDictionary alloc] init]; - - }); -} - --(void)remoteRequest:(BOOL)next peer_id:(int)peer_id callback:(void (^)(id response))callback { - - self.request = [RPCRequest sendRequest:[TLAPI_messages_search createWithPeer:[self.controller.conversation inputPeer] q:@"" filter:[TL_inputMessagesFilterAudio create] min_date:0 max_date:0 offset:0 max_id:self.controller.max_id limit:(int)self.controller.selectLimit] successHandler:^(RPCRequest *request, id response) { - - - if(callback && self != nil) { - callback(response); - } - - } errorHandler:^(RPCRequest *request, RpcError *error) { - - if(callback) { - callback(nil); - } - - } timeout:10 queue:[ASQueue globalQueue].nativeQueue]; - +-(TLMessagesFilter *)messagesFilter { + return [TL_inputMessagesFilterAudio create]; } -(NSString *)description { diff --git a/TelegramTest/AudioSenderItem.m b/TelegramTest/AudioSenderItem.m index 2c706bf8..5ba45bec 100644 --- a/TelegramTest/AudioSenderItem.m +++ b/TelegramTest/AudioSenderItem.m @@ -20,19 +20,23 @@ -(void)setState:(MessageState)state { [super setState:state]; } -- (id)initWithPath:(NSString *)filePath forConversation:(TL_conversation *)conversation { +- (id)initWithPath:(NSString *)filePath forConversation:(TL_conversation *)conversation additionFlags:(int)additionFlags { if(self = [super init]) { self.filePath = filePath; self.conversation = conversation; NSTimeInterval duration = [TGOpusAudioPlayerAU durationFile:filePath]; - TL_messageMediaAudio *audio = [TL_messageMediaAudio createWithAudio:[TL_audio createWithN_id:0 access_hash:0 user_id:[UsersManager currentUserId] date:(int)[[MTNetwork instance] getTime] duration:roundf(duration) mime_type:@"opus" size:(int)fileSize(filePath) dc_id:0]]; + TL_messageMediaAudio *audio = [TL_messageMediaAudio createWithAudio:[TL_audio createWithN_id:0 access_hash:0 date:(int)[[MTNetwork instance] getTime] duration:roundf(duration) mime_type:@"opus" size:(int)fileSize(filePath) dc_id:0]]; self.message = [MessageSender createOutMessage:@"" media:audio conversation:conversation]; self.message.flags|=TGREADEDCONTENT; + + if(additionFlags & (1 << 4)) + self.message.from_id = 0; + } return self; } @@ -73,19 +77,22 @@ -(void)performRequest { if(weakSelf.conversation.type == DialogTypeBroadcast) { request = [TLAPI_messages_sendBroadcast createWithContacts:[weakSelf.conversation.broadcast inputContacts] random_id:[weakSelf.conversation.broadcast generateRandomIds] message:@"" media:media]; } else { - request = [TLAPI_messages_sendMedia createWithFlags:weakSelf.message.reply_to_msg_id != 0 ? 1 : 0 peer:weakSelf.conversation.inputPeer reply_to_msg_id:weakSelf.message.reply_to_msg_id media:media random_id:weakSelf.message.randomId reply_markup:[TL_replyKeyboardMarkup createWithFlags:0 rows:[@[]mutableCopy]]]; + request = [TLAPI_messages_sendMedia createWithFlags:[self senderFlags] peer:weakSelf.conversation.inputPeer reply_to_msg_id:weakSelf.message.reply_to_msg_id media:media random_id:weakSelf.message.randomId reply_markup:[TL_replyKeyboardMarkup createWithFlags:0 rows:[@[]mutableCopy]]]; } weakSelf.rpc_request = [RPCRequest sendRequest:request successHandler:^(RPCRequest *request, TLUpdates *response) { - if(response.updates.count < 2) + + [weakSelf updateMessageId:response]; + + TL_localMessage *msg = [TL_localMessage convertReceivedMessage:[[weakSelf updateNewMessageWithUpdates:response] message]]; + + if(msg == nil) { [weakSelf cancel]; return; } - TL_localMessage *msg = [TL_localMessage convertReceivedMessage:(TLMessage *) ( [response.updates[1] message])]; - if(weakSelf.conversation.type != DialogTypeBroadcast) { weakSelf.message.n_id = msg.n_id; @@ -94,12 +101,6 @@ -(void)performRequest { } else { - // TL_messages_statedMessages *stated = (TL_messages_statedMessages *) response; - // [Notification perform:MESSAGE_LIST_RECEIVE data:@{KEY_MESSAGE_LIST:stated.messages}]; - // [Notification perform:MESSAGE_LIST_UPDATE_TOP data:@{KEY_MESSAGE_LIST:stated.messages,@"update_real_date":@(YES)}]; - - // msg = stated.messages[0]; - } diff --git a/TelegramTest/BlockedUserRowView.m b/TelegramTest/BlockedUserRowView.m index 957be16e..18de27a4 100644 --- a/TelegramTest/BlockedUserRowView.m +++ b/TelegramTest/BlockedUserRowView.m @@ -27,43 +27,41 @@ - (id)initWithFrame:(NSRect)frame self = [super initWithFrame:frame]; if (self) { - self.avatarImageView = [TMAvatarImageView standartNewConversationTableAvatar]; + self.avatarImageView = [TMAvatarImageView standartMessageTableAvatar]; [self addSubview:self.avatarImageView]; - [self.avatarImageView setFont:[NSFont fontWithName:@"HelveticaNeue-Light" size:15]]; - [self.avatarImageView setFrameSize:NSMakeSize(36, 36)]; - + self.titleTextField = [[TMTextField alloc] init]; [self.titleTextField setEditable:NO]; [self.titleTextField setBordered:NO]; [self.titleTextField setBackgroundColor:[NSColor clearColor]]; - [self.titleTextField setFont:[NSFont fontWithName:@"HelveticaNeue" size:13]]; + [self.titleTextField setFont:TGSystemFont(13)]; [[self.titleTextField cell] setLineBreakMode:NSLineBreakByTruncatingTail]; [[self.titleTextField cell] setTruncatesLastVisibleLine:YES]; [self addSubview:self.titleTextField]; - [self.titleTextField setFrameOrigin:NSMakePoint(145, 27)]; + [self.titleTextField setFrameOrigin:NSMakePoint(80, 27)]; self.numberTextField = [[TMTextField alloc] init]; [self.numberTextField setEditable:NO]; [self.numberTextField setBordered:NO]; [self.numberTextField setBackgroundColor:[NSColor clearColor]]; - [self.numberTextField setFont:[NSFont fontWithName:@"HelveticaNeue" size:12]]; + [self.numberTextField setFont:TGSystemFont(12)]; [self.numberTextField setTextColor:GRAY_TEXT_COLOR]; [[self.numberTextField cell] setLineBreakMode:NSLineBreakByTruncatingTail]; [[self.numberTextField cell] setTruncatesLastVisibleLine:YES]; [self addSubview:self.numberTextField]; - [self.numberTextField setFrameOrigin:NSMakePoint(145, 10)]; + [self.numberTextField setFrameOrigin:NSMakePoint(80, 10)]; - [self.avatarImageView setFrameOrigin:NSMakePoint(100, 7)]; + [self.avatarImageView setFrameOrigin:NSMakePoint(30, 7)]; self.unblockButton = [TMTextButton standartUserProfileButtonWithTitle:NSLocalizedString(@"User.Unlock", nil)]; - [self.unblockButton setFont:[NSFont fontWithName:@"HelveticaNeue" size:14]]; + [self.unblockButton setFont:TGSystemFont(14)]; [self.unblockButton setTextColor:BLUE_UI_COLOR]; [self.unblockButton sizeToFit]; @@ -105,10 +103,10 @@ - (void) redrawRow { -(void)setFrameSize:(NSSize)newSize { [super setFrameSize:newSize]; - [self.unblockButton setFrameOrigin:NSMakePoint( NSWidth(self.frame) - NSWidth(self.unblockButton.frame) - 113, 18)]; + [self.unblockButton setFrameOrigin:NSMakePoint( NSWidth(self.frame) - NSWidth(self.unblockButton.frame) - 30, 18)]; - [self.titleTextField setFrameSize:NSMakeSize(NSWidth(self.frame) - NSWidth(self.unblockButton.frame) - 260, NSHeight(_titleTextField.frame))]; - [self.numberTextField setFrameSize:NSMakeSize(NSWidth(self.frame) - NSWidth(self.unblockButton.frame) - 260, NSHeight(_numberTextField.frame))]; + [self.titleTextField setFrameSize:NSMakeSize(NSWidth(self.frame) - NSWidth(self.unblockButton.frame) - 110, NSHeight(_titleTextField.frame))]; + [self.numberTextField setFrameSize:NSMakeSize(NSWidth(self.frame) - NSWidth(self.unblockButton.frame) - 110, NSHeight(_numberTextField.frame))]; } @@ -123,7 +121,7 @@ - (void)drawRect:(NSRect)dirtyRect [NSColorFromRGB(0xe0e0e0) setFill]; - NSRectFill(NSMakeRect(145, 0, NSWidth(self.frame) - 245, 1)); + NSRectFill(NSMakeRect(80, 0, NSWidth(self.frame) - 110, 1)); } diff --git a/TelegramTest/BlockedUsersManager.m b/TelegramTest/BlockedUsersManager.m index 2f863701..666bdb71 100644 --- a/TelegramTest/BlockedUsersManager.m +++ b/TelegramTest/BlockedUsersManager.m @@ -49,11 +49,11 @@ - (void)_remoteLoadWithOffset:(int)offset limit:(int)limit array:(NSMutableArray [SharedManager proccessGlobalResponse:response]; - if([response isKindOfClass:[TL_contacts_blockedSlice class]]) { - [self _remoteLoadWithOffset:offset + limit limit:limit array:array]; - } else { +// if([response isKindOfClass:[TL_contacts_blockedSlice class]]) { +// [self _remoteLoadWithOffset:offset + limit limit:limit array:array]; +// } else { [self _compleRemoteLoad:array]; - } + // } } errorHandler:^(RPCRequest *request, RpcError *error) { MTLog(@"RpcError %@", error.error_msg); }]; diff --git a/TelegramTest/BroadcastInfoHeaderView.m b/TelegramTest/BroadcastInfoHeaderView.m index 9d77b908..8d79d87d 100644 --- a/TelegramTest/BroadcastInfoHeaderView.m +++ b/TelegramTest/BroadcastInfoHeaderView.m @@ -25,11 +25,8 @@ - (id)initWithFrame:(NSRect)frame [self.sharedMediaButton.textButton setTapBlock:^ { - [[Telegram rightViewController].messagesViewController setHistoryFilter:[PhotoHistoryFilter class] force:NO]; - [[Telegram rightViewController] showByDialog:strongSelf.controller.broadcast.conversation - withJump:0 historyFilter:[PhotoHistoryFilter class] sender:strongSelf]; }]; [self.addMembersButton.textButton setTapBlock:^ { diff --git a/TelegramTest/BroadcastManager.h b/TelegramTest/BroadcastManager.h index 9279129b..bf1f3a0c 100644 --- a/TelegramTest/BroadcastManager.h +++ b/TelegramTest/BroadcastManager.h @@ -16,7 +16,6 @@ @interface BroadcastManager : SharedManager - (BroadcastMemberChecker *)broadcastMembersCheckerById:(int)broadcastId; --(void)loadBroadcastList:(dispatch_block_t)callback; @end diff --git a/TelegramTest/BroadcastManager.m b/TelegramTest/BroadcastManager.m index eabeca09..1d21ebff 100644 --- a/TelegramTest/BroadcastManager.m +++ b/TelegramTest/BroadcastManager.m @@ -122,15 +122,6 @@ -(id)initWithQueue:(ASQueue *)queue { return self; } --(void)loadBroadcastList:(dispatch_block_t)callback { - [self.queue dispatchOnQueue:^{ - [self add:[[Storage manager] broadcastList]]; - - if(callback) - callback(); - }]; -} - -(void)save:(id)object { // [[Storage manager] insertBroadcast:object]; diff --git a/TelegramTest/CFunctions.m b/TelegramTest/CFunctions.m index 087f8a67..6b541fba 100644 --- a/TelegramTest/CFunctions.m +++ b/TelegramTest/CFunctions.m @@ -107,24 +107,59 @@ BOOL NSStringIsValidEmail(NSString *checkString) { } NSString *fileMD5(NSString * path) { - NSFileHandle *handle = [NSFileHandle fileHandleForReadingAtPath:path]; - if( handle == nil) - return [@"ERROR GETTING FILE MD5" md5]; // file didnt exist - - NSUInteger size = fileSize(path); - - NSUInteger seek = size - MIN(4096,size); - - NSData *fileData = [[NSData alloc] initWithData:[handle readDataOfLength:MIN(size, 4096)]]; - - [handle seekToFileOffset:seek]; - - fileData = [fileData dataWithData:[handle readDataToEndOfFile]]; - - - NSString *md5 = [[[NSString alloc] initWithData:fileData encoding:NSUTF8StringEncoding] md5]; - return [[NSString stringWithFormat:@"MD5_%@_%lu", md5, (unsigned long)size] md5]; -} + NSFileManager *fileManager = [NSFileManager defaultManager]; + // Make sure the file exists + if( [fileManager fileExistsAtPath:path isDirectory:nil] ) + { + NSData *data = [NSData dataWithContentsOfFile:path]; + unsigned char digest[CC_MD5_DIGEST_LENGTH]; + CC_MD5( data.bytes, (CC_LONG)data.length, digest ); + + NSMutableString *output = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2]; + + for( int i = 0; i < CC_MD5_DIGEST_LENGTH; i++ ) + { + [output appendFormat:@"%02x", digest[i]]; + } + + return output; + } + else + { + return @""; + } +} + + +//+(NSString*)fileMD5:(NSString*)path +//{ +// NSFileHandle *handle = [NSFileHandle fileHandleForReadingAtPath:path]; +// if( handle== nil ) return @";ERROR GETTING FILE MD5"; // file didnt exist +// +// CC_MD5_CTX md5; +// +// CC_MD5_Init(&md5); +// +// BOOL done = NO; +// while(!done) +// { +// NSData* fileData = [handle readDataOfLength: CHUNK_SIZE ]; +// CC_MD5_Update(&md5, [fileData bytes], [fileData length]); +// if( [fileData length] == 0 ) done = YES; +// } +// unsigned char digest[CC_MD5_DIGEST_LENGTH]; +// CC_MD5_Final(digest, &md5); +// NSString* s = [NSString stringWithFormat: @";%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", +// digest[0], digest[1], +// digest[2], digest[3], +// digest[4], digest[5], +// digest[6], digest[7], +// digest[8], digest[9], +// digest[10], digest[11], +// digest[12], digest[13], +// digest[14], digest[15]]; +// return s; +//} static NSMutableDictionary *extensions; static NSMutableDictionary *mimeTypes; diff --git a/TelegramTest/CMath.c b/TelegramTest/CMath.c index 32810feb..6b450d94 100644 --- a/TelegramTest/CMath.c +++ b/TelegramTest/CMath.c @@ -44,6 +44,10 @@ long rand_long() { return rand; } +int rand_int() { + return abs(arc4random()); +} + int rand_limit(int limit) { /* return a random number between 0 and limit inclusive. */ diff --git a/TelegramTest/CMath.h b/TelegramTest/CMath.h index 72e33b81..8a994927 100644 --- a/TelegramTest/CMath.h +++ b/TelegramTest/CMath.h @@ -13,4 +13,6 @@ int gcd(int m, int n); int rand_limit(int limit); int uniqueElement(int first, int last, int exception); long rand_long(); +int rand_int(); + #endif diff --git a/TelegramTest/CNGridView/CNGridViewItemLayout.m b/TelegramTest/CNGridView/CNGridViewItemLayout.m index e751c15b..fc2eaf3a 100755 --- a/TelegramTest/CNGridView/CNGridViewItemLayout.m +++ b/TelegramTest/CNGridView/CNGridViewItemLayout.m @@ -69,7 +69,7 @@ - (id)init { NSMutableParagraphStyle *textStyle = [[NSMutableParagraphStyle defaultParagraphStyle] mutableCopy]; [textStyle setAlignment:NSCenterTextAlignment]; - _itemTitleTextAttributes = @{NSFontAttributeName: [NSFont fontWithName:@"HelveticaNeue" size:12], + _itemTitleTextAttributes = @{NSFontAttributeName: TGSystemFont(12), NSShadowAttributeName: textShadow, NSForegroundColorAttributeName: textColor, NSParagraphStyleAttributeName: textStyle}; diff --git a/TelegramTest/CacheSettingsViewController.m b/TelegramTest/CacheSettingsViewController.m index 1759a7a6..b4eb9977 100644 --- a/TelegramTest/CacheSettingsViewController.m +++ b/TelegramTest/CacheSettingsViewController.m @@ -100,7 +100,7 @@ -(void)configureWithPhotoSize:(NSUInteger)photoSize videoSize:(NSUInteger)videoS [self.tableView removeAllItems:YES]; - GeneralSettingsRowItem *photos = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(GeneralSettingsRowItem *item) { + GeneralSettingsRowItem *photos = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(TGGeneralRowItem *item) { confirm(appName(), NSLocalizedString(@"Cache.ClearPhotoCache", nil), ^{ @@ -109,11 +109,11 @@ -(void)configureWithPhotoSize:(NSUInteger)photoSize videoSize:(NSUInteger)videoS }, nil); - } description:NSLocalizedString(@"Cache.Photos", nil) subdesc:[NSString sizeToTransformedValue:photoSize] height:82 stateback:^id(GeneralSettingsRowItem *item) { + } description:NSLocalizedString(@"Cache.Photos", nil) subdesc:[NSString sizeToTransformedValue:photoSize] height:82 stateback:^id(TGGeneralRowItem *item) { return @""; } ]; - GeneralSettingsRowItem *videos = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(GeneralSettingsRowItem *item) { + GeneralSettingsRowItem *videos = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(TGGeneralRowItem *item) { confirm(appName(), NSLocalizedString(@"Cache.ClearVideoCache", nil), ^{ @@ -121,12 +121,12 @@ -(void)configureWithPhotoSize:(NSUInteger)photoSize videoSize:(NSUInteger)videoS }, nil); - } description:NSLocalizedString(@"Cache.Videos", nil) subdesc:[NSString sizeToTransformedValue:videoSize] height:42 stateback:^id(GeneralSettingsRowItem *item) { + } description:NSLocalizedString(@"Cache.Videos", nil) subdesc:[NSString sizeToTransformedValue:videoSize] height:42 stateback:^id(TGGeneralRowItem *item) { return @""; }]; - GeneralSettingsRowItem *allCache = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(GeneralSettingsRowItem *item) { + GeneralSettingsRowItem *allCache = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(TGGeneralRowItem *item) { confirm(appName(), NSLocalizedString(@"Cache.ClearAllCache", nil), ^{ @@ -134,7 +134,7 @@ -(void)configureWithPhotoSize:(NSUInteger)photoSize videoSize:(NSUInteger)videoS }, nil); - } description:NSLocalizedString(@"Cache.AllCache", nil) subdesc:[NSString sizeToTransformedValue:fullSize] height:42 stateback:^id(GeneralSettingsRowItem *item) { + } description:NSLocalizedString(@"Cache.AllCache", nil) subdesc:[NSString sizeToTransformedValue:fullSize] height:42 stateback:^id(TGGeneralRowItem *item) { return @""; }]; @@ -149,10 +149,8 @@ -(void)configureWithPhotoSize:(NSUInteger)photoSize videoSize:(NSUInteger)videoS } - GeneralSettingsBlockHeaderItem *description = [[GeneralSettingsBlockHeaderItem alloc] initWithObject:NSLocalizedString(@"Cache.Description", nil)]; + GeneralSettingsBlockHeaderItem *description = [[GeneralSettingsBlockHeaderItem alloc] initWithString:NSLocalizedString(@"Cache.Description", nil) height:100 flipped:YES]; - description.height = 100; - description.isFlipped = YES; [self.tableView insert:description atIndex:self.tableView.count tableRedraw:NO]; diff --git a/TelegramTest/ChannelCommonFilter.h b/TelegramTest/ChannelCommonFilter.h new file mode 100644 index 00000000..fecd94bd --- /dev/null +++ b/TelegramTest/ChannelCommonFilter.h @@ -0,0 +1,14 @@ +// +// ChannelCommonFilter.h +// Telegram +// +// Created by keepcoder on 06/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "HistoryFilter.h" + +@interface ChannelCommonFilter : HistoryFilter + + +@end diff --git a/TelegramTest/ChannelCommonFilter.m b/TelegramTest/ChannelCommonFilter.m new file mode 100644 index 00000000..04535824 --- /dev/null +++ b/TelegramTest/ChannelCommonFilter.m @@ -0,0 +1,37 @@ +// +// ChannelCommonFilter.m +// Telegram +// +// Created by keepcoder on 06/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "ChannelCommonFilter.h" +#import "ChannelFilter.h" +#import "ChannelImportantFilter.h" +#import "ChatHistoryController.h" +@implementation ChannelCommonFilter + +-(NSArray *)proccessResponse:(NSArray *)result state:(ChatHistoryState)state next:(BOOL)next { + + NSArray *converted = [self filterAndAdd:result latest:NO]; + + converted = [self sortItems:converted]; + + state = next && state != ChatHistoryStateFull && self.server_min_id <= 1 ? ChatHistoryStateFull : state; + + [self setState:state next:next]; + + TL_conversation *conversation = [[DialogsManager sharedManager] find:self.peer_id]; + + if(self.prevState != ChatHistoryStateFull && conversation.universalTopMessage > 0 && conversation.universalTopMessage <= self.server_max_id) { + [self setState:ChatHistoryStateFull next:NO]; + } + + + + + return converted; +} + +@end diff --git a/TelegramTest/ChannelFilter.h b/TelegramTest/ChannelFilter.h new file mode 100644 index 00000000..cc054c22 --- /dev/null +++ b/TelegramTest/ChannelFilter.h @@ -0,0 +1,13 @@ +// +// ChannelFilter.h +// Telegram +// +// Created by keepcoder on 25.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "HistoryFilter.h" +#import "ChannelCommonFilter.h" +@interface ChannelFilter : ChannelCommonFilter +-(void)fillGroupHoles:(NSArray *)messages bottom:(BOOL)bottom; +@end diff --git a/TelegramTest/ChannelFilter.m b/TelegramTest/ChannelFilter.m new file mode 100644 index 00000000..9f00d629 --- /dev/null +++ b/TelegramTest/ChannelFilter.m @@ -0,0 +1,100 @@ +// +// ChannelFilter.m +// Telegram +// +// Created by keepcoder on 25.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "ChannelFilter.h" +#import "ChatHistoryController.h" + +@interface ChannelFilter() + +@end + +@implementation ChannelFilter + + +-(int)type { + return HistoryFilterChannelMessage; +} + ++(int)type { + return HistoryFilterChannelMessage; +} + + + + + +-(void)fillGroupHoles:(NSArray *)messages bottom:(BOOL)bottom { + + if(messages.count == 0) + return; + + // max to min + [messages enumerateObjectsWithOptions:0 usingBlock:^(TL_localMessage *obj, NSUInteger idx, BOOL *stop) { + + + if(![obj isImportantMessage]) { + + TL_localMessage *lastImportantMessage = [[Storage manager] lastMessageAroundMinId:obj.channelMsgId important:YES isTop:!bottom]; + + + + int lastImportantMessageId = [lastImportantMessage n_id] == 0 ? (bottom ? 1 : self.controller.conversation.top_message) : [lastImportantMessage n_id]; + + NSArray *holes = [[Storage manager] groupHoles:obj.peer_id min:!bottom?obj.n_id:lastImportantMessageId max:bottom?obj.n_id:lastImportantMessageId]; + + __block TGMessageGroupHole *hole; + + [holes enumerateObjectsUsingBlock:^(TGMessageGroupHole *gh, NSUInteger idx, BOOL *stop) { + if(gh.min_id <= obj.n_id && gh.max_id >= obj.n_id) { + hole = gh; + *stop = YES; + } + }]; + + + if(hole) { + + if(!hole.isImploded) { + if(bottom) { + if(hole.max_id >= obj.n_id) { + hole.max_id = obj.n_id+1; + + hole.messagesCount++; + + [hole save]; + } + } else if(hole.min_id <= obj.n_id) { + hole.min_id = obj.n_id-1; + hole.messagesCount++; + + [hole save]; + } + } + + } else { + TGMessageGroupHole *groupHole = [[TGMessageGroupHole alloc] initWithUniqueId:-rand_int() peer_id:obj.peer_id min_id:obj.n_id-1 max_id:obj.n_id+1 date:!bottom?lastImportantMessage.date:obj.date-1 count:1]; + [groupHole save]; + } + + + } + + + + }]; + + + +} + +-(int)additionSenderFlags { + return (1 << 4); +} + + +@end diff --git a/TelegramTest/ChannelHistoryController.h b/TelegramTest/ChannelHistoryController.h new file mode 100644 index 00000000..94ef57a4 --- /dev/null +++ b/TelegramTest/ChannelHistoryController.h @@ -0,0 +1,13 @@ +// +// ChannelHistoryController.h +// Telegram +// +// Created by keepcoder on 08.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "ChatHistoryController.h" + +@interface ChannelHistoryController : ChatHistoryController + +@end diff --git a/TelegramTest/ChannelHistoryController.m b/TelegramTest/ChannelHistoryController.m new file mode 100644 index 00000000..09ac3fb9 --- /dev/null +++ b/TelegramTest/ChannelHistoryController.m @@ -0,0 +1,265 @@ +// +// ChannelHistoryController.m +// Telegram +// +// Created by keepcoder on 08.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "ChannelHistoryController.h" +#import "MessageTableItem.h" +#import "TGChannelsPolling.h" + +#import "ChannelImportantFilter.h" +#import "ChannelFilter.h" +#import "MegagroupChatFilter.h" +@interface ChannelHistoryController () +@property (nonatomic,assign) BOOL pollingIsStarted; +@end + +@implementation ChannelHistoryController + + +static TGChannelsPolling *channelPolling; + +-(id)initWithController:(id)controller historyFilter:(Class)historyFilter { + if(self = [super initWithController:controller historyFilter:historyFilter]) { + + + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + channelPolling = [[TGChannelsPolling alloc] initWithDelegate:self withUpdatesLimit:50]; + + }); + + [channelPolling setDelegate:self]; + [channelPolling setCurrentConversation:controller.conversation]; + + _pollingIsStarted = NO; + + } + + return self; +} + + +-(void)request:(BOOL)next anotherSource:(BOOL)anotherSource sync:(BOOL)sync selectHandler:(selectHandler)selectHandler { + + [self.queue dispatchOnQueue:^{ + + + HistoryFilter *filter = [self filterWithNext:next]; + + if([filter checkState:ChatHistoryStateFull next:next] || self.isProccessing) { + [self performCallback:selectHandler result:@[] range:NSMakeRange(0, 0) controller:self]; + return; + } + + self.proccessing = YES; + + + [filter request:next callback:^(NSArray *result, ChatHistoryState state) { + + if([filter checkState:ChatHistoryStateLocal next:next] && result.count == 0) { + + [filter proccessResponse:result state:state next:next]; + + self.proccessing = NO; + + [self request:next anotherSource:anotherSource sync:sync selectHandler:selectHandler]; + + return; + } + + NSArray *converted = [self.controller messageTableItemsFromMessages:[filter proccessResponse:result state:state next:next]]; + + [self performCallback:selectHandler result:converted range:NSMakeRange(0, converted.count) controller:self]; + + [channelPolling checkInvalidatedMessages:result important:[self.filter isKindOfClass:[ChannelImportantFilter class]]]; + + + + + }]; + + } synchronous:sync]; + +} + + + +-(void)pollingDidSaidTooLongWithHole:(TGMessageHole *)hole { + + if(hole != nil) { + + HistoryFilter *filter = [self filterWithPeerId:self.conversation.peer_id]; + + [filter setState:ChatHistoryStateRemote next:NO]; + + [filter setHole:hole withNext:NO]; + + + + [filter request:NO callback:^(id response, ChatHistoryState state) { + + NSArray *converted = [self.controller messageTableItemsFromMessages:[filter proccessResponse:response state:state next:NO]]; + + [ASQueue dispatchOnMainQueue:^{ + + if([self.controller respondsToSelector:@selector(forceAddUnreadMark)]) { + [self.controller forceAddUnreadMark]; + } + + [self.controller receivedMessageList:converted inRange:NSMakeRange(0, converted.count) itsSelf:NO]; + + }]; + + }]; + + } + + + +} + + + +-(void)loadAroundMessagesWithMessage:(TL_localMessage *)message prevLimit:(int)prevLimit nextLimit:(int)nextLimit selectHandler:(selectHandler)selectHandler { + + + [self.queue dispatchOnQueue:^{ + + [self addMessageWithoutSavingState:message]; + + [[Storage manager] addHolesAroundMessage:message]; + + if(self.filter.class == [ChannelFilter class]) { + [(ChannelFilter *)self.filter fillGroupHoles:@[message] bottom:NO]; + } + + [[Storage manager] insertMessages:@[message]]; + + NSMutableArray *prevResult = [NSMutableArray array]; + NSMutableArray *nextResult = [NSMutableArray array]; + + self.proccessing = YES; + [self loadAroundMessagesWithSelectHandler:selectHandler prevLimit:(int)prevLimit nextLimit:(int)nextLimit prevResult:prevResult nextResult:nextResult]; + + + } synchronous:YES]; + + +} + +-(void)loadAroundMessagesWithSelectHandler:(selectHandler)selectHandler prevLimit:(int)prevLimit nextLimit:(int)nextLimit prevResult:(NSMutableArray *)prevResult nextResult:(NSMutableArray *)nextResult { + + + BOOL nextLoaded = nextResult.count >= nextLimit || self.nextState == ChatHistoryStateFull; + BOOL prevLoaded = prevResult.count >= prevLimit || self.prevState == ChatHistoryStateFull; + + + if((nextLoaded && prevLoaded) || (prevLoaded && self.nextState == ChatHistoryStateRemote && nextLimit == 1)) { + + NSArray *result = [self.filter selectAllItems]; + + if(self.isNeedSwapFilters) { + result = [[self filterAtIndex:1] selectAllItems]; + } + + NSArray *converted = [self.controller messageTableItemsFromMessages:result]; + + [self performCallback:selectHandler result:converted range:NSMakeRange(0, converted.count) controller:self]; + + [channelPolling checkInvalidatedMessages:result important:[self.filter isKindOfClass:[ChannelImportantFilter class]]]; + + self.proccessing = NO; + return; + } + + BOOL nextRequest = prevLoaded; + + + [self.filter request:nextRequest callback:^(NSArray *result, ChatHistoryState state) { + + NSArray *converted = [self.filter proccessResponse:result state:state next:nextRequest]; + + if(nextRequest) { + [nextResult addObjectsFromArray:converted]; + } else { + [prevResult addObjectsFromArray:converted]; + } + + [self loadAroundMessagesWithSelectHandler:selectHandler prevLimit:(int)prevLimit nextLimit:(int)nextLimit prevResult:prevResult nextResult:nextResult]; + + }]; + +} + + + +-(void)pollingReceivedUpdates:(id)updates endPts:(int)pts { + +} + + + +-(void)startChannelPolling { + + if(!channelPolling.isActive) { + [channelPolling start]; + _pollingIsStarted = YES; + } +} + +-(void)startChannelPollingIfAlreadyStoped { + if(!channelPolling.isActive && _pollingIsStarted) { + [channelPolling start]; + } +} + +-(void)stopChannelPolling { + [channelPolling stop]; +} + + + + +-(void)drop:(BOOL)dropMemory { + + [super drop:YES]; +} + +-(void)dealloc { + [channelPolling stop]; +} + +/* + // __block MessageTableItem *service; + // + // + // if([filter checkState:ChatHistoryStateFull next:next]) { + // [[filter selectAllItems] enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(MessageTableItem *obj, NSUInteger idx, BOOL * _Nonnull stop) { + // if(obj.message.action && [obj.message.action isKindOfClass:[TL_messageActionChannelMigrateFrom class]]) { + // service = obj; + // *stop = YES; + // } + // }]; + // + // + // if( service ) { + // + // TLChat *chat = [[ChatsManager sharedManager] find:service.message.action.chat_id]; + // + // HistoryFilter *filter = [[MegagroupChatFilter alloc] initWithController:self peer:chat.dialog.peer]; + // + // [filter setState:ChatHistoryStateFull next:NO]; + // + // [self addFilter:filter]; + // + // } + // } + + */ + + +@end diff --git a/TelegramTest/ChannelImportantFilter.h b/TelegramTest/ChannelImportantFilter.h new file mode 100644 index 00000000..9b58398c --- /dev/null +++ b/TelegramTest/ChannelImportantFilter.h @@ -0,0 +1,13 @@ +// +// ChannelImportantFilter.h +// Telegram +// +// Created by keepcoder on 30.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "HistoryFilter.h" +#import "ChannelCommonFilter.h" +@interface ChannelImportantFilter : ChannelCommonFilter + +@end diff --git a/TelegramTest/ChannelImportantFilter.m b/TelegramTest/ChannelImportantFilter.m new file mode 100644 index 00000000..eff5d454 --- /dev/null +++ b/TelegramTest/ChannelImportantFilter.m @@ -0,0 +1,136 @@ +// +// ChannelImportantFilter.m +// Telegram +// +// Created by keepcoder on 25.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "ChannelImportantFilter.h" +#import "ChatHistoryController.h" + +@interface ChannelImportantFilter() + +@end + +@implementation ChannelImportantFilter + + +-(int)type { + return HistoryFilterImportantChannelMessage; +} + ++(int)type { + return HistoryFilterImportantChannelMessage; +} + +-(NSArray *)storageRequest:(BOOL)next state:(ChatHistoryState *)state { + + + ChatHistoryState nstate; + + NSArray *result = [super storageRequest:next state:&nstate]; + + *state = [result filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.n_id > 0"]].count < self.controller.selectLimit || [self confirmHoleWithNext:next] ? ChatHistoryStateRemote : ChatHistoryStateLocal; + + return result; + +} + + +-(void)remoteRequest:(BOOL)next max_id:(int)max_id hole:(TGMessageHole *)hole callback:(void (^)(id response,ChatHistoryState state))callback { + + + TLChat *chat = [[ChatsManager sharedManager] find:self.peer.channel_id]; + + + + self.request = [RPCRequest sendRequest:[TLAPI_channels_getImportantHistory createWithChannel:[TL_inputChannel createWithChannel_id:self.peer.channel_id access_hash:chat.access_hash] offset_id:max_id add_offset:next? 0 : -(int)self.controller.selectLimit limit:(int)self.controller.selectLimit max_id:hole ? hole.max_id : INT32_MAX min_id:hole ? hole.min_id : next ? 0 : max_id] successHandler:^(RPCRequest *request, TL_messages_channelMessages * response) { + + [SharedManager proccessGlobalResponse:response]; + + + NSArray *messages = [[response messages] arrayByAddingObjectsFromArray:[self fillGroupHoles:[response collapsed] peer_id:self.peer_id bottom:next]]; + + [self setHole:[self proccessAndGetHoleWithHole:hole next:next messages:[response messages]] withNext:next]; + + if(callback) { + callback(messages,hole && ![self holeWithNext:next] ? ChatHistoryStateLocal : messages.count < self.controller.selectLimit && !hole && ![self holeWithNext:next] ? ChatHistoryStateFull : ChatHistoryStateRemote); + } + + } errorHandler:^(RPCRequest *request, RpcError *error) { + + if(callback && self.controller) { + callback(nil,ChatHistoryStateRemote); + } + + } timeout:0 queue:[ASQueue globalQueue].nativeQueue]; + + +} + + +-(void)remoteRequest:(BOOL)next hole:(TGMessageHole *)hole callback:(void (^)(id response,ChatHistoryState state))callback { + + int maxId = next ? self.server_min_id : self.server_max_id; + + [self remoteRequest:next max_id:maxId hole:hole callback:callback]; + +} + + + +-(NSArray *)fillGroupHoles:(NSArray *)collapsed peer_id:(int)peer_id bottom:(BOOL)bottom { + + NSMutableArray *messages = [[NSMutableArray alloc] init]; + + + + [collapsed enumerateObjectsUsingBlock:^(TL_messageGroup *obj, NSUInteger idx, BOOL *stop) { + + + int uniqueId = -rand_int(); + + NSArray *holes = [[Storage manager] groupHoles:peer_id min:obj.min_id max:obj.max_id]; + + TGMessageGroupHole *unslamHole = [holes lastObject]; + + if(unslamHole) + uniqueId = unslamHole.uniqueId; + + + + TGMessageGroupHole *groupHole = [[TGMessageGroupHole alloc] initWithUniqueId:uniqueId peer_id:peer_id min_id:obj.min_id max_id:obj.max_id date:obj.date count:obj.n_count isImploded:YES]; + + [[Storage manager] insertMessagesHole:groupHole]; + + + if(groupHole.uniqueId != unslamHole.uniqueId) { + TGMessageHole *hole = [[TGMessageHole alloc] initWithUniqueId:-rand_int() peer_id:peer_id min_id:obj.min_id max_id:obj.max_id date:obj.date count:0]; + + TL_localMessageService *msg = [TL_localMessageService createWithHole:groupHole]; + + [messages addObject:msg]; + + [hole save]; + } else { + [Notification perform:UPDATE_MESSAGE_GROUP_HOLE data:@{KEY_GROUP_HOLE:groupHole}]; + } + + + + + }]; + + + return [messages copy]; + + +} + + +-(int)additionSenderFlags { + return (1 << 4); +} + +@end diff --git a/TelegramTest/ChannelInfoHeaderView.h b/TelegramTest/ChannelInfoHeaderView.h new file mode 100644 index 00000000..ccde77c3 --- /dev/null +++ b/TelegramTest/ChannelInfoHeaderView.h @@ -0,0 +1,15 @@ +// +// ChannelInfoHeaderView.h +// Telegram +// +// Created by keepcoder on 21.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "ChatInfoHeaderView.h" + +@interface ChannelInfoHeaderView : ChatInfoHeaderView + + + +@end diff --git a/TelegramTest/ChannelInfoHeaderView.m b/TelegramTest/ChannelInfoHeaderView.m new file mode 100644 index 00000000..0dfb6ce0 --- /dev/null +++ b/TelegramTest/ChannelInfoHeaderView.m @@ -0,0 +1,678 @@ +// +// ChannelInfoHeaderView.m +// Telegram +// +// Created by keepcoder on 21.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "ChannelInfoHeaderView.h" +#import "UserInfoParamsView.h" +#import "ComposeActionAddChannelModeratorBehavior.h" +#import "ComposeActionBehavior.h" +#import "ComposeActionBlackListBehavior.h" +#import "ComposeActionChannelMembersBehavior.h" +@interface ChannelInfoHeaderView () +@property (nonatomic,strong) UserInfoParamsView *linkView; +@property (nonatomic,strong) UserInfoParamsView *aboutView; + +@property (nonatomic,strong) UserInfoShortButtonView *linkEditButton; + + +@property (nonatomic,strong) UserInfoShortButtonView *openOrJoinChannelButton; + + +@property (nonatomic,strong) TMGrowingTextView *aboutTextView; +@property (nonatomic,strong) TMTextField *aboutDescription; + + +@property (nonatomic,strong) TMView *editAboutContainer; + + +@property (nonatomic,strong) UserInfoShortButtonView *managmentButton; +@property (nonatomic,strong) UserInfoShortButtonView *blackListButton; +@property (nonatomic,strong) UserInfoShortButtonView *membersButton; +@property (nonatomic,strong) UserInfoShortButtonView *enableCommentsButton; + +@property (nonatomic,strong) ITSwitch *commentsSwitch; + +@property (nonatomic,strong) ComposeAction *composeActionManagment; + +@end + +@implementation ChannelInfoHeaderView + +- (void)drawRect:(NSRect)dirtyRect { + [super drawRect:dirtyRect]; + + // Drawing code here. +} + +- (void)controlTextDidChange:(NSNotification *)obj { + + +// [self.aboutTextView setStringValue:[self.aboutTextView.stringValue substringToIndex:MIN(160,self.aboutTextView.stringValue.length)]]; +// +// NSSize size = [self.aboutTextView.attributedStringValue sizeForTextFieldForWidth:NSWidth(self.aboutTextView.frame)]; +// +// [self.aboutTextView setFrameSize:NSMakeSize(NSWidth(self.aboutTextView.frame), size.height)]; +// +// [self.editAboutContainer setFrameSize:NSMakeSize(NSWidth(_editAboutContainer.frame), size.height + 20)]; +// + + +} + + +- (void) TMGrowingTextViewHeightChanged:(id)textView height:(int)height cleared:(BOOL)isCleared { + [self setFrameSize:self.frame.size]; +} +- (BOOL) TMGrowingTextViewCommandOrControlPressed:(id)textView isCommandPressed:(BOOL)isCommandPressed { + return NO; +} +- (void) TMGrowingTextViewTextDidChange:(id)textView { + [self setFrameSize:self.frame.size]; +} +- (void) TMGrowingTextViewFirstResponder:(id)textView isFirstResponder:(BOOL)isFirstResponder { + +} + + +-(instancetype)initWithFrame:(NSRect)frameRect { + if(self = [super initWithFrame:frameRect]) { + + + _editAboutContainer = [[TMView alloc] initWithFrame:NSMakeRect(0, 0, NSWidth(frameRect) - 200, 80)]; + + self.aboutTextView = [[TMGrowingTextView alloc] initWithFrame:NSMakeRect(0, 24, NSWidth(_editAboutContainer.frame) , 40)]; + + self.aboutTextView.growingDelegate = self; + + + [self.aboutTextView setMinHeight:20]; + [self.aboutTextView setMaxHeight:47]; + + [self.aboutTextView setLimit:200]; + [self.aboutTextView setDisabledBorder:YES]; + // self.aboutTextView.delegate = self; + [self.aboutTextView setFont:TGSystemFont(13)]; + + [self.aboutTextView setEditable:YES]; + [self.aboutTextView setFocusRingType:NSFocusRingTypeNone]; + + NSMutableAttributedString *str = [[NSMutableAttributedString alloc] init]; + + [str appendString:NSLocalizedString(@"Compose.ChannelAboutPlaceholder", nil) withColor:DARK_GRAY]; + [str setAlignment:NSLeftTextAlignment range:str.range]; + [str setFont:TGSystemFont(13) forRange:str.range]; + + + + [_editAboutContainer addSubview:self.aboutTextView.containerView]; + + + TMView *separator = [[TMView alloc] initWithFrame:NSMakeRect(0, 15, NSWidth(_editAboutContainer.frame), 1)]; + + separator.backgroundColor = DIALOG_BORDER_COLOR; + + + [_editAboutContainer addSubview:separator]; + + + + + _aboutDescription = [TMTextField defaultTextField]; + [_aboutDescription setFont:TGSystemFont(13)]; + [_aboutDescription setTextColor:GRAY_TEXT_COLOR]; + + + [_aboutDescription setStringValue:NSLocalizedString(@"Compose.ChannelAboutDescription", nil)]; + + + + [_aboutDescription setFrameOrigin:NSMakePoint(0, 0)]; + + [_editAboutContainer addSubview:_aboutDescription]; + + + [self addSubview:_editAboutContainer]; + + self.linkView = [[UserInfoParamsView alloc] initWithFrame:NSMakeRect(100, 50, 200, 61)]; + [self.linkView setHeader:NSLocalizedString(@"Profile.ShareLink", nil)]; + [self addSubview:self.linkView]; + + + self.aboutView = [[UserInfoParamsView alloc] initWithFrame:NSMakeRect(100, 50, 200, 61)]; + [self.aboutView setHeader:NSLocalizedString(@"Profile.About", nil)]; + [self addSubview:self.aboutView]; + + + self.linkEditButton = [UserInfoShortButtonView buttonWithText:NSLocalizedString(@"Profile.EditLink", nil) tapBlock:^{ + + + ComposeAction *action = [[ComposeAction alloc] initWithBehaviorClass:[ComposeActionBehavior class]]; + + action.result = [[ComposeResult alloc] init]; + + action.result.singleObject = self.controller.chat; + + ComposeCreateChannelUserNameStepViewController *viewController = [[ComposeCreateChannelUserNameStepViewController alloc] initWithFrame:self.controller.view.bounds]; + + [viewController setAction:action]; + + [self.controller.navigationViewController pushViewController:viewController animated:YES]; + + + }]; + + weak(); + + [self.exportChatInvite setCallback:^{ + dispatch_block_t cblock = ^ { + + ChatExportLinkViewController *export = [[ChatExportLinkViewController alloc] initWithFrame:weakSelf.controller.view.bounds]; + + [export setChat:weakSelf.controller.fullChat]; + + [weakSelf.controller.navigationViewController pushViewController:export animated:YES]; + + }; + + + if([weakSelf.controller.fullChat.exported_invite isKindOfClass:[TL_chatInviteExported class]]) { + + cblock(); + + } else { + + [weakSelf.controller showModalProgress]; + + [RPCRequest sendRequest:[TLAPI_messages_exportChatInvite createWithChat_id:weakSelf.controller.chat.n_id] successHandler:^(RPCRequest *request, TL_chatInviteExported *response) { + + [weakSelf.controller hideModalProgressWithSuccess]; + + weakSelf.controller.fullChat.exported_invite = response; + + [[Storage manager] insertFullChat:weakSelf.controller.fullChat completeHandler:nil]; + + cblock(); + + + } errorHandler:^(RPCRequest *request, RpcError *error) { + [weakSelf.controller hideModalProgress]; + } timeout:10]; + + } + + }]; + + + [self.exportChatInvite.textButton setStringValue:NSLocalizedString(@"Profile.ExportInviteLink", nil)]; + + + + self.managmentButton = [UserInfoShortButtonView buttonWithText:NSLocalizedString(@"Profile.Managment", nil) tapBlock:^{ + + + ComposeManagmentViewController *viewController = [[ComposeManagmentViewController alloc] initWithFrame:self.controller.view.bounds]; + + [viewController setAction:_composeActionManagment]; + + [self.controller.navigationViewController pushViewController:viewController animated:YES]; + + }]; + + [self addSubview:self.managmentButton]; + + + self.blackListButton = [UserInfoShortButtonView buttonWithText:NSLocalizedString(@"Profile.ChannelBlackList", nil) tapBlock:^{ + + + ComposeChannelParticipantsViewController *viewController = [[ComposeChannelParticipantsViewController alloc] initWithFrame:self.controller.view.bounds]; + + [viewController setAction:[[ComposeAction alloc] initWithBehaviorClass:[ComposeActionBlackListBehavior class] filter:@[] object:self.controller.chat reservedObjects:@[[TL_channelParticipantsKicked create]]]]; + + [self.controller.navigationViewController pushViewController:viewController animated:YES]; + + }]; + + [self addSubview:self.blackListButton]; + + + self.membersButton = [UserInfoShortButtonView buttonWithText:NSLocalizedString(@"Profile.ChannelMembers", nil) tapBlock:^{ + + + ComposeChannelParticipantsViewController *viewController = [[ComposeChannelParticipantsViewController alloc] initWithFrame:self.controller.view.bounds]; + + [viewController setAction:[[ComposeAction alloc] initWithBehaviorClass:[ComposeActionChannelMembersBehavior class] filter:@[] object:self.controller.chat reservedObjects:@[[TL_channelParticipantsRecent create]]]]; + + [self.controller.navigationViewController pushViewController:viewController animated:YES]; + + }]; + + [self addSubview:self.membersButton]; + + + self.enableCommentsButton = [UserInfoShortButtonView buttonWithText:NSLocalizedString(@"Profile.EnableComments", nil) tapBlock:nil]; + + + _commentsSwitch = [[ITSwitch alloc] initWithFrame:NSMakeRect(0, 0, 30, 20)]; + + + [_commentsSwitch setDidChangeHandler:^(BOOL isOn){ + + [RPCRequest sendRequest:[TLAPI_channels_toggleComments createWithChannel:weakSelf.controller.chat.inputPeer enabled:isOn] successHandler:^(id request, id response) { + + + + } errorHandler:^(id request, RpcError *error) { + + }]; + + + }]; + + [self.enableCommentsButton setRightContainer:_commentsSwitch]; + + + [self addSubview:self.enableCommentsButton]; + + + [self.setGroupPhotoButton.textButton setStringValue:NSLocalizedString(@"Profile.SetChannelPhoto", nil)]; + + [self.setGroupPhotoButton sizeToFit]; + + [self addSubview:self.linkEditButton]; + + self.linkEditButton.textButton.textColor = TEXT_COLOR; + self.setGroupPhotoButton.textButton.textColor = TEXT_COLOR; + self.addMembersButton.textButton.textColor = TEXT_COLOR; + self.enableCommentsButton.textButton.textColor = TEXT_COLOR; + self.managmentButton.textButton.textColor = TEXT_COLOR; + self.membersButton.textButton.textColor = TEXT_COLOR; + self.blackListButton.textButton.textColor = TEXT_COLOR; + self.exportChatInvite.textButton.textColor = TEXT_COLOR; + self.openOrJoinChannelButton = [UserInfoShortButtonView buttonWithText:NSLocalizedString(@"Profile.OpenChannel", nil) tapBlock:^{ + + [self.controller.navigationViewController gotoViewController:self.controller.messagesViewController]; + + }]; + + + [self addSubview:self.openOrJoinChannelButton]; + + } + + return self; +} + +- (void)reload { + + + TLChat *chat = self.controller.chat; + + self.avatarImageView.sourceType = ChatAvatarSourceChannel; + + [self rebuildOrigins]; + + _composeActionManagment = [[ComposeAction alloc] initWithBehaviorClass:[ComposeActionBehavior class] filter:@[] object:chat]; + + [[FullChatManager sharedManager] performLoad:chat.n_id callback:^(TLChatFull *fullChat) { + + self.controller.fullChat = fullChat; + + [self.managmentButton setRightContainer:[self buildTitleWithString:[NSString stringWithFormat:@"%d",fullChat.admins_count]]]; + [self.blackListButton setRightContainer:[self buildTitleWithString:[NSString stringWithFormat:@"%d",fullChat.kicked_count]]]; + [self.membersButton setRightContainer:[self buildTitleWithString:[NSString stringWithFormat:@"%d",fullChat.participants_count]]]; + + [self.aboutTextView setString:self.controller.fullChat.about]; + [self.aboutTextView controlTextDidChange:nil]; + + [self.statusTextField setChat:chat]; + [self.statusTextField sizeToFit]; + + if(!self.controller.fullChat) { + MTLog(@"full chat is not loading"); + return; + } + + + if(self.controller.chat.username.length > 0) { + + NSString *str = [NSString stringWithFormat:@"/%@",[self.controller.chat.username substringToIndex:MIN(20,self.controller.chat.username.length)]]; + + if(str.length == 21 && self.controller.chat.username.length > 20) { + str = [str stringByAppendingString:@"..."]; + } + + [self.linkEditButton setRightContainer:[self buildTitleWithString:str]]; + } else { + [self.linkEditButton setRightContainer:nil]; + + NSUInteger idx = [self.controller.fullChat.exported_invite.link rangeOfString:@"/joinchat"].location; + + + + [self.exportChatInvite setRightContainer:[self buildTitleWithString:[self.controller.fullChat.exported_invite.link substringWithRange:NSMakeRange(idx == NSNotFound ? 0 : idx, MIN(15, self.controller.fullChat.exported_invite.link.length - idx))]]]; + } + + + [_commentsSwitch setOn:!chat.isBroadcast]; + + [self.sharedLinksButton setConversation:self.controller.chat.dialog]; + [self.filesMediaButton setConversation:self.controller.chat.dialog]; + [self.sharedMediaButton setConversation:self.controller.chat.dialog]; + + [self buildNotificationsTitle]; + + + self.avatarImageView.sourceType = ChatAvatarSourceChannel; + [self.avatarImageView setChat:chat]; + [self.avatarImageView rebuild]; + + [self.nameTextField setChat:chat]; + + + int h = [self.linkView setString:self.controller.chat.usernameLink]; + + [self.linkView setFrameSize:NSMakeSize(NSWidth(self.linkView.frame), h+50)]; + + h = [self.aboutView setString:self.controller.fullChat.about]; + + [self.aboutView setFrameSize:NSMakeSize(NSWidth(self.linkView.frame), h+50)]; + + + [self TMNameTextFieldDidChanged:self.nameTextField]; + + + + [self rebuildOrigins]; + + }]; + +} + +-(TMTextField *)buildTitleWithString:(NSString *)str { + + TMTextField *textField = [TMTextField defaultTextField]; + + [[textField cell] setLineBreakMode:NSLineBreakByTruncatingTail]; + + NSMutableAttributedString *string = [[NSMutableAttributedString alloc] init]; + [string appendString:str withColor:NSColorFromRGB(0xa1a1a1)]; + + [string setFont:TGSystemFont(13) forRange:NSMakeRange(0, string.length)]; + + [textField setAttributedStringValue:string]; + + [textField sizeToFit]; + + return textField; +} + +-(void)rebuildOrigins { + + [self.exportChatInvite setHidden:YES]; + [self.sharedMediaButton setHidden:self.type == ChatInfoViewControllerEdit]; + [self.filesMediaButton setHidden:self.type == ChatInfoViewControllerEdit]; + [self.sharedLinksButton setHidden:self.type == ChatInfoViewControllerEdit]; + + [self.admins setHidden:YES]; + + + [self.linkView setHidden:self.type == ChatInfoViewControllerEdit || self.linkView.string.length == 0]; + [self.aboutView setHidden:self.type == ChatInfoViewControllerEdit || self.aboutView.string.length == 0]; + + + [self.exportChatInvite setHidden:self.type != ChatInfoViewControllerEdit || self.controller.chat.username.length > 0]; + + [self.editAboutContainer setHidden:self.type != ChatInfoViewControllerEdit]; + + [self.linkEditButton setHidden:self.type != ChatInfoViewControllerEdit || self.controller.chat.isMegagroup]; + [self.setGroupPhotoButton setHidden:self.type != ChatInfoViewControllerEdit]; + + + [self.openOrJoinChannelButton setHidden:self.controller.chat.isManager || self.controller.chat.isMegagroup]; + + + [self.managmentButton setHidden:!self.controller.chat.isManager]; + + [self.membersButton setHidden:!self.controller.chat.isManager]; + [self.blackListButton setHidden:self.type != ChatInfoViewControllerEdit || !self.controller.chat.isManager || self.controller.chat.isBroadcast]; + + + [self.enableCommentsButton setHidden:YES]; + + [self.addMembersButton setHidden:self.type == ChatInfoViewControllerEdit || !self.controller.chat.isAdmin || self.controller.fullChat.participants_count >= 200]; + + + int yOffset = 42; + + [self.notificationView setFrame:NSMakeRect(100, yOffset, NSWidth(self.frame) - 200, 42)]; + + yOffset+=42; + + if(!self.sharedLinksButton.isHidden) { + [self.sharedLinksButton setFrame:NSMakeRect(100, yOffset, NSWidth(self.frame) - 200, 42)]; + yOffset+=42; + } + + if(!self.filesMediaButton.isHidden) { + [self.filesMediaButton setFrame:NSMakeRect(100, yOffset, NSWidth(self.frame) - 200, 42)]; + yOffset+=42; + } + + if(!self.sharedMediaButton.isHidden) { + [self.sharedMediaButton setFrame:NSMakeRect(100, yOffset, NSWidth(self.frame) - 200, 42)]; + yOffset+=42; + } + + yOffset+=42; + + if(!self.addMembersButton.isHidden) { + + [self.addMembersButton setFrame:NSMakeRect(100, yOffset, NSWidth(self.frame) - 200, 42)]; + + yOffset+=42; + } + + if(!self.managmentButton.isHidden) { + [self.managmentButton setFrame:NSMakeRect(100, yOffset, NSWidth(self.frame) - 200, 42)]; + yOffset+=42; + } + + if(!self.membersButton.isHidden) { + [self.membersButton setFrame:NSMakeRect(100, yOffset, NSWidth(self.frame) - 200, 42)]; + + yOffset+=42; + } + + + if(!self.blackListButton.isHidden) { + [self.blackListButton setFrame:NSMakeRect(100, yOffset, NSWidth(self.frame) - 200, 42)]; + + yOffset+=42; + } + + + + + + if(!self.exportChatInvite.isHidden) { + + yOffset+=42; + + [self.exportChatInvite setFrame:NSMakeRect(100, yOffset, NSWidth(self.frame) - 200, NSHeight(self.exportChatInvite.frame))]; + + yOffset+=42; + + } + + + if(!self.openOrJoinChannelButton.isHidden) { + [self.openOrJoinChannelButton setFrame:NSMakeRect(100, yOffset, NSWidth(self.frame)-200, 42)]; + + yOffset+=NSHeight(self.openOrJoinChannelButton.frame); + } + + if(!self.linkView.isHidden || !self.aboutView.isHidden || !self.openOrJoinChannelButton.isHidden) { + yOffset+=42; + } + + + if(!self.aboutView.isHidden) { + [self.aboutView setFrame:NSMakeRect(100, yOffset, NSWidth(self.frame) - 200, NSHeight(self.aboutView.frame))]; + + yOffset+=NSHeight(self.aboutView.frame); + } + + if(!self.linkView.isHidden) { + [self.linkView setFrame:NSMakeRect(100, yOffset, NSWidth(self.frame) - 200, NSHeight(self.linkView.frame))]; + + yOffset+=NSHeight(self.linkView.frame); + } + + + + + if(!self.enableCommentsButton.isHidden) { + + [self.enableCommentsButton setFrame:NSMakeRect(100, yOffset, NSWidth(self.frame) - 200, 42)]; + + yOffset+=42; + } + + + if(!self.linkEditButton.isHidden) { + [self.linkEditButton setFrame:NSMakeRect(100, yOffset, NSWidth(self.frame) - 200, 42)]; + + yOffset+=NSHeight(self.linkEditButton.frame); + } + + if(!self.setGroupPhotoButton.isHidden) { + [self.setGroupPhotoButton setFrame:NSMakeRect(100, yOffset, NSWidth(self.frame) - 200, 42)]; + + yOffset+=NSHeight(self.setGroupPhotoButton.frame) + 42; + } + + + + + if(!self.editAboutContainer.isHidden) { + + [_aboutTextView scrollToEndOfDocument:self]; + + [_aboutTextView textDidChange:nil]; + + [_editAboutContainer setFrame:NSMakeRect(100, yOffset-14,NSWidth(self.frame) - 200, NSHeight(_editAboutContainer.frame))]; + yOffset+=50; + } + + + + + + [self.nameTextField setFrameOrigin:NSMakePoint(180, yOffset + (NSHeight(self.avatarImageView.frame)/2) + roundf(NSHeight(self.statusTextField.frame)/2 + NSHeight(self.nameTextField.frame)/2)) ]; + + [self.statusTextField setFrameOrigin:NSMakePoint(180, yOffset + (NSHeight(self.avatarImageView.frame)/2) )]; + + + [self.nameLiveView setFrameOrigin:NSMakePoint(182, NSMinY(self.nameTextField.frame) - 5)]; + + + [self.nameLiveView setFrameSize:NSMakeSize(NSWidth(self.frame) - NSMinX(self.nameLiveView.frame) - 100, NSHeight(self.nameLiveView.frame))]; + [self.nameTextField setFrameSize:NSMakeSize(NSWidth(self.frame) - NSMinX(self.nameTextField.frame) - 100, NSHeight(self.nameTextField.frame))]; + + + yOffset+=20; + + [self.avatarImageView setFrameOrigin:NSMakePoint(100, yOffset)]; + + + yOffset+=100; + + [self setFrameSize:NSMakeSize(NSWidth(self.frame), yOffset)]; + + [self.controller buildFirstItem]; + + +} + +-(void)setFrameSize:(NSSize)newSize { + [super setFrameSize:newSize]; + + [_editAboutContainer setFrameSize:NSMakeSize(newSize.width - 200, NSHeight(_editAboutContainer.frame))]; + + [_aboutTextView.containerView setFrameSize:NSMakeSize(NSWidth(_editAboutContainer.frame), NSHeight(_aboutTextView.containerView.frame))]; + [_aboutDescription setFrameSize:NSMakeSize(NSWidth(_editAboutContainer.frame)+10, 18)]; + + [_aboutTextView.containerView setFrameOrigin:NSMakePoint(-5, 16)]; + + [self.nameLiveView setFrameSize:NSMakeSize(NSWidth(self.frame) - NSMinX(self.nameLiveView.frame) - 100, NSHeight(self.nameLiveView.frame))]; + + + [self.nameTextField sizeToFit]; + + [self.nameTextField setFrameSize:NSMakeSize(MIN(NSWidth(self.frame) - NSMinX(self.nameTextField.frame) - 100,NSWidth(self.nameTextField.frame)), NSHeight(self.nameTextField.frame))]; + +} + +-(void)save { + dispatch_block_t block = ^{ + self.controller.type = ChatInfoViewControllerNormal; + [self reload]; + + [self.controller hideModalProgress]; + }; + + + dispatch_block_t next = ^{ + + if(![self.controller.fullChat.about isEqualToString:self.aboutTextView.stringValue]) { + + + + [RPCRequest sendRequest:[TLAPI_channels_editAbout createWithChannel:self.controller.chat.inputPeer about:self.aboutTextView.stringValue] successHandler:^(RPCRequest *request, id response) { + + if(self.controller.fullChat != nil) { + self.controller.fullChat.about = [request.object about]; + + [[Storage manager] insertFullChat:self.controller.fullChat completeHandler:nil]; + } else { + [[FullChatManager sharedManager] loadIfNeed:self.controller.chat.n_id force:YES]; + } + + + block(); + } errorHandler:^(id request, RpcError *error) { + block(); + }]; + + } else { + block(); + } + + }; + + [self.controller showModalProgress]; + + if(![self.nameTextField.stringValue isEqualToString:self.controller.chat.title] && self.nameTextField.stringValue.length > 0) { + + [RPCRequest sendRequest:[TLAPI_channels_editTitle createWithChannel:self.controller.chat.inputPeer title:self.nameTextField.stringValue] successHandler:^(RPCRequest *request, id response) { + next(); + } errorHandler:^(RPCRequest *request, RpcError *error) { + next(); + }]; + } else + next(); +} + + +-(void)setType:(ChatInfoViewControllerType)type { + [super setType:type]; + + [self reload]; +} + + +@end diff --git a/TelegramTest/ChannelInfoViewController.h b/TelegramTest/ChannelInfoViewController.h new file mode 100644 index 00000000..8ebde82b --- /dev/null +++ b/TelegramTest/ChannelInfoViewController.h @@ -0,0 +1,13 @@ +// +// ChannelInfoViewController.h +// Telegram +// +// Created by keepcoder on 21.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "ChatInfoViewController.h" + +@interface ChannelInfoViewController : ChatInfoViewController + +@end diff --git a/TelegramTest/ChannelInfoViewController.m b/TelegramTest/ChannelInfoViewController.m new file mode 100644 index 00000000..db839edb --- /dev/null +++ b/TelegramTest/ChannelInfoViewController.m @@ -0,0 +1,75 @@ +// +// ChannelInfoViewController.m +// Telegram +// +// Created by keepcoder on 21.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "ChannelInfoViewController.h" +#import "ChannelInfoHeaderView.h" +#import "ChatParticipantItem.h" +#import "ComposeActionAddChannelModeratorBehavior.h" +#import "TGSettingsTableView.h" + + +@interface ChannelInfoViewController () +@end + +@implementation ChannelInfoViewController + +-(void)loadView { + [super loadView]; + self.headerView = [[ChannelInfoHeaderView alloc] initWithFrame:NSMakeRect(0, 0, self.view.bounds.size.width, 350)]; + +} + + +-(void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; + [super setType:ChatInfoViewControllerNormal]; +} + +-(void)setType:(ChatInfoViewControllerType)type { + [super setType:type]; + + [self reloadParticipants]; +} + +-(void)save { + [self.headerView save]; +} + +-(void)setChat:(TLChat *)chat { + [super setChat:chat]; + + [self.rightNavigationBarView setHidden:!self.chat.isAdmin]; +} + +-(void)buildRightView { + [super buildRightView]; + [self.rightNavigationBarView setHidden:!self.chat.isAdmin]; +} + +- (void)reloadParticipants { + [self.tableView removeAllItems:NO]; + [self.tableView addItem:self.headerItem tableRedraw:NO]; + + + if(self.chat.isAdmin) { + if(self.type == ChatInfoViewControllerEdit) + [self.tableView addItem:self.bottomItem tableRedraw:NO]; + } else { + if(!self.chat.dialog.invisibleChannel) + [self.tableView addItem:self.bottomItem tableRedraw:NO]; + } + + + + + [self.tableView reloadData]; +} + + + +@end diff --git a/TelegramTest/ChannelsManager.h b/TelegramTest/ChannelsManager.h new file mode 100644 index 00000000..a1e57b99 --- /dev/null +++ b/TelegramTest/ChannelsManager.h @@ -0,0 +1,13 @@ +// +// ChannelsManager.h +// Telegram +// +// Created by keepcoder on 09.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "SharedManager.h" + +@interface ChannelsManager : SharedManager + +@end diff --git a/TelegramTest/ChannelsManager.m b/TelegramTest/ChannelsManager.m new file mode 100644 index 00000000..22d816dd --- /dev/null +++ b/TelegramTest/ChannelsManager.m @@ -0,0 +1,66 @@ +// +// ChannelsManager.m +// Telegram +// +// Created by keepcoder on 09.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "ChannelsManager.h" + +@implementation ChannelsManager + +- (void)add:(NSArray *)all { + + [self.queue dispatchOnQueue:^{ + [all enumerateObjectsUsingBlock:^(TL_conversation * dialog, NSUInteger idx, BOOL *stop) { + TL_conversation *current = [keys objectForKey:@(dialog.peer_id)]; + if(current) { + current.unread_count = dialog.unread_count; + current.top_message = dialog.top_message; + current.last_message_date = dialog.last_message_date; + current.notify_settings = dialog.notify_settings; + current.fake = dialog.fake; + current.last_marked_message = dialog.last_marked_message; + current.top_message_fake = dialog.top_message_fake; + current.last_marked_date = dialog.last_marked_date; + current.last_real_message_date = dialog.last_real_message_date; + current.dstate = dialog.dstate; + current.read_inbox_max_id = dialog.read_inbox_max_id; + current.top_important_message = dialog.top_important_message; + current.unread_important_count = dialog.unread_important_count; + current.invisibleChannel = dialog.invisibleChannel; + current.lastMessage = dialog.lastMessage; + } else { + [self->list addObject:dialog]; + [self->keys setObject:dialog forKey:@(dialog.peer_id)]; + current = dialog; + } + + if(!current.notify_settings) { + current.notify_settings = [TL_peerNotifySettingsEmpty create]; + [current save]; + } + + [self resort]; + + }]; + }]; +} + ++(id)sharedManager { + static id instance; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + + instance = [[[self class] alloc] initWithQueue:[ASQueue globalQueue]]; + }); + return instance; +} + + +-(void)resort { +} + + +@end diff --git a/TelegramTest/ChatAdminsViewController.h b/TelegramTest/ChatAdminsViewController.h new file mode 100644 index 00000000..be36fd65 --- /dev/null +++ b/TelegramTest/ChatAdminsViewController.h @@ -0,0 +1,16 @@ +// +// ChatAdminsViewController.h +// Telegram +// +// Created by keepcoder on 29/10/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "TMViewController.h" + +@interface ChatAdminsViewController : TMViewController + + +@property (nonatomic,weak) TLChat *chat; + +@end diff --git a/TelegramTest/ChatAdminsViewController.m b/TelegramTest/ChatAdminsViewController.m new file mode 100644 index 00000000..9188f037 --- /dev/null +++ b/TelegramTest/ChatAdminsViewController.m @@ -0,0 +1,205 @@ +// +// ChatAdminsViewController.m +// Telegram +// +// Created by keepcoder on 29/10/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "ChatAdminsViewController.h" +#import "TGSettingsTableView.h" +#import "TGUserContainerRowItem.h" +#import "TGSearchRowItem.h" +@interface ChatAdminsViewController () +@property (nonatomic,strong) TGSettingsTableView *tableView; + + + +@end + +@implementation ChatAdminsViewController + +-(void)loadView { + [super loadView]; + + [self setCenterBarViewText:NSLocalizedString(@"Chat.Administrators", nil)]; + + _tableView = [[TGSettingsTableView alloc] initWithFrame:self.view.bounds]; + + [self.view addSubview:_tableView.containerView]; +} + +-(void)setChat:(TLChat *)chat { + _chat = chat; + + [self loadViewIfNeeded]; + + [self reloadData]; +} + + +-(void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; + + [Notification addObserver:self selector:@selector(didChangeChatFlags:) name:CHAT_FLAGS_UPDATED]; + [Notification addObserver:self selector:@selector(updateParticipantsNotification:) name:CHAT_UPDATE_PARTICIPANTS]; + + [self reloadData]; +} + +- (void)updateParticipantsNotification:(NSNotification *)notify { + int chat_id = [[notify.userInfo objectForKey:KEY_CHAT_ID] intValue]; + + if(self.chat.n_id == chat_id) { + [self reloadData]; + } + + +} + +-(void)didChangeChatFlags:(NSNotification *)notification { + TLChat *chat = notification.userInfo[KEY_CHAT]; + + if(self.chat == chat) { + [self reloadData]; + } +} + +-(void)viewWillDisappear:(BOOL)animated { + [super viewWillDisappear:animated]; + [Notification removeObserver:self]; +} + + +-(void)reloadData { + + [_tableView removeAllItems:YES]; + + GeneralSettingsRowItem *header = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSwitch callback:^(TGGeneralRowItem *item) { + + [self showModalProgress]; + + [RPCRequest sendRequest:[TLAPI_messages_toggleChatAdmins createWithChat_id:_chat.n_id enabled:!self.chat.isAdmins_enabled] successHandler:^(id request, id response) { + + [self hideModalProgressWithSuccess]; + + [SharedManager proccessGlobalResponse:response]; + + + [self reloadData]; + + + } errorHandler:^(id request, RpcError *error) { + + [self hideModalProgress]; + }]; + + } description:NSLocalizedString(@"Chat.SwitchAllAdmins", nil) height:62 stateback:^id(TGGeneralRowItem *item) { + + return @(!self.chat.isAdmins_enabled); + + }]; + + + [_tableView addItem:header tableRedraw:NO]; + + GeneralSettingsBlockHeaderItem *fakeItem = [[GeneralSettingsBlockHeaderItem alloc] initWithString:self.chat.isAdmins_enabled ? NSLocalizedString(@"Chat.SwitchAdminsDescriptionOff", nil) : NSLocalizedString(@"Chat.SwitchAdminsDescription", nil) height:42 flipped:YES]; + + [_tableView addItem:fakeItem tableRedraw:NO]; + + + + TGSearchRowItem *searchItem = [[TGSearchRowItem alloc] init]; + searchItem.height = 50; + + searchItem.delegate = self; + + [_tableView addItem:searchItem tableRedraw:NO]; + + [_tableView reloadData]; + + [self searchFieldTextChange:@""]; + + +} + +- (void) searchFieldTextChange:(NSString*)searchString { + + [_tableView removeItemsInRange:NSMakeRange(3, _tableView.count - 3) tableRedraw:YES]; + + NSArray *participants = [_chat.chatFull.participants.participants copy]; + + [participants enumerateObjectsUsingBlock:^(TLChatParticipant *obj, NSUInteger idx, BOOL * _Nonnull stop) { + + TLUser *user = [[UsersManager sharedManager] find:obj.user_id]; + + if(![obj isKindOfClass:[TL_chatParticipantCreator class]] && (searchString.length == 0 || [user.fullName searchInStringByWordsSeparated:searchString])) { + + TLUser *user = [[UsersManager sharedManager] find:obj.user_id]; + TGUserContainerRowItem *userItem = [[TGUserContainerRowItem alloc] initWithUser:user]; + userItem.height = 42; + userItem.type = SettingsRowItemTypeSelected; + + BOOL isAdmin = ([obj isKindOfClass:[TL_chatParticipantAdmin class]] || [obj isKindOfClass:[TL_chatParticipantCreator class]]) && self.chat.isAdmins_enabled; + + [userItem setStateback:^id(TGGeneralRowItem *i) { + + return @(isAdmin); + + }]; + + + if(self.chat.isAdmins_enabled) { + [userItem setStateCallback:^ { + + confirm(appName(), !isAdmin ? NSLocalizedString(@"Chat.ToggleUserToAdminConfirm", nil) : NSLocalizedString(@"Chat.ToggleAdminToUserConfirm", nil), ^{ + + [self showModalProgress]; + + [RPCRequest sendRequest:[TLAPI_messages_editChatAdmin createWithChat_id:self.chat.n_id user_id:user.inputUser is_admin:!isAdmin] successHandler:^(id request, id response) { + + if([response isKindOfClass:[TL_boolTrue class]]) { + + [[FullChatManager sharedManager] loadIfNeed:self.chat.n_id force:YES]; + + + NSArray *f = [_chat.chatFull.participants.participants filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.user_id == %d",user.n_id]]; + + if(f.count == 1) + { + TLChatParticipant *participant = [f firstObject]; + + TLChatParticipant *newParticipant = !isAdmin ? [TL_chatParticipantAdmin createWithUser_id:participant.user_id inviter_id:participant.inviter_id date:participant.date] : [TL_chatParticipant createWithUser_id:participant.user_id inviter_id:participant.inviter_id date:participant.date]; + + [_chat.chatFull.participants.participants replaceObjectAtIndex:[_chat.chatFull.participants.participants indexOfObject:participant] withObject:newParticipant]; + + [ASQueue dispatchOnMainQueue:^{ + [self reloadData]; + }]; + + } + + } + + [self hideModalProgressWithSuccess]; + + } errorHandler:^(id request, RpcError *error) { + [self hideModalProgress]; + } timeout:0 queue:[ASQueue globalQueue].nativeQueue]; + + }, nil); + + }]; + } + + + [_tableView addItem:userItem tableRedraw:YES]; + + } + + + }]; + +} + +@end diff --git a/TelegramTest/ChatAvatarImageView.h b/TelegramTest/ChatAvatarImageView.h index d3b77b1c..1f71c2c8 100644 --- a/TelegramTest/ChatAvatarImageView.h +++ b/TelegramTest/ChatAvatarImageView.h @@ -15,14 +15,15 @@ typedef enum { ChatAvatarSourceUser, ChatAvatarSourceGroup, - ChatAvatarSourceBroadcast + ChatAvatarSourceBroadcast, + ChatAvatarSourceChannel } ChatAvatarSourceType; @property (nonatomic,assign) ChatAvatarSourceType sourceType; -@property (nonatomic,strong) TLUser *user; -@property (nonatomic,strong) TLChat *chat; + +@property (nonatomic,assign,getter=isEditable) BOOL editable; @property (nonatomic, strong) ChatInfoViewController *controller; - (void)rebuild; diff --git a/TelegramTest/ChatAvatarImageView.m b/TelegramTest/ChatAvatarImageView.m index 813b268f..ad3dcfd3 100644 --- a/TelegramTest/ChatAvatarImageView.m +++ b/TelegramTest/ChatAvatarImageView.m @@ -9,7 +9,7 @@ #import "ChatAvatarImageView.h" #import "ImageUtils.h" #import "TMLoaderView.h" - +#import "TGPhotoViewer.h" @interface AvatarUpdaterItem : NSObject @property (nonatomic, strong) UploadOperation *operation; @property (nonatomic, strong) RPCRequest *request; @@ -24,6 +24,11 @@ @interface ChatAvatarImageView() @property (nonatomic, strong) TMView *progressContainer; @property (nonatomic, strong) BTRButton *cancelButton; @property (nonatomic, strong) AvatarUpdaterItem *updaterItem; + +@property (nonatomic,strong) NSImageView *editCamera; + +@property (nonatomic,strong) TMView *editBlank; + @end @implementation ChatAvatarImageView @@ -35,12 +40,62 @@ - (id)initWithFrame:(NSRect)frame [self addSubview:self.progressContainer]; self.sourceType = ChatAvatarSourceGroup; + [self setFont:TGSystemLightFont(18)]; - + + _editCamera = imageViewWithImage(image_EditPhotoCamera()); + + + + _editBlank = [[TMView alloc] initWithFrame:self.bounds]; + + _editBlank.wantsLayer = YES; + _editBlank.layer.backgroundColor = [NSColor blackColor].CGColor; + _editBlank.layer.opacity = 0.7; + _editBlank.layer.cornerRadius = NSWidth(self.frame)/2; + + [self addSubview:_editBlank]; + + [_editBlank setHidden:YES]; + + [_editCamera setCenterByView:self]; + [self addSubview:_editCamera]; + + [_editCamera setHidden:YES]; + + + } return self; } +-(void)updateWithConversation:(TL_conversation *)conversation { + [super updateWithConversation:conversation]; + + switch (conversation.type) { + case DialogTypeBroadcast: + _sourceType = ChatAvatarSourceBroadcast; + break; + case DialogTypeChannel: + _sourceType = ChatAvatarSourceChannel; + break; + case DialogTypeUser: + _sourceType = ChatAvatarSourceUser; + break; + default: + break; + } +} + + +-(void)setEditable:(BOOL)editable { + _editable = editable; + + [_editCamera setHidden:!editable]; + + [_editBlank setHidden:!editable]; +} + - (void)drawRect:(NSRect)dirtyRect { [super drawRect:dirtyRect]; @@ -83,6 +138,44 @@ -(TMView *)progressContainer { } +-(void)mouseDown:(NSEvent *)theEvent { + [super mouseDown:theEvent]; + + + if(self.isEditable) + { + [self rightMouseDown:theEvent]; + + return; + } + + PreviewObject *previewObject; + + if(self.sourceType == ChatAvatarSourceUser) { + if(![self.user.photo isKindOfClass:[TL_userProfilePhotoEmpty class]] && self.user.photo != nil) { + + previewObject = [[PreviewObject alloc] initWithMsdId:NSIntegerMax media:[TL_photoSize createWithType:@"x" location:self.user.photo.photo_big w:640 h:640 size:0] peer_id:self.user.n_id]; + + previewObject.reservedObject = [TGCache cachedImage:self.user.photo.photo_small.cacheKey]; + + + [[TGPhotoViewer viewer] show:previewObject user:self.user]; + } + } else { + + if(![self.chat.photo isKindOfClass:[TL_chatPhotoEmpty class]] && self.chat.photo != nil) { + + + previewObject = [[PreviewObject alloc] initWithMsdId:NSIntegerMax media:[TL_photoSize createWithType:@"x" location:self.chat.photo.photo_big w:640 h:640 size:0] peer_id:self.chat.n_id]; + + previewObject.reservedObject = [TGCache cachedImage:self.chat.photo.photo_big.cacheKey]; + + [[TGPhotoViewer viewer] show:previewObject]; + } + } + +} + - (void)rightMouseDown:(NSEvent *)theEvent { [super rightMouseDown:theEvent]; @@ -96,7 +189,7 @@ - (void)rightMouseDown:(NSEvent *)theEvent { }]]; } else { - if(self.sourceType == ChatAvatarSourceBroadcast || self.sourceType == ChatAvatarSourceGroup || (self.sourceType == ChatAvatarSourceUser && self.user.type == TLUserTypeSelf)) { + if(self.sourceType == ChatAvatarSourceBroadcast || self.sourceType == ChatAvatarSourceGroup || self.sourceType == ChatAvatarSourceChannel || (self.sourceType == ChatAvatarSourceUser && self.user.type == TLUserTypeSelf)) { [menu addItem:[NSMenuItem menuItemWithTitle:NSLocalizedString(@"Profile.UpdatePhoto", nil) withBlock:^(id sender) { [strongSelf showUpdateChatPhotoBox]; @@ -273,12 +366,19 @@ - (void)updateChatPhoto:(NSImage *)image { }; + if(self.sourceType == ChatAvatarSourceGroup) { + request = [TLAPI_messages_editChatPhoto createWithChat_id:lockId photo:[TL_inputChatPhotoEmpty create]]; + } else if(self.sourceType == ChatAvatarSourceChannel) { + request = [TLAPI_channels_editPhoto createWithChannel:self.chat.inputPeer photo:[TL_inputChatPhotoEmpty create]]; + } else { + request = [TLAPI_photos_updateProfilePhoto createWithN_id:[TL_inputPhotoEmpty create] crop:[TL_inputPhotoCropAuto create]]; + } + + if(!image) { - if(self.sourceType == ChatAvatarSourceGroup) { - request = [TLAPI_messages_editChatPhoto createWithChat_id:lockId photo:[TL_inputChatPhotoEmpty create]]; + if(self.sourceType == ChatAvatarSourceGroup || self.sourceType == ChatAvatarSourceChannel) { groupBlock(); - } else { - request = [TLAPI_photos_updateProfilePhoto createWithN_id:[TL_inputPhotoEmpty create] crop:[TL_inputPhotoCropAuto create]]; + } else { userBlock(); } @@ -287,11 +387,19 @@ - (void)updateChatPhoto:(NSImage *)image { UploadOperation *operation = [[UploadOperation alloc] init]; [operation setUploadComplete:^(UploadOperation *operation, id input) { + + if(self.sourceType == ChatAvatarSourceGroup) { request = [TLAPI_messages_editChatPhoto createWithChat_id:lockId photo:[TL_inputChatUploadedPhoto createWithFile:input crop:[TL_inputPhotoCropAuto create]]]; - groupBlock(); + } else if(self.sourceType == ChatAvatarSourceChannel) { + request = [TLAPI_channels_editPhoto createWithChannel:self.chat.inputPeer photo:[TL_inputChatUploadedPhoto createWithFile:input crop:[TL_inputPhotoCropAuto create]]]; } else { request = [TLAPI_photos_uploadProfilePhoto createWithFile:input caption:@"me" geo_point:[TL_inputGeoPointEmpty create] crop:[TL_inputPhotoCropAuto create]]; + } + + if(self.sourceType == ChatAvatarSourceGroup || self.sourceType == ChatAvatarSourceChannel) { + groupBlock(); + } else { userBlock(); } }]; diff --git a/TelegramTest/ChatExportLinkViewController.m b/TelegramTest/ChatExportLinkViewController.m index f4d8a9c9..e3a0db72 100644 --- a/TelegramTest/ChatExportLinkViewController.m +++ b/TelegramTest/ChatExportLinkViewController.m @@ -46,43 +46,81 @@ -(void)rebuild { [self.tableView removeAllItems:YES]; - GeneralSettingsRowItem *copyLink = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(GeneralSettingsRowItem *item) { + dispatch_block_t cblock = ^{ + NSPasteboard* cb = [NSPasteboard generalPasteboard]; + + [cb declareTypes:[NSArray arrayWithObjects:NSStringPboardType, nil] owner:self]; + [cb setString:_chat.exported_invite.link forType:NSStringPboardType]; + }; + + GeneralSettingsRowItem *copyLink = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(TGGeneralRowItem *item) { if([_chat.exported_invite isKindOfClass:[TL_chatInviteExported class]]) { - [TMViewController showModalProgress]; - - NSPasteboard* cb = [NSPasteboard generalPasteboard]; + [self showModalProgress]; - [cb declareTypes:[NSArray arrayWithObjects:NSStringPboardType, nil] owner:self]; - [cb setString:_chat.exported_invite.link forType:NSStringPboardType]; + cblock(); dispatch_after_seconds(0.2, ^{ - [TMViewController hideModalProgressWithSuccess]; + [self hideModalProgressWithSuccess]; }); + } else if([_chat.exported_invite isKindOfClass:[TL_chatInviteEmpty class]]) { + + [self showModalProgress]; + + id request = [TLAPI_messages_exportChatInvite createWithChat_id:_chat.n_id]; + + TLChat *chat = [[ChatsManager sharedManager] find:self.chat.n_id]; + + if([chat isKindOfClass:[TL_channel class]]) { + request = [TLAPI_channels_exportInvite createWithChannel:chat.inputPeer]; + } + + [RPCRequest sendRequest:request successHandler:^(RPCRequest *request, TL_chatInviteExported *response) { + + [self hideModalProgressWithSuccess]; + + _chat.exported_invite = response; + + [[Storage manager] insertFullChat:_chat completeHandler:nil]; + + cblock(); + + + } errorHandler:^(RPCRequest *request, RpcError *error) { + [self hideModalProgress]; + } timeout:10]; } - } description:NSLocalizedString(@"ChatExportLink.CopyLink", nil) height:62 stateback:^id(GeneralSettingsRowItem *item) { + } description:NSLocalizedString(@"ChatExportLink.CopyLink", nil) height:62 stateback:^id(TGGeneralRowItem *item) { return nil; }]; [self.tableView insert:copyLink atIndex:self.tableView.list.count tableRedraw:NO]; - GeneralSettingsRowItem *revokeLink = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(GeneralSettingsRowItem *item) { + GeneralSettingsRowItem *revokeLink = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(TGGeneralRowItem *item) { confirm(appName(), NSLocalizedString(@"ChatExportLink.RevokeConfirm", nil), ^{ - [TMViewController showModalProgress]; + [self showModalProgress]; - [RPCRequest sendRequest:[TLAPI_messages_exportChatInvite createWithChat_id:_chat.n_id] successHandler:^(RPCRequest *request, TL_chatInviteExported *response) { + id request = [TLAPI_messages_exportChatInvite createWithChat_id:_chat.n_id]; + + TLChat *chat = [[ChatsManager sharedManager] find:self.chat.n_id]; + + if([chat isKindOfClass:[TL_channel class]]) { + request = [TLAPI_channels_exportInvite createWithChannel:chat.inputPeer]; + } + + [RPCRequest sendRequest:request successHandler:^(RPCRequest *request, TL_chatInviteExported *response) { - [TMViewController hideModalProgressWithSuccess]; + [self hideModalProgressWithSuccess]; _chat.exported_invite = response; @@ -91,13 +129,13 @@ -(void)rebuild { alert(nil, NSLocalizedString(@"ChatExportLink.Alert.Revoked", nil)); } errorHandler:^(RPCRequest *request, RpcError *error) { - [TMViewController hideModalProgress]; + [self hideModalProgress]; } timeout:10]; }, nil); - } description:NSLocalizedString(@"ChatExportLink.RevokeLink", nil) height:42 stateback:^id(GeneralSettingsRowItem *item) { + } description:NSLocalizedString(@"ChatExportLink.RevokeLink", nil) height:42 stateback:^id(TGGeneralRowItem *item) { return nil; }]; @@ -105,11 +143,7 @@ -(void)rebuild { [self.tableView insert:revokeLink atIndex:self.tableView.list.count tableRedraw:NO]; - GeneralSettingsBlockHeaderItem *description = [[GeneralSettingsBlockHeaderItem alloc] initWithObject:[NSString stringWithFormat:NSLocalizedString(@"ChatExportLink.Description", nil)]]; - - description.height = 100; - - description.isFlipped = YES; + GeneralSettingsBlockHeaderItem *description = [[GeneralSettingsBlockHeaderItem alloc] initWithString:[NSString stringWithFormat:NSLocalizedString(@"ChatExportLink.Description", nil)] height:100 flipped:YES]; [self.tableView insert:description atIndex:self.tableView.count tableRedraw:NO]; diff --git a/TelegramTest/ChatHistoryController.h b/TelegramTest/ChatHistoryController.h index d7fc9bf6..f1764d14 100644 --- a/TelegramTest/ChatHistoryController.h +++ b/TelegramTest/ChatHistoryController.h @@ -11,19 +11,15 @@ #import "SenderListener.h" #import "HistoryFilter.h" +#import "TGHistoryResponse.h" + -@interface ChatHistoryController : NSObject +@interface ChatHistoryController : NSObject -typedef enum { - ChatHistoryStateCache = 0, - ChatHistoryStateLocal = 1, - ChatHistoryStateRemote = 2, - ChatHistoryStateFull = 3 -} ChatHistoryState; -@property (atomic,assign) ChatHistoryState nextState; -@property (atomic,assign) ChatHistoryState prevState; +-(ChatHistoryState)prevState; +-(ChatHistoryState)nextState; //@property (nonatomic,strong,readonly) TL_conversation *conversation; @property (nonatomic,readonly) id controller; @@ -31,38 +27,33 @@ typedef enum { -(BOOL)isProccessing; - @property (nonatomic,assign) BOOL need_save_to_db; -@property (nonatomic,assign) int max_id; -@property (nonatomic,assign) int min_id; - -@property (nonatomic,assign) int start_min; - - -@property (nonatomic,assign) int server_max_id; -@property (nonatomic,assign) int server_min_id; - -@property (nonatomic,assign) int server_start_min; - -@property (nonatomic,assign) int minDate; -@property (nonatomic,assign) int maxDate; @property (nonatomic,assign) NSUInteger selectLimit; // default = 70; +-(void)prevStateAsync:(void (^)(ChatHistoryState state))block; +-(void)nextStateAsync:(void (^)(ChatHistoryState state))block; - +-(HistoryFilter *)filterWithNext:(BOOL)next; +-(HistoryFilter *)filterWithPeerId:(int)peer_id; +-(HistoryFilter *)filterAtIndex:(int)index; -(HistoryFilter *)filter; -(void)setFilter:(HistoryFilter *)filter; - --(id)initWithController:(id)controller; +-(void)addFilter:(HistoryFilter *)filter; -(id)initWithController:(id)controller historyFilter:(Class)historyFilter; -typedef void (^selectHandler)(NSArray *result, NSRange range); + +typedef void (^selectHandler)(NSArray *result, NSRange range, id controller); -(void)request:(BOOL)next anotherSource:(BOOL)anotherSource sync:(BOOL)sync selectHandler:(selectHandler)selectHandler; + +-(void)loadAroundMessagesWithMessage:(TL_localMessage *)msg prevLimit:(int)prevLimit nextLimit:(int)nextLimit selectHandler:(selectHandler)selectHandler; +-(void)loadAroundMessagesWithSelectHandler:(selectHandler)selectHandler prevLimit:(int)prevLimit nextLimit:(int)nextLimit prevResult:(NSMutableArray *)prevResult nextResult:(NSMutableArray *)nextResult; + + -(void)addItem:(MessageTableItem *)item; -(void)addItems:(NSArray *)items conversation:(TL_conversation *)conversation; -(void)addItems:(NSArray *)items conversation:(TL_conversation *)conversation sentControllerCallback:(dispatch_block_t)sentControllerCallback; @@ -71,12 +62,27 @@ typedef void (^selectHandler)(NSArray *result, NSRange range); -(void)addItem:(MessageTableItem *)item conversation:(TL_conversation *)conversation callback:(dispatch_block_t)callback sentControllerCallback:(dispatch_block_t)sentControllerCallback; -(void)addItems:(NSArray *)items conversation:(TL_conversation *)conversation callback:(dispatch_block_t)callback sentControllerCallback:(dispatch_block_t)sentControllerCallback; +-(void)addMessageWithoutSavingState:(TL_localMessage *)message; --(void)removeAllItems; +-(void)swapFiltersBeforePrevLoaded; +-(BOOL)isNeedSwapFilters; -+(void)drop; -(void)drop:(BOOL)dropMemory; +-(void)startChannelPolling; +-(void)stopChannelPolling; +-(void)startChannelPollingIfAlreadyStoped; -(TL_conversation *)conversation; + +-(void)items:(NSArray *)msgIds complete:(void (^)(NSArray *list))complete; + +-(int)itemsCount; + +// protected methods + +-(ASQueue *)queue; + +-(void)setProccessing:(BOOL)isProccessing; +-(void)performCallback:(selectHandler)selectHandler result:(NSArray *)result range:(NSRange )range controller:(ChatHistoryController *)controller; @end diff --git a/TelegramTest/ChatHistoryController.m b/TelegramTest/ChatHistoryController.m index 3d34badf..f8e92158 100644 --- a/TelegramTest/ChatHistoryController.m +++ b/TelegramTest/ChatHistoryController.m @@ -1,3 +1,5 @@ + + // // ChatHistoryController.m // Messenger for Telegram @@ -22,37 +24,37 @@ #import "MP3HistoryFilter.h" #import "TGTimer.h" #import "TGProccessUpdates.h" +#import "ChannelFilter.h" +#import "TGChannelsPolling.h" +#import "ChannelImportantFilter.h" +#import "WeakReference.h" +#import "MegagroupChatFilter.h" @interface ChatHistoryController () -@property (nonatomic,strong) NSMutableArray * messageItems; -@property (nonatomic,strong) NSMutableDictionary * messageKeys; - @property (atomic) dispatch_semaphore_t semaphore; @property (atomic,assign) int requestCounter; -@property (nonatomic,strong) HistoryFilter *h_filter; @property (atomic,assign) BOOL proccessing; + +@property (nonatomic,strong) TL_conversation *conversation; + +@property (nonatomic,strong) NSString *internalId; + +@property (nonatomic,strong) NSMutableArray *filters; + +@property (nonatomic,assign) BOOL isNeedSwapFilters; + @end @implementation ChatHistoryController -@synthesize messageItems = messageItems; -@synthesize messageKeys = messageKeys; -static NSMutableArray *filters; static ASQueue *queue; static NSMutableArray *listeners; --(id)initWithController:(id)controller { - if(self = [self initWithController:controller historyFilter:[HistoryFilter class]]) { - - } - - return self; -} - +static ChatHistoryController *observer; -(id)initWithController:(id)controller historyFilter:(Class)historyFilter { if(self = [super init]) { @@ -62,821 +64,686 @@ -(id)initWithController:(id)controller historyFilter:(Class)hi queue = [ASQueue globalQueue]; - filters = [[NSMutableArray alloc] init]; - [filters addObject:[HistoryFilter class]]; - [filters addObject:[PhotoHistoryFilter class]]; - [filters addObject:[PhotoVideoHistoryFilter class]]; - [filters addObject:[DocumentHistoryFilter class]]; - [filters addObject:[VideoHistoryFilter class]]; - [filters addObject:[AudioHistoryFilter class]]; - [filters addObject:[MP3HistoryFilter class]]; - [filters addObject:[SharedLinksHistoryFilter class]]; listeners = [[NSMutableArray alloc] init]; - }); - - - [queue dispatchOnQueue:^{ - [listeners addObject:self]; + observer = [[ChatHistoryController alloc] init]; - - // self.controller.conversation = conversation; - _controller = controller; + [Notification addObserver:observer selector:@selector(notificationReceiveMessages:) name:MESSAGE_LIST_RECEIVE]; + [Notification addObserver:observer selector:@selector(notificationReceiveMessage:) name:MESSAGE_RECEIVE_EVENT]; - self.semaphore = dispatch_semaphore_create(1); + [Notification addObserver:observer selector:@selector(notificationDeleteMessage:) name:MESSAGE_DELETE_EVENT]; - _selectLimit = 50; - [self setFilter:[[historyFilter alloc] initWithController:self]]; - _need_save_to_db = YES; + [Notification addObserver:observer selector:@selector(notificationFlushHistory:) name: MESSAGE_FLUSH_HISTORY]; + + [Notification addObserver:observer selector:@selector(notificationUpdateMessageId:) name:MESSAGE_UPDATE_MESSAGE_ID]; + + }); - - } synchronous:YES]; + _internalId = [NSString stringWithFormat:@"%ld",rand_long()]; - [Notification addObserver:self selector:@selector(notificationReceiveMessages:) name:MESSAGE_LIST_RECEIVE]; + _conversation = [controller conversation]; - [Notification addObserver:self selector:@selector(notificationReceiveMessage:) name:MESSAGE_RECEIVE_EVENT]; + [listeners addObject:[WeakReference weakReferenceWithObject:self]]; - [Notification addObserver:self selector:@selector(notificationDeleteMessage:) name:MESSAGE_DELETE_EVENT]; - [Notification addObserver:self selector:@selector(notificationFlushHistory:) name: MESSAGE_FLUSH_HISTORY]; + _filters = [NSMutableArray array]; - [Notification addObserver:self selector:@selector(notificationDeleteObjectMessage:) name:DELETE_MESSAGE]; + _controller = controller; - - } - - return self; -} - - - --(void)checkMaxItems { - - for (Class filterClass in filters) { + self.semaphore = dispatch_semaphore_create(1); - NSMutableArray *filterItems = [filterClass messageItems:self.conversation.peer_id]; - NSMutableDictionary *filterKeys = [filterClass messageKeys:self.conversation.peer_id]; + self.selectLimit = 100; - const int max = 300; + [self addFilter:[[historyFilter alloc] initWithController:self peer:_conversation.peer]]; - if(filterItems.count >= max) { + if(_conversation.type == DialogTypeChannel) { - MTLog(@"h_items_count:%lu",filterItems.count); + __block BOOL requestNext = NO; - NSMutableDictionary *peers = [[NSMutableDictionary alloc] init]; - - - [filterItems enumerateObjectsUsingBlock:^(MessageTableItem *obj, NSUInteger idx, BOOL *stop) { - - NSMutableArray *items = peers[@(obj.message.peer_id)]; + dispatch_block_t block = ^{ - if(!items) { - items = [[NSMutableArray alloc] init]; + if( _conversation.chat.chatFull.migrated_from_chat_id != 0) { - peers[@(obj.message.peer_id)] = items; + HistoryFilter *filter = [[historyFilter == [ChannelFilter class] ? [MegagroupChatFilter class] : historyFilter alloc] initWithController:self peer:[TL_peerChat createWithChat_id:_conversation.chat.chatFull.migrated_from_chat_id]]; + + [self addFilter:filter]; + + if(requestNext && [controller respondsToSelector:@selector(requestNextHistory)]) { + [controller requestNextHistory]; + } } - if(obj.message.dstate == DeliveryStateNormal || obj.message.dstate == DeliveryStateError) - [items addObject:obj]; - - }]; - - NSUInteger average = max/2/peers.count; + }; - [filterItems removeAllObjects]; - - [filterKeys removeAllObjects]; - - [peers enumerateKeysAndObjectsUsingBlock:^(NSNumber *key, id peerItems, BOOL *stop) { - - NSArray *items = [self sortItems:peerItems]; - - items = [items subarrayWithRange:NSMakeRange(0, MIN(average,items.count))]; - - [filterItems addObjectsFromArray:items]; - - [items enumerateObjectsUsingBlock:^(MessageTableItem *item, NSUInteger idx, BOOL *stop) { + if(_conversation.chat.chatFull != nil) { + block(); + } else { + [[FullChatManager sharedManager] performLoad:_conversation.chat.n_id callback:^(TLChatFull *fullChat) { - filterKeys[@(item.message.n_id)] = item; + requestNext = YES; + block(); }]; - - }]; + } - MTLog(@"h_items_count:%lu",filterItems.count); } + + } - + return self; } --(void)notificationReceiveMessages:(NSNotification *)notify { +-(ASQueue *)queue { + return queue; +} + +-(HistoryFilter *)filterWithNext:(BOOL)next { - [queue dispatchOnQueue:^{ - - NSArray *list = notify.object; - - list = [[self filterAndAdd:[self.controller messageTableItemsFromMessages:list] isLates:YES] mutableCopy]; - + __block HistoryFilter *filter; + + + [ASQueue dispatchOnStageQueue:^{ + + filter = [_filters lastObject]; - [listeners enumerateObjectsUsingBlock:^(ChatHistoryController *controller, NSUInteger idx, BOOL *stop) { - - NSMutableArray *accepted = [[NSMutableArray alloc] init]; - NSMutableArray *ignored = [[NSMutableArray alloc] init]; - - [list enumerateObjectsUsingBlock:^(MessageTableItem *obj, NSUInteger idx, BOOL *stop) { - if(controller.controller.conversation.peer.peer_id == obj.message.peer_id) { - [accepted addObject:obj]; - } else { - [ignored addObject:obj]; - } - }]; - + if(!next && !_isNeedSwapFilters) + { + filter = [_filters firstObject]; + } else { + [_filters enumerateObjectsWithOptions: _isNeedSwapFilters ? NSEnumerationReverse : 0 usingBlock:^(HistoryFilter *obj, NSUInteger idx, BOOL * _Nonnull stop) { - if(accepted.count == 0) { - - [ASQueue dispatchOnMainQueue:^{ - [controller.controller didAddIgnoredMessages:ignored]; - }]; - return; + if(![obj checkState:ChatHistoryStateFull next:next]) + { + *stop = YES; + filter = obj; } - NSArray *items = [controller selectAllItems]; - - int pos = (int) [items indexOfObject:accepted[0]]; - - - NSRange range = NSMakeRange(pos+1, accepted.count); - - - accepted = [accepted mutableCopy]; - [SelfDestructionController addMessages:accepted]; - - [[ASQueue mainQueue] dispatchOnQueue:^{ - [controller.controller receivedMessageList:accepted inRange:range itsSelf:NO]; - }]; - - }]; - }]; + } + + + + + } synchronous:YES]; + return filter; } -- (BOOL)isFiltredAccepted:(int)filterType { - return (self.filter.class == HistoryFilter.class || (filterType & [self.filter type]) > 0); +-(void)swapFiltersBeforePrevLoaded { + [self.queue dispatchOnQueue:^{ + _isNeedSwapFilters = YES; + }]; } - --(void)setMin_id:(int)min_id { - self->_min_id = min_id; - _server_min_id = min_id; +-(BOOL)isNeedSwapFilters { + __block BOOL needSwap = NO; + + [self.queue dispatchOnQueue:^{ + needSwap = _isNeedSwapFilters; + } synchronous:YES]; + + return needSwap; } --(void)setMax_id:(int)max_id { - _max_id = max_id; - _server_max_id = max_id; +-(HistoryFilter *)filterAtIndex:(int)index +{ + __block HistoryFilter *filter; + + [ASQueue dispatchOnStageQueue:^{ + filter = _filters[index]; + } synchronous:YES]; + + return filter; + } --(void)setStart_min:(int)start_min { - _start_min = start_min; - _server_start_min = start_min; +-(HistoryFilter *)filterWithPeerId:(int)peer_id { + __block HistoryFilter *filter; + + [ASQueue dispatchOnStageQueue:^{ + [_filters enumerateObjectsUsingBlock:^(HistoryFilter *obj, NSUInteger idx, BOOL * _Nonnull stop) { + + if(obj.peer_id == peer_id) + { + *stop = YES; + filter = obj; + } + + }]; + } synchronous:YES]; + + + + + return filter; + } --(void)notificationDeleteMessage:(NSNotification *)notification { +-(HistoryFilter *)filter { + __block HistoryFilter *filter; - [queue dispatchOnQueue:^{ - - self.proccessing = YES; - - NSArray *msgs = [notification.userInfo objectForKey:KEY_MESSAGE_ID_LIST]; - - if(msgs.count == 0) - return; - - NSMutableDictionary *deleted = [[NSMutableDictionary alloc] init]; + [self.queue dispatchOnQueue:^{ - for (Class filterClass in filters) { - - NSArray *r = [filterClass removeItems:msgs]; - - deleted[NSStringFromClass(filterClass)] = r; + if(_isNeedSwapFilters) { + filter = [_filters lastObject]; + if([filter checkState:ChatHistoryStateFull next:NO]) { + filter = [_filters firstObject]; + } + } else { + filter = [_filters firstObject]; } - [listeners enumerateObjectsUsingBlock:^(ChatHistoryController *obj, NSUInteger idx, BOOL *stop) { - - NSArray * td = deleted[obj.filter.className]; - - td = [td filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.message.peer_id == %d", obj.conversation.peer_id]]; - - if(td.count > 0) { - [[ASQueue mainQueue] dispatchOnQueue:^{ - [obj.controller deleteMessages:msgs]; - - }]; - } + + } synchronous:YES]; + + return filter; +} - }]; +-(void)setFilter:(HistoryFilter *)filter { + [self.queue dispatchOnQueue:^{ - self.proccessing = NO; + [_filters replaceObjectAtIndex:0 withObject:filter]; }]; - } --(void)setProccessing:(BOOL)isProccessing { + +-(void)addFilter:(HistoryFilter *)filter { - [ASQueue dispatchOnStageQueue:^{ - _proccessing = isProccessing; - }]; + assert([self filterWithPeerId:filter.peer_id] == nil); + [_filters addObject:filter]; - [ASQueue dispatchOnMainQueue:^{ - [self.controller updateLoading]; - }]; } --(BOOL)isProccessing { - - - __block BOOL isProccessing = YES; - - - isProccessing = _proccessing; - - - return isProccessing; +-(ChatHistoryState)prevState { + HistoryFilter *filter = self.filter; + return filter.prevState; } --(void)notificationFlushHistory:(NSNotification *)notification { - - + +-(void)prevStateAsync:(void (^)(ChatHistoryState state))block { - [queue dispatchOnQueue:^{ + [ASQueue dispatchOnStageQueue:^{ - self.proccessing = YES; + ChatHistoryState state = self.prevState; - TL_conversation *conversation = [notification.userInfo objectForKey:KEY_DIALOG]; + [ASQueue dispatchOnMainQueue:^{ + + block(state); + + }]; - for (Class filterClass in filters) { - [filterClass removeAllItems:conversation.peer.peer_id]; - } + }]; + +} +-(void)nextStateAsync:(void (^)(ChatHistoryState state))block { + [ASQueue dispatchOnStageQueue:^{ + ChatHistoryState state = self.nextState; - [listeners enumerateObjectsUsingBlock:^(ChatHistoryController *controller, NSUInteger idx, BOOL *stop) { - - if(controller.controller.conversation == conversation) { - - [[ASQueue mainQueue] dispatchOnQueue:^{ - [controller.controller flushMessages]; - }]; - - } + [ASQueue dispatchOnMainQueue:^{ + + block(state); }]; - self.proccessing = NO; - }]; +} + +-(ChatHistoryState)nextState { + HistoryFilter *filter = self.filter; + return filter.nextState; +} + + +-(void)addMessageWithoutSavingState:(TL_localMessage *)message { + [queue dispatchOnQueue:^{ + + [[self filterWithPeerId:message.peer_id] filterAndAdd:@[message] latest:NO]; + + if(message.peer_id != self.filter.peer_id) { + [self swapFiltersBeforePrevLoaded]; + } + + }]; } --(void)notificationDeleteObjectMessage:(NSNotification *)notification { + + +-(void)notificationReceiveMessages:(NSNotification *)notify { [queue dispatchOnQueue:^{ - TLMessage *msg = [notification.userInfo objectForKey:KEY_MESSAGE]; - [messageItems enumerateObjectsUsingBlock:^(MessageTableItem * obj, NSUInteger idx, BOOL *stop) { - if(obj.message == msg) { - [messageItems removeObject:obj]; - *stop = YES; + NSArray *messages = [notify.object copy]; + + [listeners enumerateObjectsUsingBlock:^(WeakReference *weak, NSUInteger idx, BOOL *stop) { + + ChatHistoryController *controller = [weak nonretainedObjectValue]; + + NSArray *accepted = [controller.filter sortItems:[controller.filter filterAndAdd:messages latest:YES]]; + + if(accepted.count == 0) { + return; } + + NSArray *items = [controller.filter selectAllItems]; + + int pos = (int) [items indexOfObject:[accepted firstObject]]; + + NSRange range = NSMakeRange(pos+1, accepted.count); + + [SelfDestructionController addMessages:accepted]; + + NSArray *converted = [controller.controller messageTableItemsFromMessages:accepted]; + + [[ASQueue mainQueue] dispatchOnQueue:^{ + [controller.controller receivedMessageList:converted inRange:range itsSelf:NO]; + }]; + + }]; }]; } --(void)notificationReceiveMessage:(NSNotification *)notification { +-(void)notificationDeleteMessage:(NSNotification *)notification { + [queue dispatchOnQueue:^{ + self.proccessing = YES; - TL_localMessage *message = [notification.userInfo objectForKey:KEY_MESSAGE]; - - // [self markAsReceived:[message n_id]]; - - if(!message || self.prevState != ChatHistoryStateFull) - return; - - MessageTableItem *tableItem = (MessageTableItem *) [[self.controller messageTableItemsFromMessages:@[message]] lastObject]; + NSArray *updateData = [notification.userInfo objectForKey:KEY_DATA]; - if(!tableItem) + if(updateData.count == 0) return; - NSArray *res = [self filterAndAdd:@[tableItem] isLates:YES]; - [listeners enumerateObjectsUsingBlock:^(ChatHistoryController *obj, NSUInteger idx, BOOL *stop) { + [updateData enumerateObjectsUsingBlock:^(NSDictionary *obj, NSUInteger idx, BOOL *stop) { - if(message.peer_id == obj.controller.conversation.peer.peer_id) { + + [listeners enumerateObjectsUsingBlock:^(WeakReference *weak, NSUInteger idx, BOOL *stop) { - NSArray *items = [obj selectAllItems]; + ChatHistoryController *controller = [weak nonretainedObjectValue]; - int position = (int) [items indexOfObject:tableItem]; + int peer_id = [obj[KEY_PEER_ID] intValue]; - if(res.count == 1) { - - [SelfDestructionController addMessages:@[message]]; + [controller.filters enumerateObjectsUsingBlock:^(HistoryFilter *filter, NSUInteger idx, BOOL * _Nonnull stop) { - [[ASQueue mainQueue] dispatchOnQueue:^{ + if(filter.peer_id == peer_id) { + + TL_localMessage *message = filter.messageKeys[obj[KEY_MESSAGE_ID]]; - if([obj isFiltredAccepted:message.filterType]) { - [obj.controller receivedMessage:tableItem position:position+1 itsSelf:NO]; + [filter.messageItems removeObject:message]; + [filter.messageKeys removeObjectForKey:obj[KEY_MESSAGE_ID]]; + + if(message != nil) { + + [[ASQueue mainQueue] dispatchOnQueue:^{ + [controller.controller deleteItems:@[message] orMessageIds:@[@(message.n_id)]]; + }]; } + + } - }]; - } - } else { - [ASQueue dispatchOnMainQueue:^{ - [obj.controller didAddIgnoredMessages:@[tableItem]]; }]; - } + + + + + }]; }]; + self.proccessing = NO; + }]; } - --(NSArray *)filterAndAdd:(NSArray *)items isLates:(BOOL)isLatest { - - __block NSMutableArray *filtred; +-(void)setProccessing:(BOOL)isProccessing { - filtred = [[NSMutableArray alloc] init]; - - for (Class filterClass in filters) { - - [items enumerateObjectsUsingBlock:^(MessageTableItem *obj, NSUInteger idx, BOOL *stop) { - - - NSMutableArray *filterItems = [filterClass messageItems:obj.message.peer_id]; - NSMutableDictionary *filterKeys = [filterClass messageKeys:obj.message.peer_id]; - - BOOL needAdd = [filterItems indexOfObject:obj] == NSNotFound; - - // здесь лучше бы подумать над условием, мб что нибудь в голову придет, пока так. - - if( ((filterClass == HistoryFilter.class && self.filter.class == HistoryFilter.class) || - (filterClass == HistoryFilter.class && isLatest)) || - (filterClass != HistoryFilter.class && obj.message.filterType & [filterClass type]) > 0) { - - - if(obj.message.n_id != 0) { - id saved = filterKeys[@(obj.message.n_id)]; - if(!saved) { - filterKeys[@(obj.message.n_id)] = obj; - } else { - needAdd = NO; - } - } - - if(needAdd) { - [filterItems addObject:obj]; - - if(self.filter.class == filterClass) { - [filtred addObject:obj]; - } - } - } - }]; - - - - } + [ASQueue dispatchOnStageQueue:^{ + _proccessing = isProccessing; + }]; - return filtred; + [ASQueue dispatchOnMainQueue:^{ + [self.controller updateLoading]; + }]; } - - --(void)performCallback:(selectHandler)selectHandler result:(NSArray *)result range:(NSRange )range { - +-(BOOL)isProccessing { - self.proccessing = NO; - [[ASQueue mainQueue] dispatchOnQueue:^{ + __block BOOL isProccessing = YES; + + + isProccessing = _proccessing; - if(selectHandler) - selectHandler(result,range); - }]; - for (MessageTableItem *item in result) { - [SelfDestructionController addMessages:@[item.message]]; - } -} - --(HistoryFilter *)filter { - return _h_filter; + return isProccessing; } --(void)setFilter:(HistoryFilter *)filter { +-(void)notificationFlushHistory:(NSNotification *)notification { - [queue dispatchOnQueue:^{ - _h_filter = filter; - messageKeys = [filter messageKeys:self.conversation.peer_id]; - messageItems = [filter messageItems:self.conversation.peer_id]; - _requestCounter = 0; - - _start_min = _min_id = self.controller.conversation.last_marked_message == 0 ? self.controller.conversation.top_message : self.controller.conversation.last_marked_message; - _max_id = 0; + + [queue dispatchOnQueue:^{ - _maxDate = [[MTNetwork instance] getTime]; - _minDate = self.controller.conversation.last_marked_date; + self.proccessing = YES; + TL_conversation *conversation = [notification.userInfo objectForKey:KEY_DIALOG]; - NSArray *items = [self selectAllItems]; - if(items.count > 0) { - MessageTableItem *item = items[0]; + [listeners enumerateObjectsUsingBlock:^(WeakReference *weak, NSUInteger idx, BOOL *stop) { - if(self.filter.class == HistoryFilter.class && (item.message.n_id != self.controller.conversation.top_message && item.message.n_id < TGMINFAKEID)) { - [[self.filter class] removeAllItems:self.controller.conversation.peer.peer_id]; - } - } - + ChatHistoryController *controller = [weak nonretainedObjectValue]; + + [controller.filters enumerateObjectsUsingBlock:^(HistoryFilter *obj, NSUInteger idx, BOOL * _Nonnull stop) { + + if(obj.peer_id == conversation.peer_id) { + + [obj clear]; + + [[ASQueue mainQueue] dispatchOnQueue:^{ + [controller.controller flushMessages]; + }]; + } + + }]; + + + }]; + self.proccessing = NO; - _nextState = ChatHistoryStateCache; - _prevState = ChatHistoryStateCache; - - } synchronous:YES]; - + }]; + } - --(void)request:(BOOL)next anotherSource:(BOOL)anotherSource sync:(BOOL)sync selectHandler:(selectHandler)selectHandler { +-(void)notificationReceiveMessage:(NSNotification *)notification { [queue dispatchOnQueue:^{ + TL_localMessage *message = [notification.userInfo objectForKey:KEY_MESSAGE]; - - if([self checkState:ChatHistoryStateFull next:next] || self.isProccessing) { + if(!message) return; - } - if(self.conversation.peer_id == 46575809) { - int bp = 0; - } - - self.proccessing = YES; - - - BOOL notify = NO; - - - NSArray *allItems; - - - if( [self checkState:ChatHistoryStateCache next:next]) { - - - allItems = [self selectAllItems]; - - - - NSMutableArray *memory = [[NSMutableArray alloc] init]; - - [allItems enumerateObjectsUsingBlock:^(MessageTableItem * obj, NSUInteger idx, BOOL *stop) { - - if((self.filter.type & obj.message.filterType) > 0) { - - int source_date = next ? _maxDate : _minDate; - - if(next) { - - if(obj.message.date <= source_date) - [memory addObject:obj]; - } else { - if(obj.message.date >= source_date ) - [memory addObject:obj]; - } - - - } - }]; - + [listeners enumerateObjectsUsingBlock:^(WeakReference *weak, NSUInteger idx, BOOL *stop) { - if(memory.count >= _selectLimit) { - - NSUInteger location = next ? 0 : (memory.count-_selectLimit); - memory = [[memory subarrayWithRange:NSMakeRange(location, _selectLimit)] mutableCopy]; - - MessageTableItem *lastItem = [memory lastObject]; - - NSArray *merge = [[allItems filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.message.date == %d",lastItem.message.date]] filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"NOT(self IN %@)",memory]]; - - [memory addObjectsFromArray:merge]; - - } else { - - ChatHistoryState state; - - if(!next) { - state = self.filter.class == HistoryFilter.class && ( _max_id == 0 || (_min_id >= self.controller.conversation.sync_message_id && self.controller.conversation.sync_message_id != 0) || self.controller.conversation.type == DialogTypeSecretChat || self.controller.conversation.type == DialogTypeBroadcast) ? ChatHistoryStateLocal : ChatHistoryStateRemote; - - } else { - state = (self.filter.class == HistoryFilter.class && (_max_id == 0 ? _min_id >= _controller.conversation.sync_message_id : _max_id > self.conversation.sync_message_id) ) || self.controller.conversation.type == DialogTypeSecretChat || self.controller.conversation.type == DialogTypeBroadcast ? ChatHistoryStateLocal : ChatHistoryStateRemote; - - } - - [self setState:state next:next]; - } + ChatHistoryController *obj = [weak nonretainedObjectValue]; - if(memory.count > 0) - notify = YES; - - - [self saveId:memory next:next]; - - if((!next && _min_id == self.controller.conversation.top_message)) { - [self setState:ChatHistoryStateFull next:next]; - - notify = YES; - } - - - if(notify) - [self performCallback:selectHandler result:memory range:NSMakeRange(0, memory.count)]; - - } - - - - if(anotherSource && !notify) { - if([self checkState:ChatHistoryStateLocal next:next]) { - - - [self.filter storageRequest:next callback:^(NSArray *result) { - - [TGProccessUpdates checkAndLoadIfNeededSupportMessages:result asyncCompletionHandler:^{ - - - [[MessagesManager sharedManager] add:result]; - - NSArray *items = [self.controller messageTableItemsFromMessages:result]; - - - NSArray *converted = [self filterAndAdd:items isLates:NO]; - - - converted = [self sortItems:converted]; - - - [self saveId:converted next:next]; - - - if(result.count < _selectLimit) { - - if(!next && (_min_id >= self.conversation.top_message)) { - [self setState:ChatHistoryStateFull next:NO]; - } else { - [self setState: self.controller.conversation.type != DialogTypeSecretChat && self.controller.conversation.type != DialogTypeBroadcast ? ChatHistoryStateRemote : ChatHistoryStateFull next:next]; - } - - } - - - - [self performCallback:selectHandler result:converted range:NSMakeRange(0, converted.count)]; - - }]; - - - - }]; + NSArray *items = [obj.filter filterAndAdd:@[message] latest:YES]; + + if(items.count != 1) + return; + + if(obj.filter.peer_id == message.peer_id) { + NSArray *items = [obj.filter selectAllItems]; + int position = (int) [items indexOfObject:message]; - } else if([self checkState:ChatHistoryStateRemote next:next]) { + [SelfDestructionController addMessages:@[message]]; - [self.filter remoteRequest:next peer_id:self.conversation.peer_id callback:^(id response) { + NSArray *converted = [obj.controller messageTableItemsFromMessages:@[message]]; - [TL_localMessage convertReceivedMessages:[response messages]]; - - [TGProccessUpdates checkAndLoadIfNeededSupportMessages:[response messages] asyncCompletionHandler:^{ - - [queue dispatchOnQueue:^{ - - - NSArray *messages = [[response messages] copy]; - - if(self.filter.class != HistoryFilter.class || !_need_save_to_db) { - [[response messages] removeAllObjects]; - } - - - TL_localMessage *sync_message = [[response messages] lastObject]; - - if(sync_message) { - self.controller.conversation.sync_message_id = sync_message.n_id; - [self.controller.conversation save]; - } - - -// if(!next) { -// -// TL_localMessage *last; -// if(messages.count > 0) -// last = messages[0]; -// -// ChatHistoryState old_state = _prevState; -// ChatHistoryState new_state = self.filter.class == HistoryFilter.class && (last && (last.n_id < self.controller.conversation.sync_message_id && self.controller.conversation.sync_message_id != 0) ) ? ChatHistoryStateLocal : ChatHistoryStateRemote; -// [self setState:new_state next:next]; -// -// if(old_state != new_state && new_state == ChatHistoryStateLocal) { -// NSMutableArray *copy = [messages mutableCopy]; -// -// [messages enumerateObjectsUsingBlock:^(TL_localMessage *obj, NSUInteger idx, BOOL *stop) { -// if(obj.n_id < self.controller.conversation.sync_message_id) -// [copy removeObject:obj]; -// }]; -// -// messages = copy; -// } -// -// } - - - - [SharedManager proccessGlobalResponse:response]; - - - NSArray *converted = [self filterAndAdd:[self.controller messageTableItemsFromMessages:messages] isLates:NO]; - - converted = [self sortItems:converted]; - - [self saveId:converted next:next]; - - - - - if(next && converted.count < (_selectLimit-1)) { - [self setState:ChatHistoryStateFull next:next]; - } - - if(!next && (_min_id) == self.controller.conversation.top_message) { - [self setState:ChatHistoryStateFull next:next]; - } - - self.filter.request = nil; - - [self performCallback:selectHandler result:converted range:NSMakeRange(0, converted.count)]; - }]; + [[ASQueue mainQueue] dispatchOnQueue:^{ - }]; - - + [obj.controller receivedMessageList:converted inRange:NSMakeRange(position+1, converted.count) itsSelf:NO]; }]; - + } - } - - } synchronous:sync]; + }]; + + }]; } --(BOOL)checkState:(ChatHistoryState)state next:(BOOL)next { - return next ? _nextState == state : _prevState == state; -} - --(void)setState:(ChatHistoryState)state next:(BOOL)next { - if(next) - _nextState = state; - else { - _prevState = state; +-(void)notificationUpdateMessageId:(NSNotification *)notification { + + [queue dispatchOnQueue:^{ - if(_prevState == ChatHistoryStateRemote) - { - int bp = 0; - } - } + int n_id = [notification.userInfo[KEY_MESSAGE_ID] intValue]; + long random_id = [notification.userInfo[KEY_RANDOM_ID] longValue]; + + [self updateItemId:random_id withId:n_id]; + + + }]; } --(void)saveId:(NSArray *)source next:(BOOL)next { +-(void)performCallback:(selectHandler)selectHandler result:(NSArray *)result range:(NSRange )range controller:(id)controller { - - if(source.count > 0) { - - if(next || _start_min == _min_id) { - BOOL localSaved = NO; - BOOL serverSaved = NO; - for (int i = (int) source.count-1; i >= 0; i--) { - if(!localSaved) { - _max_id = [[(MessageTableItem *)source[i] message] n_id]; - _maxDate = [[(MessageTableItem *)source[i] message] date]-1; - localSaved = YES; - } - - if(!serverSaved && [[(MessageTableItem *)source[i] message] n_id] != 0 && [[(MessageTableItem *)source[i] message] n_id] < TGMINFAKEID) { - _server_max_id = [[(MessageTableItem *)source[i] message] n_id]; - serverSaved = YES; - } - - if(localSaved && serverSaved) - break; - - } - + self.proccessing = NO; + + [[ASQueue mainQueue] dispatchOnQueue:^{ + + if(selectHandler) + selectHandler(result,range,controller); + }]; + +} + + + +-(void)request:(BOOL)next anotherSource:(BOOL)anotherSource sync:(BOOL)sync selectHandler:(selectHandler)selectHandler { + + [queue dispatchOnQueue:^{ + + HistoryFilter *filter = [self filterWithNext:next]; + + if([filter checkState:ChatHistoryStateFull next:next] || self.isProccessing) { + [self performCallback:selectHandler result:@[] range:NSMakeRange(0, 0) controller:self]; + return; } - if(!next) { - BOOL localSaved = NO; - BOOL serverSaved = NO; + self.proccessing = YES; + + + [filter request:next callback:^(NSArray *result, ChatHistoryState state) { - for (MessageTableItem *item in source) { - if(!localSaved) { - _min_id = [item.message n_id]; - _minDate = [item.message date]+1; - localSaved = YES; - } + + if([filter checkState:ChatHistoryStateLocal next:next] && result.count == 0) { - if(!serverSaved && item.message.n_id != 0 && item.message.n_id < TGMINFAKEID) { - _server_min_id = [item.message n_id]; - serverSaved = YES; - } + [filter proccessResponse:result state:state next:next]; + + self.proccessing = NO; + [self request:next anotherSource:anotherSource sync:sync selectHandler:selectHandler]; + return ; } - } + + NSArray *converted = [self.controller messageTableItemsFromMessages:[filter proccessResponse:result state:state next:next]]; + + [self performCallback:selectHandler result:converted range:NSMakeRange(0, converted.count) controller:self]; + + }]; - } - + + } synchronous:sync]; + } +-(void)loadAroundMessagesWithMessage:(TL_localMessage *)message prevLimit:(int)prevLimit nextLimit:(int)nextLimit selectHandler:(selectHandler)selectHandler { + + + [self.queue dispatchOnQueue:^{ + + [self addMessageWithoutSavingState:message]; + + [[Storage manager] addHolesAroundMessage:message]; + + [[Storage manager] insertMessages:@[message]]; + + + NSMutableArray *prevResult = [NSMutableArray array]; + NSMutableArray *nextResult = [NSMutableArray array]; + + self.proccessing = YES; + [self loadAroundMessagesWithSelectHandler:selectHandler prevLimit:(int)prevLimit nextLimit:(int)nextLimit prevResult:prevResult nextResult:nextResult]; + + + } synchronous:YES]; + + +} - - --(NSArray *)selectAllItems { - +-(void)loadAroundMessagesWithSelectHandler:(selectHandler)selectHandler prevLimit:(int)prevLimit nextLimit:(int)nextLimit prevResult:(NSMutableArray *)prevResult nextResult:(NSMutableArray *)nextResult { + + + BOOL nextLoaded = nextResult.count >= nextLimit || self.nextState == ChatHistoryStateFull; + BOOL prevLoaded = prevResult.count >= prevLimit || self.prevState == ChatHistoryStateFull; + + + if((nextLoaded && prevLoaded) || (prevLoaded && self.nextState == ChatHistoryStateRemote && nextLimit == 1)) { - NSArray *memory = [self sortItems:messageItems]; - + NSArray *result = [self.filter selectAllItems]; + + [self performCallback:selectHandler result:[self.controller messageTableItemsFromMessages:result] range:NSMakeRange(0, result.count) controller:self]; + + self.proccessing = NO; + return; + } + + BOOL nextRequest = prevLoaded; + + + [self.filter request:nextRequest callback:^(NSArray *result, ChatHistoryState state) { + + NSArray *converted = [self.filter proccessResponse:result state:state next:nextRequest]; + + if(nextRequest) { + [nextResult addObjectsFromArray:converted]; + } else { + [prevResult addObjectsFromArray:converted]; + } + + + [self loadAroundMessagesWithSelectHandler:selectHandler prevLimit:(int)prevLimit nextLimit:(int)nextLimit prevResult:prevResult nextResult:nextResult]; + + }]; - return memory; } --(NSArray *)sortItems:(NSArray *)sort { - return [sort sortedArrayUsingComparator:^NSComparisonResult(MessageTableItem *obj1, MessageTableItem *obj2) { + + +-(void)items:(NSArray *)msgIds complete:(void (^)(NSArray *list))complete { + + dispatch_queue_t dqueue = dispatch_get_current_queue(); + + [queue dispatchOnQueue:^{ + + NSMutableArray *items = [NSMutableArray array]; + + [msgIds enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + + TL_localMessage *item = self.filter.messageKeys[obj]; + + if(item != nil) { + [items addObject:item]; + } + + }]; + + dispatch_async(dqueue, ^{ + complete(items); + }); - return (obj1.message.date < obj2.message.date && (obj1.message.n_id < TGMINFAKEID && obj2.message.n_id < TGMINFAKEID) ? NSOrderedDescending : (obj1.message.date > obj2.message.date && (obj1.message.n_id < TGMINFAKEID && obj2.message.n_id < TGMINFAKEID) ? NSOrderedAscending : (obj1.message.n_id < obj2.message.n_id ? NSOrderedDescending : NSOrderedAscending))); }]; } --(void)removeAllItems { - for (Class filterClass in filters) { - [filterClass removeAllItems:self.controller.conversation.peer.peer_id]; - } +-(void)updateItemId:(long)randomId withId:(int)n_id { + [queue dispatchOnQueue:^{ + + [listeners enumerateObjectsUsingBlock:^(WeakReference *obj, NSUInteger idx, BOOL * _Nonnull stop) { + + ChatHistoryController *controller = obj.nonretainedObjectValue; + + NSArray *f = [controller.filter.messageItems filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.randomId = %ld",randomId]]; + TL_localMessage *message = [f firstObject]; + + if(message) { + [controller.filter.messageKeys removeObjectForKey:@(message.n_id)]; + message.n_id = n_id; + controller.filter.messageKeys[@(message.n_id)] = message; + } + + }]; + + + + }]; } - --(int)posAtMessage:(TLMessage *)message { - - - NSArray *memoryItems = [self selectAllItems]; +-(void)updateMessageIds:(NSArray *)items { + [items enumerateObjectsUsingBlock:^(TL_localMessage *obj, NSUInteger idx, BOOL * _Nonnull stop) { + + [_filters enumerateObjectsUsingBlock:^(HistoryFilter *filter, NSUInteger idx, BOOL * _Nonnull stop) { + + if(obj.peer_id == filter.peer_id) { + TL_localMessage *message = filter.messageKeys[@(obj.n_id)]; + + if(message != nil) { + [filter.messageItems removeObject:message]; + [filter.messageItems addObject:obj]; + filter.messageKeys[@(obj.n_id)] = obj; + } + } + + }]; + + + + }]; +} + +-(int)itemsCount { + __block int count = 0; - int pos = 0; - if(memoryItems.count > 0) { - pos = [self posInArray:memoryItems date:message.date n_id:message.n_id]; - } + [self.queue dispatchOnQueue:^{ + + [_filters enumerateObjectsUsingBlock:^(HistoryFilter *obj, NSUInteger idx, BOOL * _Nonnull stop) { + + count+=obj.selectAllItems.count; + + }]; + + } synchronous:YES]; - return pos; + return count; } -(void)addItem:(MessageTableItem *)item { - [self addItem:item conversation:self.controller.conversation callback:nil sentControllerCallback:nil]; + [self addItem:item conversation:self.conversation callback:nil sentControllerCallback:nil]; } @@ -889,44 +756,44 @@ -(void)addItems:(NSArray *)items conversation:(TL_conversation *)conversation s } -(void)addItem:(MessageTableItem *)item sentControllerCallback:(dispatch_block_t)sentControllerCallback { - [self addItem:item conversation:self.controller.conversation callback:nil sentControllerCallback:sentControllerCallback]; + [self addItem:item conversation:self.conversation callback:nil sentControllerCallback:sentControllerCallback]; } -(void)addItem:(MessageTableItem *)item conversation:(TL_conversation *)conversation callback:(dispatch_block_t)callback sentControllerCallback:(dispatch_block_t)sentControllerCallback { - - - - dispatch_block_t block = ^ { + dispatch_block_t block = ^ { [queue dispatchOnQueue:^{ [item.messageSender addEventListener:self]; - NSArray *added = [self filterAndAdd:@[item] isLates:YES]; - [listeners enumerateObjectsUsingBlock:^(ChatHistoryController *controller, NSUInteger idx, BOOL *stop) { + [listeners enumerateObjectsUsingBlock:^(WeakReference *weak, NSUInteger idx, BOOL *stop) { + + ChatHistoryController *controller = weak.nonretainedObjectValue; + + NSArray *filtred = [controller.filter filterAndAdd:@[item.message] latest:YES];; - if(added.count == 1 && (item.message.filterType & controller.filter.type) > 0 && item.messageSender.conversation.peer.peer_id == controller.conversation.peer.peer_id) { + if(filtred.count > 0) { + + NSArray *copyItems = [controller.controller messageTableItemsFromMessages:filtred]; + + [controller updateMessageIds:filtred]; [[ASQueue mainQueue] dispatchOnQueue:^{ - - [controller.controller receivedMessage:item position:0 itsSelf:YES]; + [controller.controller receivedMessageList:copyItems inRange:NSMakeRange(0, filtred.count) itsSelf:YES]; if(controller == self) { if(sentControllerCallback) sentControllerCallback(); } - + }]; } + }]; - - - - item.messageSender.conversation.last_marked_message = item.message.n_id; item.messageSender.conversation.last_marked_date = item.message.date+1; @@ -934,7 +801,7 @@ -(void)addItem:(MessageTableItem *)item conversation:(TL_conversation *)conversa [item.messageSender send]; - [LoopingUtils runOnMainQueueAsync:^{ + [ASQueue dispatchOnMainQueue:^{ if(callback != nil) callback(); }]; @@ -951,22 +818,36 @@ -(void)addItems:(NSArray *)items conversation:(TL_conversation *)conversation ca dispatch_block_t block = ^ { [queue dispatchOnQueue:^{ - NSArray *filtred = [self filterAndAdd:items isLates:YES]; - MessageTableItem *item = [items lastObject]; - NSRange range = NSMakeRange(0, filtred.count); - if(filtred.count == items.count && self.filter.class == [HistoryFilter class] && item.messageSender.conversation.peer.peer_id == self.controller.conversation.peer.peer_id) { - [[ASQueue mainQueue] dispatchOnQueue:^{ - - [self.controller receivedMessageList:filtred inRange:range itsSelf:YES]; - - if(sentControllerCallback) - sentControllerCallback(); - - }]; - } + NSMutableArray *messages = [NSMutableArray array]; + + [items enumerateObjectsUsingBlock:^(MessageTableItem *obj, NSUInteger idx, BOOL * _Nonnull stop) { + [messages addObject:obj.message]; + }]; + [listeners enumerateObjectsUsingBlock:^(WeakReference *weak, NSUInteger idx, BOOL *stop) { + + ChatHistoryController *controller = weak.nonretainedObjectValue; + + NSArray *filtred = [controller.filter filterAndAdd:messages latest:YES]; + + if(filtred.count > 0) { + + [controller updateMessageIds:filtred]; + + [[ASQueue mainQueue] dispatchOnQueue:^{ + + [controller.controller receivedMessageList:[items reversedArray] inRange:NSMakeRange(0, items.count) itsSelf:YES]; + + if(controller == self) { + if(sentControllerCallback) + sentControllerCallback(); + } + + }]; + } + }]; conversation.last_marked_message = item.message.n_id; conversation.last_marked_date = item.message.date+1; @@ -1004,20 +885,28 @@ -(void)onStateChanged:(SenderItem *)sender { [queue dispatchOnQueue:^{ - if(self.controller.conversation.last_marked_message > TGMINFAKEID || self.controller.conversation.last_marked_message < checkItem.message.n_id) { + if(self.conversation.last_marked_message > TGMINFAKEID || self.conversation.last_marked_message < checkItem.message.n_id) { checkItem.messageSender.conversation.last_marked_message = checkItem.message.n_id; checkItem.messageSender.conversation.last_marked_date = checkItem.message.date; - [self.controller.conversation save]; - - [messageItems removeObject:checkItem]; - [messageKeys removeObjectForKey:@(checkItem.message.n_id)]; + [self.conversation save]; - [self filterAndAdd:@[checkItem] isLates:YES]; + } + + if(![checkItem.message isKindOfClass:[TL_destructMessage class]]) { + [listeners enumerateObjectsUsingBlock:^(WeakReference *obj, NSUInteger idx, BOOL * _Nonnull stop) { + + ChatHistoryController *controller = obj.nonretainedObjectValue; + + [controller updateItemId:checkItem.message.randomId withId:checkItem.message.n_id]; + + }]; } + + } synchronous:YES]; @@ -1044,36 +933,19 @@ -(void)onStateChanged:(SenderItem *)sender { } --(int)posInArray:(NSArray *)list date:(int)date n_id:(int)n_id { - int pos = 0; - - - - while (pos+1 < list.count && - ([((MessageTableItem *)list[pos]).message date] > date || - ([((MessageTableItem *)list[pos]).message date] == date && [((MessageTableItem *)list[pos]).message n_id] > n_id))) - pos++; - - return pos; -} + -(void)drop:(BOOL)dropMemory { - if(dropMemory) { - [queue dispatchOnQueue:^{ - [self removeAllItems]; - } synchronous:YES]; - } - + [queue dispatchOnQueue:^{ - _h_filter.controller = nil; - [_h_filter.request cancelRequest]; - _h_filter = nil; + [_filters removeAllObjects]; _controller = nil; - [listeners removeObject:self]; } synchronous:YES]; + _controller = nil; + [[NSNotificationCenter defaultCenter] removeObserver:self]; [Notification removeObserver:self]; @@ -1082,18 +954,42 @@ -(void)drop:(BOOL)dropMemory { } -(TL_conversation *)conversation { - return _controller.conversation; + return _conversation; +} + +-(void)startChannelPolling { + +} + +-(void)startChannelPollingIfAlreadyStoped { + +} + +-(void)stopChannelPolling { + } -(void)dealloc { + + __block NSUInteger index = NSNotFound; + + [listeners enumerateObjectsUsingBlock:^(WeakReference *obj, NSUInteger idx, BOOL *stop) { + + if(obj.originalObjectValue == (__bridge void *)(self)) { + index = idx; + *stop = YES; + } + }]; + + assert(index != NSNotFound); + + [listeners removeObjectAtIndex:index]; + [queue dispatchOnQueue:^{ - [self drop:NO]; + [self drop:YES]; } synchronous:YES]; } -+(void)drop { - [HistoryFilter drop]; -} @end diff --git a/TelegramTest/ChatInfoHeaderView.h b/TelegramTest/ChatInfoHeaderView.h index c509d69d..8d765e96 100644 --- a/TelegramTest/ChatInfoHeaderView.h +++ b/TelegramTest/ChatInfoHeaderView.h @@ -12,6 +12,7 @@ #import "UserInfoShortButtonView.h" #import "TMSharedMediaButton.h" #import "ChatInfoNotificationView.h" + @class ChatInfoViewController; @interface LineView : NSView @@ -22,7 +23,7 @@ @property (nonatomic) ChatInfoViewControllerType type; @property (nonatomic, strong) TMSharedMediaButton *sharedMediaButton; @property (nonatomic, strong) TMSharedMediaButton *filesMediaButton; - +@property (nonatomic, strong) TMSharedMediaButton *sharedLinksButton; @property (nonatomic,strong) ProfileSharedMediaView *mediaView; @property (nonatomic, strong) TMNameTextField *nameTextField; @@ -34,12 +35,14 @@ @property (nonatomic, strong,readonly) UserInfoShortButtonView *addMembersButton; @property (nonatomic, strong, readonly) UserInfoShortButtonView *exportChatInvite; +@property (nonatomic, strong, readonly) UserInfoShortButtonView *admins; @property (nonatomic, strong,readonly) UserInfoShortButtonView *notificationView; @property (nonatomic, strong,readonly) ITSwitch *notificationSwitcher; @property (nonatomic, strong,readonly) LineView *nameLiveView; - +-(void)save; +-(void)buildNotificationsTitle; - (NSString *)title; - (void)reload; diff --git a/TelegramTest/ChatInfoHeaderView.m b/TelegramTest/ChatInfoHeaderView.m index db8ea5d5..a4e4f0e1 100644 --- a/TelegramTest/ChatInfoHeaderView.m +++ b/TelegramTest/ChatInfoHeaderView.m @@ -20,6 +20,7 @@ #import "ComposeActionAddGroupMembersBehavior.h" #import "TGPhotoViewer.h" #import "MessagesUtils.h" +#import "ChatAdminsViewController.h" @implementation LineView - (void)drawRect:(NSRect)dirtyRect { @@ -53,7 +54,7 @@ - (id)initWithFrame:(NSRect)frame { [self.avatarImageView setFrameSize:NSMakeSize(70, 70)]; - [self.avatarImageView setFrameOrigin:NSMakePoint(100, self.bounds.size.height - self.avatarImageView.bounds.size.height - 30)]; + [self addSubview:self.avatarImageView]; @@ -64,7 +65,7 @@ - (id)initWithFrame:(NSRect)frame { if(strongSelf.avatarImageView.sourceType != ChatAvatarSourceBroadcast) { - if(![strongSelf.fullChat.chat_photo isKindOfClass:[TL_photoEmpty class]]) { + if(![strongSelf.fullChat.chat_photo isKindOfClass:[TL_photoEmpty class]] && strongSelf.fullChat.chat_photo) { TL_photoSize *size = [strongSelf.fullChat.chat_photo.sizes lastObject]; @@ -97,6 +98,8 @@ - (id)initWithFrame:(NSRect)frame { [self.nameTextField setAction:@selector(enter)]; [self addSubview:self.nameTextField]; + [[self.nameTextField cell] setTruncatesLastVisibleLine:YES]; + _nameLiveView = [[LineView alloc] initWithFrame:NSMakeRect(185, self.bounds.size.height - 80, NSWidth(self.frame) - 310, 1)]; [self.nameLiveView setHidden:YES]; [self addSubview:self.nameLiveView]; @@ -126,8 +129,16 @@ - (id)initWithFrame:(NSRect)frame { } - if(self.fullChat.participants.participants.count < maxChatUsers()) - [[Telegram rightViewController] showComposeWithAction:[[ComposeAction alloc]initWithBehaviorClass:[ComposeActionAddGroupMembersBehavior class] filter:filter object:self.fullChat]]; + if(self.fullChat.participants.participants.count < maxChatUsers()) { + + ComposePickerViewController *viewController = [[ComposePickerViewController alloc] initWithFrame:self.controller.view.bounds]; + + [viewController setAction:[[ComposeAction alloc]initWithBehaviorClass:[ComposeActionAddGroupMembersBehavior class] filter:filter object:self.controller.fullChat reservedObjects:@[self.controller.chat]]]; + + [self.controller.navigationViewController pushViewController:viewController animated:YES]; + + } + }]; @@ -146,7 +157,11 @@ - (id)initWithFrame:(NSRect)frame { dispatch_block_t cblock = ^ { - [[Telegram rightViewController] showChatExportLinkController:_fullChat]; + ChatExportLinkViewController *viewController = [[ChatExportLinkViewController alloc] initWithFrame:self.controller.view.frame]; + + [viewController setChat:_fullChat]; + + [self.controller.navigationViewController pushViewController:viewController animated:YES]; }; @@ -157,11 +172,11 @@ - (id)initWithFrame:(NSRect)frame { } else { - [TMViewController showModalProgress]; + [self.controller showModalProgress]; - [RPCRequest sendRequest:[TLAPI_messages_exportChatInvite createWithChat_id:_fullChat.n_id] successHandler:^(RPCRequest *request, TL_chatInviteExported *response) { + [RPCRequest sendRequest:[TLAPI_messages_exportChatInvite createWithChat_id:self.controller.chat.n_id] successHandler:^(RPCRequest *request, TL_chatInviteExported *response) { - [TMViewController hideModalProgressWithSuccess]; + [self.controller hideModalProgressWithSuccess]; _fullChat.exported_invite = response; @@ -171,7 +186,7 @@ - (id)initWithFrame:(NSRect)frame { } errorHandler:^(RPCRequest *request, RpcError *error) { - [TMViewController hideModalProgress]; + [self.controller hideModalProgress]; } timeout:10]; } @@ -193,9 +208,15 @@ - (id)initWithFrame:(NSRect)frame { self.sharedMediaButton = [TMSharedMediaButton buttonWithText:NSLocalizedString(@"Profile.SharedMedia", nil) tapBlock:^{ - [[Telegram rightViewController] showCollectionPage:self.controller.chat.dialog]; + TMCollectionPageController *viewController = [[TMCollectionPageController alloc] initWithFrame:self.controller.view.bounds]; + + [viewController loadViewIfNeeded]; + + [viewController setConversation:self.controller.chat.dialog]; + + [self.controller.navigationViewController pushViewController:viewController animated:YES]; - [[Telegram rightViewController].collectionViewController showAllMedia]; + [viewController showAllMedia]; }]; [self.sharedMediaButton setFrameSize:NSMakeSize(self.exportChatInvite.bounds.size.width, 42)]; @@ -205,18 +226,52 @@ - (id)initWithFrame:(NSRect)frame { self.filesMediaButton = [TMSharedMediaButton buttonWithText:NSLocalizedString(@"Profile.SharedMediaFiles", nil) tapBlock:^{ - [[Telegram rightViewController] showCollectionPage:self.controller.chat.dialog]; + TMCollectionPageController *viewController = [[TMCollectionPageController alloc] initWithFrame:self.controller.view.bounds]; - [[Telegram rightViewController].collectionViewController showFiles]; + [viewController loadViewIfNeeded]; + + [viewController setConversation:self.controller.chat.dialog]; + + [self.controller.navigationViewController pushViewController:viewController animated:YES]; + + [viewController showFiles]; }]; - self.filesMediaButton.isFiles = YES; + [self.filesMediaButton setFrameSize:NSMakeSize(self.addMembersButton.bounds.size.width, 42)]; [self.filesMediaButton setFrameOrigin:NSMakePoint(self.sharedMediaButton.frame.origin.x, self.sharedMediaButton.frame.origin.y -42)]; [self addSubview:self.filesMediaButton]; + + + + self.sharedLinksButton = [TMSharedMediaButton buttonWithText:NSLocalizedString(@"Conversation.Filter.SharedLinks", nil) tapBlock:^{ + + TMCollectionPageController *viewController = [[TMCollectionPageController alloc] initWithFrame:self.controller.view.bounds]; + + [viewController loadViewIfNeeded]; + + [viewController setConversation:self.controller.chat.dialog]; + + [self.controller.navigationViewController pushViewController:viewController animated:YES]; + + [viewController showSharedLinks]; + + }]; + + + + [self.sharedLinksButton setFrameSize:NSMakeSize(self.filesMediaButton.bounds.size.width, 42)]; + + [self.sharedLinksButton setFrameOrigin:NSMakePoint(self.sharedLinksButton.frame.origin.x, self.sharedLinksButton.frame.origin.y -42)]; + + [self addSubview:self.sharedLinksButton]; + + self.sharedMediaButton.type = TMSharedMediaPhotoVideoType; + self.filesMediaButton.type = TMSharedMediaDocumentsType; + self.sharedLinksButton.type = TMSharedMediaSharedLinksType; _notificationView = [UserInfoShortButtonView buttonWithText:NSLocalizedString(@"Notifications", nil) tapBlock:^{ @@ -235,28 +290,30 @@ - (id)initWithFrame:(NSRect)frame { [menuPopover showRelativeToRect:strongSelf.muteUntilTitle.bounds ofView:strongSelf.muteUntilTitle preferredEdge:CGRectMinYEdge]; }]; -// -// _notificationSwitcher = [[ITSwitch alloc] initWithFrame:NSMakeRect(0, 0, 36, 20)]; -// -// _notificationView.rightContainer = self.notificationSwitcher; -// -// [self.notificationSwitcher setDidChangeHandler:^(BOOL isOn) { -// -// TL_conversation *dialog = [[DialogsManager sharedManager] findByChatId:strongSelf.controller.chat.n_id]; -// -// BOOL isMute = dialog.isMute; -// if(isMute == isOn) { -// // [dialog muteOrUnmute:nil]; -// } -// -// }]; - [_notificationView setFrame:NSMakeRect(100, NSMinY(self.filesMediaButton.frame) - 42, NSWidth(self.frame) - 200, 42)]; + [_notificationView setFrame:NSMakeRect(100, NSMinY(self.sharedLinksButton.frame) - 42, NSWidth(self.frame) - 200, 42)]; [self addSubview:self.notificationView]; - self.filesMediaButton.textButton.textColor = self.sharedMediaButton.textButton.textColor = self.notificationView.textButton.textColor = DARK_BLACK; + + + _admins = [UserInfoShortButtonView buttonWithText:NSLocalizedString(@"Chat.Administrators", nil) tapBlock:^{ + + ChatAdminsViewController *viewController = [[ChatAdminsViewController alloc] initWithFrame:self.controller.view.bounds]; + + viewController.chat = self.controller.chat; + + [self.controller.navigationViewController pushViewController:viewController animated:YES]; + + }]; + + [_admins setFrameSize:NSMakeSize(self.addMembersButton.bounds.size.width, 42)]; + + [self addSubview:_admins]; + + + self.sharedLinksButton.textButton.textColor = self.filesMediaButton.textButton.textColor = self.sharedMediaButton.textButton.textColor = self.notificationView.textButton.textColor = DARK_BLACK; @@ -326,11 +383,20 @@ - (NSString *)title { - (void) TMNameTextFieldDidChanged:(TMNameTextField *)textField { [self.nameTextField sizeToFit]; - [self.nameTextField setFrame:NSMakeRect(185, self.bounds.size.height - 43 - self.nameTextField.bounds.size.height, self.bounds.size.width - 185 - 30, self.nameTextField.bounds.size.height)]; - [self.statusTextField sizeToFit]; + + [self setFrameSize:self.frame.size]; +} + +-(void)setFrameSize:(NSSize)newSize { + [super setFrameSize:newSize]; + + [self.nameTextField setFrame:NSMakeRect(185, self.bounds.size.height - 43 - self.nameTextField.bounds.size.height, MIN(self.bounds.size.width - 185 - 100, NSWidth(self.nameTextField.frame)), self.nameTextField.bounds.size.height)]; + [self.statusTextField setFrame:NSMakeRect(182, self.nameTextField.frame.origin.y - self.statusTextField.bounds.size.height - 3, MIN(self.bounds.size.width - 310,NSWidth(self.statusTextField.frame)), self.nameTextField.bounds.size.height)]; + + [self.avatarImageView setFrameOrigin:NSMakePoint(100, self.bounds.size.height - self.avatarImageView.bounds.size.height - 30)]; } - (void)setController:(ChatInfoViewController *)controller { @@ -343,43 +409,72 @@ - (void)reload { TLChat *chat = self.controller.chat; - [self.statusTextField setChat:chat]; - [self.statusTextField sizeToFit]; - - self.fullChat = [[FullChatManager sharedManager] find:chat.n_id]; - if(!self.fullChat) { - MTLog(@"full chat is not loading"); - return; - } + [[FullChatManager sharedManager] performLoad:chat.n_id callback:^(TLChatFull *fullChat) { - [self.avatarImageView setChat:chat]; - [self.avatarImageView rebuild]; + self.fullChat = fullChat; - [_mediaView setConversation:chat.dialog]; - [self.sharedMediaButton setConversation:chat.dialog]; - [self.filesMediaButton setConversation:chat.dialog]; - - [self.nameTextField setChat:chat]; - - - [self buildNotificationsTitle]; - - [self TMNameTextFieldDidChanged:self.nameTextField]; - - - [_exportChatInvite setHidden:self.fullChat.participants.admin_id != [UsersManager currentUserId]]; - - - - [self.sharedMediaButton setFrameOrigin:NSMakePoint(NSMinX(_exportChatInvite.isHidden ? self.addMembersButton.frame : self.exportChatInvite.frame), NSMinY(_exportChatInvite.isHidden ? self.addMembersButton.frame : self.exportChatInvite.frame) - 72)]; + BOOL cantEditGroup = !self.controller.chat.isCreator && ( self.controller.chat.isAdmins_enabled && !self.controller.chat.isAdmin ); - - [self.filesMediaButton setFrameOrigin:NSMakePoint(self.sharedMediaButton.frame.origin.x, self.sharedMediaButton.frame.origin.y -42)]; - + + [self setFrameSize:NSMakeSize(NSWidth(self.frame), self.controller.chat.isCreator ? 500 : cantEditGroup ? 324 : 408)]; + + [self.statusTextField setChat:chat]; + [self.statusTextField sizeToFit]; + + if(!self.fullChat) { + MTLog(@"full chat is not loading"); + return; + } + + [self.avatarImageView setChat:chat]; + [self.avatarImageView rebuild]; + + [_mediaView setConversation:chat.dialog]; + [self.sharedMediaButton setConversation:chat.dialog]; + [self.filesMediaButton setConversation:chat.dialog]; + [self.sharedLinksButton setConversation:chat.dialog]; + + [self.nameTextField setChat:chat]; + + + [self buildNotificationsTitle]; + + [self TMNameTextFieldDidChanged:self.nameTextField]; + + + [self.setGroupPhotoButton setFrameOrigin:NSMakePoint(100, self.bounds.size.height - 156)]; + [self.addMembersButton setFrameOrigin:NSMakePoint(self.setGroupPhotoButton.frame.origin.x, self.setGroupPhotoButton.frame.origin.y - 42)]; + + [_addMembersButton setHidden:cantEditGroup]; + [_setGroupPhotoButton setHidden:cantEditGroup]; + + [_exportChatInvite setFrameOrigin:NSMakePoint(self.sharedMediaButton.frame.origin.x,self.addMembersButton.isHidden ? _setGroupPhotoButton.frame.origin.y -42 : _addMembersButton.frame.origin.y-42)]; + + [_exportChatInvite setHidden:!self.controller.chat.isCreator]; + + + [_admins setFrameOrigin:NSMakePoint(self.exportChatInvite.frame.origin.x,self.exportChatInvite.isHidden ? (self.addMembersButton.isHidden ? _setGroupPhotoButton.frame.origin.y -42 : _addMembersButton.frame.origin.y-42) : _exportChatInvite.frame.origin.y-42)]; + + [_admins setHidden:!self.controller.chat.isCreator || !ACCEPT_FEATURE]; + + + [self.sharedMediaButton setFrameOrigin:NSMakePoint(NSMinX(_admins.isHidden ? self.addMembersButton.frame : self.admins.frame), (cantEditGroup ? NSHeight(self.frame) - 100 : NSMinY(_admins.isHidden ? self.addMembersButton.frame : self.admins.frame)) - 72)]; + + + [self.filesMediaButton setFrameOrigin:NSMakePoint(self.sharedMediaButton.frame.origin.x, self.sharedMediaButton.frame.origin.y -42)]; + + [self.sharedLinksButton setFrameOrigin:NSMakePoint(self.filesMediaButton.frame.origin.x, self.filesMediaButton.frame.origin.y -42)]; + + [_notificationView setFrame:NSMakeRect(100, NSMinY(self.sharedLinksButton.frame) - 42, NSWidth(self.frame) - 200, 42)]; + - [_notificationView setFrame:NSMakeRect(100, NSMinY(self.filesMediaButton.frame) - 42, NSWidth(self.frame) - 200, 42)]; - + + + [self.controller buildFirstItem]; + }]; + + } @@ -397,7 +492,7 @@ -(void)buildNotificationsTitle { [string appendString:str withColor:NSColorFromRGB(0xa1a1a1)]; - [string setFont:[NSFont fontWithName:@"HelveticaNeue-Light" size:15] forRange:NSMakeRange(0, string.length)]; + [string setFont:TGSystemLightFont(15) forRange:NSMakeRange(0, string.length)]; [string appendAttributedString:[NSAttributedString attributedStringWithAttachment:attach]]; [self.muteUntilTitle setAttributedStringValue:string]; @@ -408,11 +503,16 @@ -(void)buildNotificationsTitle { } +-(void)save { + +} - (void)drawRect:(NSRect)dirtyRect { [super drawRect:dirtyRect]; - // Drawing code here. + if(self.controller.chat.dialog.type == DialogTypeChannel && self.controller.chat.dialog.chat.isVerified) { + [image_Verify() drawInRect:NSMakeRect(NSMaxX(self.nameTextField.frame),NSMinY(self.nameTextField.frame) +1 , image_Verify().size.width, image_Verify().size.height) fromRect:NSZeroRect operation:NSCompositeHighlight fraction:1]; + } } @end diff --git a/TelegramTest/ChatInfoViewController.h b/TelegramTest/ChatInfoViewController.h index 18ec226a..5a014f19 100644 --- a/TelegramTest/ChatInfoViewController.h +++ b/TelegramTest/ChatInfoViewController.h @@ -8,6 +8,7 @@ #import "TMViewController.h" #import "UserInfoShortButtonView.h" +#import "ChatAvatarImageView.h" @interface ChatHeaderItem : TMRowItem @end @@ -18,6 +19,7 @@ @interface ChatBottomView : TMRowView @property (nonatomic,strong) UserInfoShortButtonView *button; @property (nonatomic,strong) TL_conversation *conversation; + @end @class ChatParticipantItem; @@ -29,6 +31,9 @@ typedef enum { @interface ChatInfoViewController : TMViewController + +@property (nonatomic,weak) MessagesViewController *messagesViewController; + @property (nonatomic, strong) TLChat *chat; @property (nonatomic) ChatInfoViewControllerType type; diff --git a/TelegramTest/ChatInfoViewController.m b/TelegramTest/ChatInfoViewController.m index ea38eeca..e3a7546c 100644 --- a/TelegramTest/ChatInfoViewController.m +++ b/TelegramTest/ChatInfoViewController.m @@ -49,7 +49,7 @@ -(id)initWithFrame:(NSRect)frameRect { } -(void)redrawRow { - [self.button.textButton setStringValue:_conversation.type == DialogTypeChat ? NSLocalizedString(@"Conversation.DeleteAndExit", nil) : NSLocalizedString(@"Profile.DeleteBroadcast", nil)]; + [self.button.textButton setStringValue:_conversation.type == DialogTypeChat ? NSLocalizedString(@"Conversation.DeleteAndExit", nil) : (_conversation.chat.isAdmin ? NSLocalizedString(@"Profile.DeleteChannel", nil) : NSLocalizedString(@"Profile.LeaveChannel", nil))]; [self.button sizeToFit]; } @@ -109,7 +109,8 @@ -(void)loadView { - _headerView = [[ChatInfoHeaderView alloc] initWithFrame:NSMakeRect(0, 0, self.view.bounds.size.width, 410)]; + + _headerView = [[ChatInfoHeaderView alloc] initWithFrame:NSMakeRect(0, 0, self.view.bounds.size.width, 450)]; _tableView = [[TMTableView alloc] initWithFrame:self.view.bounds]; @@ -120,66 +121,78 @@ -(void)loadView { } -- (void)navigationGoBack { - [[Telegram rightViewController] navigationGoBack]; + +-(void)buildFirstItem { + [self.tableView reloadData]; +} + +-(void)setType:(ChatInfoViewControllerType)type { + _type = type; + [self.headerView setType:type]; + [self buildRightView]; } - (void)buildRightView { TMView *view = [[TMView alloc] init]; - - [_headerView setType:self.type]; - + int width = 0; TMTextButton *button; - if(self.type == ChatInfoViewControllerNormal) { - - button = [TMTextButton standartUserProfileNavigationButtonWithTitle:NSLocalizedString(@"Profile.Edit", nil)]; - [button setTapBlock:^{ - self.type = ChatInfoViewControllerEdit; - [self buildRightView]; - }]; - [view addSubview:button]; - - } else { - - - - button = [TMTextButton standartUserProfileNavigationButtonWithTitle:NSLocalizedString(@"Profile.Save", nil)]; - - - - [button setTapBlock:^{ - [self save]; - }]; - [view addSubview:button]; - - - - TMTextButton *cancelButton = [TMTextButton standartUserProfileNavigationButtonWithTitle:NSLocalizedString(@"Profile.Cancel", nil)]; - [cancelButton setFrameOrigin:NSMakePoint(button.bounds.size.width + 10, button.frame.origin.y)]; - weakify(); - - [cancelButton setTapBlock:^{ + + if((!self.chat.isAdmins_enabled || self.chat.isAdmin) || self.chat.isCreator) { + if(self.type == ChatInfoViewControllerNormal) { - [strongSelf.headerView.nameTextField setChat:nil]; - [strongSelf.headerView.nameTextField setChat:self.chat]; - strongSelf.type = ChatInfoViewControllerNormal; - [self buildRightView]; - }]; - [view addSubview:cancelButton]; - - width = cancelButton.frame.size.width+10; + button = [TMTextButton standartUserProfileNavigationButtonWithTitle:NSLocalizedString(@"Profile.Edit", nil)]; + [button setTapBlock:^{ + self.type = ChatInfoViewControllerEdit; + [self buildRightView]; + }]; + [view addSubview:button]; + + } else { + + + + button = [TMTextButton standartUserProfileNavigationButtonWithTitle:NSLocalizedString(@"Profile.Save", nil)]; + + + + [button setTapBlock:^{ + [self save]; + }]; + [view addSubview:button]; + + + + TMTextButton *cancelButton = [TMTextButton standartUserProfileNavigationButtonWithTitle:NSLocalizedString(@"Profile.Cancel", nil)]; + [cancelButton setFrameOrigin:NSMakePoint(button.bounds.size.width + 10, button.frame.origin.y)]; + weakify(); + + [cancelButton setTapBlock:^{ + + [strongSelf.headerView.nameTextField setChat:nil]; + [strongSelf.headerView.nameTextField setChat:self.chat]; + strongSelf.type = ChatInfoViewControllerNormal; + [self buildRightView]; + }]; + [view addSubview:cancelButton]; + + width = cancelButton.frame.size.width+10; + + [view setFrameSize:NSMakeSize(cancelButton.frame.origin.x + cancelButton.bounds.size.width, cancelButton.bounds.size.height)]; + + } - [view setFrameSize:NSMakeSize(cancelButton.frame.origin.x + cancelButton.bounds.size.width, cancelButton.bounds.size.height)]; + width+= button.frame.size.width; + [view setFrameSize:NSMakeSize(width, button.frame.size.height)]; + [self setRightNavigationBarView:view]; + } else { + [self setRightNavigationBarView:nil]; } - width+= button.frame.size.width; - - [view setFrameSize:NSMakeSize(width, button.frame.size.height)]; - [self setRightNavigationBarView:view]; + } - (void)save { @@ -207,6 +220,15 @@ - (void)viewWillAppear:(BOOL)animated { [self reloadParticipants]; [Notification addObserver:self selector:@selector(chatStatusNotification:) name:CHAT_STATUS]; + [Notification addObserver:self selector:@selector(didChangeChatFlags:) name:CHAT_FLAGS_UPDATED]; +} + +-(void)didChangeChatFlags:(NSNotification *)notification { + TLChat *chat = notification.userInfo[KEY_CHAT]; + + if(self.chat == chat) { + self.chat = chat; + } } - (void)viewWillDisappear:(BOOL)animated { @@ -244,41 +266,38 @@ - (void)chatStatusNotification:(NSNotification *)notify { - (void)setChat:(TLChat *)chat { self->_chat = chat; - [self view]; + if(chat) { + [self view]; + + [_headerView setController:self]; - if(chat) + [_headerView reload]; + _bottomView.conversation = chat.dialog; + + [_tableView scrollToBeginningOfDocument:_tableView]; + [_tableView.scrollView scrollToPoint:NSMakePoint(0, 0) animation:NO]; + + + self.fullChat = [[FullChatManager sharedManager] find:chat.n_id]; + + + + + [_tableView noteHeightOfRowsWithIndexesChanged:[NSIndexSet indexSetWithIndex:0]]; + + [_tableView reloadDataForRowIndexes:[NSIndexSet indexSetWithIndex:0] columnIndexes:[NSIndexSet indexSetWithIndex:0]]; + [self reloadParticipants]; + + self.type = ChatInfoViewControllerNormal; + [self buildRightView]; + + } else { + _type = ChatInfoViewControllerNormal; + [_tableView removeAllItems:NO]; + [_tableView reloadData]; + } - [_tableView scrollToBeginningOfDocument:_tableView]; - [_tableView.scrollView scrollToPoint:NSMakePoint(0, 0) animation:NO]; - - - - self.fullChat = [[FullChatManager sharedManager] find:chat.n_id]; - - [_headerView setController:self]; - [_headerView reload]; - - -// [self.fullChat.participants.participants enumerateObjectsUsingBlock:^(TL_chatParticipant *obj, NSUInteger idx, BOOL *stop) { -// -// if(obj.user_id == [UsersManager currentUserId]) { -// -// MTLog(@"inviter:%@, inviteDate:%@",[[[UsersManager sharedManager] find:obj.inviter_id] fullName],[NSDate dateWithTimeIntervalSince1970:obj.date]); -// -// } -// -// }]; - - // [_tableView.con setFrameOrigin:NSMakePoint(_tableView.frame.origin.x, _headerView.frame.size.height)]; - - [_tableView noteHeightOfRowsWithIndexesChanged:[NSIndexSet indexSetWithIndex:0]]; - - [_tableView reloadDataForRowIndexes:[NSIndexSet indexSetWithIndex:0] columnIndexes:[NSIndexSet indexSetWithIndex:0]]; - [self reloadParticipants]; - - self.type = ChatInfoViewControllerNormal; - [self buildRightView]; } - (void)kickParticipantByItem:(ChatParticipantItem *)item { @@ -288,10 +307,7 @@ - (void)kickParticipantByItem:(ChatParticipantItem *)item { [RPCRequest sendRequest:[TLAPI_messages_deleteChatUser createWithChat_id:self.chat.n_id user_id:item.user.inputUser] successHandler:^(RPCRequest *request, id response) { - - - - TLChatParticipants *participants = strongSelf.fullChat.participants; + TLChatParticipants *participants = strongSelf.fullChat.participants; NSArray *participant = [participants.participants filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.user_id == %d",item.user.n_id]]; @@ -346,7 +362,7 @@ - (void)reloadParticipants { for(TLChatParticipant *participant in participants.participants) { ChatParticipantItem *item = [[ChatParticipantItem alloc] initWithObject:participant]; item.isBlocking = ((ChatParticipantItem *)[_tableView itemByHash:item.hash]).isBlocking; - item.isCanKicked = (participant.inviter_id == selfId || self.fullChat.participants.admin_id == selfId) && participant.user_id != selfId; + item.isCanKicked = self.chat.isAdmins_enabled ? (participant.user_id != selfId && self.chat.isAdmin && ![participant isKindOfClass:[TL_chatParticipantCreator class]]) : (participant.user_id != selfId && participant.inviter_id == [UsersManager currentUserId]); item.viewController = self; [array addObject:item]; @@ -381,7 +397,7 @@ - (void)reloadParticipants { - (CGFloat)rowHeight:(NSUInteger)row item:(TMRowItem *) item { if([item isEqualTo:_headerItem]) { return _headerView.bounds.size.height; - } else if([item isEqualTo:_bottomItem]) { + } else if([item isKindOfClass:[ChatBottomItem class]]) { return 70; } else { return 50; @@ -403,7 +419,16 @@ - (TMRowView *)viewForRow:(NSUInteger)row item:(TMRowItem *) item { } - (void)selectionDidChange:(NSInteger)row item:(ChatParticipantItem *) item { - [[Telegram rightViewController] showUserInfoPage:item.user]; + + TMViewController *infoViewController; + + infoViewController = [[UserInfoViewController alloc] initWithFrame:self.view.bounds]; + + [(UserInfoViewController *)infoViewController setUser:item.user conversation:item.user.dialog]; + + [self.navigationViewController pushViewController:infoViewController animated:YES]; + + } - (BOOL)selectionWillChange:(NSInteger)row item:(TMRowItem *) item { diff --git a/TelegramTest/ChatParticipantRowView.m b/TelegramTest/ChatParticipantRowView.m index 8df9a622..0b6fb633 100644 --- a/TelegramTest/ChatParticipantRowView.m +++ b/TelegramTest/ChatParticipantRowView.m @@ -118,10 +118,12 @@ - (void)redrawRow { - (void) TMNameTextFieldDidChanged:(TMNameTextField *)textField { [self.nameTextField sizeToFit]; + [self setFrameSize:self.frame.size]; } - (void) TMStatusTextFieldDidChanged:(TMStatusTextField *)textField { [self.statusTextField sizeToFit]; + [self setFrameSize:self.frame.size]; } diff --git a/TelegramTest/ChatsManager.h b/TelegramTest/ChatsManager.h index 2bb93250..95acb6f8 100644 --- a/TelegramTest/ChatsManager.h +++ b/TelegramTest/ChatsManager.h @@ -11,4 +11,11 @@ @interface ChatsManager : SharedManager - (NSArray *)secretChats; -(void)acceptEncryption:(TL_encryptedChatRequested *)request; + + ++(TLChat *)findChatByName:(NSString *)userName; ++(NSArray *)findChatsByName:(NSString *)userName; +-(void)updateChannelUserName:(NSString *)userName channel:(TL_channel *)channel completeHandler:(void (^)(TL_channel *))completeHandler errorHandler:(void (^)(NSString *))errorHandler; + + @end diff --git a/TelegramTest/ChatsManager.m b/TelegramTest/ChatsManager.m index da9151cc..7fa64aea 100644 --- a/TelegramTest/ChatsManager.m +++ b/TelegramTest/ChatsManager.m @@ -24,7 +24,7 @@ +(id)sharedManager { - (void)add:(NSArray *)all withCustomKey:(NSString*)key { - + int bp = 0; [self.queue dispatchOnQueue:^{ @@ -40,6 +40,9 @@ - (void)add:(NSArray *)all withCustomKey:(NSString*)key { TLChat *currentChat = [self->keys objectForKey:[obj valueForKey:key]]; if(currentChat != nil) { + BOOL isNeedUpdateTypeNotification = NO; + + if([currentChat.photo.photo_small hashCacheKey] != [newChat.photo.photo_small hashCacheKey]) { currentChat.photo = newChat.photo; @@ -51,24 +54,48 @@ - (void)add:(NSArray *)all withCustomKey:(NSString*)key { [Notification perform:CHAT_UPDATE_TITLE data:@{KEY_CHAT: currentChat}]; } + currentChat.username = newChat.username; + currentChat.participants_count = newChat.participants_count; currentChat.date = newChat.date; - currentChat.version = newChat.version; + currentChat.access_hash = newChat.access_hash; - BOOL isNeedUpdateTypeNotification = NO; - if(currentChat.left != newChat.left) { - currentChat.left = newChat.left; - isNeedUpdateTypeNotification = YES; + if(currentChat.version != newChat.version) { + currentChat.version = newChat.version; + + [[FullChatManager sharedManager] loadIfNeed:currentChat.n_id force:YES]; // force load chat if changed version. } - if(currentChat.type != newChat.type) { + if(currentChat.flags != newChat.flags) { + if(!(currentChat.type == TLChatTypeNormal && newChat.type == TLChatTypeForbidden)) { + currentChat.flags = newChat.flags; + isNeedUpdateTypeNotification = YES; + } + } + + if((currentChat.migrated_to || newChat.migrated_to) && (![currentChat.migrated_to isKindOfClass:newChat.migrated_to.class] || currentChat.migrated_to.channel_id != newChat.migrated_to.channel_id)) { + currentChat.migrated_to = newChat.migrated_to; + + if(currentChat.isDeactivated && currentChat.migrated_to.channel_id != 0) { + [Notification perform:DIALOG_DELETE data:@{KEY_DIALOG:currentChat.dialog}]; + } + } + + + + if(currentChat.type != newChat.type) { currentChat.type = newChat.type; isNeedUpdateTypeNotification = YES; } - if(isNeedUpdateTypeNotification) - [Notification perform:CHAT_UPDATE_TYPE data:@{KEY_CHAT:currentChat}]; + + + if(isNeedUpdateTypeNotification) { + [Notification perform:CHAT_FLAGS_UPDATED data:@{KEY_CHAT:currentChat}]; + [Notification perform:CHAT_UPDATE_TYPE data:@{KEY_CHAT:currentChat}]; + } + } else { @@ -166,4 +193,51 @@ -(void)acceptEncryption:(TL_encryptedChatRequested *)request { } ++(TLChat *)findChatByName:(NSString *)userName { + if([userName hasPrefix:@"@"]) + userName = [userName substringFromIndex:1]; + + NSArray *chats = [[[ChatsManager sharedManager] all] filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.username == %@",userName]]; + + if(chats.count == 1) + return chats[0]; + + return nil; +} + ++(NSArray *)findChatsByName:(NSString *)userName { + if([userName hasPrefix:@"@"]) + userName = [userName substringFromIndex:1]; + + NSArray *chats = [[[ChatsManager sharedManager] all] filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.username BEGINSWITH[c] %@",userName]]; + + + return chats; +} + + +-(void)updateChannelUserName:(NSString *)userName channel:(TL_channel *)channel completeHandler:(void (^)(TL_channel *))completeHandler errorHandler:(void (^)(NSString *))errorHandler { + + [RPCRequest sendRequest:[TLAPI_channels_updateUsername createWithChannel:channel.inputPeer username:userName] successHandler:^(id request, id response) { + + if([response isKindOfClass:[TL_boolTrue class]]) { + channel.username = userName; + [[Storage manager] insertChat:channel completeHandler:nil]; + + if(completeHandler != nil) { + completeHandler(channel); + } + } + + } errorHandler:^(id request, RpcError *error) { + + if(errorHandler != nil) { + errorHandler(error.error_msg); + } + + }]; + +} + + @end diff --git a/TelegramTest/ClassStore.m b/TelegramTest/ClassStore.m index 7e74e520..0e39b978 100644 --- a/TelegramTest/ClassStore.m +++ b/TelegramTest/ClassStore.m @@ -3,7 +3,7 @@ // ClassStore.m // Telegram // - // Created by keepcoder on 24.07.15. + // Created by keepcoder on 27.11.15. // Copyright (c) 2015 keepcoder. All rights reserved. // @@ -148,15 +148,12 @@ +(void)initialize { // insert constructors here. [cs_classes setObject:[TL_boolFalse class] forKey:[NSNumber numberWithInt:-1132882121]]; [cs_classes setObject:[TL_boolTrue class] forKey:[NSNumber numberWithInt:-1720552011]]; + [cs_classes setObject:[TL_true class] forKey:[NSNumber numberWithInt:1072550713]]; [cs_classes setObject:[TL_inputPeerEmpty class] forKey:[NSNumber numberWithInt:2134579434]]; [cs_classes setObject:[TL_inputPeerSelf class] forKey:[NSNumber numberWithInt:2107670217]]; - [cs_classes setObject:[TL_inputPeerContact class] forKey:[NSNumber numberWithInt:270785512]]; - [cs_classes setObject:[TL_inputPeerForeign class] forKey:[NSNumber numberWithInt:-1690012891]]; [cs_classes setObject:[TL_inputPeerChat class] forKey:[NSNumber numberWithInt:396093539]]; [cs_classes setObject:[TL_inputUserEmpty class] forKey:[NSNumber numberWithInt:-1182234929]]; [cs_classes setObject:[TL_inputUserSelf class] forKey:[NSNumber numberWithInt:-138301121]]; - [cs_classes setObject:[TL_inputUserContact class] forKey:[NSNumber numberWithInt:-2031530139]]; - [cs_classes setObject:[TL_inputUserForeign class] forKey:[NSNumber numberWithInt:1700689151]]; [cs_classes setObject:[TL_inputPhoneContact class] forKey:[NSNumber numberWithInt:-208488460]]; [cs_classes setObject:[TL_inputFile class] forKey:[NSNumber numberWithInt:-181407105]]; [cs_classes setObject:[TL_inputMediaEmpty class] forKey:[NSNumber numberWithInt:-1771768449]]; @@ -164,8 +161,8 @@ +(void)initialize { [cs_classes setObject:[TL_inputMediaPhoto class] forKey:[NSNumber numberWithInt:-373312269]]; [cs_classes setObject:[TL_inputMediaGeoPoint class] forKey:[NSNumber numberWithInt:-104578748]]; [cs_classes setObject:[TL_inputMediaContact class] forKey:[NSNumber numberWithInt:-1494984313]]; - [cs_classes setObject:[TL_inputMediaUploadedVideo class] forKey:[NSNumber numberWithInt:-515910468]]; - [cs_classes setObject:[TL_inputMediaUploadedThumbVideo class] forKey:[NSNumber numberWithInt:-1761896484]]; + [cs_classes setObject:[TL_inputMediaUploadedVideo class] forKey:[NSNumber numberWithInt:-2106507297]]; + [cs_classes setObject:[TL_inputMediaUploadedThumbVideo class] forKey:[NSNumber numberWithInt:2004934137]]; [cs_classes setObject:[TL_inputMediaVideo class] forKey:[NSNumber numberWithInt:-1821749571]]; [cs_classes setObject:[TL_inputChatPhotoEmpty class] forKey:[NSNumber numberWithInt:480546647]]; [cs_classes setObject:[TL_inputChatUploadedPhoto class] forKey:[NSNumber numberWithInt:-1809496270]]; @@ -202,17 +199,17 @@ +(void)initialize { [cs_classes setObject:[TL_userStatusOnline class] forKey:[NSNumber numberWithInt:-306628279]]; [cs_classes setObject:[TL_userStatusOffline class] forKey:[NSNumber numberWithInt:9203775]]; [cs_classes setObject:[TL_chatEmpty class] forKey:[NSNumber numberWithInt:-1683826688]]; - [cs_classes setObject:[TL_chat class] forKey:[NSNumber numberWithInt:1855757255]]; - [cs_classes setObject:[TL_chatForbidden class] forKey:[NSNumber numberWithInt:-83047359]]; + [cs_classes setObject:[TL_chat class] forKey:[NSNumber numberWithInt:-652419756]]; + [cs_classes setObject:[TL_chatForbidden class] forKey:[NSNumber numberWithInt:120753115]]; [cs_classes setObject:[TL_chatFull class] forKey:[NSNumber numberWithInt:771925524]]; [cs_classes setObject:[TL_chatParticipant class] forKey:[NSNumber numberWithInt:-925415106]]; - [cs_classes setObject:[TL_chatParticipantsForbidden class] forKey:[NSNumber numberWithInt:265468810]]; - [cs_classes setObject:[TL_chatParticipants class] forKey:[NSNumber numberWithInt:2017571861]]; + [cs_classes setObject:[TL_chatParticipantsForbidden class] forKey:[NSNumber numberWithInt:-57668565]]; + [cs_classes setObject:[TL_chatParticipants class] forKey:[NSNumber numberWithInt:1061556205]]; [cs_classes setObject:[TL_chatPhotoEmpty class] forKey:[NSNumber numberWithInt:935395612]]; [cs_classes setObject:[TL_chatPhoto class] forKey:[NSNumber numberWithInt:1632839530]]; [cs_classes setObject:[TL_messageEmpty class] forKey:[NSNumber numberWithInt:-2082087340]]; - [cs_classes setObject:[TL_message class] forKey:[NSNumber numberWithInt:-1023016155]]; - [cs_classes setObject:[TL_messageService class] forKey:[NSNumber numberWithInt:495384334]]; + [cs_classes setObject:[TL_message class] forKey:[NSNumber numberWithInt:1537633299]]; + [cs_classes setObject:[TL_messageService class] forKey:[NSNumber numberWithInt:-1066691065]]; [cs_classes setObject:[TL_messageMediaEmpty class] forKey:[NSNumber numberWithInt:1038967584]]; [cs_classes setObject:[TL_messageMediaPhoto class] forKey:[NSNumber numberWithInt:1032643901]]; [cs_classes setObject:[TL_messageMediaVideo class] forKey:[NSNumber numberWithInt:1540298357]]; @@ -224,16 +221,16 @@ +(void)initialize { [cs_classes setObject:[TL_messageActionChatEditTitle class] forKey:[NSNumber numberWithInt:-1247687078]]; [cs_classes setObject:[TL_messageActionChatEditPhoto class] forKey:[NSNumber numberWithInt:2144015272]]; [cs_classes setObject:[TL_messageActionChatDeletePhoto class] forKey:[NSNumber numberWithInt:-1780220945]]; - [cs_classes setObject:[TL_messageActionChatAddUser class] forKey:[NSNumber numberWithInt:1581055051]]; + [cs_classes setObject:[TL_messageActionChatAddUser class] forKey:[NSNumber numberWithInt:1217033015]]; [cs_classes setObject:[TL_messageActionChatDeleteUser class] forKey:[NSNumber numberWithInt:-1297179892]]; [cs_classes setObject:[TL_dialog class] forKey:[NSNumber numberWithInt:-1042448310]]; [cs_classes setObject:[TL_photoEmpty class] forKey:[NSNumber numberWithInt:590459437]]; - [cs_classes setObject:[TL_photo class] forKey:[NSNumber numberWithInt:-1014792074]]; + [cs_classes setObject:[TL_photo class] forKey:[NSNumber numberWithInt:-840088834]]; [cs_classes setObject:[TL_photoSizeEmpty class] forKey:[NSNumber numberWithInt:236446268]]; [cs_classes setObject:[TL_photoSize class] forKey:[NSNumber numberWithInt:2009052699]]; [cs_classes setObject:[TL_photoCachedSize class] forKey:[NSNumber numberWithInt:-374917894]]; [cs_classes setObject:[TL_videoEmpty class] forKey:[NSNumber numberWithInt:-1056548696]]; - [cs_classes setObject:[TL_video class] forKey:[NSNumber numberWithInt:-291550643]]; + [cs_classes setObject:[TL_video class] forKey:[NSNumber numberWithInt:-148338733]]; [cs_classes setObject:[TL_geoPointEmpty class] forKey:[NSNumber numberWithInt:286776671]]; [cs_classes setObject:[TL_geoPoint class] forKey:[NSNumber numberWithInt:541710092]]; [cs_classes setObject:[TL_auth_checkedPhone class] forKey:[NSNumber numberWithInt:-2128698738]]; @@ -252,13 +249,16 @@ +(void)initialize { [cs_classes setObject:[TL_peerNotifySettingsEmpty class] forKey:[NSNumber numberWithInt:1889961234]]; [cs_classes setObject:[TL_peerNotifySettings class] forKey:[NSNumber numberWithInt:-1923214866]]; [cs_classes setObject:[TL_wallPaper class] forKey:[NSNumber numberWithInt:-860866985]]; + [cs_classes setObject:[TL_inputReportReasonSpam class] forKey:[NSNumber numberWithInt:1490799288]]; + [cs_classes setObject:[TL_inputReportReasonViolence class] forKey:[NSNumber numberWithInt:505595789]]; + [cs_classes setObject:[TL_inputReportReasonPornography class] forKey:[NSNumber numberWithInt:777640226]]; + [cs_classes setObject:[TL_inputReportReasonOther class] forKey:[NSNumber numberWithInt:-512463606]]; [cs_classes setObject:[TL_userFull class] forKey:[NSNumber numberWithInt:1518971995]]; [cs_classes setObject:[TL_contact class] forKey:[NSNumber numberWithInt:-116274796]]; [cs_classes setObject:[TL_importedContact class] forKey:[NSNumber numberWithInt:-805141448]]; [cs_classes setObject:[TL_contactBlocked class] forKey:[NSNumber numberWithInt:1444661369]]; [cs_classes setObject:[TL_contactSuggested class] forKey:[NSNumber numberWithInt:1038193057]]; [cs_classes setObject:[TL_contactStatus class] forKey:[NSNumber numberWithInt:-748155807]]; - [cs_classes setObject:[TL_chatLocated class] forKey:[NSNumber numberWithInt:909233996]]; [cs_classes setObject:[TL_contacts_link class] forKey:[NSNumber numberWithInt:986597452]]; [cs_classes setObject:[TL_contacts_contactsNotModified class] forKey:[NSNumber numberWithInt:-1219778094]]; [cs_classes setObject:[TL_contacts_contacts class] forKey:[NSNumber numberWithInt:1871416498]]; @@ -270,8 +270,6 @@ +(void)initialize { [cs_classes setObject:[TL_messages_dialogsSlice class] forKey:[NSNumber numberWithInt:1910543603]]; [cs_classes setObject:[TL_messages_messages class] forKey:[NSNumber numberWithInt:-1938715001]]; [cs_classes setObject:[TL_messages_messagesSlice class] forKey:[NSNumber numberWithInt:189033187]]; - [cs_classes setObject:[TL_messages_messageEmpty class] forKey:[NSNumber numberWithInt:1062078024]]; - [cs_classes setObject:[TL_messages_sentMessage class] forKey:[NSNumber numberWithInt:1279084531]]; [cs_classes setObject:[TL_messages_chats class] forKey:[NSNumber numberWithInt:1694474197]]; [cs_classes setObject:[TL_messages_chatFull class] forKey:[NSNumber numberWithInt:-438840932]]; [cs_classes setObject:[TL_messages_affectedHistory class] forKey:[NSNumber numberWithInt:-1269012015]]; @@ -301,8 +299,8 @@ +(void)initialize { [cs_classes setObject:[TL_updates_difference class] forKey:[NSNumber numberWithInt:16030880]]; [cs_classes setObject:[TL_updates_differenceSlice class] forKey:[NSNumber numberWithInt:-1459938943]]; [cs_classes setObject:[TL_updatesTooLong class] forKey:[NSNumber numberWithInt:-484987010]]; - [cs_classes setObject:[TL_updateShortMessage class] forKey:[NSNumber numberWithInt:-312729305]]; - [cs_classes setObject:[TL_updateShortChatMessage class] forKey:[NSNumber numberWithInt:1378061116]]; + [cs_classes setObject:[TL_updateShortMessage class] forKey:[NSNumber numberWithInt:-136766906]]; + [cs_classes setObject:[TL_updateShortChatMessage class] forKey:[NSNumber numberWithInt:-892863022]]; [cs_classes setObject:[TL_updateShort class] forKey:[NSNumber numberWithInt:2027216577]]; [cs_classes setObject:[TL_updatesCombined class] forKey:[NSNumber numberWithInt:1918567619]]; [cs_classes setObject:[TL_updates class] forKey:[NSNumber numberWithInt:1957577280]]; @@ -311,25 +309,11 @@ +(void)initialize { [cs_classes setObject:[TL_photos_photo class] forKey:[NSNumber numberWithInt:539045032]]; [cs_classes setObject:[TL_upload_file class] forKey:[NSNumber numberWithInt:157948117]]; [cs_classes setObject:[TL_dcOption class] forKey:[NSNumber numberWithInt:98092748]]; - [cs_classes setObject:[TL_config class] forKey:[NSNumber numberWithInt:1311946900]]; + [cs_classes setObject:[TL_config class] forKey:[NSNumber numberWithInt:1823925854]]; [cs_classes setObject:[TL_nearestDc class] forKey:[NSNumber numberWithInt:-1910892683]]; [cs_classes setObject:[TL_help_appUpdate class] forKey:[NSNumber numberWithInt:-1987579119]]; [cs_classes setObject:[TL_help_noAppUpdate class] forKey:[NSNumber numberWithInt:-1000708810]]; [cs_classes setObject:[TL_help_inviteText class] forKey:[NSNumber numberWithInt:415997816]]; - [cs_classes setObject:[TL_messages_sentMessageLink class] forKey:[NSNumber numberWithInt:899786339]]; - [cs_classes setObject:[TL_inputGeoChat class] forKey:[NSNumber numberWithInt:1960072954]]; - [cs_classes setObject:[TL_inputNotifyGeoChatPeer class] forKey:[NSNumber numberWithInt:1301143240]]; - [cs_classes setObject:[TL_geoChat class] forKey:[NSNumber numberWithInt:1978329690]]; - [cs_classes setObject:[TL_geoChatMessageEmpty class] forKey:[NSNumber numberWithInt:1613830811]]; - [cs_classes setObject:[TL_geoChatMessage class] forKey:[NSNumber numberWithInt:1158019297]]; - [cs_classes setObject:[TL_geoChatMessageService class] forKey:[NSNumber numberWithInt:-749755826]]; - [cs_classes setObject:[TL_geochats_statedMessage class] forKey:[NSNumber numberWithInt:397498251]]; - [cs_classes setObject:[TL_geochats_located class] forKey:[NSNumber numberWithInt:1224651367]]; - [cs_classes setObject:[TL_geochats_messages class] forKey:[NSNumber numberWithInt:-783127119]]; - [cs_classes setObject:[TL_geochats_messagesSlice class] forKey:[NSNumber numberWithInt:-1135057944]]; - [cs_classes setObject:[TL_messageActionGeoChatCreate class] forKey:[NSNumber numberWithInt:1862504124]]; - [cs_classes setObject:[TL_messageActionGeoChatCheckin class] forKey:[NSNumber numberWithInt:209540062]]; - [cs_classes setObject:[TL_updateNewGeoChatMessage class] forKey:[NSNumber numberWithInt:1516823543]]; [cs_classes setObject:[TL_wallPaperSolid class] forKey:[NSNumber numberWithInt:1662091044]]; [cs_classes setObject:[TL_updateNewEncryptedMessage class] forKey:[NSNumber numberWithInt:314359194]]; [cs_classes setObject:[TL_updateEncryptedChatTyping class] forKey:[NSNumber numberWithInt:386986326]]; @@ -355,7 +339,7 @@ +(void)initialize { [cs_classes setObject:[TL_messages_sentEncryptedFile class] forKey:[NSNumber numberWithInt:-1802240206]]; [cs_classes setObject:[TL_inputFileBig class] forKey:[NSNumber numberWithInt:-95482955]]; [cs_classes setObject:[TL_inputEncryptedFileBigUploaded class] forKey:[NSNumber numberWithInt:767652808]]; - [cs_classes setObject:[TL_updateChatParticipantAdd class] forKey:[NSNumber numberWithInt:974056226]]; + [cs_classes setObject:[TL_updateChatParticipantAdd class] forKey:[NSNumber numberWithInt:-364179876]]; [cs_classes setObject:[TL_updateChatParticipantDelete class] forKey:[NSNumber numberWithInt:1851755554]]; [cs_classes setObject:[TL_updateDcOptions class] forKey:[NSNumber numberWithInt:-1906403213]]; [cs_classes setObject:[TL_inputMediaUploadedAudio class] forKey:[NSNumber numberWithInt:1313442987]]; @@ -372,7 +356,7 @@ +(void)initialize { [cs_classes setObject:[TL_inputAudioFileLocation class] forKey:[NSNumber numberWithInt:1960591437]]; [cs_classes setObject:[TL_inputDocumentFileLocation class] forKey:[NSNumber numberWithInt:1313188841]]; [cs_classes setObject:[TL_audioEmpty class] forKey:[NSNumber numberWithInt:1483311320]]; - [cs_classes setObject:[TL_audio class] forKey:[NSNumber numberWithInt:-945003370]]; + [cs_classes setObject:[TL_audio class] forKey:[NSNumber numberWithInt:-102543275]]; [cs_classes setObject:[TL_documentEmpty class] forKey:[NSNumber numberWithInt:922273905]]; [cs_classes setObject:[TL_document class] forKey:[NSNumber numberWithInt:-106717361]]; [cs_classes setObject:[TL_help_support class] forKey:[NSNumber numberWithInt:398898678]]; @@ -393,8 +377,7 @@ +(void)initialize { [cs_classes setObject:[TL_sendMessageUploadDocumentAction class] forKey:[NSNumber numberWithInt:-1441998364]]; [cs_classes setObject:[TL_sendMessageGeoLocationAction class] forKey:[NSNumber numberWithInt:393186209]]; [cs_classes setObject:[TL_sendMessageChooseContactAction class] forKey:[NSNumber numberWithInt:1653390447]]; - [cs_classes setObject:[TL_contactFound class] forKey:[NSNumber numberWithInt:-360210539]]; - [cs_classes setObject:[TL_contacts_found class] forKey:[NSNumber numberWithInt:90570766]]; + [cs_classes setObject:[TL_contacts_found class] forKey:[NSNumber numberWithInt:446822276]]; [cs_classes setObject:[TL_updateServiceNotification class] forKey:[NSNumber numberWithInt:942527460]]; [cs_classes setObject:[TL_userStatusRecently class] forKey:[NSNumber numberWithInt:-496024847]]; [cs_classes setObject:[TL_userStatusLastWeek class] forKey:[NSNumber numberWithInt:129960444]]; @@ -428,7 +411,7 @@ +(void)initialize { [cs_classes setObject:[TL_messages_stickers class] forKey:[NSNumber numberWithInt:-1970352846]]; [cs_classes setObject:[TL_stickerPack class] forKey:[NSNumber numberWithInt:313694676]]; [cs_classes setObject:[TL_messages_allStickersNotModified class] forKey:[NSNumber numberWithInt:-395967805]]; - [cs_classes setObject:[TL_messages_allStickers class] forKey:[NSNumber numberWithInt:-719474725]]; + [cs_classes setObject:[TL_messages_allStickers class] forKey:[NSNumber numberWithInt:-302170017]]; [cs_classes setObject:[TL_disabledFeature class] forKey:[NSNumber numberWithInt:-1369215196]]; [cs_classes setObject:[TL_updateReadHistoryInbox class] forKey:[NSNumber numberWithInt:-1721631396]]; [cs_classes setObject:[TL_updateReadHistoryOutbox class] forKey:[NSNumber numberWithInt:791617983]]; @@ -437,10 +420,10 @@ +(void)initialize { [cs_classes setObject:[TL_contactLinkNone class] forKey:[NSNumber numberWithInt:-17968211]]; [cs_classes setObject:[TL_contactLinkHasPhone class] forKey:[NSNumber numberWithInt:646922073]]; [cs_classes setObject:[TL_contactLinkContact class] forKey:[NSNumber numberWithInt:-721239344]]; - [cs_classes setObject:[TL_updateWebPage class] forKey:[NSNumber numberWithInt:751004017]]; + [cs_classes setObject:[TL_updateWebPage class] forKey:[NSNumber numberWithInt:2139689491]]; [cs_classes setObject:[TL_webPageEmpty class] forKey:[NSNumber numberWithInt:-350980120]]; [cs_classes setObject:[TL_webPagePending class] forKey:[NSNumber numberWithInt:-981018084]]; - [cs_classes setObject:[TL_webPage class] forKey:[NSNumber numberWithInt:-1558273867]]; + [cs_classes setObject:[TL_webPage class] forKey:[NSNumber numberWithInt:-897446185]]; [cs_classes setObject:[TL_messageMediaWebPage class] forKey:[NSNumber numberWithInt:-1557277184]]; [cs_classes setObject:[TL_authorization class] forKey:[NSNumber numberWithInt:2079516406]]; [cs_classes setObject:[TL_account_authorizations class] forKey:[NSNumber numberWithInt:307276766]]; @@ -455,7 +438,7 @@ +(void)initialize { [cs_classes setObject:[TL_chatInviteEmpty class] forKey:[NSNumber numberWithInt:1776236393]]; [cs_classes setObject:[TL_chatInviteExported class] forKey:[NSNumber numberWithInt:-64092740]]; [cs_classes setObject:[TL_chatInviteAlready class] forKey:[NSNumber numberWithInt:1516793212]]; - [cs_classes setObject:[TL_chatInvite class] forKey:[NSNumber numberWithInt:-829325875]]; + [cs_classes setObject:[TL_chatInvite class] forKey:[NSNumber numberWithInt:-1813406880]]; [cs_classes setObject:[TL_messageActionChatJoinedByLink class] forKey:[NSNumber numberWithInt:-123931160]]; [cs_classes setObject:[TL_updateReadMessagesContents class] forKey:[NSNumber numberWithInt:1757493555]]; [cs_classes setObject:[TL_inputStickerSetEmpty class] forKey:[NSNumber numberWithInt:-4838507]]; @@ -472,6 +455,73 @@ +(void)initialize { [cs_classes setObject:[TL_replyKeyboardHide class] forKey:[NSNumber numberWithInt:-1606526075]]; [cs_classes setObject:[TL_replyKeyboardForceReply class] forKey:[NSNumber numberWithInt:-200242528]]; [cs_classes setObject:[TL_replyKeyboardMarkup class] forKey:[NSNumber numberWithInt:889353612]]; + [cs_classes setObject:[TL_inputPeerUser class] forKey:[NSNumber numberWithInt:2072935910]]; + [cs_classes setObject:[TL_inputUser class] forKey:[NSNumber numberWithInt:-668391402]]; + [cs_classes setObject:[TL_help_appChangelogEmpty class] forKey:[NSNumber numberWithInt:-1350696044]]; + [cs_classes setObject:[TL_help_appChangelog class] forKey:[NSNumber numberWithInt:1181279933]]; + [cs_classes setObject:[TL_messageEntityUnknown class] forKey:[NSNumber numberWithInt:-1148011883]]; + [cs_classes setObject:[TL_messageEntityMention class] forKey:[NSNumber numberWithInt:-100378723]]; + [cs_classes setObject:[TL_messageEntityHashtag class] forKey:[NSNumber numberWithInt:1868782349]]; + [cs_classes setObject:[TL_messageEntityBotCommand class] forKey:[NSNumber numberWithInt:1827637959]]; + [cs_classes setObject:[TL_messageEntityUrl class] forKey:[NSNumber numberWithInt:1859134776]]; + [cs_classes setObject:[TL_messageEntityEmail class] forKey:[NSNumber numberWithInt:1692693954]]; + [cs_classes setObject:[TL_messageEntityBold class] forKey:[NSNumber numberWithInt:-1117713463]]; + [cs_classes setObject:[TL_messageEntityItalic class] forKey:[NSNumber numberWithInt:-2106619040]]; + [cs_classes setObject:[TL_messageEntityCode class] forKey:[NSNumber numberWithInt:681706865]]; + [cs_classes setObject:[TL_messageEntityPre class] forKey:[NSNumber numberWithInt:1938967520]]; + [cs_classes setObject:[TL_messageEntityTextUrl class] forKey:[NSNumber numberWithInt:1990644519]]; + [cs_classes setObject:[TL_updateShortSentMessage class] forKey:[NSNumber numberWithInt:301019932]]; + [cs_classes setObject:[TL_inputChannelEmpty class] forKey:[NSNumber numberWithInt:-292807034]]; + [cs_classes setObject:[TL_inputChannel class] forKey:[NSNumber numberWithInt:-1343524562]]; + [cs_classes setObject:[TL_peerChannel class] forKey:[NSNumber numberWithInt:-1109531342]]; + [cs_classes setObject:[TL_inputPeerChannel class] forKey:[NSNumber numberWithInt:548253432]]; + [cs_classes setObject:[TL_channel class] forKey:[NSNumber numberWithInt:1737397639]]; + [cs_classes setObject:[TL_channelForbidden class] forKey:[NSNumber numberWithInt:763724588]]; + [cs_classes setObject:[TL_contacts_resolvedPeer class] forKey:[NSNumber numberWithInt:2131196633]]; + [cs_classes setObject:[TL_channelFull class] forKey:[NSNumber numberWithInt:-1640751649]]; + [cs_classes setObject:[TL_dialogChannel class] forKey:[NSNumber numberWithInt:1535415986]]; + [cs_classes setObject:[TL_messageRange class] forKey:[NSNumber numberWithInt:182649427]]; + [cs_classes setObject:[TL_messageGroup class] forKey:[NSNumber numberWithInt:-399216813]]; + [cs_classes setObject:[TL_messages_channelMessages class] forKey:[NSNumber numberWithInt:-1139861572]]; + [cs_classes setObject:[TL_messageActionChannelCreate class] forKey:[NSNumber numberWithInt:-1781355374]]; + [cs_classes setObject:[TL_updateChannelTooLong class] forKey:[NSNumber numberWithInt:1620337698]]; + [cs_classes setObject:[TL_updateChannel class] forKey:[NSNumber numberWithInt:-1227598250]]; + [cs_classes setObject:[TL_updateChannelGroup class] forKey:[NSNumber numberWithInt:-1016324548]]; + [cs_classes setObject:[TL_updateNewChannelMessage class] forKey:[NSNumber numberWithInt:1656358105]]; + [cs_classes setObject:[TL_updateReadChannelInbox class] forKey:[NSNumber numberWithInt:1108669311]]; + [cs_classes setObject:[TL_updateDeleteChannelMessages class] forKey:[NSNumber numberWithInt:-1015733815]]; + [cs_classes setObject:[TL_updateChannelMessageViews class] forKey:[NSNumber numberWithInt:-1734268085]]; + [cs_classes setObject:[TL_updates_channelDifferenceEmpty class] forKey:[NSNumber numberWithInt:1041346555]]; + [cs_classes setObject:[TL_updates_channelDifferenceTooLong class] forKey:[NSNumber numberWithInt:1578530374]]; + [cs_classes setObject:[TL_updates_channelDifference class] forKey:[NSNumber numberWithInt:543450958]]; + [cs_classes setObject:[TL_channelMessagesFilterEmpty class] forKey:[NSNumber numberWithInt:-1798033689]]; + [cs_classes setObject:[TL_channelMessagesFilter class] forKey:[NSNumber numberWithInt:-847783593]]; + [cs_classes setObject:[TL_channelMessagesFilterCollapsed class] forKey:[NSNumber numberWithInt:-100588754]]; + [cs_classes setObject:[TL_channelParticipant class] forKey:[NSNumber numberWithInt:367766557]]; + [cs_classes setObject:[TL_channelParticipantSelf class] forKey:[NSNumber numberWithInt:-1557620115]]; + [cs_classes setObject:[TL_channelParticipantModerator class] forKey:[NSNumber numberWithInt:-1861910545]]; + [cs_classes setObject:[TL_channelParticipantEditor class] forKey:[NSNumber numberWithInt:-1743180447]]; + [cs_classes setObject:[TL_channelParticipantKicked class] forKey:[NSNumber numberWithInt:-1933187430]]; + [cs_classes setObject:[TL_channelParticipantCreator class] forKey:[NSNumber numberWithInt:-471670279]]; + [cs_classes setObject:[TL_channelParticipantsRecent class] forKey:[NSNumber numberWithInt:-566281095]]; + [cs_classes setObject:[TL_channelParticipantsAdmins class] forKey:[NSNumber numberWithInt:-1268741783]]; + [cs_classes setObject:[TL_channelParticipantsKicked class] forKey:[NSNumber numberWithInt:1010285434]]; + [cs_classes setObject:[TL_channelRoleEmpty class] forKey:[NSNumber numberWithInt:-1299865402]]; + [cs_classes setObject:[TL_channelRoleModerator class] forKey:[NSNumber numberWithInt:-1776756363]]; + [cs_classes setObject:[TL_channelRoleEditor class] forKey:[NSNumber numberWithInt:-2113143156]]; + [cs_classes setObject:[TL_channels_channelParticipants class] forKey:[NSNumber numberWithInt:-177282392]]; + [cs_classes setObject:[TL_channels_channelParticipant class] forKey:[NSNumber numberWithInt:-791039645]]; + [cs_classes setObject:[TL_chatParticipantCreator class] forKey:[NSNumber numberWithInt:-636267638]]; + [cs_classes setObject:[TL_chatParticipantAdmin class] forKey:[NSNumber numberWithInt:-489233354]]; + [cs_classes setObject:[TL_updateChatAdmins class] forKey:[NSNumber numberWithInt:1855224129]]; + [cs_classes setObject:[TL_updateChatParticipantAdmin class] forKey:[NSNumber numberWithInt:-1232070311]]; + [cs_classes setObject:[TL_messageActionChatMigrateTo class] forKey:[NSNumber numberWithInt:1371385889]]; + [cs_classes setObject:[TL_messageActionChannelMigrateFrom class] forKey:[NSNumber numberWithInt:-1336546578]]; + [cs_classes setObject:[TL_channelParticipantsBots class] forKey:[NSNumber numberWithInt:-1328445861]]; + [cs_classes setObject:[TL_help_termsOfService class] forKey:[NSNumber numberWithInt:-236044656]]; + [cs_classes setObject:[TL_updateNewStickerSet class] forKey:[NSNumber numberWithInt:1753886890]]; + [cs_classes setObject:[TL_updateStickerSetsOrder class] forKey:[NSNumber numberWithInt:-253774767]]; + [cs_classes setObject:[TL_updateStickerSets class] forKey:[NSNumber numberWithInt:1135492588]]; [cs_classes setObject:[TL_userSelf class] forKey:[NSNumber numberWithInt:476112392]]; [cs_classes setObject:[TL_userContact class] forKey:[NSNumber numberWithInt:-894214632]]; [cs_classes setObject:[TL_userRequest class] forKey:[NSNumber numberWithInt:-640891665]]; @@ -479,6 +529,20 @@ +(void)initialize { [cs_classes setObject:[TL_userDeleted class] forKey:[NSNumber numberWithInt:-704549510]]; [cs_classes setObject:[TL_chatFull_old29 class] forKey:[NSNumber numberWithInt:-891418735]]; [cs_classes setObject:[TL_documentAttributeAudio_old31 class] forKey:[NSNumber numberWithInt:85215461]]; + [cs_classes setObject:[TL_photo_old31 class] forKey:[NSNumber numberWithInt:-1014792074]]; + [cs_classes setObject:[TL_audio_old29 class] forKey:[NSNumber numberWithInt:-945003370]]; + [cs_classes setObject:[TL_video_old29 class] forKey:[NSNumber numberWithInt:-291550643]]; + [cs_classes setObject:[TL_webPage_old34 class] forKey:[NSNumber numberWithInt:-1558273867]]; + [cs_classes setObject:[TL_chat_old34 class] forKey:[NSNumber numberWithInt:1855757255]]; + [cs_classes setObject:[TL_inputMediaUploadedVideo_old34 class] forKey:[NSNumber numberWithInt:-515910468]]; + [cs_classes setObject:[TL_inputMediaUploadedThumbVideo_old32 class] forKey:[NSNumber numberWithInt:-1761896484]]; + [cs_classes setObject:[TL_chatForbidden_old34 class] forKey:[NSNumber numberWithInt:-83047359]]; + [cs_classes setObject:[TL_chatParticipantsForbidden_old34 class] forKey:[NSNumber numberWithInt:265468810]]; + [cs_classes setObject:[TL_chatParticipants_old38 class] forKey:[NSNumber numberWithInt:2017571861]]; + [cs_classes setObject:[TL_chat_old38 class] forKey:[NSNumber numberWithInt:1930607688]]; + [cs_classes setObject:[TL_channelFull_old39 class] forKey:[NSNumber numberWithInt:-88925533]]; + [cs_classes setObject:[TL_chatParticipants_old39 class] forKey:[NSNumber numberWithInt:2017571861]]; + [cs_classes setObject:[TL_messageActionChatAddUser_old40 class] forKey:[NSNumber numberWithInt:1581055051]]; [cs_classes setObject:[TL_proto_message class] forKey:[NSNumber numberWithInt:1538843921]]; [cs_classes setObject:[TL_msg_container class] forKey:[NSNumber numberWithInt:1945237724]]; [cs_classes setObject:[TL_req_pq class] forKey:[NSNumber numberWithInt:1615239032]]; diff --git a/TelegramTest/CommonMediaHistoryFilter.h b/TelegramTest/CommonMediaHistoryFilter.h new file mode 100644 index 00000000..4da076bf --- /dev/null +++ b/TelegramTest/CommonMediaHistoryFilter.h @@ -0,0 +1,13 @@ +// +// CommonMediaHistoryFilter.h +// Telegram +// +// Created by keepcoder on 09/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "HistoryFilter.h" + +@interface CommonMediaHistoryFilter : HistoryFilter + +@end diff --git a/TelegramTest/CommonMediaHistoryFilter.m b/TelegramTest/CommonMediaHistoryFilter.m new file mode 100644 index 00000000..f237fdab --- /dev/null +++ b/TelegramTest/CommonMediaHistoryFilter.m @@ -0,0 +1,47 @@ +// +// CommonMediaHistoryFilter.m +// Telegram +// +// Created by keepcoder on 09/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "CommonMediaHistoryFilter.h" +#import "ChatHistoryController.h" +@implementation CommonMediaHistoryFilter + + + +-(void)remoteRequest:(BOOL)next max_id:(int)max_id hole:(TGMessageHole *)hole callback:(void (^)(id response,ChatHistoryState state))callback { + + int maxDate = next ? self.minDate : INT32_MAX; + int minDate = next ? 0 : self.maxDate; + + + self.request = [RPCRequest sendRequest:[TLAPI_messages_search createWithFlags:0 peer:[self.peer inputPeer] q:@"" filter:self.messagesFilter min_date:minDate max_date:maxDate offset:0 max_id:INT32_MAX limit:(int)self.controller.selectLimit] successHandler:^(RPCRequest *request, TL_messages_messages *response) { + + + NSMutableArray *messages = [response.messages mutableCopy]; + + [TL_localMessage convertReceivedMessages:messages]; + + [response.messages removeAllObjects]; + + [SharedManager proccessGlobalResponse:response]; + + if(callback) { + callback(messages,messages.count < self.controller.selectLimit ? ChatHistoryStateFull : ChatHistoryStateRemote); + } + + } errorHandler:^(RPCRequest *request, RpcError *error) { + + if(callback) { + callback(nil,ChatHistoryStateRemote); + } + + } timeout:0 queue:[ASQueue globalQueue].nativeQueue]; + +} + + +@end diff --git a/TelegramTest/ComposeAction.h b/TelegramTest/ComposeAction.h index a7711c5a..195e1084 100644 --- a/TelegramTest/ComposeAction.h +++ b/TelegramTest/ComposeAction.h @@ -9,14 +9,21 @@ #import #import "ComposeActionBehavior.h" #import "TMViewController.h" + +@class ComposeViewController; + @interface ComposeResult : NSObject @property (nonatomic,strong) id singleObject; -@property (nonatomic,strong,readonly) NSArray *multiObjects; +@property (nonatomic,strong) NSArray *multiObjects; + +@property (nonatomic,strong) NSArray *stepResult; -(id)initWithMultiObjects:(NSArray *)multiObjects; +-(id)initWithStepResult:(NSArray *)stepResult; + @end @@ -28,17 +35,20 @@ @property (nonatomic,strong,readonly) ComposeActionBehavior *behavior; @property (nonatomic,strong,readonly) NSArray *filter; -@property (nonatomic,strong,readonly) id object; +@property (nonatomic,strong) id object; @property (nonatomic,strong) id reservedObject1; @property (nonatomic,strong) id reservedObject2; @property (nonatomic,strong) id reservedObject3; -@property (nonatomic,strong) TMViewController *currentViewController; +@property (nonatomic,weak) ComposeViewController *currentViewController; -(id)initWithBehaviorClass:(Class)behavior; -(id)initWithBehaviorClass:(Class)behavior filter:(NSArray *)filter object:(id)object; -(id)initWithBehaviorClass:(Class)behavior filter:(NSArray *)filter object:(id)object reservedObjects:(NSArray *)objects; + + +@property (nonatomic,assign, getter=isEditable) BOOL editable; @end diff --git a/TelegramTest/ComposeAction.m b/TelegramTest/ComposeAction.m index db69b7d1..b3d296a5 100644 --- a/TelegramTest/ComposeAction.m +++ b/TelegramTest/ComposeAction.m @@ -27,6 +27,12 @@ -(id)initWithSingleObject:(id)singleObject { return self; } +-(id)initWithStepResult:(NSArray *)stepResult { + if(self = [super init]) { + _stepResult = stepResult; + } + return self; +} @end @@ -41,6 +47,8 @@ -(id)initWithBehaviorClass:(Class)behavior { return self; } + + -(id)initWithBehaviorClass:(Class)behavior filter:(NSArray *)filter object:(id)object { if(self = [self initWithBehaviorClass:behavior]) { _filter = filter; diff --git a/TelegramTest/ComposeActionAddBroadcastMembersBehavior.m b/TelegramTest/ComposeActionAddBroadcastMembersBehavior.m index aec76aa7..d6bdd3b4 100644 --- a/TelegramTest/ComposeActionAddBroadcastMembersBehavior.m +++ b/TelegramTest/ComposeActionAddBroadcastMembersBehavior.m @@ -31,7 +31,7 @@ -(NSAttributedString *)centerTitle { NSRange range = [attr appendString:[NSString stringWithFormat:@" - %lu/%lu",self.action.result.multiObjects.count,[self limit]] withColor:DARK_GRAY]; - [attr setFont:[NSFont fontWithName:@"HelveticaNeue" size:12] forRange:range]; + [attr setFont:TGSystemFont(12) forRange:range]; [attr setAlignment:NSCenterTextAlignment range:NSMakeRange(0, attr.length-1)]; @@ -57,7 +57,7 @@ -(void)composeDidDone { dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - [[Telegram rightViewController] navigationGoBack]; + [self.action.currentViewController.navigationViewController goBackWithAnimation:YES]; }); diff --git a/TelegramTest/ComposeActionAddChannelModeratorBehavior.h b/TelegramTest/ComposeActionAddChannelModeratorBehavior.h new file mode 100644 index 00000000..0a644f43 --- /dev/null +++ b/TelegramTest/ComposeActionAddChannelModeratorBehavior.h @@ -0,0 +1,13 @@ +// +// ComposeActionAddChannelModeratorBehavior.h +// Telegram +// +// Created by keepcoder on 16.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "ComposeActionBehavior.h" + +@interface ComposeActionAddChannelModeratorBehavior : ComposeActionBehavior + +@end diff --git a/TelegramTest/ComposeActionAddChannelModeratorBehavior.m b/TelegramTest/ComposeActionAddChannelModeratorBehavior.m new file mode 100644 index 00000000..be86b544 --- /dev/null +++ b/TelegramTest/ComposeActionAddChannelModeratorBehavior.m @@ -0,0 +1,117 @@ +// +// ComposeActionAddChannelModeratorBehavior.m +// Telegram +// +// Created by keepcoder on 16.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "ComposeActionAddChannelModeratorBehavior.h" +#import "SelectUserItem.h" +@implementation ComposeActionAddChannelModeratorBehavior + +-(NSString *)doneTitle { + return [self.action.currentViewController isKindOfClass:[ComposePickerViewController class]] ? @"" : NSLocalizedString(@"Compose.Next", nil); +} + +-(NSUInteger)limit { + return 0; +} + +-(NSAttributedString *)centerTitle { + + NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] init]; + + [attr appendString:NSLocalizedString(@"Compose.Contacts", nil) withColor:NSColorFromRGB(0x333333)]; + + [attr setAlignment:NSCenterTextAlignment range:attr.range]; + + return attr; +} + +-(TL_channel *)chat { + return self.action.object; +} + +-(TLUser *)user { + return self.action.result.multiObjects[0]; +} + + +-(void)composeDidChangeSelected { + [self composeDidDone]; +} + +-(void)composeDidDone { + + if([self.action.currentViewController isKindOfClass:[ComposePickerViewController class]]) { + + if(!self.chat.isBroadcast && !self.chat.isMegagroup) { + + ComposeConfirmModeratorViewController *viewController = [[ComposeConfirmModeratorViewController alloc] initWithFrame:self.action.currentViewController.view.bounds]; + + [viewController setAction:self.action]; + + [self.action.currentViewController.navigationViewController pushViewController:viewController animated:YES]; + } else { + self.action.result.singleObject = [TL_channelRoleEditor create]; + [self addAccess]; + } + + } else { + + [self addAccess]; + + } + +} + + +-(void)addAccess { + + + confirm(appName(), NSLocalizedString(@"Chat.ToggleUserToAdminConfirm", nil), ^{ + [RPCRequest sendRequest:[TLAPI_channels_editAdmin createWithChannel:self.chat.inputPeer user_id:[self.user inputUser] role: self.action.result.singleObject] successHandler:^(id request, id response) { + + [self.delegate behaviorDidStartRequest]; + + [RPCRequest sendRequest:[TLAPI_channels_getParticipants createWithChannel:self.chat.inputPeer filter:[TL_channelParticipantsAdmins create] offset:0 limit:100] successHandler:^(id request, TL_channels_channelParticipants *response) { + + [SharedManager proccessGlobalResponse:response]; + + [[FullChatManager sharedManager] performLoad:self.chat.n_id force:YES callback:^(TLChatFull *fullChat) { + ComposeAction *action = [[ComposeAction alloc] initWithBehaviorClass:[ComposeActionBehavior class] filter:@[] object:self.chat]; + + action.result = [[ComposeResult alloc] initWithMultiObjects:response.participants]; + + ComposeManagmentViewController *viewController = [[ComposeManagmentViewController alloc] initWithFrame:self.action.currentViewController.view.bounds]; + + [viewController setAction:self.action]; + + [self.action.currentViewController.navigationViewController gotoViewController:viewController]; + + [self.delegate behaviorDidEndRequest:response]; + }]; + + + + } errorHandler:^(id request, RpcError *error) { + [self.delegate behaviorDidEndRequest:nil]; + }]; + + + + } errorHandler:^(id request, RpcError *error) { + [self.delegate behaviorDidEndRequest:nil]; + + if(error.error_code == 400) { + alert(appName(), NSLocalizedString(error.error_msg, nil)); + } + + }]; + }, nil); + +} + + +@end diff --git a/TelegramTest/ComposeActionAddGroupMembersBehavior.m b/TelegramTest/ComposeActionAddGroupMembersBehavior.m index f1df9ec1..d92412aa 100644 --- a/TelegramTest/ComposeActionAddGroupMembersBehavior.m +++ b/TelegramTest/ComposeActionAddGroupMembersBehavior.m @@ -29,13 +29,22 @@ -(NSString *)doneTitle { } -(NSAttributedString *)centerTitle { + NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] init]; + + + if([self.chat isKindOfClass:[TL_channelFull class]]) { + [attr appendString:NSLocalizedString(@"Compose.Members", nil) withColor:NSColorFromRGB(0x333333)]; + [attr setAlignment:NSCenterTextAlignment range:NSMakeRange(0, attr.length-1)]; + return attr; + } + [attr appendString:NSLocalizedString(@"Compose.Contacts", nil) withColor:NSColorFromRGB(0x333333)]; NSRange range = [attr appendString:[NSString stringWithFormat:@" - %lu/%lu",self.action.result.multiObjects.count,[self limit]] withColor:DARK_GRAY]; - [attr setFont:[NSFont fontWithName:@"HelveticaNeue" size:12] forRange:range]; + [attr setFont:TGSystemFont(12) forRange:range]; [attr setAlignment:NSCenterTextAlignment range:NSMakeRange(0, attr.length-1)]; @@ -46,38 +55,65 @@ -(void)composeDidDone { [self.delegate behaviorDidStartRequest]; - [self addMembersToChat:[self.action.result.multiObjects mutableCopy] toChatId:self.chat.n_id]; + TLChat *chat = [[ChatsManager sharedManager] find:self.chat.n_id]; + + if([chat isKindOfClass:[TL_channel class]]) { + + NSMutableArray *array = [[NSMutableArray alloc] init]; + for(TLUser* item in self.action.result.multiObjects) { + if(item.type != TLUserTypeSelf) { + [array addObject:[item inputUser]]; + } + + } + + [RPCRequest sendRequest:[TLAPI_channels_inviteToChannel createWithChannel:chat.inputPeer users:array] successHandler:^(id request, id response) { + + + [self.action.currentViewController.navigationViewController goBackWithAnimation:YES]; + + [[FullChatManager sharedManager] loadIfNeed:chat.n_id force:YES]; + + [self.delegate behaviorDidEndRequest:nil]; + + + } errorHandler:^(id request, RpcError *error) { + [self.delegate behaviorDidEndRequest:nil]; + + alert(appName(), NSLocalizedString(error.error_msg, nil)); + }]; + + + } else + [self addMembersToChat:[self.action.result.multiObjects mutableCopy] toChatId:self.chat.n_id]; } -(void)addMembersToChat:(NSMutableArray *)members toChatId:(int)chatId { - SelectUserItem *item = members[0]; + TLUser *user = members[0]; [members removeObjectAtIndex:0]; - [RPCRequest sendRequest:[TLAPI_messages_addChatUser createWithChat_id:chatId user_id:item.user.inputUser fwd_limit:100] successHandler:^(RPCRequest *request, id response) { + [RPCRequest sendRequest:[TLAPI_messages_addChatUser createWithChat_id:chatId user_id:user.inputUser fwd_limit:100] successHandler:^(RPCRequest *request, id response) { - if(self.chat) { - [self.chat.participants.participants addObject:[TL_chatParticipant createWithUser_id:item.user.n_id inviter_id:[UsersManager currentUserId] date:[[MTNetwork instance] getTime]]]; - [Notification perform:CHAT_STATUS data:@{KEY_CHAT_ID:@(self.chat.n_id)}]; - } - if(members.count > 0) { [self addMembersToChat:members toChatId:chatId]; } else { - [self.delegate behaviorDidEndRequest:response]; - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - [[Telegram rightViewController] navigationGoBack]; - }); + [[FullChatManager sharedManager] performLoad:chatId force:YES callback:^(TLChatFull *fullChat) { + [self.delegate behaviorDidEndRequest:response]; + [self.action.currentViewController.navigationViewController goBackWithAnimation:YES]; + }]; + } } errorHandler:^(RPCRequest *request, RpcError *error) { [self.delegate behaviorDidEndRequest:request.response]; - }]; + alert(appName(), NSLocalizedString(error.error_msg, nil)); + } timeout:0 queue:[ASQueue globalQueue].nativeQueue]; } diff --git a/TelegramTest/ComposeActionAddUserToGroupBehavior.m b/TelegramTest/ComposeActionAddUserToGroupBehavior.m index 4be6664e..d55fa997 100644 --- a/TelegramTest/ComposeActionAddUserToGroupBehavior.m +++ b/TelegramTest/ComposeActionAddUserToGroupBehavior.m @@ -46,30 +46,61 @@ -(void)composeDidDone { -(void)addMemberToChat:(NSArray *)members user:(TLUser *)user { - SelectChatItem *item = members[0]; + TLChat *chat = members[0]; - [RPCRequest sendRequest:[TLAPI_messages_addChatUser createWithChat_id:item.chat.n_id user_id:user.inputUser fwd_limit:100] successHandler:^(RPCRequest *request, id response) { - - [item.chat.chatFull.participants.participants addObject:[TL_chatParticipant createWithUser_id:user.n_id inviter_id:[UsersManager currentUserId] date:[[MTNetwork instance] getTime]]]; - [Notification perform:CHAT_STATUS data:@{KEY_CHAT_ID:@(item.chat.n_id)}]; - - [self.delegate behaviorDidEndRequest:response]; + id request = [TLAPI_messages_addChatUser createWithChat_id:chat.n_id user_id:user.inputUser fwd_limit:100]; + + if(chat.isChannel) { + request = [TLAPI_channels_inviteToChannel createWithChannel:chat.inputPeer users:[@[user.inputUser] mutableCopy]]; + } + + + dispatch_block_t addblock = ^{ + [RPCRequest sendRequest:request successHandler:^(RPCRequest *request, id response) { - dispatch_after_seconds(0.2, ^{ - [[Telegram rightViewController] showByDialog:item.chat.dialog sender:self]; + [self.delegate behaviorDidEndRequest:response]; - if(self.action.reservedObject1) { - [[Telegram rightViewController].messagesViewController showBotStartButton:self.action.reservedObject1[@"startgroup"] bot:user]; - } + dispatch_after_seconds(0.2, ^{ + + [self.action.currentViewController.navigationViewController showMessagesViewController:chat.dialog]; + + if(self.action.reservedObject1) { + [self.action.currentViewController.messagesViewController showBotStartButton:self.action.reservedObject1[@"startgroup"] bot:user]; + } + + }); - }); - - - } errorHandler:^(RPCRequest *request, RpcError *error) { - [self.delegate behaviorDidEndRequest:request.response]; - - alert(appName(), NSLocalizedString([error.error_msg isEqualToString:@"USER_ALREADY_PARTICIPANT"] ? @"Bot.AlreadyInGroup" : error.error_msg, nil)); - }]; + + } errorHandler:^(RPCRequest *request, RpcError *error) { + [self.delegate behaviorDidEndRequest:request.response]; + + alert(appName(), NSLocalizedString([error.error_msg isEqualToString:@"USER_ALREADY_PARTICIPANT"] ? @"Bot.AlreadyInGroup" : error.error_msg, nil)); + }]; + }; + + + addblock(); + +// if(chat.isChannel) { +// [RPCRequest sendRequest:[TLAPI_channels_getParticipant createWithChannel:chat.inputPeer user_id:user.inputUser] successHandler:^(id request, TL_channels_channelParticipant *participant) { +// +// +// // TL_channelParticipant +// [self.delegate behaviorDidEndRequest:participant]; +// +// alert(appName(), NSLocalizedString(@"Bot.AlreadyInGroup", nil)); +// +// } errorHandler:^(id request, RpcError *error) { +// if([error.error_msg isEqualToString:@"USER_NOT_PARTICIPANT"]) { +// addblock(); +// } else { +// [self.delegate behaviorDidEndRequest:nil]; +// alert(appName(), NSLocalizedString(error.error_msg, nil)); +// } +// }]; +// } else { +// addblock(); +// } } diff --git a/TelegramTest/ComposeActionBehavior.h b/TelegramTest/ComposeActionBehavior.h index 9f8e9053..ead32352 100644 --- a/TelegramTest/ComposeActionBehavior.h +++ b/TelegramTest/ComposeActionBehavior.h @@ -36,4 +36,8 @@ -(NSString *)doneTitle; -(NSAttributedString *)centerTitle; + +-(NSString *)leftEditTitle; +-(NSString *)rightEditTitle; + @end diff --git a/TelegramTest/ComposeActionBehavior.m b/TelegramTest/ComposeActionBehavior.m index 60d964b4..5062f1b8 100644 --- a/TelegramTest/ComposeActionBehavior.m +++ b/TelegramTest/ComposeActionBehavior.m @@ -31,6 +31,13 @@ -(void)composeDidDone { +-(NSString *)leftEditTitle { + return NSLocalizedString(@"Compose.Cancel", nil); +} +-(NSString *)rightEditTitle { + return NSLocalizedString(@"Compose.Done", nil); +} + -(NSString *)doneTitle { return NSLocalizedString(@"Compose.Done", nil); } diff --git a/TelegramTest/ComposeActionBlackListBehavior.h b/TelegramTest/ComposeActionBlackListBehavior.h new file mode 100644 index 00000000..973c1154 --- /dev/null +++ b/TelegramTest/ComposeActionBlackListBehavior.h @@ -0,0 +1,13 @@ +// +// ComposeActionBlackListBehavior.h +// Telegram +// +// Created by keepcoder on 17.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "ComposeActionBehavior.h" + +@interface ComposeActionBlackListBehavior : ComposeActionBehavior + +@end diff --git a/TelegramTest/ComposeActionBlackListBehavior.m b/TelegramTest/ComposeActionBlackListBehavior.m new file mode 100644 index 00000000..f89c8f35 --- /dev/null +++ b/TelegramTest/ComposeActionBlackListBehavior.m @@ -0,0 +1,93 @@ +// +// ComposeActionBlackListBehavior.m +// Telegram +// +// Created by keepcoder on 17.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "ComposeActionBlackListBehavior.h" + +@implementation ComposeActionBlackListBehavior + +-(NSAttributedString *)centerTitle { + + + NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] init]; + + if(self.action.result.multiObjects.count > 0) { + + [attr appendString:NSLocalizedString(@"Compose.Unban", nil) withColor:NSColorFromRGB(0x333333)]; + + NSRange range = [attr appendString:[NSString stringWithFormat:@" - %lu/%lu",self.action.result.multiObjects.count,[self limit]] withColor:DARK_GRAY]; + + [attr setFont:TGSystemFont(12) forRange:range]; + + [attr setAlignment:NSCenterTextAlignment range:attr.range]; + } else { + + [attr appendString:NSLocalizedString(@"Compose.ChannelBlackList", nil) withColor:NSColorFromRGB(0x333333)]; + + [attr setAlignment:NSCenterTextAlignment range:attr.range]; + } + + + return attr; +} + +-(NSString *)doneTitle { + return self.action.isEditable ? NSLocalizedString(@"Compose.Done", nil) : NSLocalizedString(@"Compose.Edit", nil); +} + +-(NSUInteger)limit { + return 10; +} + + +-(TLChat *)chat { + return self.action.object; +} + +-(void)composeDidDone { + + if(self.action.result.multiObjects > 0) { + [self unbanUsers:[self.action.result.multiObjects mutableCopy]]; + [self.delegate behaviorDidStartRequest]; + } +} + + +-(void)unbanUsers:(NSMutableArray *)users { + + if(users.count > 0) { + + TLUser *user = users[0]; + + [users removeObjectAtIndex:0]; + + [RPCRequest sendRequest:[TLAPI_channels_kickFromChannel createWithChannel:self.chat.inputPeer user_id:user.inputUser kicked:NO] successHandler:^(id request, id response) { + + if(users.count == 0) { + + [[FullChatManager sharedManager] performLoad:self.chat.n_id force:YES callback:^(TLChatFull *fullChat) { + [self.delegate behaviorDidEndRequest:nil]; + }]; + + } else { + [self unbanUsers:users]; + } + + } errorHandler:^(id request, RpcError *error) { + + if(users.count > 0) { + [self unbanUsers:users]; + } else { + [self.delegate behaviorDidEndRequest:nil]; + } + + }]; + } + +} + +@end diff --git a/TelegramTest/ComposeActionBlockUsersBehavior.m b/TelegramTest/ComposeActionBlockUsersBehavior.m index d68260cb..0f782b55 100644 --- a/TelegramTest/ComposeActionBlockUsersBehavior.m +++ b/TelegramTest/ComposeActionBlockUsersBehavior.m @@ -31,7 +31,7 @@ -(NSAttributedString *)centerTitle { // NSRange range = [attr appendString:[NSString stringWithFormat:@" - %lu/%lu",self.action.result.multiObjects.count,[self limit]] withColor:DARK_GRAY]; - // [attr setFont:[NSFont fontWithName:@"HelveticaNeue" size:12] forRange:range]; + // [attr setFont:TGSystemFont(12) forRange:range]; [attr setAlignment:NSCenterTextAlignment range:NSMakeRange(0, attr.length-1)]; @@ -48,17 +48,17 @@ -(void)composeDidDone { -(void)blockUsers:(NSMutableArray *)members { - SelectUserItem *item = members[0]; + TLUser *user = members[0]; [members removeObjectAtIndex:0]; - [[BlockedUsersManager sharedManager] block:item.user.n_id completeHandler:^(BOOL response) { + [[BlockedUsersManager sharedManager] block:user.n_id completeHandler:^(BOOL response) { if(members.count == 0) { [self.delegate behaviorDidEndRequest:nil]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - [[Telegram rightViewController] navigationGoBack]; + [self.action.currentViewController.navigationViewController goBackWithAnimation:YES]; }); } else { [self blockUsers:members]; diff --git a/TelegramTest/ComposeActionBroadcastBehavior.m b/TelegramTest/ComposeActionBroadcastBehavior.m index e34b3b7e..e053b639 100644 --- a/TelegramTest/ComposeActionBroadcastBehavior.m +++ b/TelegramTest/ComposeActionBroadcastBehavior.m @@ -33,7 +33,7 @@ -(NSAttributedString *)centerTitle { NSRange range = [attr appendString:[NSString stringWithFormat:@" - %lu/%lu",self.action.result.multiObjects.count,[self limit]] withColor:DARK_GRAY]; - [attr setFont:[NSFont fontWithName:@"HelveticaNeue" size:12] forRange:range]; + [attr setFont:TGSystemFont(12) forRange:range]; @@ -54,7 +54,13 @@ -(void)composeDidDone { [self createBroadcast]; } else { - [[Telegram rightViewController] showComposeWithAction:self.action]; + + ComposePickerViewController *viewController = [[ComposePickerViewController alloc] initWithFrame:self.action.currentViewController.navigationViewController.view.bounds]; + + [viewController setAction:self.action]; + + [self.action.currentViewController.navigationViewController pushViewController:viewController animated:YES]; + } } @@ -65,8 +71,8 @@ -(void)createBroadcast { NSMutableArray *array = [[NSMutableArray alloc] init]; for(SelectUserItem* item in selected) { - if(!item.user.type != TLUserTypeSelf) { - TL_inputUserContact *_contact = [TL_inputUserContact createWithUser_id:item.user.n_id]; + if(item.user.type != TLUserTypeSelf) { + TL_inputUser *_contact = [TL_inputUser createWithUser_id:item.user.n_id access_hash:item.user.access_hash]; [array addObject:_contact]; } @@ -80,7 +86,7 @@ -(void)createBroadcast { TL_broadcast *broadcast = [TL_broadcast createWithN_id:arc4random() participants:participants title:@"" date:[[MTNetwork instance] getTime]]; - TL_conversation *conversation = [TL_conversation createWithPeer:[TL_peerBroadcast createWithChat_id:broadcast.n_id] top_message:0 unread_count:0 last_message_date:[[MTNetwork instance] getTime] notify_settings:[TL_peerNotifySettingsEmpty create] last_marked_message:0 top_message_fake:0 last_marked_date:[[MTNetwork instance] getTime] sync_message_id:0]; + TL_conversation *conversation = [TL_conversation createWithPeer:[TL_peerBroadcast createWithChat_id:broadcast.n_id] top_message:0 unread_count:0 last_message_date:[[MTNetwork instance] getTime] notify_settings:[TL_peerNotifySettingsEmpty create] last_marked_message:0 top_message_fake:0 last_marked_date:[[MTNetwork instance] getTime] sync_message_id:0 read_inbox_max_id:0 unread_important_count:0 lastMessage:nil]; [[DialogsManager sharedManager] add:@[conversation]]; [conversation save]; @@ -90,14 +96,14 @@ -(void)createBroadcast { int fakeId = [MessageSender getFakeMessageId]; - TL_localMessageService *msg = [TL_localMessageService createWithN_id:fakeId flags:TGOUTMESSAGE from_id:[UsersManager currentUserId] to_id:conversation.peer date:[[MTNetwork instance] getTime] action:[TL_messageActionEncryptedChat createWithTitle:NSLocalizedString(@"MessageAction.ServiceMessage.CreatedBroadcast", nil)] fakeId:fakeId randomId:rand_long() dstate:DeliveryStateNormal]; + TL_localMessageService *msg = [TL_localMessageService createWithFlags:TGOUTMESSAGE n_id:fakeId from_id:[UsersManager currentUserId] to_id:conversation.peer date:[[MTNetwork instance] getTime] action:[TL_messageActionEncryptedChat createWithTitle:NSLocalizedString(@"MessageAction.ServiceMessage.CreatedBroadcast", nil)] fakeId:fakeId randomId:rand_long() dstate:DeliveryStateNormal]; [MessagesManager addAndUpdateMessage:msg]; [self.delegate behaviorDidEndRequest:nil]; - [[Telegram rightViewController] showByDialog:conversation sender:self]; + [self.action.currentViewController.navigationViewController gotoViewController:self.action.currentViewController.messagesViewController]; } diff --git a/TelegramTest/ComposeActionChangeChannelAboutBehavior.h b/TelegramTest/ComposeActionChangeChannelAboutBehavior.h new file mode 100644 index 00000000..18de785b --- /dev/null +++ b/TelegramTest/ComposeActionChangeChannelAboutBehavior.h @@ -0,0 +1,17 @@ +// +// ComposeActionChangeChannelAboutBehavior.h +// Telegram +// +// Created by keepcoder on 05/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "ComposeActionBehavior.h" + +@interface ComposeActionChangeChannelAboutBehavior : ComposeActionBehavior + + +-(NSString *)placeholder; +-(NSString *)placeholderDescription; + +@end diff --git a/TelegramTest/ComposeActionChangeChannelAboutBehavior.m b/TelegramTest/ComposeActionChangeChannelAboutBehavior.m new file mode 100644 index 00000000..1a47feaa --- /dev/null +++ b/TelegramTest/ComposeActionChangeChannelAboutBehavior.m @@ -0,0 +1,45 @@ +// +// ComposeActionChangeChannelAboutBehavior.m +// Telegram +// +// Created by keepcoder on 05/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "ComposeActionChangeChannelAboutBehavior.h" + +@implementation ComposeActionChangeChannelAboutBehavior + + +-(NSAttributedString *)centerTitle { + return [[NSMutableAttributedString alloc] initWithString:NSLocalizedString(@"Compose.ChannelAboutPlaceholder", nil) attributes:@{NSFontAttributeName:TGSystemFont(15)}]; +} + + +-(void)composeDidDone { + [self.action.currentViewController showModalProgress]; + + TLChat *chat = self.action.object; + + [RPCRequest sendRequest:[TLAPI_channels_editAbout createWithChannel:chat.inputPeer about:self.action.result.singleObject] successHandler:^(RPCRequest *request, id response) { + + if(chat.chatFull != nil) { + chat.chatFull.about = self.action.result.singleObject; + + [[Storage manager] insertFullChat:chat.chatFull completeHandler:nil]; + } else { + [[FullChatManager sharedManager] loadIfNeed:chat.n_id force:YES]; + } + + [self.action.currentViewController hideModalProgressWithSuccess]; + + [self.action.currentViewController.navigationViewController goBackWithAnimation:YES]; + + } errorHandler:^(id request, RpcError *error) { + + [self.action.currentViewController hideModalProgress]; + + }]; +} + +@end diff --git a/TelegramTest/ComposeActionChannelMembersBehavior.h b/TelegramTest/ComposeActionChannelMembersBehavior.h new file mode 100644 index 00000000..cfadbb0f --- /dev/null +++ b/TelegramTest/ComposeActionChannelMembersBehavior.h @@ -0,0 +1,13 @@ +// +// ComposeActionChannelMembersBehavior.h +// Telegram +// +// Created by keepcoder on 17.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "ComposeActionBehavior.h" + +@interface ComposeActionChannelMembersBehavior : ComposeActionBehavior + +@end diff --git a/TelegramTest/ComposeActionChannelMembersBehavior.m b/TelegramTest/ComposeActionChannelMembersBehavior.m new file mode 100644 index 00000000..4241ab15 --- /dev/null +++ b/TelegramTest/ComposeActionChannelMembersBehavior.m @@ -0,0 +1,90 @@ +// +// ComposeActionChannelMembersBehavior.m +// Telegram +// +// Created by keepcoder on 17.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "ComposeActionChannelMembersBehavior.h" + +@implementation ComposeActionChannelMembersBehavior + +-(NSUInteger)limit { + return 10; +} +-(NSAttributedString *)centerTitle { + + + NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] init]; + + if(self.action.result.multiObjects.count > 0) { + + [attr appendString:NSLocalizedString(@"Compose.Kick", nil) withColor:NSColorFromRGB(0x333333)]; + + NSRange range = [attr appendString:[NSString stringWithFormat:@" - %lu/%lu",self.action.result.multiObjects.count,[self limit]] withColor:DARK_GRAY]; + + [attr setFont:TGSystemFont(12) forRange:range]; + + [attr setAlignment:NSCenterTextAlignment range:attr.range]; + } else { + + [attr appendString:NSLocalizedString(@"Compose.Members", nil) withColor:NSColorFromRGB(0x333333)]; + + [attr setAlignment:NSCenterTextAlignment range:attr.range]; + } + + + return attr; +} + +-(NSString *)doneTitle { + return self.action.isEditable ? NSLocalizedString(@"Compose.Done", nil) : NSLocalizedString(@"Compose.Edit", nil); +} + + + +-(TLChat *)chat { + return self.action.object; +} + +-(void)composeDidDone { + if(self.action.result.multiObjects > 0) { + [self banUsers:[self.action.result.multiObjects mutableCopy]]; + [self.delegate behaviorDidStartRequest]; + }} + + +-(void)banUsers:(NSMutableArray *)users { + + if(users.count > 0) { + + TLUser *user = users[0]; + + [users removeObjectAtIndex:0]; + + [RPCRequest sendRequest:[TLAPI_channels_kickFromChannel createWithChannel:self.chat.inputPeer user_id:user.inputUser kicked:YES] successHandler:^(id request, id response) { + + + if(users.count == 0) { + [[FullChatManager sharedManager] performLoad:self.chat.n_id force:YES callback:^(TLChatFull *fullChat) { + [self.delegate behaviorDidEndRequest:nil]; + }]; + } else { + [self banUsers:users]; + } + + } errorHandler:^(id request, RpcError *error) { + + if(users.count > 0) { + [self banUsers:users]; + } else { + [self.delegate behaviorDidEndRequest:nil]; + } + + }]; + } + +} + +@end diff --git a/TelegramTest/ComposeActionCreateChannelBehavior.h b/TelegramTest/ComposeActionCreateChannelBehavior.h new file mode 100644 index 00000000..ff86f2bd --- /dev/null +++ b/TelegramTest/ComposeActionCreateChannelBehavior.h @@ -0,0 +1,13 @@ +// +// ComposeActionCreateChannelBehavior.h +// Telegram +// +// Created by keepcoder on 19.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "ComposeActionBehavior.h" + +@interface ComposeActionCreateChannelBehavior : ComposeActionBehavior + +@end diff --git a/TelegramTest/ComposeActionCreateChannelBehavior.m b/TelegramTest/ComposeActionCreateChannelBehavior.m new file mode 100644 index 00000000..6fd366d5 --- /dev/null +++ b/TelegramTest/ComposeActionCreateChannelBehavior.m @@ -0,0 +1,207 @@ +// +// ComposeActionCreateChannelBehavior.m +// Telegram +// +// Created by keepcoder on 19.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "ComposeActionCreateChannelBehavior.h" +#import "SelectUserItem.h" +#import "ComposeActionAddGroupMembersBehavior.h" +@interface ComposeActionCreateChannelBehavior () +@property (nonatomic,strong) RPCRequest *request; +@end + +@implementation ComposeActionCreateChannelBehavior + +-(NSUInteger)limit { + return -1; +} + +-(NSString *)doneTitle { + if([self.action.currentViewController isKindOfClass:[ComposeCreateChannelUserNameStepViewController class]]) + return NSLocalizedString(@"Compose.Save", nil); + if([self.action.currentViewController isKindOfClass:[ComposePickerViewController class]]) + return NSLocalizedString(@"Compose.Create", nil); + else + return NSLocalizedString(@"Compose.Next", nil); +} + +-(NSAttributedString *)centerTitle { + + NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] init]; + + NSString *title; + + if([self.action.currentViewController isKindOfClass:[ComposeCreateChannelUserNameStepViewController class]]) + title = NSLocalizedString(@"Channel.Link", nil); + if([self.action.currentViewController isKindOfClass:[ComposePickerViewController class]]) + title = NSLocalizedString(@"Compose.Members", nil); + else + title = NSLocalizedString(@"Compose.NewChannel", nil); + + + [attr appendString:title withColor:NSColorFromRGB(0x333333)]; + + [attr setAlignment:NSCenterTextAlignment range:NSMakeRange(0, attr.length-1)]; + + return attr; +} + + +-(void)composeDidDone { + if([self.action.currentViewController isKindOfClass:[ComposeCreateChannelViewController class]]) { + + [self createChannel]; + + } else if([self.action.currentViewController isKindOfClass:[ComposeSettingupNewChannelViewController class]]) { + + + [self updateChannel]; + + } +} + +-(void)updateChannel { + + + BOOL isPublic = [self.action.result.singleObject boolValue]; + + if(isPublic) { + + if([self.action.reservedObject2 length] >= 5) { + [self.action.currentViewController showModalProgress]; + + [[ChatsManager sharedManager] updateChannelUserName:self.action.reservedObject2 channel:self.action.object completeHandler:^(TL_channel *channel) { + + [TMViewController hideModalProgressWithSuccess]; + + [self showAddingCompose]; + + } errorHandler:^(NSString *result) { + + [self.action.currentViewController hideModalProgress]; + + }]; + + } else { + alert(appName(), NSLocalizedString(@"Channel.SetPublicUsernameDescription", nil)); + } + + } else { + [self showAddingCompose]; + } + +} + +-(void)showAddingCompose { + + int chatId = [(TLChat *)self.action.object n_id]; + + __block TLChatFull *chatFull = [[FullChatManager sharedManager] find:chatId]; + + + dispatch_block_t block = ^{ + [self.action.currentViewController.navigationViewController gotoViewController:self.action.currentViewController.messagesViewController animated:NO]; + + ComposePickerViewController *viewController = [[ComposePickerViewController alloc] initWithFrame:self.action.currentViewController.view.bounds]; + + [viewController setAction:[[ComposeAction alloc] initWithBehaviorClass:[ComposeActionAddGroupMembersBehavior class] filter:@[@([UsersManager currentUserId])] object:chatFull]]; + + [self.action.currentViewController.navigationViewController pushViewController:viewController animated:YES]; + }; + + + if(!chatFull) { + + [self.action.currentViewController showModalProgress]; + + [[FullChatManager sharedManager] performLoad:chatId force:YES callback:^(TLChatFull *fullChat) { + + chatFull = fullChat; + + [self.action.currentViewController hideModalProgressWithSuccess]; + + block(); + + }]; + } else { + block(); + } + + +} + + +-(void)createChannel { + + [self.delegate behaviorDidStartRequest]; + + if(self.action.result.stepResult.count < 2) + return; + + BOOL discussion = [self.action.result.stepResult[1] intValue]; + + self.request = [RPCRequest sendRequest:[TLAPI_channels_createChannel createWithFlags:discussion ? 0 : 1 << 0 title:self.action.result.stepResult.firstObject[0] about:[self.action.result.stepResult.firstObject count] > 1 ? self.action.result.stepResult.firstObject[1] : nil] successHandler:^(RPCRequest *request, TLUpdates * response) { + + + if(response.chats.count > 0) { + + TL_channel *channel = [[ChatsManager sharedManager] find:[(TL_channel *)response.chats[0] n_id]]; + + self.action.object = channel; + + dispatch_block_t block = ^{ + [self.delegate behaviorDidEndRequest:response]; + + [[FullChatManager sharedManager] loadIfNeed:channel.n_id force:YES]; + + + [self.action.currentViewController.messagesViewController setCurrentConversation:channel.dialog]; + + [self.action.currentViewController.navigationViewController gotoViewController:self.action.currentViewController.messagesViewController animated:NO]; + + ComposeSettingupNewChannelViewController *viewController = [[ComposeSettingupNewChannelViewController alloc] initWithFrame:self.action.currentViewController.view.bounds];; + + [viewController setAction:self.action]; + + [self.action.currentViewController.navigationViewController pushViewController:viewController animated:YES]; + + [self.delegate behaviorDidEndRequest:self]; + }; + + block(); + + [RPCRequest sendRequest:[TLAPI_channels_exportInvite createWithChannel:channel.inputPeer] successHandler:^(id request, id response) { + + + self.action.reservedObject1 = response; + + [self.action.currentViewController setAction:self.action]; + + + } errorHandler:^(id request, RpcError *error) { + block(); + }]; + + + } + + + } errorHandler:^(RPCRequest *request, RpcError *error) { + [self.delegate behaviorDidEndRequest:nil]; + }]; + + +} + + +-(void)composeDidCancel { + + [self.request cancelRequest]; + + [self.delegate behaviorDidEndRequest:nil]; +} + +@end diff --git a/TelegramTest/ComposeActionCreateMegaGroupBehavior.h b/TelegramTest/ComposeActionCreateMegaGroupBehavior.h new file mode 100644 index 00000000..02225b9a --- /dev/null +++ b/TelegramTest/ComposeActionCreateMegaGroupBehavior.h @@ -0,0 +1,13 @@ +// +// ComposeActionCreateMegaGroupBehavior.h +// Telegram +// +// Created by keepcoder on 02/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "ComposeActionBehavior.h" + +@interface ComposeActionCreateMegaGroupBehavior : ComposeActionBehavior + +@end diff --git a/TelegramTest/ComposeActionCreateMegaGroupBehavior.m b/TelegramTest/ComposeActionCreateMegaGroupBehavior.m new file mode 100644 index 00000000..c54754a7 --- /dev/null +++ b/TelegramTest/ComposeActionCreateMegaGroupBehavior.m @@ -0,0 +1,100 @@ +// +// ComposeActionCreateMegaGroupBehavior.m +// Telegram +// +// Created by keepcoder on 02/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "ComposeActionCreateMegaGroupBehavior.h" + +@interface ComposeActionCreateMegaGroupBehavior () +@property (nonatomic,weak) RPCRequest *request; +@end + +@implementation ComposeActionCreateMegaGroupBehavior + + +-(NSUInteger)limit { + return -1; +} + +-(NSString *)doneTitle { + if([self.action.currentViewController isKindOfClass:[ComposeCreateChannelUserNameStepViewController class]]) + return NSLocalizedString(@"Compose.Save", nil); + if([self.action.currentViewController isKindOfClass:[ComposePickerViewController class]]) + return NSLocalizedString(@"Compose.Create", nil); + else + return NSLocalizedString(@"Compose.Next", nil); +} + +-(NSAttributedString *)centerTitle { + + NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] init]; + + NSString *title; + + if([self.action.currentViewController isKindOfClass:[ComposePickerViewController class]]) + title = NSLocalizedString(@"Compose.Members", nil); + else + title = NSLocalizedString(@"Compose.NewMegaGroup", nil); + + + [attr appendString:title withColor:NSColorFromRGB(0x333333)]; + + [attr setAlignment:NSCenterTextAlignment range:NSMakeRange(0, attr.length-1)]; + + return attr; +} + + +-(void)composeDidDone { + if([self.action.currentViewController isKindOfClass:[ComposeCreateChannelViewController class]]) { + + [self createMegagroup]; + + } +} + + +-(void)createMegagroup { + + [self.delegate behaviorDidStartRequest]; + + if(self.action.result.stepResult.count < 1) + return; + + self.request = [RPCRequest sendRequest:[TLAPI_channels_createChannel createWithFlags:1 << 1 title:self.action.result.stepResult.firstObject[0] about:[self.action.result.stepResult.firstObject count] > 1 ? self.action.result.stepResult.firstObject[1] : nil] successHandler:^(RPCRequest *request, TLUpdates * response) { + + + + if(response.chats.count > 0) { + + TLChat *chat = response.chats[0]; + + [self.delegate behaviorDidEndRequest:response]; + + [self.action.currentViewController.messagesViewController setCurrentConversation:chat.dialog]; + + [self.action.currentViewController.navigationViewController gotoViewController:self.action.currentViewController.messagesViewController animated:NO]; + + } + + } errorHandler:^(RPCRequest *request, RpcError *error) { + [self.delegate behaviorDidEndRequest:nil]; + }]; + +} + + +-(void)composeDidCancel { + + if(self.request) + [self.request cancelRequest]; + + [self.delegate behaviorDidEndRequest:nil]; +} + + + +@end diff --git a/TelegramTest/ComposeActionDeleteChannelMessagesBehavior.h b/TelegramTest/ComposeActionDeleteChannelMessagesBehavior.h new file mode 100644 index 00000000..bcdbdc79 --- /dev/null +++ b/TelegramTest/ComposeActionDeleteChannelMessagesBehavior.h @@ -0,0 +1,13 @@ +// +// ComposeActionDeleteChannelMessagesBehavior.h +// Telegram +// +// Created by keepcoder on 17.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "ComposeActionBehavior.h" + +@interface ComposeActionDeleteChannelMessagesBehavior : ComposeActionBehavior + +@end diff --git a/TelegramTest/ComposeActionDeleteChannelMessagesBehavior.m b/TelegramTest/ComposeActionDeleteChannelMessagesBehavior.m new file mode 100644 index 00000000..b53aa52e --- /dev/null +++ b/TelegramTest/ComposeActionDeleteChannelMessagesBehavior.m @@ -0,0 +1,94 @@ +// +// ComposeActionDeleteChannelMessagesBehavior.m +// Telegram +// +// Created by keepcoder on 17.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "ComposeActionDeleteChannelMessagesBehavior.h" + +@implementation ComposeActionDeleteChannelMessagesBehavior + + +-(void)composeDidCancel { + +} + +-(TL_channel *)channel { + return self.action.object; +} + +-(NSMutableArray *)msgIds { + return self.action.reservedObject1; +} + +-(TLUser *)user { + return self.action.result.singleObject; +} + +-(void)composeDidDone { + [self.delegate behaviorDidStartRequest]; + + id request = [TLAPI_channels_deleteMessages createWithChannel:self.channel.inputPeer n_id:self.msgIds]; + + [RPCRequest sendRequest:request successHandler:^(id request, id response) { + + [[MTNetwork instance].updateService.proccessor addUpdate:[TL_updateDeleteChannelMessages createWithChannel_id:self.channel.n_id messages:self.msgIds pts:[response pts] pts_count:[response pts_count]]]; + + + dispatch_block_t success = ^{ + [self.delegate behaviorDidEndRequest:nil]; + }; + + + BOOL banUser = [self.action.result.multiObjects[1] boolValue]; + BOOL reportSpam = [self.action.result.multiObjects[2] boolValue]; + + + dispatch_block_t report_spam_block = ^{ + [RPCRequest sendRequest:[TLAPI_channels_reportSpam createWithChannel:self.channel.inputPeer user_id:self.user.inputUser n_id:self.msgIds] successHandler:^(id request, id response1) { + + success(); + + } errorHandler:^(id request, RpcError *error) { + success(); + }]; + }; + + dispatch_block_t ban_block = ^{ + + [RPCRequest sendRequest:[TLAPI_channels_kickFromChannel createWithChannel:self.channel.inputPeer user_id:self.user.inputUser kicked:YES] successHandler:^(id request, id response2) { + + if(reportSpam) + report_spam_block(); + else + success(); + + } errorHandler:^(id request, RpcError *error) { + + if(reportSpam) + report_spam_block(); + else + success(); + + }]; + + }; + + + if(banUser) { + ban_block(); + } else if(reportSpam) { + report_spam_block(); + } else { + success(); + } + + + } errorHandler:^(id request, RpcError *error) { + [self.delegate behaviorDidEndRequest:nil]; + }]; +} + +@end diff --git a/TelegramTest/ComposeActionGroupBehavior.m b/TelegramTest/ComposeActionGroupBehavior.m index 144c01eb..4a5bd467 100644 --- a/TelegramTest/ComposeActionGroupBehavior.m +++ b/TelegramTest/ComposeActionGroupBehavior.m @@ -17,7 +17,7 @@ @interface ComposeActionGroupBehavior () @implementation ComposeActionGroupBehavior -(NSUInteger)limit { - return maxChatUsers(); + return maxChatUsers()-1; } -(NSString *)doneTitle { @@ -34,7 +34,7 @@ -(NSAttributedString *)centerTitle { NSRange range = [attr appendString:[NSString stringWithFormat:@" - %lu/%lu",self.action.result.multiObjects.count,[self limit]] withColor:DARK_GRAY]; - [attr setFont:[NSFont fontWithName:@"HelveticaNeue" size:12] forRange:range]; + [attr setFont:TGSystemFont(12) forRange:range]; @@ -51,8 +51,12 @@ -(NSAttributedString *)centerTitle { -(void)composeDidDone { if([self.action.currentViewController isKindOfClass:[ComposePickerViewController class]]) { - [[Telegram rightViewController] showComposeCreateChat:self.action]; + ComposeChatCreateViewController *viewController = [[ComposeChatCreateViewController alloc] initWithFrame:NSZeroRect]; + [viewController setAction:self.action]; + + [self.action.currentViewController.navigationViewController pushViewController:viewController animated:YES]; + } else { [self.delegate behaviorDidStartRequest]; @@ -68,9 +72,9 @@ -(void)createGroupChat { NSMutableArray *array = [[NSMutableArray alloc] init]; - for(SelectUserItem* item in selected) { - if(item.user.type != TLUserTypeSelf) { - [array addObject:[item.user inputUser]]; + for(TLUser* item in selected) { + if(item.type != TLUserTypeSelf) { + [array addObject:[item inputUser]]; } } @@ -83,9 +87,7 @@ -(void)createGroupChat { [[FullChatManager sharedManager] performLoad:msg.conversation.chat.n_id callback:^(TLChatFull *fullChat) { [self.delegate behaviorDidEndRequest:response]; - [[Telegram rightViewController] clearStack]; - - [[Telegram sharedInstance] showMessagesFromDialog:msg.conversation sender:self]; + [self.action.currentViewController.navigationViewController showMessagesViewController:msg.conversation]; }]; } diff --git a/TelegramTest/ComposeActionInfoProfileBehavior.h b/TelegramTest/ComposeActionInfoProfileBehavior.h new file mode 100644 index 00000000..f315ab79 --- /dev/null +++ b/TelegramTest/ComposeActionInfoProfileBehavior.h @@ -0,0 +1,13 @@ +// +// ComposeActionBehaviorUserProfile.h +// Telegram +// +// Created by keepcoder on 03/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "ComposeActionBehavior.h" + +@interface ComposeActionInfoProfileBehavior : ComposeActionBehavior + +@end diff --git a/TelegramTest/ComposeActionInfoProfileBehavior.m b/TelegramTest/ComposeActionInfoProfileBehavior.m new file mode 100644 index 00000000..d1c814e4 --- /dev/null +++ b/TelegramTest/ComposeActionInfoProfileBehavior.m @@ -0,0 +1,30 @@ +// +// ComposeActionBehaviorUserProfile.m +// Telegram +// +// Created by keepcoder on 03/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "ComposeActionInfoProfileBehavior.h" + +@implementation ComposeActionInfoProfileBehavior + + + +-(NSString *)doneTitle { + return self.action.isEditable ? NSLocalizedString(@"Profile.Done", nil) : NSLocalizedString(@"Profile.Edit", nil); +} + +-(NSAttributedString *)centerTitle { + NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] init]; + + [attr appendString:NSLocalizedString(@"Profile.Info", nil) withColor:NSColorFromRGB(0x222222)]; + [attr setFont:TGSystemFont(15) forRange:attr.range]; + + [attr setAlignment:NSCenterTextAlignment range:NSMakeRange(0, attr.length-1)]; + + return attr; +} + +@end diff --git a/TelegramTest/ComposeActionSecretChatBehavior.m b/TelegramTest/ComposeActionSecretChatBehavior.m index 99521b12..341550f3 100644 --- a/TelegramTest/ComposeActionSecretChatBehavior.m +++ b/TelegramTest/ComposeActionSecretChatBehavior.m @@ -39,10 +39,13 @@ -(void)composeDidChangeSelected { [self.delegate behaviorDidStartRequest]; - SelectUserItem *item = self.action.result.multiObjects[0]; + TLUser *user = self.action.result.multiObjects[0]; - [MessageSender startEncryptedChat:item.user callback:^{ + [MessageSender startEncryptedChat:user callback:^{ [self.delegate behaviorDidEndRequest:nil]; + + + }]; } diff --git a/TelegramTest/ComposeActionStickersBehavior.h b/TelegramTest/ComposeActionStickersBehavior.h new file mode 100644 index 00000000..e175011c --- /dev/null +++ b/TelegramTest/ComposeActionStickersBehavior.h @@ -0,0 +1,13 @@ +// +// ComposeActionStickersBehavior.h +// Telegram +// +// Created by keepcoder on 26/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "ComposeActionBehavior.h" + +@interface ComposeActionStickersBehavior : ComposeActionBehavior + +@end diff --git a/TelegramTest/ComposeActionStickersBehavior.m b/TelegramTest/ComposeActionStickersBehavior.m new file mode 100644 index 00000000..a1fcf189 --- /dev/null +++ b/TelegramTest/ComposeActionStickersBehavior.m @@ -0,0 +1,28 @@ +// +// ComposeActionStickersBehavior.m +// Telegram +// +// Created by keepcoder on 26/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "ComposeActionStickersBehavior.h" + +@implementation ComposeActionStickersBehavior + +-(NSString *)doneTitle { + return self.action.isEditable ? NSLocalizedString(@"Profile.Done", nil) : NSLocalizedString(@"Profile.Edit", nil); +} + +-(NSAttributedString *)centerTitle { + + NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] init]; + + [attr appendString:NSLocalizedString(@"Settings.Stickers", nil) withColor:NSColorFromRGB(0x333333)]; + + [attr setAlignment:NSCenterTextAlignment range:attr.range]; + + return attr; +} + +@end diff --git a/TelegramTest/ComposeBroadcastListViewController.m b/TelegramTest/ComposeBroadcastListViewController.m index 900fdcb6..ff3e309c 100644 --- a/TelegramTest/ComposeBroadcastListViewController.m +++ b/TelegramTest/ComposeBroadcastListViewController.m @@ -80,7 +80,7 @@ -(id)initWithFrame:(NSRect)frameRect { [self.descField setEditable:NO]; [self.descField setBordered:NO]; [self.descField setBackgroundColor:[NSColor clearColor]]; - [self.descField setFont:[NSFont fontWithName:@"HelveticaNeue" size:12.5]]; + [self.descField setFont:TGSystemFont(12.5)]; [[self.descField cell] setLineBreakMode:NSLineBreakByCharWrapping]; [[self.descField cell] setTruncatesLastVisibleLine:YES]; [self.descField setAutoresizingMask:NSViewWidthSizable]; @@ -92,10 +92,9 @@ -(id)initWithFrame:(NSRect)frameRect { [self.dateTextField setEditable:NO]; [self.dateTextField setBordered:NO]; [self.dateTextField setBackgroundColor:[NSColor clearColor]]; - [self.dateTextField setFont:[NSFont fontWithName:@"Helvetica-Light" size:11]]; + [self.dateTextField setFont:TGSystemLightFont(11)]; [self addSubview:self.dateTextField]; - [self setSelectedBackgroundColor: NSColorFromRGB(0xfafafa)]; [self setNormalBackgroundColor:NSColorFromRGB(0xffffff)]; @@ -196,7 +195,7 @@ - (TMRowView *)viewForRow:(NSUInteger)row item:(TMRowItem *) item { return [self.tableView cacheViewForClass:[ComposeBroadcastTableItemView class] identifier:@"BroadcastItem" withSize:NSMakeSize(self.view.bounds.size.width, 66)]; } - (void)selectionDidChange:(NSInteger)row item:(ComposeBroadcastTableItem *) item { - [[Telegram rightViewController] showByDialog:item.broadcast.conversation sender:self]; + [appWindow().navigationController showMessagesViewController:item.broadcast.conversation]; } - (BOOL)selectionWillChange:(NSInteger)row item:(TMRowItem *) item { return YES; diff --git a/TelegramTest/ComposeChangeChannelDescriptionViewController.h b/TelegramTest/ComposeChangeChannelDescriptionViewController.h new file mode 100644 index 00000000..3b9a9c57 --- /dev/null +++ b/TelegramTest/ComposeChangeChannelDescriptionViewController.h @@ -0,0 +1,13 @@ +// +// ComposeChangeChannelDescriptionViewController.h +// Telegram +// +// Created by keepcoder on 05/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "ComposeViewController.h" + +@interface ComposeChangeChannelDescriptionViewController : ComposeViewController + +@end diff --git a/TelegramTest/ComposeChangeChannelDescriptionViewController.m b/TelegramTest/ComposeChangeChannelDescriptionViewController.m new file mode 100644 index 00000000..75a67b1b --- /dev/null +++ b/TelegramTest/ComposeChangeChannelDescriptionViewController.m @@ -0,0 +1,66 @@ +// +// ComposeChangeChannelDescriptionViewController.m +// Telegram +// +// Created by keepcoder on 05/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "ComposeChangeChannelDescriptionViewController.h" +#import "TGSettingsTableView.h" +#import "TGGeneralInputRowItem.h" +#import "ComposeActionChangeChannelAboutBehavior.h" + +@interface ComposeChangeChannelDescriptionViewController () +@property (nonatomic,strong) TGSettingsTableView *tableView; +@property (nonatomic,strong) TGGeneralInputRowItem *inputItem; +@end + +@implementation ComposeChangeChannelDescriptionViewController + + +-(void)loadView { + [super loadView]; + + + _tableView = [[TGSettingsTableView alloc] initWithFrame:self.view.bounds]; + + weak(); + + [self.doneButton setTapBlock:^{ + weakSelf.action.result = [[ComposeResult alloc] init]; + weakSelf.action.result.singleObject = weakSelf.inputItem.result.string; + + [weakSelf.action.behavior composeDidDone]; + }]; + + [self.view addSubview:_tableView.containerView]; +} + + +-(void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; + + + + [_tableView removeAllItems:YES]; + + [_tableView addItem:[[TGGeneralRowItem alloc] initWithHeight:20] tableRedraw:YES]; + + + _inputItem = [[TGGeneralInputRowItem alloc] initWithObject:self.action.reservedObject1]; + + TLChat *chat = self.action.object; + + _inputItem.result = [[NSAttributedString alloc] initWithString:chat.chatFull.about attributes:@{NSFontAttributeName:TGSystemFont(13)}]; + + [_tableView addItem:_inputItem tableRedraw:YES]; + + + GeneralSettingsBlockHeaderItem *description = [[GeneralSettingsBlockHeaderItem alloc] initWithString:self.action.reservedObject2 height:50 flipped:YES]; + + + [_tableView addItem:description tableRedraw:YES]; +} + +@end diff --git a/TelegramTest/ComposeChannelParticipantsViewController.h b/TelegramTest/ComposeChannelParticipantsViewController.h new file mode 100644 index 00000000..806f68a1 --- /dev/null +++ b/TelegramTest/ComposeChannelParticipantsViewController.h @@ -0,0 +1,13 @@ +// +// ComposeChannelParticipantsViewController.h +// Telegram +// +// Created by keepcoder on 17.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "ComposeViewController.h" + +@interface ComposeChannelParticipantsViewController : ComposeViewController + +@end diff --git a/TelegramTest/ComposeChannelParticipantsViewController.m b/TelegramTest/ComposeChannelParticipantsViewController.m new file mode 100644 index 00000000..7818608a --- /dev/null +++ b/TelegramTest/ComposeChannelParticipantsViewController.m @@ -0,0 +1,339 @@ +// +// ComposeChannelParticipantsViewController.m +// Telegram +// +// Created by keepcoder on 17.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "ComposeChannelParticipantsViewController.h" +#import "SelectUsersTableView.h" +#import "ComposeActionChannelMembersBehavior.h" +#import "TGSettingsTableView.h" +#import "TGUserContainerRowItem.h" +#import "ComposeActionAddGroupMembersBehavior.h" +#import "TGUserContainerView.h" +#import "TGModernUserViewController.h" + +@interface ComposeChannelParticipantsViewControllerView : TMView +@property (nonatomic,strong) TMTextField *textField; +@end + +@implementation ComposeChannelParticipantsViewControllerView + + +-(instancetype)initWithFrame:(NSRect)frameRect { + if(self = [super initWithFrame:frameRect]) { + _textField = [TMTextField defaultTextField]; + + [_textField setFont:TGSystemFont(14)]; + [_textField setAlignment:NSCenterTextAlignment]; + [_textField setTextColor:GRAY_TEXT_COLOR]; + [[_textField cell] setLineBreakMode:NSLineBreakByWordWrapping]; + [self addSubview:_textField]; + + + [_textField setHidden:YES]; + } + + return self; +} + +-(void)setFrameSize:(NSSize)newSize { + [super setFrameSize:newSize]; + + NSSize size = [_textField.attributedStringValue sizeForTextFieldForWidth:newSize.width - 60]; + + [_textField setFrame:NSMakeRect(30, 0, size.width, size.height)]; + + [_textField setCenteredYByView:self]; + +} + +@end + +@interface ComposeChannelParticipantsViewController () +@property (nonatomic,strong) TGSettingsTableView *tableView; +@property (nonatomic,strong) RPCRequest *request; + + + +@property (nonatomic,assign) int offset; +@end + +@implementation ComposeChannelParticipantsViewController + +-(void)loadView { + + ComposeChannelParticipantsViewControllerView *mview = [[ComposeChannelParticipantsViewControllerView alloc] initWithFrame:self.frameInit]; + + self.view = mview; + + [super loadView]; + + _tableView = [[TGSettingsTableView alloc] initWithFrame:self.view.bounds]; + + [self.view addSubview:_tableView.containerView]; + + [mview.textField setStringValue:NSLocalizedString(@"Compose.ChannelEmptyBlackList", nil)]; + +} + +-(void)didUpdatedEditableState { + + [_tableView.list enumerateObjectsUsingBlock:^(TMRowItem *obj, NSUInteger idx, BOOL * _Nonnull stop) { + + if([obj isKindOfClass:[TMRowItem class]]) { + [obj setEditable:self.action.isEditable]; + } + + }]; + + [_tableView enumerateAvailableRowViewsUsingBlock:^(__kindof NSTableRowView * _Nonnull rowView, NSInteger row) { + + TMRowView *view = [rowView.subviews firstObject]; + + TMRowItem *item = _tableView.list[row]; + + if([view isKindOfClass:[TGUserContainerView class]]) { + + TGUserContainerView *v = (TGUserContainerView *) view; + + [v setEditable:item.isEditable animated:YES]; + + } + + }]; +} + +-(void)behaviorDidEndRequest:(id)response { + + [self hideModalProgress]; + +} + +-(void)behaviorDidStartRequest { + [self showModalProgress]; +} + +-(void)setAction:(ComposeAction *)action { + [super setAction:action]; +} + + +-(void)setLoading:(BOOL)isLoading { + [super setLoading:isLoading]; + + [self.doneButton setDisable:isLoading]; +} + +-(void)loadNext { + TLChat *channel = self.action.object; + + _request = [RPCRequest sendRequest:[TLAPI_channels_getParticipants createWithChannel:channel.inputPeer filter:self.action.reservedObject1 offset:_offset limit:100] successHandler:^(id request, TL_channels_channelParticipants *response) { + + if(request != _request) { + + [ASQueue dispatchOnMainQueue:^{ + [self setLoading:NO]; + }]; + [self updateText]; + return; + } + + + _request = nil; + + NSMutableArray *items = [[NSMutableArray alloc] init]; + + NSMutableDictionary *users = [[NSMutableDictionary alloc] init]; + + [response.users enumerateObjectsUsingBlock:^(TLUser *obj, NSUInteger idx, BOOL *stop) { + users[@(obj.n_id)] = obj; + }]; + + [response.participants enumerateObjectsUsingBlock:^(TLChannelParticipant *obj, NSUInteger idx, BOOL *stop) { + TLUser *user = users[@(obj.user_id)]; + + TGUserContainerRowItem *item = [[TGUserContainerRowItem alloc] initWithUser:user]; + item.type = SettingsRowItemTypeNone; + item.editable = self.action.isEditable; + [item setStateback:^id(TGGeneralRowItem *item) { + + TGUserContainerRowItem *userItem = (TGUserContainerRowItem *) item; + + return @(userItem.user.n_id != [UsersManager currentUserId] && (channel.isCreator || (channel.isManager && (![obj isKindOfClass:[TL_channelParticipantCreator class]] && ![obj isKindOfClass:[TL_channelParticipantModerator class]] && ![obj isKindOfClass:[TL_channelParticipantEditor class]])) )); + + }]; + + __weak TGUserContainerRowItem *weakItem = item; + + [item setStateCallback:^ { + + if(self.action.isEditable) { + if([weakItem.stateback(weakItem) boolValue]) + [self kickParticipant:weakItem]; + } else { + TGModernUserViewController *viewController = [[TGModernUserViewController alloc] initWithFrame:NSZeroRect]; + + [viewController setUser:weakItem.user conversation:weakItem.user.dialog]; + + [self.navigationViewController pushViewController:viewController animated:YES]; + } + + }]; + + item.height = 50; + [items addObject:item]; + }]; + + + + [ASQueue dispatchOnMainQueue:^{ + + [_tableView insert:items startIndex:_tableView.count tableRedraw:NO]; + [_tableView reloadData]; + + [self setLoading:NO]; + + [self updateText]; + }]; + + + } errorHandler:^(id request, RpcError *error) { + [ASQueue dispatchOnMainQueue:^{ + [self setLoading:NO]; + }]; + + } timeout:0 queue:[ASQueue globalQueue].nativeQueue]; + + +} + +-(void)updateText { + ComposeChannelParticipantsViewControllerView *view = (ComposeChannelParticipantsViewControllerView *) self.view; + + [_tableView.containerView setHidden:_tableView.count == 1]; + [view.textField setHidden:_tableView.count > 1]; + + [self.doneButton setHidden:_tableView.count == 1]; +} + +-(void)kickParticipant:(TGUserContainerRowItem *)participant { + + + _tableView.defaultAnimation = NSTableViewAnimationEffectFade; + + [_tableView removeItem:participant]; + + _tableView.defaultAnimation = NSTableViewAnimationEffectNone; + + TLChat *chat = self.action.object; + + + [self updateText]; + + BOOL kick = [self.action.behavior isKindOfClass:[ComposeActionChannelMembersBehavior class]]; + + + [RPCRequest sendRequest:[TLAPI_channels_kickFromChannel createWithChannel:chat.inputPeer user_id:participant.user.inputUser kicked:kick] successHandler:^(id request, id response) { + + chat.chatFull.participants_count+= kick ? -1 : 1; + chat.chatFull.kicked_count+= !kick ? -1 : 1; + + [[FullChatManager sharedManager] loadIfNeed:[chat n_id] force:YES]; + + [[Storage manager] insertFullChat:chat.chatFull completeHandler:nil]; + + + } errorHandler:^(id request, RpcError *error) { + + }]; + +} + +-(void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; + + TLChat *chat = self.action.object; + + [[FullChatManager sharedManager] loadIfNeed:[chat n_id] force:YES]; + + self.action.behavior.delegate = self; + + [_request cancelRequest]; + _request = nil; + + [_tableView removeAllItems:YES]; + + [_tableView addItem:[[TGGeneralRowItem alloc] initWithHeight:20] tableRedraw:YES]; + + if([self.action.behavior isKindOfClass:[ComposeActionChannelMembersBehavior class]] && (chat.isManager)) { + + if(chat.chatFull.participants_count < maxChatUsers()) { + GeneralSettingsRowItem *addMembersItem = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNone callback:^(TGGeneralRowItem *item) { + + NSMutableArray *filter = [[NSMutableArray alloc] init]; + + [_tableView.list enumerateObjectsUsingBlock:^(TGUserContainerRowItem *obj, NSUInteger idx, BOOL * _Nonnull stop) { + + if([obj isKindOfClass:[TGUserContainerRowItem class]]) { + [filter addObject:@(obj.user.n_id)]; + } + + ComposePickerViewController *viewController = [[ComposePickerViewController alloc] initWithFrame:NSZeroRect]; + + [viewController setAction:[[ComposeAction alloc]initWithBehaviorClass:[ComposeActionAddGroupMembersBehavior class] filter:filter object:chat.chatFull reservedObjects:@[chat]]]; + + [self.navigationViewController pushViewController:viewController animated:YES]; + + }]; + + } description:NSLocalizedString(@"Group.AddMembers", nil) height:42 stateback:nil]; + addMembersItem.textColor = BLUE_UI_COLOR; + [_tableView addItem:addMembersItem tableRedraw:YES]; + } + + + if(chat.username.length == 0 && chat.isCreator) { + GeneralSettingsRowItem *inviteViaLink = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNone callback:^(TGGeneralRowItem *item) { + + ChatExportLinkViewController *export = [[ChatExportLinkViewController alloc] initWithFrame:NSZeroRect]; + + [export setChat:chat.chatFull]; + + [self.navigationViewController pushViewController:export animated:YES]; + + + } description:NSLocalizedString(@"Modern.Channel.InviteViaLink", nil) height:42 stateback:nil]; + inviteViaLink.textColor = BLUE_UI_COLOR; + [_tableView addItem:inviteViaLink tableRedraw:YES]; + } + + if(!chat.isMegagroup) { + GeneralSettingsBlockHeaderItem *description = [[GeneralSettingsBlockHeaderItem alloc] initWithString:NSLocalizedString(@"Modern.Channel.ChannelMembersDescription", nil) height:42 flipped:YES]; + + description.autoHeight = YES; + + [_tableView addItem:description tableRedraw:YES]; + } + + [_tableView addItem:[[TGGeneralRowItem alloc] initWithHeight:20] tableRedraw:YES]; + + } + + [self setLoading:YES]; + + _offset = 0; + + [self loadNext]; +} + +-(void)viewWillDisappear:(BOOL)animated { + [super viewWillDisappear:animated]; + [_request cancelRequest]; + _request = nil; + +} + +@end diff --git a/TelegramTest/ComposeChatCreateViewController.m b/TelegramTest/ComposeChatCreateViewController.m index 8e4f3ccd..1b4f5c43 100644 --- a/TelegramTest/ComposeChatCreateViewController.m +++ b/TelegramTest/ComposeChatCreateViewController.m @@ -105,7 +105,7 @@ -(id)initWithFrame:(NSRect)frameRect { - [self.nameField setFont:[NSFont fontWithName:@"HelveticaNeue" size:15]]; + [self.nameField setFont:TGSystemFont(15)]; [self.nameField setAlignment:NSCenterTextAlignment]; @@ -124,7 +124,7 @@ -(id)initWithFrame:(NSRect)frameRect { self.textView = [[TMTextField alloc] initWithFrame:NSMakeRect(90, 45, NSWidth(frameRect) - 110, 23)]; - [self.textView setFont:[NSFont fontWithName:@"HelveticaNeue" size:15]]; + [self.textView setFont:TGSystemFont(15)]; [self.textView setEditable:YES]; [self.textView setBordered:NO]; @@ -139,7 +139,7 @@ -(id)initWithFrame:(NSRect)frameRect { [str appendString:NSLocalizedString(@"Compose.GroupNamePlaceHolder", nil) withColor:DARK_GRAY]; [str setAlignment:NSLeftTextAlignment range:str.range]; - [str setFont:[NSFont fontWithName:@"HelveticaNeue" size:15] forRange:str.range]; + [str setFont:TGSystemFont(15) forRange:str.range]; [self.textView.cell setPlaceholderAttributedString:str]; [self.textView setPlaceholderPoint:NSMakePoint(2, 0)]; @@ -154,7 +154,7 @@ -(id)initWithFrame:(NSRect)frameRect { [self addSubview:self.textView]; - self.chat = [TL_chat createWithN_id:-1 title:@"" photo:[TL_chatPhotoEmpty create] participants_count:0 date:0 left:NO version:1]; + self.chat = [TL_chat createWithFlags:0 n_id:-1 title:@"" photo:[TL_chatPhotoEmpty create] participants_count:0 date:0 version:0 migrated_to:nil]; } @@ -188,6 +188,14 @@ -(void)setName:(NSString *)name { } +-(void)setFrameSize:(NSSize)newSize { + [super setFrameSize:newSize]; + + [self.nameField setFrameOrigin:NSMakePoint(0, NSHeight(self.nameField.frame) - 5)]; + + [self.textView setFrame:NSMakeRect(90, 45, newSize.width - 110, 23)]; +} + -(void)drawRect:(NSRect)dirtyRect { [super drawRect:dirtyRect]; @@ -290,8 +298,7 @@ -(void)viewWillAppear:(BOOL)animated { [self setCenterBarViewTextAttributed:self.action.behavior.centerTitle]; - - + [self.view.window makeFirstResponder:self.headerView.textView]; [self.doneButton setStringValue:self.action.behavior.doneTitle]; @@ -303,8 +310,8 @@ -(void)viewWillAppear:(BOOL)animated { NSMutableArray *array = [[NSMutableArray alloc] init]; - for (SelectUserItem *item in self.action.result.multiObjects) { - [array addObject:[item copy]]; + for (TLUser *item in self.action.result.multiObjects) { + [array addObject:[[SelectUserItem alloc] initWithObject:item]]; } [self.tableView removeAllItems:NO]; diff --git a/TelegramTest/ComposeChooseGroupViewController.m b/TelegramTest/ComposeChooseGroupViewController.m index 1d575937..6baf0e7a 100644 --- a/TelegramTest/ComposeChooseGroupViewController.m +++ b/TelegramTest/ComposeChooseGroupViewController.m @@ -52,6 +52,8 @@ -(void)_didStackRemoved { -(void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; + self.tableView.selectLimit = 0; + self.action.behavior.delegate = self; [self.tableView readyChats]; @@ -69,14 +71,21 @@ -(void)viewWillAppear:(BOOL)animated { } + + -(void)selectTableDidChangedItem:(SelectChatItem *)item { + [self.tableView cancelSelection]; + confirm(appName(), [NSString stringWithFormat:NSLocalizedString(@"Bot.confirmAddBot", nil),item.chat.title], ^{ - self.action.result = [[ComposeResult alloc] initWithMultiObjects:@[item]]; + self.action.result = [[ComposeResult alloc] initWithMultiObjects:@[item.chat]]; [self.action.behavior composeDidDone]; + [self.tableView cancelSelection]; + + }, nil); } diff --git a/TelegramTest/ComposeConfirmModeratorViewController.h b/TelegramTest/ComposeConfirmModeratorViewController.h new file mode 100644 index 00000000..49deb5d1 --- /dev/null +++ b/TelegramTest/ComposeConfirmModeratorViewController.h @@ -0,0 +1,13 @@ +// +// ComposeConfirmModeratorViewController.h +// Telegram +// +// Created by keepcoder on 16.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "ComposeViewController.h" + +@interface ComposeConfirmModeratorViewController : ComposeViewController + +@end diff --git a/TelegramTest/ComposeConfirmModeratorViewController.m b/TelegramTest/ComposeConfirmModeratorViewController.m new file mode 100644 index 00000000..ca4ae2d3 --- /dev/null +++ b/TelegramTest/ComposeConfirmModeratorViewController.m @@ -0,0 +1,130 @@ +// +// ComposeConfirmModeratorViewController.m +// Telegram +// +// Created by keepcoder on 16.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "ComposeConfirmModeratorViewController.h" +#import "TGSettingsTableView.h" +#import "TGUserContainerRowItem.h" +#import "SelectUserItem.h" + +@interface ComposeConfirmModeratorViewController () +@property (nonatomic,strong) TGSettingsTableView *tableView; +@property (nonatomic,strong) TGUserContainerRowItem *userContainer; + +@property (nonatomic,strong) TLChannelParticipantRole *participantRole; +@end + +@implementation ComposeConfirmModeratorViewController + +-(void)loadView { + [super loadView]; + + _tableView = [[TGSettingsTableView alloc] initWithFrame:self.view.bounds]; + + [self.view addSubview:_tableView.containerView]; + + [self setCenterBarViewText:NSLocalizedString(@"Channel.Moderator", nil)]; + + +} + + +-(void)setAction:(ComposeAction *)action { + + [super setAction:action]; + + + _participantRole = [self.action.object isBroadcast] ? [TL_channelRoleEditor create] : [TL_channelRoleModerator create]; + + _userContainer = [[TGUserContainerRowItem alloc] initWithUser:action.result.multiObjects[0]]; + _userContainer.type = SettingsRowItemTypeNone; + _userContainer.height = 60; + + [_tableView removeAllItems:NO]; + + [_tableView addItem:_userContainer tableRedraw:NO]; + + GeneralSettingsRowItem *moderatorItem = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSelected callback:^(TGGeneralRowItem *item) { + + self.participantRole = [TL_channelRoleModerator create]; + [_tableView reloadData]; + + } description:NSLocalizedString(@"Channel.Comments.Moderator", nil) height:42 stateback:^id(TGGeneralRowItem *item) { + return @([self.participantRole isKindOfClass:[TL_channelRoleModerator class]]); + }]; + + + GeneralSettingsRowItem *editorItem = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSelected callback:^(TGGeneralRowItem *item) { + + self.participantRole = [TL_channelRoleEditor create]; + [_tableView reloadData]; + + } description:NSLocalizedString(@"Channel.Comments.Editor", nil) height:42 stateback:^id(TGGeneralRowItem *item) { + return @(![self.participantRole isKindOfClass:[TL_channelRoleModerator class]]); + }]; + + moderatorItem.xOffset = 30; + editorItem.xOffset = 30; + + + + + GeneralSettingsBlockHeaderItem *accessHeader = [[GeneralSettingsBlockHeaderItem alloc] initWithString:NSLocalizedString(@"Channel.AccessHeader", nil) height:42 flipped:NO]; + + accessHeader.xOffset = 30; + + GeneralSettingsBlockHeaderItem *accessDescription = [[GeneralSettingsBlockHeaderItem alloc] initWithString:NSLocalizedString(@"Channel.AccessDescription", nil) height:42 flipped:YES]; + + accessDescription.xOffset = 30; + accessDescription.autoHeight = YES; + + + [_tableView addItem:accessHeader tableRedraw:NO]; + + + if(![self.action.object isBroadcast]) + [_tableView addItem:moderatorItem tableRedraw:NO]; + [_tableView addItem:editorItem tableRedraw:NO]; + + [_tableView addItem:accessDescription tableRedraw:NO]; + + + if([self.action.reservedObject1 boolValue]) { + + GeneralSettingsRowItem *dismissModerator = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(TGGeneralRowItem *item) { + + confirm(appName(), NSLocalizedString(@"Channel.DismissModeratorConfirm", nil), ^{ + self.participantRole = [TL_channelRoleEmpty create]; + + [self.action.behavior composeDidDone]; + + }, nil); + + + } description:NSLocalizedString(@"Channel.DismissModerator", nil) height:82 stateback:^id(TGGeneralRowItem *item) { + return nil; + }]; + + dismissModerator.textColor = [NSColor redColor]; + + dismissModerator.xOffset = 30; + + [_tableView addItem:dismissModerator tableRedraw:NO]; + + } + + [_tableView reloadData]; +} + +-(void)setParticipantRole:(TLChannelParticipantRole *)participantRole { + _participantRole = participantRole; + + self.action.result.singleObject = participantRole; +} + + +@end diff --git a/TelegramTest/ComposeCreateChannelUserNameStepViewController.h b/TelegramTest/ComposeCreateChannelUserNameStepViewController.h new file mode 100644 index 00000000..8903a63f --- /dev/null +++ b/TelegramTest/ComposeCreateChannelUserNameStepViewController.h @@ -0,0 +1,13 @@ +// +// ComposeCreateChannelUserNameStepViewController.h +// Telegram +// +// Created by keepcoder on 13.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "ComposeViewController.h" + +@interface ComposeCreateChannelUserNameStepViewController : ComposeViewController + +@end diff --git a/TelegramTest/ComposeCreateChannelUserNameStepViewController.m b/TelegramTest/ComposeCreateChannelUserNameStepViewController.m new file mode 100644 index 00000000..2710da1c --- /dev/null +++ b/TelegramTest/ComposeCreateChannelUserNameStepViewController.m @@ -0,0 +1,156 @@ +// +// ComposeCreateChannelUserNameStepViewController.m +// Telegram +// +// Created by keepcoder on 13.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "ComposeCreateChannelUserNameStepViewController.h" + +#import "TGChangeUserNameContainerView.h" +#import "NSAttributedString+Hyperlink.h" + +@interface ComposeCreateChannelUserNameStepViewController () +@property (nonatomic,strong) TGChangeUserNameContainerView *changeUserNameContainerView; + +@property (nonatomic,strong) TGChangeUserObserver *observer; +@end + +@implementation ComposeCreateChannelUserNameStepViewController + + +-(void)loadView { + [super loadView]; + + + NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] init]; + + [attr appendString:NSLocalizedString(@"Channel.SetChannelLinkDescription", nil) withColor:TEXT_COLOR]; + + [attr setFont:TGSystemFont(12) forRange:attr.range]; + + [attr detectBoldColorInStringWithFont:TGSystemMediumFont(12)]; + + _observer = [[TGChangeUserObserver alloc] initWithDescription:attr placeholder:nil defaultUserName:nil]; + + [_observer setNeedDescriptionWithError:^NSString *(NSString *error) { + + if([error isEqualToString:@"USERNAME_CANT_FIRST_NUMBER"]) { + return NSLocalizedString(@"Channel.Username.InvalidStartsWithNumber", nil); + } else if([error isEqualToString:@"USERNAME_IS_ALREADY_TAKEN"]) { + return NSLocalizedString(@"Channel.Username.InvalidTaken", nil); + } else if([error isEqualToString:@"USERNAME_MIN_SYMBOLS_ERROR"]) { + return NSLocalizedString(@"Channel.Username.InvalidTooShort", nil); + } else if([error isEqualToString:@"USERNAME_INVALID"]) { + return NSLocalizedString(@"Channel.Username.InvalidCharacters", nil); + } else if([error isEqualToString:@"UserName.avaiable"]) { + return NSLocalizedString(@"Channel.Username.UsernameIsAvailable", nil); + } + + return NSLocalizedString(error, nil); + + }]; + + weak(); + + [_observer setWillNeedSaveUserName:^(NSString *userName) { + + if(!(userName.length == 0 && weakSelf.observer.defaultUserName == nil) && ![userName isEqualToString:weakSelf.observer.defaultUserName]) { + [weakSelf showModalProgress]; + + [[ChatsManager sharedManager] updateChannelUserName:userName channel:weakSelf.action.result.singleObject completeHandler:^(TL_channel *channel) { + + [weakSelf hideModalProgressWithSuccess]; + + [weakSelf.navigationViewController goBackWithAnimation:YES]; + + } errorHandler:^(NSString *result) { + + [weakSelf hideModalProgress]; + + }]; + } else { + [weakSelf.navigationViewController goBackWithAnimation:YES]; + } + + + }]; + + [_observer setDidChangedUserName:^(NSString *userName, BOOL isAcceptable) { + + [weakSelf.doneButton setDisable:!isAcceptable]; + + }]; + + [_observer setNeedApiObjectWithUserName:^id(NSString *userName) { + + return [TLAPI_channels_checkUsername createWithChannel:[weakSelf.action.result.singleObject inputPeer] username:userName]; + }]; + + self.view = _changeUserNameContainerView = [[TGChangeUserNameContainerView alloc] initWithFrame:self.view.bounds observer:_observer]; + + + + + [self.doneButton setTapBlock:^{ + [weakSelf.changeUserNameContainerView dispatchSaveBlock]; + }]; + +} + + + +-(void)behaviorDidEndRequest:(id)response { + [self hideModalProgress]; +} + + +-(void)behaviorDidStartRequest { + [self showModalProgress]; +} + +-(void)viewDidDisappear:(BOOL)animated { + [self.action.behavior composeDidCancel]; +} + +-(void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; + + + self.action.currentViewController = self; + + TL_channel *channel = self.action.result.singleObject; + + self.observer.defaultUserName = channel.username; + + [self setCenterBarViewTextAttributed:self.action.behavior.centerTitle]; + + + [_changeUserNameContainerView setOberser:_observer]; + + [self.doneButton setStringValue:self.action.behavior.doneTitle]; + + [self.doneButton sizeToFit]; + + [self.doneButton setDisable:NO]; + + [self.doneButton.superview setFrameSize:self.doneButton.frame.size]; + self.rightNavigationBarView = (TMView *) self.doneButton.superview; + +} + + +-(void)updateCompose { + + +} + +-(BOOL)becomeFirstResponder { + + return YES; + + //return [self.headerView becomeFirstResponder]; +} + +@end diff --git a/TelegramTest/ComposeCreateChannelViewController.h b/TelegramTest/ComposeCreateChannelViewController.h new file mode 100644 index 00000000..e3939248 --- /dev/null +++ b/TelegramTest/ComposeCreateChannelViewController.h @@ -0,0 +1,13 @@ +// +// ComposeCreateChannelViewController.h +// Telegram +// +// Created by keepcoder on 19.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "ComposeViewController.h" + +@interface ComposeCreateChannelViewController : ComposeViewController + +@end diff --git a/TelegramTest/ComposeCreateChannelViewController.m b/TelegramTest/ComposeCreateChannelViewController.m new file mode 100644 index 00000000..57abfbf4 --- /dev/null +++ b/TelegramTest/ComposeCreateChannelViewController.m @@ -0,0 +1,390 @@ +// +// ComposeChatCreateViewController.m +// Telegram +// +// Created by keepcoder on 01.09.14. +// Copyright (c) 2014 keepcoder. All rights reserved. +// + +#import "ComposeCreateChannelViewController.h" +#import "SelectUserRowView.h" +#import "SelectUserItem.h" +#import "SelectUsersTableView.h" +#import "ITSwitch.h" +#import "TGSettingsTableView.h" + + +@interface CreateChannelHeaderItem : TGGeneralRowItem +@property (nonatomic,strong) NSString *channelName; +@property (nonatomic,strong) NSString *channelAbout; +@property (nonatomic,assign) BOOL discussion; +@property (nonatomic,weak) ComposeCreateChannelViewController *controller; +@end + +@interface ComposeCreateChannelViewController () +-(void)updateComposeWithHeight:(int)height; +@end + + + +@interface CreateChannelHeaderView : TMRowView +@property (nonatomic,strong) TMTextField *nameTextView; +@property (nonatomic,strong) TMTextField *aboutTextView; + + +@property (nonatomic,strong) TMTextField *aboutDescription; + + + + + +@end + +@implementation CreateChannelHeaderView + +-(id)initWithFrame:(NSRect)frameRect { + if(self = [super initWithFrame:frameRect]) { + + + self.aboutTextView = [[TMTextField alloc] initWithFrame:NSMakeRect(30, 24, NSWidth(frameRect) - 60, 23)]; + + + [self.aboutTextView setFont:TGSystemFont(15)]; + + [self.aboutTextView setEditable:YES]; + [self.aboutTextView setBordered:NO]; + [self.aboutTextView setFocusRingType:NSFocusRingTypeNone]; + [self.aboutTextView setTextOffset:NSMakeSize(0, 5)]; + + NSMutableAttributedString *str = [[NSMutableAttributedString alloc] init]; + + [str appendString:NSLocalizedString(@"Compose.ChannelAboutPlaceholder", nil) withColor:DARK_GRAY]; + [str setAlignment:NSLeftTextAlignment range:str.range]; + [str setFont:TGSystemFont(15) forRange:str.range]; + + [self.aboutTextView.cell setPlaceholderAttributedString:str]; + [self.aboutTextView setPlaceholderPoint:NSMakePoint(2, 0)]; + + + [self addSubview:self.aboutTextView]; + + + + _aboutDescription = [TMTextField defaultTextField]; + [_aboutDescription setFont:TGSystemFont(13)]; + [_aboutDescription setTextColor:GRAY_TEXT_COLOR]; + + [_aboutDescription setStringValue:NSLocalizedString(@"Compose.ChannelAboutDescription", nil)]; + + + [_aboutDescription sizeToFit]; + + + [_aboutDescription setFrameOrigin:NSMakePoint(30, 0)]; + + [self addSubview:_aboutDescription]; + + + self.nameTextView = [[TMTextField alloc] initWithFrame:NSMakeRect(92, 90, NSWidth(frameRect) - 122, 23)]; + + + [self.nameTextView setFont:TGSystemFont(15)]; + + [self.nameTextView setEditable:YES]; + [self.nameTextView setBordered:NO]; + [self.nameTextView setFocusRingType:NSFocusRingTypeNone]; + [self.nameTextView setTextOffset:NSMakeSize(0, 5)]; + + str = [[NSMutableAttributedString alloc] init]; + + [str appendString:NSLocalizedString(@"Compose.ChannelTitlePlaceholder", nil) withColor:DARK_GRAY]; + [str setAlignment:NSLeftTextAlignment range:str.range]; + [str setFont:TGSystemFont(15) forRange:str.range]; + + [self.nameTextView.cell setPlaceholderAttributedString:str]; + [self.nameTextView setPlaceholderPoint:NSMakePoint(2, 0)]; + + + + [self.nameTextView becomeFirstResponder]; + + + [self addSubview:self.nameTextView]; + + + + [self.nameTextView setDelegate:self]; + [self.aboutTextView setDelegate:self]; + + + + } + + return self; +} + +-(void)redrawRow { + [super redrawRow]; + + CreateChannelHeaderItem *item = (CreateChannelHeaderItem *) [self rowItem]; + + [self.aboutTextView setStringValue:item.channelAbout]; + [self.nameTextView setStringValue:item.channelName]; + + +} + + + +-(void)controlTextDidChange:(NSNotification *)obj { + + [self.aboutTextView setStringValue:[self.aboutTextView.stringValue substringToIndex:MIN(200,self.aboutTextView.stringValue.length)]]; + + CreateChannelHeaderItem *item = (CreateChannelHeaderItem *) [self rowItem]; + + item.channelAbout = self.aboutTextView.stringValue; + item.channelName = self.nameTextView.stringValue; + + NSSize size = [self.aboutTextView.attributedStringValue sizeForTextFieldForWidth:NSWidth(self.frame) - 60]; + + size.height = MAX(21, size.height); + + int nh = 139 + size.height; + + [item.controller updateComposeWithHeight:nh]; + + +} + + +-(void)setFrameSize:(NSSize)newSize { + [super setFrameSize:newSize]; + + NSSize size = [self.aboutTextView.attributedStringValue sizeForTextFieldForWidth:newSize.width - 60]; + size.width = newSize.width - 60; + size.height = MAX(21, size.height); + + [self.aboutTextView setFrameSize:size]; + + [self.aboutTextView setFrame:NSMakeRect(30, 22, size.width, size.height)]; + + [self.aboutDescription setFrameOrigin:NSMakePoint(30, 0)]; + [self.nameTextView setFrameOrigin:NSMakePoint(92, newSize.height - 70)]; + + [self.nameTextView setFrameSize:NSMakeSize(newSize.width - 92 - 30, 20)]; +} + +-(BOOL)becomeFirstResponder { + return [self.nameTextView becomeFirstResponder]; +} + + + +-(void)drawRect:(NSRect)dirtyRect { + [super drawRect:dirtyRect]; + + NSBezierPath *path = [NSBezierPath bezierPath]; + + [path appendBezierPathWithArcWithCenter: NSMakePoint(55,NSHeight(dirtyRect) - 60) + radius: 25 + startAngle: 0 + endAngle: 360 clockwise:NO]; + + + [image_Camera() drawInRect:NSMakeRect(40,NSHeight(dirtyRect) - 70, image_Camera().size.width, image_Camera().size.height) fromRect:NSZeroRect operation:NSCompositeHighlight fraction:1]; + + [GRAY_BORDER_COLOR set]; + [path stroke]; + + NSRectFill(NSMakeRect(92, NSHeight(self.frame) - 84, NSWidth(self.frame) - 122, 1)); + + + + NSRectFill(NSMakeRect(30, 20, NSWidth(self.frame) - 60, 1)); +} + + + +@end + + + + +@implementation CreateChannelHeaderItem + +-(Class)viewClass { + return [CreateChannelHeaderView class]; +} + +@end + + +@interface ComposeCreateChannelViewController () + +@property (nonatomic,strong) TGSettingsTableView *tableView; + +@property (nonatomic,strong) CreateChannelHeaderItem *headerItem; + +@end + +@implementation ComposeCreateChannelViewController + + + +-(void)loadView { + [super loadView]; + + self.view.isFlipped = YES; + + + + self.tableView = [[TGSettingsTableView alloc] initWithFrame:self.view.bounds]; + + + [self.view addSubview:self.tableView.containerView]; + + + _headerItem = [[CreateChannelHeaderItem alloc] initWithHeight:160]; + _headerItem.controller = self; + + [self.tableView addItem:_headerItem tableRedraw:NO]; + + + +// +// GeneralSettingsRowItem *discussionItem = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSwitch callback:^(TGGeneralRowItem *item) { +// +// _headerItem.discussion = !_headerItem.discussion; +// +// [self updateCompose]; +// +// } description:NSLocalizedString(@"Channel.Discussion", nil) height:60 stateback:^id(TGGeneralRowItem *item) { +// +// return @(_headerItem.discussion); +// +// }]; +// +// +// discussionItem.xOffset = 30; +// +// [self.tableView addItem:discussionItem tableRedraw:NO]; +// +// +// GeneralSettingsBlockHeaderItem *discussionDescription = [[GeneralSettingsBlockHeaderItem alloc] initWithString:NSLocalizedString(@"Channel.DiscussionEnableDescription", nil) height:62 flipped:YES]; +// +// discussionDescription.xOffset = 30; +// +// +// [self.tableView addItem:discussionDescription tableRedraw:NO]; + + + [self.tableView reloadData]; + + + + // [self.view addSubview:self.headerView]; +} + + +-(void)setAction:(ComposeAction *)action { + [super setAction:action]; + + action.behavior.delegate = self; +} + +-(void)behaviorDidEndRequest:(id)response { + [self hideModalProgress]; +} + + +-(void)behaviorDidStartRequest { + [self showModalProgress]; +} + +-(void)viewDidDisappear:(BOOL)animated { + [self.action.behavior composeDidCancel]; +} + +-(void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; + + + self.action.currentViewController = self; + + [self setCenterBarViewTextAttributed:self.action.behavior.centerTitle]; + + if(self.action.result.stepResult.count > 0) { + + self.headerItem.channelName = ((NSArray *)self.action.result.stepResult[0]).count > 0 ? [self.action.result.stepResult[0] firstObject] : @""; + self.headerItem.channelAbout = ((NSArray *)self.action.result.stepResult[0]).count == 2 ? [self.action.result.stepResult[0] lastObject] : @""; + + self.headerItem.discussion = [self.action.result.stepResult[1] intValue]; + + } else { + self.headerItem.channelName = @""; + self.headerItem.channelAbout = nil; + } + + [self.tableView reloadData]; + + + [self.doneButton setDisable:self.headerItem.channelName.length == 0]; + + [self.doneButton setStringValue:self.action.behavior.doneTitle]; + + [self.doneButton sizeToFit]; + + [self.doneButton.superview setFrameSize:self.doneButton.frame.size]; + self.rightNavigationBarView = (TMView *) self.doneButton.superview; + +} + + +-(void)updateComposeWithHeight:(int)height { + + [self.doneButton setDisable:self.headerItem.channelName.length == 0]; + + NSArray *result = [NSArray array]; + + if(self.headerItem.channelName.length > 0) + result = [result arrayByAddingObject:self.headerItem.channelName]; + if(self.headerItem.channelAbout.length > 0) + result = [result arrayByAddingObject:self.headerItem.channelAbout]; + + + + NSArray *allSteps = self.action.result.stepResult; + + result = [@[result,@(self.headerItem.discussion)] arrayByAddingObjectsFromArray:[allSteps subarrayWithRange:NSMakeRange(MIN(1,allSteps.count), MIN(allSteps.count,abs((int)allSteps.count - 1)))]]; + + if(!self.action.result) { + self.action.result = [[ComposeResult alloc] initWithStepResult:result]; + } else { + self.action.result.stepResult = result; + } + + self.headerItem.height = height; + + // id responder = self.view.window.firstResponder; + + [[NSAnimationContext currentContext] setDuration:0]; + [self.tableView noteHeightOfRowsWithIndexesChanged:[NSIndexSet indexSetWithIndex:0]]; + + CreateChannelHeaderView *header = [self.tableView viewAtColumn:0 row:0 makeIfNecessary:NO]; + + if(header) { + [header setFrameSize:NSMakeSize(NSWidth(header.frame), height)]; + } + + // [responder becomeFirstResponder]; + +} + +-(BOOL)becomeFirstResponder { + + return YES; +} + + + +@end diff --git a/TelegramTest/ComposeManagmentViewController.h b/TelegramTest/ComposeManagmentViewController.h new file mode 100644 index 00000000..2ab91489 --- /dev/null +++ b/TelegramTest/ComposeManagmentViewController.h @@ -0,0 +1,13 @@ +// +// ComposeManagmentViewController.h +// Telegram +// +// Created by keepcoder on 17.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "ComposeViewController.h" + +@interface ComposeManagmentViewController : ComposeViewController + +@end diff --git a/TelegramTest/ComposeManagmentViewController.m b/TelegramTest/ComposeManagmentViewController.m new file mode 100644 index 00000000..8c1e26ae --- /dev/null +++ b/TelegramTest/ComposeManagmentViewController.m @@ -0,0 +1,174 @@ +// +// ComposeManagmentViewController.m +// Telegram +// +// Created by keepcoder on 17.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "ComposeManagmentViewController.h" + +#include "TGSettingsTableView.h" +#import "TGUserContainerRowItem.h" +#import "ComposeActionAddChannelModeratorBehavior.h" +#import "SelectUserItem.h" +#import "ComposeActionAddChannelModeratorBehavior.h" +@interface ComposeManagmentViewController () +@property (nonatomic,strong) TGSettingsTableView *tableView; +@end + +@implementation ComposeManagmentViewController + + +-(void)loadView { + [super loadView]; + + _tableView = [[TGSettingsTableView alloc] initWithFrame:self.view.bounds]; + [self.view addSubview:_tableView.containerView]; + + +} + +-(void)setAction:(ComposeAction *)action { + [super setAction:action]; + + + + [self setLoading:YES]; + + [RPCRequest sendRequest:[TLAPI_channels_getParticipants createWithChannel:[self.action.object inputPeer] filter:[TL_channelParticipantsAdmins create] offset:0 limit:100] successHandler:^(id request, TL_channels_channelParticipants *response) { + + [SharedManager proccessGlobalResponse:response]; + + action.result = [[ComposeResult alloc] initWithMultiObjects:response.participants]; + + [self reload]; + + [self setLoading:NO]; + + } errorHandler:^(id request, RpcError *error) { + + }]; + + +} + + +-(void)reload { + + [self.tableView removeAllItems:NO]; + + TLChat *chat = self.action.object; + + if(chat.isCreator) { + GeneralSettingsRowItem *addModerator = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(TGGeneralRowItem *item) { + + + ComposePickerViewController *viewController = [[ComposePickerViewController alloc] initWithFrame:self.view.bounds]; + + [viewController setAction:[[ComposeAction alloc] initWithBehaviorClass:[ComposeActionAddChannelModeratorBehavior class] filter:@[] object:chat]]; + + [self.navigationViewController pushViewController:viewController animated:YES]; + + } description:chat.isBroadcast ? NSLocalizedString(@"Channel.AddEditor", nil) : NSLocalizedString(@"Channel.AddModerator", nil) height:62 stateback:^id(TGGeneralRowItem *item) { + return nil; + }]; + + [_tableView addItem:addModerator tableRedraw:NO]; + + GeneralSettingsBlockHeaderItem *description = [[GeneralSettingsBlockHeaderItem alloc] initWithString:chat.isMegagroup ? NSLocalizedString(@"Group.AddModeratorDescription", nil) : NSLocalizedString(@"Channel.AddModeratorDescription", nil) height:62 flipped:YES]; + + [_tableView addItem:description tableRedraw:NO]; + + } else { + GeneralSettingsBlockHeaderItem *description = [[GeneralSettingsBlockHeaderItem alloc] initWithString:@"" height:30 flipped:YES]; + + [_tableView addItem:description tableRedraw:NO]; + } + + + NSArray *sort = @[NSStringFromClass([TL_channelParticipantCreator class]),NSStringFromClass([TL_channelParticipantEditor class]),NSStringFromClass([TL_channelParticipantModerator class])]; + + NSArray *admins = [self.action.result.multiObjects sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) { + + return [@([sort indexOfObject:[obj1 className]]) compare:@([sort indexOfObject:[obj2 className]])]; + + }]; + + + [admins enumerateObjectsWithOptions:0 usingBlock:^(TL_channelParticipant *obj, NSUInteger idx, BOOL *stop) { + + TGUserContainerRowItem *item = [[TGUserContainerRowItem alloc] initWithUser:[[UsersManager sharedManager] find:obj.user_id]]; + item.type = SettingsRowItemTypeNone; + item.height = 42; + item.avatarHeight = 30; + item.status = [obj isKindOfClass:[TL_channelParticipantCreator class]] ? NSLocalizedString(@"Channel.Creator", nil) : [obj isKindOfClass:[TL_channelParticipantModerator class]] ? NSLocalizedString(@"Channel.Moderator", nil) : [TL_channelParticipantEditor class] ? NSLocalizedString(@"Channel.Editor", nil) : @""; + + [_tableView addItem:item tableRedraw:NO]; + + TLUser *user = item.user; + + __weak TGUserContainerRowItem *weakItem = item; + + item.stateCallback = ^{ + + if(![obj isKindOfClass:[TL_channelParticipantCreator class]]) { + if((chat.isBroadcast || chat.isMegagroup) && chat.isCreator) { + + confirm(NSLocalizedString(@"Channel.DismissModerator", nil), NSLocalizedString(@"Channel.DismissModeratorConfirm", nil), ^{ + + + [RPCRequest sendRequest:[TLAPI_channels_editAdmin createWithChannel:chat.inputPeer user_id:user.inputUser role:[TL_channelRoleEmpty create]] successHandler:^(id request, id response) { + + + self.tableView.defaultAnimation = NSTableViewAnimationEffectFade; + [self.tableView removeItem:weakItem tableRedraw:YES]; + self.tableView.defaultAnimation = NSTableViewAnimationEffectNone; + + } errorHandler:^(id request, RpcError *error) { + + }]; + + + }, ^{ + + }); + + } else { + + ComposeAction *action = [[ComposeAction alloc] initWithBehaviorClass:[ComposeActionAddChannelModeratorBehavior class] filter:@[] object:chat reservedObjects:@[@(YES),obj]]; + + action.result = [[ComposeResult alloc] initWithMultiObjects:@[user]]; + + ComposeConfirmModeratorViewController *viewController = [[ComposeConfirmModeratorViewController alloc] initWithFrame:self.view.bounds]; + + [viewController setAction:action]; + + [self.navigationViewController pushViewController:viewController animated:YES]; + } + + } + + + + }; + + }]; + + + + [_tableView reloadData]; +} + + +-(void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; + + [self setCenterBarViewText:NSLocalizedString(@"Channel.Managment", nil)]; + + [self.doneButton setStringValue:@""]; + + self.action = self.action; +} + +@end diff --git a/TelegramTest/ComposePickerViewController.m b/TelegramTest/ComposePickerViewController.m index 4609b4f6..2bafb9e1 100644 --- a/TelegramTest/ComposePickerViewController.m +++ b/TelegramTest/ComposePickerViewController.m @@ -84,9 +84,9 @@ -(void)viewWillAppear:(BOOL)animated { NSMutableArray *ids = [[NSMutableArray alloc] init]; - [self.action.result.multiObjects enumerateObjectsUsingBlock:^(SelectUserItem *obj, NSUInteger idx, BOOL *stop) { + [self.action.result.multiObjects enumerateObjectsUsingBlock:^(TLUser *obj, NSUInteger idx, BOOL *stop) { - [ids addObject:@(obj.user.n_id)]; + [ids addObject:@(obj.n_id)]; }]; self.tableView.selectedItems = ids; @@ -115,7 +115,19 @@ -(void)viewWillAppear:(BOOL)animated { -(void)selectTableDidChangedItem:(SelectUserItem *)item { - self.action.result = [[ComposeResult alloc] initWithMultiObjects:[self.tableView selectedItems]]; + NSMutableArray *users = [[NSMutableArray alloc] init]; + + [self.tableView.selectedItems enumerateObjectsUsingBlock:^(SelectUserItem *obj, NSUInteger idx, BOOL *stop) { + + [users addObject:obj.user]; + + }]; + + if(!self.action.result) + self.action.result = [[ComposeResult alloc] initWithMultiObjects:users]; + else + self.action.result.multiObjects = users; + [self setCenterBarViewTextAttributed:self.action.behavior.centerTitle]; diff --git a/TelegramTest/ComposeSettingupNewChannelViewController.h b/TelegramTest/ComposeSettingupNewChannelViewController.h new file mode 100644 index 00000000..f54a77d4 --- /dev/null +++ b/TelegramTest/ComposeSettingupNewChannelViewController.h @@ -0,0 +1,13 @@ +// +// ComposeSettingupNewChannelViewController.h +// Telegram +// +// Created by keepcoder on 20.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "ComposeViewController.h" + +@interface ComposeSettingupNewChannelViewController : ComposeViewController + +@end diff --git a/TelegramTest/ComposeSettingupNewChannelViewController.m b/TelegramTest/ComposeSettingupNewChannelViewController.m new file mode 100644 index 00000000..8cd7e78f --- /dev/null +++ b/TelegramTest/ComposeSettingupNewChannelViewController.m @@ -0,0 +1,256 @@ +// +// ComposeSettingupNewChannelViewController.m +// Telegram +// +// Created by keepcoder on 20.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "ComposeSettingupNewChannelViewController.h" +#import "TGSettingsTableView.h" +#import "TGChangeUserNameContainerView.h" +#import "NSAttributedString+Hyperlink.h" +@interface TGUserNameContainerRowItem : TGGeneralRowItem +@property (nonatomic,strong) TGChangeUserObserver *observer; +@end + +@interface TGUserNameContainerRowView : TMRowView +@property (nonatomic,strong) TGChangeUserNameContainerView *container; +@end + +@implementation TGUserNameContainerRowView + +-(instancetype)initWithFrame:(NSRect)frameRect { + if(self =[super initWithFrame:frameRect]) { + _container = [[TGChangeUserNameContainerView alloc] initWithFrame:self.bounds observer:nil]; + + [self addSubview:_container]; + } + + return self; +} + +-(void)redrawRow { + [super redrawRow]; + + TGUserNameContainerRowItem *item = (TGUserNameContainerRowItem *) [self rowItem]; + + [_container setOberser:item.observer]; +} + +-(void)setFrameSize:(NSSize)newSize { + [super setFrameSize:newSize]; + + [_container setFrameSize:newSize]; +} + +@end + + + + +@implementation TGUserNameContainerRowItem + +-(Class)viewClass { + return [TGUserNameContainerRowView class]; +} + + +@end + + +@interface ComposeSettingupNewChannelViewController () +@property (nonatomic,strong) TGSettingsTableView *tableView; +@property (nonatomic,strong) TGUserNameContainerRowItem *userNameContainerItem; +@property (nonatomic,strong) GeneralSettingsBlockHeaderItem *joinLinkItem; +@end + +@implementation ComposeSettingupNewChannelViewController + + +-(void)loadView { + [super loadView]; + + _tableView = [[TGSettingsTableView alloc] initWithFrame:self.view.bounds]; + + [self.view addSubview:_tableView.containerView]; + + + +} + + +-(void)setAction:(ComposeAction *)action { + [super setAction:action]; + + self.action.result = [[ComposeResult alloc] init]; + + self.action.result.singleObject = @(YES); + + _userNameContainerItem = [[TGUserNameContainerRowItem alloc] initWithHeight:120]; + + NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] init]; + + [attr appendString:NSLocalizedString(@"Channel.NewChannelSettingUpUserNameDescription", nil) withColor:GRAY_TEXT_COLOR]; + + [attr setFont:TGSystemFont(12) forRange:attr.range]; + + [attr detectBoldColorInStringWithFont:TGSystemMediumFont(12)]; + + + _userNameContainerItem.observer = [[TGChangeUserObserver alloc] initWithDescription:attr placeholder:@"" defaultUserName:@""]; + + + [_userNameContainerItem.observer setNeedDescriptionWithError:^NSString *(NSString *error) { + + if([error isEqualToString:@"USERNAME_CANT_FIRST_NUMBER"]) { + return NSLocalizedString(@"Channel.Username.InvalidStartsWithNumber", nil); + } else if([error isEqualToString:@"USERNAME_IS_ALREADY_TAKEN"]) { + return NSLocalizedString(@"Channel.Username.InvalidTaken", nil); + } else if([error isEqualToString:@"USERNAME_MIN_SYMBOLS_ERROR"]) { + return NSLocalizedString(@"Channel.Username.InvalidTooShort", nil); + } else if([error isEqualToString:@"USERNAME_INVALID"]) { + return NSLocalizedString(@"Channel.Username.InvalidCharacters", nil); + } else if([error isEqualToString:@"UserName.avaiable"]) { + return NSLocalizedString(@"Channel.Username.UsernameIsAvailable", nil); + } + + return NSLocalizedString(error, nil); + + }]; + + + TL_chatInviteExported *export = self.action.reservedObject1; + + _joinLinkItem = [[GeneralSettingsBlockHeaderItem alloc] initWithString:export.link height:34 flipped:NO]; + _joinLinkItem.xOffset = 30; + [_joinLinkItem setTextColor:TEXT_COLOR]; + [_joinLinkItem setFont:TGSystemFont(14)]; + _joinLinkItem.drawsSeparator = YES; + + _joinLinkItem.type = SettingsRowItemTypeNone; + [_joinLinkItem setCallback:^(TGGeneralRowItem *item) { + + GeneralSettingsBlockHeaderItem *header = (GeneralSettingsBlockHeaderItem *) item; + + [TMViewController showModalProgressWithDescription:NSLocalizedString(@"Conversation.CopyToClipboard", nil)]; + + NSPasteboard* cb = [NSPasteboard generalPasteboard]; + + [cb declareTypes:[NSArray arrayWithObjects:NSStringPboardType, nil] owner:item]; + [cb setString:header.header.string forType:NSStringPboardType]; + + dispatch_after_seconds(0.2, ^{ + [TMViewController hideModalProgressWithSuccess]; + }); + + }]; + + weak(); + + [_userNameContainerItem.observer setWillNeedSaveUserName:^(NSString *username) { + if(username.length >= 5) { + + weakSelf.action.reservedObject2 = username; + + [weakSelf.action.behavior composeDidDone]; + + } + }]; + + [_userNameContainerItem.observer setDidChangedUserName:^(NSString *username, BOOL accept) { + + weakSelf.action.reservedObject2 = username; + + if(!accept) { + weakSelf.action.reservedObject2 = nil; + } + + }]; + + [_userNameContainerItem.observer setNeedApiObjectWithUserName:^id(NSString *username) { + + return [TLAPI_channels_checkUsername createWithChannel:[weakSelf.action.object inputPeer] username:username]; + }]; + + + [self reload]; +} + + + + + +-(void)reload { + + [self.tableView removeAllItems:NO]; + + + GeneralSettingsBlockHeaderItem *headerItem = [[GeneralSettingsBlockHeaderItem alloc] initWithString:NSLocalizedString(@"Channel.TypeHeader", nil) height:60 flipped:NO]; + headerItem.xOffset = 30; + + + GeneralSettingsRowItem *publicSelector = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSelected callback:^(TGGeneralRowItem *item) { + + + self.action.result.singleObject = @(YES); + + [self reload]; + + } description:NSLocalizedString(@"Channel.Public", nil) height:42 stateback:^id(TGGeneralRowItem *item) { + return self.action.result.singleObject; + }]; + + GeneralSettingsRowItem *privateSelector = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSelected callback:^(TGGeneralRowItem *item) { + + self.action.result.singleObject = @(NO); + + [self reload]; + + } description:NSLocalizedString(@"Channel.Private", nil) height:42 stateback:^id(TGGeneralRowItem *item) { + return @(![self.action.result.singleObject boolValue]); + }]; + + + + + GeneralSettingsBlockHeaderItem *selectorDesc = [[GeneralSettingsBlockHeaderItem alloc] initWithString:[self.action.result.singleObject boolValue] ? NSLocalizedString(@"Channel.ChoiceTypeDescriptionPublic", nil) : NSLocalizedString(@"Channel.ChoiceTypeDescriptionPrivate", nil) height:42 flipped:YES]; + + + selectorDesc.xOffset = privateSelector.xOffset = publicSelector.xOffset = 30; + + + + + [self.tableView addItem:headerItem tableRedraw:NO]; + [self.tableView addItem:publicSelector tableRedraw:NO]; + [self.tableView addItem:privateSelector tableRedraw:NO]; + [self.tableView addItem:selectorDesc tableRedraw:NO]; + + + if([self.action.result.singleObject boolValue]) { + [self.tableView addItem:_userNameContainerItem tableRedraw:NO]; + } else { + [self.tableView addItem:_joinLinkItem tableRedraw:NO]; + + + + GeneralSettingsBlockHeaderItem *joinDescription = [[GeneralSettingsBlockHeaderItem alloc] initWithString:NSLocalizedString(@"Channel.NewChannelSettingUpJoinLinkDescription", nil) height:42 flipped:YES]; + + [self.tableView addItem:joinDescription tableRedraw:NO]; + + joinDescription.xOffset = 30; + } + + + + + + [self.tableView reloadData]; +} + +-(void)performEnter { + +} + +@end diff --git a/TelegramTest/ComposeViewController.h b/TelegramTest/ComposeViewController.h index ab9551a7..d8da46de 100644 --- a/TelegramTest/ComposeViewController.h +++ b/TelegramTest/ComposeViewController.h @@ -13,6 +13,13 @@ @property (nonatomic,strong,readonly) TMTextButton *doneButton; @property (nonatomic,strong) ComposeAction *action; --(void)setAction:(ComposeAction *)action animated:(BOOL)animated; +@property (nonatomic,assign,setter=setLoading:) BOOL isLoading; + + +@property (nonatomic,assign, setter=setEditable:) BOOL isEditable; + +-(void)updateActionNavigation; + +-(void)didUpdatedEditableState; @end diff --git a/TelegramTest/ComposeViewController.m b/TelegramTest/ComposeViewController.m index 822bfbcb..2932cc23 100644 --- a/TelegramTest/ComposeViewController.m +++ b/TelegramTest/ComposeViewController.m @@ -9,7 +9,7 @@ #import "ComposeViewController.h" @interface ComposeViewController () - +@property (nonatomic,strong) NSProgressIndicator *progress; @end @implementation ComposeViewController @@ -18,13 +18,25 @@ -(void)loadView { [super loadView]; + _progress = [[NSProgressIndicator alloc] initWithFrame:NSMakeRect(0, 0, 30, 30)]; + + [_progress setStyle:NSProgressIndicatorSpinningStyle]; + + [_progress setAutoresizingMask:NSViewMinXMargin | NSViewMaxXMargin | NSViewMaxYMargin | NSViewMinYMargin]; + TMView *rightView = [[TMView alloc] init]; - weakify(); + weak(); _doneButton = [TMTextButton standartUserProfileNavigationButtonWithTitle:@"Done"]; [self.doneButton setTapBlock:^{ - [strongSelf.action.behavior composeDidDone]; + [weakSelf.action.behavior composeDidDone]; + + weakSelf.action.editable = !weakSelf.action.editable; + [weakSelf updateActionNavigation]; + + [weakSelf didUpdatedEditableState]; + }]; [rightView setFrameSize:self.doneButton.frame.size]; @@ -38,9 +50,68 @@ -(void)loadView { } +-(void)setLoading:(BOOL)isLoading { + _isLoading = isLoading; + + if(isLoading) + [self.view addSubview:_progress]; + else + [_progress removeFromSuperview]; + + if(_isLoading) + [_progress startAnimation:self]; + else + [_progress stopAnimation:self]; + + [_progress setCenterByView:_progress.superview]; + + [self.view.subviews enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + + [obj setHidden:isLoading]; + + if(obj == _progress) { + + [obj setHidden:!isLoading]; + } + + }]; +} + +-(void)setEditable:(BOOL)isEditable { + _isEditable = isEditable; + + +} + -(void)setAction:(ComposeAction *)action { _action = action; - [self view]; + + [self loadViewIfNeeded]; +} + +-(void)updateActionNavigation { + + [self setCenterBarViewTextAttributed:self.action.behavior.centerTitle]; + + [self.doneButton setStringValue:self.action.behavior.doneTitle]; + + [self.doneButton sizeToFit]; + + [self.doneButton.superview setFrameSize:self.doneButton.frame.size]; + self.rightNavigationBarView = (TMView *) self.doneButton.superview; +} + +-(void)didUpdatedEditableState { + +} + +-(void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; + _action.currentViewController = self; + [self updateActionNavigation]; } + + + @end diff --git a/TelegramTest/ConnectionStatusViewControllerView.m b/TelegramTest/ConnectionStatusViewControllerView.m index 46987be8..e99ef5cf 100644 --- a/TelegramTest/ConnectionStatusViewControllerView.m +++ b/TelegramTest/ConnectionStatusViewControllerView.m @@ -45,7 +45,7 @@ - (id)initWithFrame:(NSRect)frame self.progress.autoresizingMask = self.field.autoresizingMask = NSViewMinXMargin | NSViewMaxXMargin; - [self.field setFont:[NSFont fontWithName:@"HelveticaNeue" size:15]]; + [self.field setFont:TGSystemFont(15)]; [self addSubview:self.field]; diff --git a/TelegramTest/ContactsViewController.m b/TelegramTest/ContactsViewController.m index 7d36edfb..8399588a 100644 --- a/TelegramTest/ContactsViewController.m +++ b/TelegramTest/ContactsViewController.m @@ -13,7 +13,6 @@ #import "SelectUserItem.h" #import "SelectUserRowView.h" -#import "NewConversationViewController.h" #import "RBLPopover.h" #import "TLPeer+Extensions.h" #import "AddContactViewController.h" @@ -43,7 +42,7 @@ -(id)initWithFrame:(NSRect)frameRect { self.field = [TMTextField defaultTextField]; [self.field setBackgroundColor:[NSColor clearColor]]; - [self.field setFont:[NSFont fontWithName:@"HelveticaNeue-Medium" size:12]]; + [self.field setFont:TGSystemMediumFont(12)]; [[self.field cell] setLineBreakMode:NSLineBreakByCharWrapping]; [[self.field cell] setTruncatesLastVisibleLine:YES]; @@ -428,7 +427,9 @@ - (void) selectionDidChange:(NSInteger)row item:(TMRowItem *) item { if([item isKindOfClass:[ContactUserItem class]]) { ContactUserItem *searchItem = (ContactUserItem *) item; - [[Telegram sharedInstance] showMessagesWidthUser:searchItem.user sender:self]; + + [appWindow().navigationController showMessagesViewController:searchItem.user.dialog]; + } else if([item isKindOfClass:[ContactFirstItem class]]) { [[Telegram rightViewController] showAddContactController]; diff --git a/TelegramTest/DialogsHistoryController.h b/TelegramTest/DialogsHistoryController.h deleted file mode 100644 index 4bbc16c1..00000000 --- a/TelegramTest/DialogsHistoryController.h +++ /dev/null @@ -1,26 +0,0 @@ -// -// DialogsHistoryController.h -// Telegram P-Edition -// -// Created by keepcoder on 12.02.14. -// Copyright (c) 2014 keepcoder. All rights reserved. -// - -#import - -@interface DialogsHistoryController : NSObject - -typedef enum { - DialogsHistoryStateNeedLocal = 0, - DialogsHistoryStateNeedRemote = 1, - DialogsHistoryStateNeedUsers = 3, - DialogsHistoryStateEnd = 2, -} DialogHistoryState; - -@property (nonatomic,assign) DialogHistoryState state; -@property (nonatomic,assign) BOOL isLoading; --(void)next:(int)offset limit:(int)limit callback:(void (^)(NSArray *))callback usersCallback:(void (^)(NSArray *))usersCallback; -+(DialogsHistoryController *)sharedController; --(void)initialize; --(void)drop; -@end diff --git a/TelegramTest/DialogsHistoryController.m b/TelegramTest/DialogsHistoryController.m deleted file mode 100644 index c46a9a44..00000000 --- a/TelegramTest/DialogsHistoryController.m +++ /dev/null @@ -1,151 +0,0 @@ -// -// DialogsHistoryController.m -// Telegram P-Edition -// -// Created by keepcoder on 12.02.14. -// Copyright (c) 2014 keepcoder. All rights reserved. -// - -#import "DialogsHistoryController.h" -#import "TLPeer+Extensions.h" - -@interface DialogsHistoryController () -@property (nonatomic,strong) ASQueue *queue; -@end - -@implementation DialogsHistoryController - - --(id)init { - if(self = [super init]) { - self.state = DialogsHistoryStateNeedLocal; - self.queue = [(DialogsManager *)[DialogsManager sharedManager] queue]; - } - return self; -} - -+(DialogsHistoryController *)sharedController { - static DialogsHistoryController *controller; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - controller = [[DialogsHistoryController alloc] init]; - }); - return controller; -} - --(void)initialize { - -} - - --(void)next:(int)offset limit:(int)limit callback:(void (^)(NSArray *))callback usersCallback:(void (^)(NSArray *))usersCallback { - - [self.queue dispatchOnQueue:^{ - self.isLoading = YES; - if(self.state == DialogsHistoryStateNeedLocal) { - [self loadlocal:offset limit:limit callback:callback]; - } else { - [self loadremote:offset limit:limit callback:callback]; - } - }]; -} - --(void)loadlocal:(int)offset limit:(int)limit callback:(void (^)(NSArray *))callback { - - [[Storage manager] dialogsWithOffset:offset limit:limit completeHandler:^(NSArray *d, NSArray *m) { - - [ASQueue dispatchOnStageQueue:^{ - - NSMutableArray *converted = [[NSMutableArray alloc] init]; - - [d enumerateObjectsUsingBlock:^(TL_conversation *obj, NSUInteger idx, BOOL *stop) { - - if(![[DialogsManager sharedManager] find:obj.peer_id]) - { - [converted addObject:obj]; - } - }]; - - [[DialogsManager sharedManager] add:converted]; - [[MessagesManager sharedManager] add:m]; - - if(d.count < limit) { - self.state = DialogsHistoryStateNeedRemote; - - } - - self.isLoading = NO; - [[ASQueue mainQueue] dispatchOnQueue:^{ - if(callback) - callback(converted); - }]; - }]; - - }]; -} - --(void)loadremote:(int)offset limit:(int)limit callback:(void (^)(NSArray *))callback { - - [RPCRequest sendRequest:[TLAPI_messages_getDialogs createWithOffset:offset max_id:0 limit:limit]successHandler:^(RPCRequest *request, id response) { - - TL_messages_dialogs *dialogs = response; - - - [SharedManager proccessGlobalResponse:response]; - - - NSMutableArray *converted = [[NSMutableArray alloc] init]; - for (TL_dialog *dialog in [dialogs dialogs]) { - - TLMessage *msg = [[MessagesManager sharedManager] find:dialog.top_message]; - - if(![[DialogsManager sharedManager] find:dialog.peer.peer_id]) - [converted addObject:[TL_conversation createWithPeer:dialog.peer top_message:dialog.top_message unread_count:dialog.unread_count last_message_date:msg.date notify_settings:dialog.notify_settings last_marked_message:dialog.top_message top_message_fake:dialog.top_message last_marked_date:msg.date sync_message_id:msg.n_id]]; - - - - - } - - [[DialogsManager sharedManager] add:converted]; - [[Storage manager] insertDialogs:converted completeHandler:nil]; - - [MessagesManager updateUnreadBadge]; - - - if(dialogs.dialogs.count < limit) { - self.state = DialogsHistoryStateEnd; - } - - self.isLoading = NO; - - - - [[ASQueue mainQueue] dispatchOnQueue:^{ - if(callback) - callback(converted); - }]; - - - - - } errorHandler:^(RPCRequest *request, RpcError *error) { - - self.isLoading = NO; - - if(error.error_code == 502) { - [self loadremote:offset limit:limit callback:callback]; - return; - } - - } timeout:10 queue:self.queue.nativeQueue]; - -} - --(void)drop { - self.state = DialogsHistoryStateNeedLocal; -} - - - -@end diff --git a/TelegramTest/DialogsManager.h b/TelegramTest/DialogsManager.h index 2cdcab9b..bf312559 100644 --- a/TelegramTest/DialogsManager.h +++ b/TelegramTest/DialogsManager.h @@ -22,13 +22,26 @@ - (TL_conversation *)createDialogForUser:(TLUser *)user; - (TL_conversation *)createDialogForChat:(TLChat *)chat; - (TL_conversation *)createDialogEncryptedChat:(TLEncryptedChat *)chat; - +- (TL_conversation *)createDialogForChannel:(TLChat *)chat; - (void) insertDialog:(TL_conversation *)dialog; - (void) markAllMessagesAsRead:(TL_conversation *)dialog; -- (void) markAllMessagesAsRead:(TLPeer *)peer max_id:(int)max_id; +- (void) markAllMessagesAsRead:(TLPeer *)peer max_id:(int)max_id out:(BOOL)n_out; + +-(void)markChannelMessagesAsRead:(int)channel_id max_id:(int)max_id; + +-(void)completeDeleteConversation:(dispatch_block_t)completeHandler dialog:(TL_conversation *)dialog; + +// delete messages +-(void)deleteMessagesWithMessageIds:(NSArray *)ids; +-(void)deleteChannelMessags:(NSArray *)messageIds; +-(void)deleteMessagesWithRandomMessageIds:(NSArray *)ids isChannelMessages:(BOOL)isChannelMessages; + - (void)deleteDialog:(TL_conversation *)dialog completeHandler:(dispatch_block_t)completeHandler; - (void)clearHistory:(TL_conversation *)dialog completeHandler:(dispatch_block_t)block; -(void)updateLastMessageForDialog:(TL_conversation *)dialog; + +-(void)notifyAfterUpdateConversation:(TL_conversation *)conversation; + @end diff --git a/TelegramTest/DialogsManager.m b/TelegramTest/DialogsManager.m index 16e7c064..19ca7eb0 100644 --- a/TelegramTest/DialogsManager.m +++ b/TelegramTest/DialogsManager.m @@ -25,7 +25,6 @@ -(id)initWithQueue:(ASQueue *)queue { if(self = [super initWithQueue:queue]) { [Notification addObserver:self selector:@selector(setTopMessageToDialog:) name:MESSAGE_UPDATE_TOP_MESSAGE]; [Notification addObserver:self selector:@selector(setTopMessagesToDialogs:) name:MESSAGE_LIST_UPDATE_TOP]; - [Notification addObserver:self selector:@selector(deleteMessages:) name:MESSAGE_DELETE_EVENT]; [Notification addObserver:self selector:@selector(updateReadList:) name:MESSAGE_READ_EVENT]; } return self; @@ -35,7 +34,20 @@ - (void)dealloc { [Notification removeObserver:self]; } - +-(NSArray *)unloadedConversationsWithMessages:(NSArray *)messages { + NSMutableDictionary *unloaded = [NSMutableDictionary dictionary]; + + [messages enumerateObjectsUsingBlock:^(TL_localMessage *obj, NSUInteger idx, BOOL * _Nonnull stop) { + + TL_conversation *conversation = [self find:obj.peer_id]; + + if(!conversation) + unloaded[@(obj.peer_id)] = @(1); + + }]; + + return unloaded.allKeys; +} - (void)updateReadList:(NSNotification *)notify { NSArray *copy = [notify.userInfo objectForKey:KEY_MESSAGE_ID_LIST]; @@ -43,14 +55,20 @@ - (void)updateReadList:(NSNotification *)notify { [[Storage manager] messages:^(NSArray *messages) { NSMutableDictionary *updateDialogs = [[NSMutableDictionary alloc] init]; - int total = 0; - for (TL_localMessage *message in messages) { - if(message.conversation) { + + NSArray *unloaded = [self unloadedConversationsWithMessages:messages]; + + [[Storage manager] conversationsWithPeerIds:unloaded completeHandler:^(NSArray *result) { + + [self add:result]; + + [messages enumerateObjectsUsingBlock:^(TL_localMessage *message, NSUInteger idx, BOOL * _Nonnull stop) { if(!message.n_out) { - if(message.conversation.unread_count != 0) - ++total; message.conversation.unread_count--; - + } + + if(message.conversation.lastMessage.n_id == message.n_id) { + message.conversation.lastMessage.flags&= ~TGUNREADMESSAGE; } if(message.n_id > message.conversation.last_marked_message) { @@ -58,23 +76,21 @@ - (void)updateReadList:(NSNotification *)notify { message.conversation.last_marked_date = message.date; } - [updateDialogs setObject:message.conversation forKey:@(message.conversation.peer.peer_id)]; + [updateDialogs setObject:message.conversation forKey:@(message.conversation.peer_id)]; + }]; + + for (TL_conversation *dialog in updateDialogs.allValues) { + [dialog save]; + [Notification perform:DIALOG_UPDATE data:@{KEY_DIALOG:dialog}]; + [Notification perform:[Notification notificationNameByDialog:dialog action:@"unread_count"] data:@{KEY_DIALOG:dialog,KEY_LAST_CONVRESATION_DATA:[MessagesUtils conversationLastData:dialog]}]; } - } - - for (TL_conversation *dialog in updateDialogs.allValues) { - [dialog save]; - [Notification perform:DIALOG_UPDATE data:@{KEY_DIALOG:dialog}]; - [Notification perform:[Notification notificationNameByDialog:dialog action:@"unread_count"] data:@{KEY_DIALOG:dialog,KEY_LAST_CONVRESATION_DATA:[MessagesUtils conversationLastData:dialog]}]; - } - - - - [[Storage manager] markMessagesAsRead:copy useRandomIds:@[]]; - - - [MessagesManager updateUnreadBadge]; + [[Storage manager] markMessagesAsRead:copy useRandomIds:@[]]; + + + [MessagesManager updateUnreadBadge]; + + }]; } forIds:copy random:NO queue:self.queue]; @@ -97,7 +113,7 @@ - (TL_conversation *)createDialogForUser:(TLUser *)user { __block TL_conversation *dialog; [ASQueue dispatchOnStageQueue:^{ - dialog = [TL_conversation createWithPeer:[TL_peerUser createWithUser_id:user.n_id] top_message:0 unread_count:0 last_message_date:0 notify_settings:nil last_marked_message:0 top_message_fake:0 last_marked_date:0 sync_message_id:0]; + dialog = [TL_conversation createWithPeer:[TL_peerUser createWithUser_id:user.n_id] top_message:0 unread_count:0 last_message_date:0 notify_settings:nil last_marked_message:0 top_message_fake:0 last_marked_date:0 sync_message_id:0 read_inbox_max_id:0 unread_important_count:0 lastMessage:nil]; dialog.fake = YES; @@ -114,7 +130,11 @@ - (TL_conversation *)createDialogForChat:(TLChat *)chat { __block TL_conversation *dialog; [ASQueue dispatchOnStageQueue:^{ - dialog = [TL_conversation createWithPeer:[TL_peerChat createWithChat_id:chat.n_id] top_message:0 unread_count:0 last_message_date:0 notify_settings:nil last_marked_message:0 top_message_fake:0 last_marked_date:0 sync_message_id:0]; + + if([chat isKindOfClass:[TL_channel class]]) { + dialog = [self createDialogForChannel:chat]; + } else + dialog = [TL_conversation createWithPeer:[TL_peerChat createWithChat_id:chat.n_id] top_message:0 unread_count:0 last_message_date:0 notify_settings:nil last_marked_message:0 top_message_fake:0 last_marked_date:0 sync_message_id:0 read_inbox_max_id:0 unread_important_count:0 lastMessage:nil]; dialog.fake = YES; @@ -126,12 +146,32 @@ - (TL_conversation *)createDialogForChat:(TLChat *)chat { } +- (TL_conversation *)createDialogForChannel:(TLChat *)chat { + + + __block TL_conversation *dialog; + + [ASQueue dispatchOnStageQueue:^{ + dialog = [TL_conversation createWithPeer:[TL_peerChannel createWithChannel_id:chat.n_id] top_message:0 unread_count:0 last_message_date:0 notify_settings:nil last_marked_message:0 top_message_fake:0 last_marked_date:0 sync_message_id:0 read_inbox_max_id:0 unread_important_count:0 lastMessage:nil pts:0 isInvisibleChannel:YES top_important_message:0]; + + [dialog save]; + + + dialog.fake = YES; + [self add:@[dialog]]; + + } synchronous:YES]; + + return dialog; + +} + - (TL_conversation *)createDialogEncryptedChat:(TLEncryptedChat *)chat { __block TL_conversation *dialog; [ASQueue dispatchOnStageQueue:^{ - dialog = [TL_conversation createWithPeer:[TL_peerSecret createWithChat_id:chat.n_id] top_message:0 unread_count:0 last_message_date:0 notify_settings:nil last_marked_message:0 top_message_fake:0 last_marked_date:0 sync_message_id:0]; + dialog = [TL_conversation createWithPeer:[TL_peerSecret createWithChat_id:chat.n_id] top_message:0 unread_count:0 last_message_date:0 notify_settings:nil last_marked_message:0 top_message_fake:0 last_marked_date:0 sync_message_id:0 read_inbox_max_id:0 unread_important_count:0 lastMessage:nil]; dialog.fake = YES; @@ -148,7 +188,7 @@ - (TL_conversation *)createDialogForMessage:(TL_localMessage *)message { __block TL_conversation *dialog; [ASQueue dispatchOnStageQueue:^{ - dialog = [TL_conversation createWithPeer:[message peer] top_message:0 unread_count:0 last_message_date:message.date notify_settings:nil last_marked_message:message.n_id top_message_fake:0 last_marked_date:message.date sync_message_id:message.n_id]; + dialog = [TL_conversation createWithPeer:[message peer] top_message:0 unread_count:0 last_message_date:message.date notify_settings:nil last_marked_message:message.n_id top_message_fake:0 last_marked_date:message.date sync_message_id:message.n_id read_inbox_max_id:0 unread_important_count:0 lastMessage:message]; dialog.fake = YES; @@ -160,44 +200,81 @@ - (TL_conversation *)createDialogForMessage:(TL_localMessage *)message { } -- (void)deleteMessages:(NSNotification *)messages { +- (void)deleteMessagesWithMessageIds:(NSArray *)ids { - NSArray *deleted = [messages.userInfo objectForKey:KEY_MESSAGE_ID_LIST]; [self.queue dispatchOnQueue:^{ - [[Storage manager] deleteMessages:deleted completeHandler:nil]; + [[Storage manager] deleteMessages:ids completeHandler:^(NSArray *peer_update) { + + [peer_update enumerateObjectsUsingBlock:^(NSDictionary *obj, NSUInteger idx, BOOL *stop) { + + TL_conversation *conversation = [[DialogsManager sharedManager] find:[obj[KEY_PEER_ID] intValue]]; + + [self updateLastMessageForDialog:conversation]; + + }]; + + [Notification perform:MESSAGE_DELETE_EVENT data:@{KEY_DATA:peer_update}]; + + }]; - NSMutableDictionary *dialogstoUpdate = [[NSMutableDictionary alloc] init]; + }]; + +} + + +- (void)deleteMessagesWithRandomMessageIds:(NSArray *)ids isChannelMessages:(BOOL)isChannelMessages { + + + [self.queue dispatchOnQueue:^{ - for (NSNumber *msg_id in deleted) { - TL_localMessage *message = [[MessagesManager sharedManager] find:[msg_id intValue]]; - if(message.conversation) - [dialogstoUpdate setObject:message.conversation forKey:@(message.conversation.peer.peer_id)]; - } + [[Storage manager] deleteMessagesWithRandomIds:ids isChannelMessages:isChannelMessages completeHandler:^(NSArray *peer_update_data) { + + [peer_update_data enumerateObjectsUsingBlock:^(NSDictionary *obj, NSUInteger idx, BOOL *stop) { + + TL_conversation *conversation = [[DialogsManager sharedManager] find:[obj[KEY_PEER_ID] intValue]]; + + [self updateLastMessageForDialog:conversation]; + + }]; + + [Notification perform:MESSAGE_DELETE_EVENT data:@{KEY_DATA:peer_update_data}]; + + }]; - for(TL_conversation *dialog in dialogstoUpdate.allValues) { - [self updateLastMessageForDialog:dialog]; - } + }]; + +} + +-(void)deleteChannelMessags:(NSArray *)messageIds { + [[Storage manager] deleteChannelMessages:messageIds completeHandler:^(NSArray *peer_update,NSDictionary *readCount) { + [peer_update enumerateObjectsUsingBlock:^(NSDictionary *obj, NSUInteger idx, BOOL *stop) { + + TL_conversation *conversation = [[DialogsManager sharedManager] find:[obj[KEY_PEER_ID] intValue]]; + + conversation.unread_count-=[readCount[@(conversation.peer_id)] intValue]; + + [self updateLastMessageForDialog:conversation]; + + }]; + + [Notification perform:MESSAGE_DELETE_EVENT data:@{KEY_DATA:peer_update}]; }]; - + } -(void)updateLastMessageForDialog:(TL_conversation *)dialog { - [[Storage manager] lastMessageForPeer:dialog.peer completeHandler:^(TL_localMessage *lastMessage) { + [[Storage manager] lastMessageWithConversation:dialog completeHandler:^(TL_localMessage *lastMessage, int importantMessage) { [self.queue dispatchOnQueue:^{ if(lastMessage) { - if(![[MessagesManager sharedManager] find:lastMessage.n_id]) - [[MessagesManager sharedManager] TGsetMessage:lastMessage]; - - dialog.top_message = lastMessage.n_id; dialog.last_message_date = lastMessage ? lastMessage.date : dialog.last_message_date; dialog.last_marked_message = lastMessage.n_id; @@ -207,25 +284,41 @@ -(void)updateLastMessageForDialog:(TL_conversation *)dialog { } else { dialog.last_marked_message = dialog.top_message = dialog.last_marked_date = 0; + dialog.unread_count = 0; + dialog.unread_important_count = 0; } + dialog.top_important_message = importantMessage; + dialog.lastMessage = lastMessage; [dialog save]; - [Notification perform:[Notification notificationNameByDialog:dialog action:@"message"] data:@{KEY_DIALOG:dialog,KEY_LAST_CONVRESATION_DATA:[MessagesUtils conversationLastData:dialog]}]; - - NSUInteger position = [self positionForConversation:dialog]; - [Notification perform:DIALOG_MOVE_POSITION data:@{KEY_DIALOG:dialog, KEY_POSITION:@(position)}]; - - [MessagesManager updateUnreadBadge]; - + [self notifyAfterUpdateConversation:dialog]; }]; }]; + +} + +-(void)notifyAfterUpdateConversation:(TL_conversation *)conversation { + + [self.queue dispatchOnQueue:^{ + + if(conversation != nil) { + [Notification perform:[Notification notificationNameByDialog:conversation action:@"message"] data:@{KEY_DIALOG:conversation,KEY_LAST_CONVRESATION_DATA:[MessagesUtils conversationLastData:conversation]}]; + + NSUInteger position = [self positionForConversation:conversation]; + + [Notification perform:DIALOG_MOVE_POSITION data:@{KEY_DIALOG:conversation, KEY_POSITION:@(position)}]; + + [MessagesManager updateUnreadBadge]; + } + + }]; } @@ -314,6 +407,35 @@ -(NSUInteger)positionForConversation:(TL_conversation *)dialog { return [self->list indexOfObject:dialog]; } + +-(void)completeDeleteConversation:(dispatch_block_t)completeHandler dialog:(TL_conversation *)dialog { + + [[Storage manager] deleteDialog:dialog completeHandler:^{ + [self.queue dispatchOnQueue:^{ + + [Notification perform:DIALOG_DELETE data:@{KEY_DIALOG:dialog}]; + + [Notification perform:MESSAGE_FLUSH_HISTORY data:@{KEY_DIALOG:dialog}]; + + [self->list removeObject:dialog]; + [self->keys removeObjectForKey:@(dialog.peer_id)]; + + [MessagesManager updateUnreadBadge]; + + if(dialog.chat != nil) { + [[FullChatManager sharedManager] removeObjectWithKey:@(dialog.chat.n_id)]; + [[ChatsManager sharedManager] removeObjectWithKey:@(dialog.chat.n_id)]; + } + + + }]; + + if(completeHandler) + completeHandler(); + }]; + +} + - (void)deleteDialog:(TL_conversation *)dialog completeHandler:(dispatch_block_t)completeHandler { if(dialog == nil) { ELog(@"dialog is nil, check this"); @@ -323,27 +445,11 @@ - (void)deleteDialog:(TL_conversation *)dialog completeHandler:(dispatch_block_t dispatch_block_t newBlock = ^{ dispatch_block_t block = ^{ - [[Storage manager] deleteDialog:dialog completeHandler:^{ - [self.queue dispatchOnQueue:^{ - - [Notification perform:DIALOG_DELETE data:@{KEY_DIALOG:dialog}]; - - [self->list removeObject:dialog]; - [self->keys removeObjectForKey:@(dialog.peer.peer_id)]; - - [MessagesManager updateUnreadBadge]; - - - - }]; - - if(completeHandler) - completeHandler(); - }]; + [self completeDeleteConversation:completeHandler dialog:dialog]; }; - if(dialog.type != DialogTypeSecretChat && dialog.type != DialogTypeBroadcast) - [self _clearHistory:dialog offset:0 completeHandler:^{ + if(dialog.type != DialogTypeSecretChat && dialog.type != DialogTypeBroadcast && dialog.type != DialogTypeChannel) + [self _clearHistory:dialog completeHandler:^{ block(); }]; else { @@ -366,21 +472,35 @@ - (void)deleteDialog:(TL_conversation *)dialog completeHandler:(dispatch_block_t return; } - if(dialog.type == DialogTypeChat && !dialog.chat.left && dialog.chat.type == TLChatTypeNormal) { - [RPCRequest sendRequest:[TLAPI_messages_deleteChatUser createWithChat_id:dialog.peer.chat_id user_id:[[UsersManager currentUser] inputUser]] successHandler:^(RPCRequest *request, id response) { + if((dialog.type == DialogTypeChat || dialog.type == DialogTypeChannel) && !dialog.chat.left && dialog.chat.type == TLChatTypeNormal) { + + id request = [TLAPI_messages_deleteChatUser createWithChat_id:dialog.chat.n_id user_id:[[UsersManager currentUser] inputUser]]; + + if(dialog.type == DialogTypeChannel) { + request = [TLAPI_channels_leaveChannel createWithChannel:dialog.chat.inputPeer]; + if(dialog.chat.isCreator) { + request = [TLAPI_channels_deleteChannel createWithChannel:dialog.chat.inputPeer]; + } + + } + + + [RPCRequest sendRequest:request successHandler:^(RPCRequest *request, id response) { newBlock(); } errorHandler:^(RPCRequest *request, RpcError *error) { newBlock(); }]; return; } + + newBlock(); } -- (void)_clearHistory:(TL_conversation *)dialog offset:(int)offset completeHandler:(dispatch_block_t)block { - [RPCRequest sendRequest:[TLAPI_messages_deleteHistory createWithPeer:[dialog inputPeer] offset:offset] successHandler:^(RPCRequest *request, TL_messages_affectedHistory *response) { +- (void)_clearHistory:(TL_conversation *)dialog completeHandler:(dispatch_block_t)block { + [RPCRequest sendRequest:[TLAPI_messages_deleteHistory createWithPeer:[dialog inputPeer] max_id:INT32_MAX] successHandler:^(RPCRequest *request, TL_messages_affectedHistory *response) { if([response offset] != 0) - [self _clearHistory:dialog offset:[response offset] completeHandler:(dispatch_block_t)block]; + [self _clearHistory:dialog completeHandler:(dispatch_block_t)block]; else { if(block) block(); @@ -397,7 +517,7 @@ -(void)clearHistory:(TL_conversation *)dialog completeHandler:(dispatch_block_t) dispatch_block_t blockSuccess = ^{ dialog.top_message = 0; - + dialog.top_important_message = 0; dialog.unread_count = 0; @@ -415,7 +535,7 @@ -(void)clearHistory:(TL_conversation *)dialog completeHandler:(dispatch_block_t) }; if(dialog.type != DialogTypeSecretChat) { - [self _clearHistory:dialog offset:0 completeHandler:^{ + [self _clearHistory:dialog completeHandler:^{ blockSuccess(); }]; } else { @@ -442,7 +562,6 @@ - (void)setTopMessageToDialog:(NSNotification *)notify { [self.queue dispatchOnQueue:^{ if([message.media isKindOfClass:[TL_messageMediaPhoto class]] || [message.media isKindOfClass:[TL_messageMediaVideo class]]) { - [[Storage manager] insertMedia:message]; PreviewObject *previewObject = [[PreviewObject alloc] initWithMsdId:message.n_id media:message peer_id:message.peer_id]; @@ -451,101 +570,91 @@ - (void)setTopMessageToDialog:(NSNotification *)notify { [self updateTop:message needUpdate:YES update_real_date:update_real_date]; - [Notification perform:MESSAGE_RECEIVE_EVENT data:@{KEY_MESSAGE:message}]; + [Notification performOnStageQueue:MESSAGE_RECEIVE_EVENT data:@{KEY_MESSAGE:message}]; }]; } - (void)updateTop:(TL_localMessage *)message needUpdate:(BOOL)needUpdate update_real_date:(BOOL)update_real_date { [self.queue dispatchOnQueue:^{ - TL_conversation *dialog = message.conversation; - if(dialog.top_message != 0 && dialog.top_message != -1 && ((dialog.top_message > message.n_id && dialog.top_message < TGMINFAKEID))) - return; - - - if(message.unread && !message.n_out) { - dialog.unread_count++; - } - - dialog.top_message = message.n_id; - - dialog.lastMessage = message; - - if(message.n_out) { - dialog.last_marked_message = message.n_id; - dialog.last_marked_date = message.date + 1; - } - if(dialog.last_marked_message == 0) { - dialog.last_marked_message = dialog.top_message; - dialog.last_marked_date = dialog.last_message_date; - } - - - if((message.n_out|| !message.unread) && dialog.last_marked_message < message.n_id) { - dialog.last_marked_message = message.n_id; - dialog.last_marked_date = message.date; - } - - int last_real_date = dialog.last_real_message_date; - - dialog.last_message_date = message.date; - - if(update_real_date) { - dialog.last_real_message_date = last_real_date; - } - - [dialog save]; - - [MessagesManager updateUnreadBadge]; - - [self add:@[dialog]]; - [self checkBotKeyboard:dialog forMessage:message notify:YES]; + NSArray *unloaded = [self unloadedConversationsWithMessages:@[message]]; - - - if(needUpdate) { + [[Storage manager] conversationsWithPeerIds:unloaded completeHandler:^(NSArray *result) { - NSUInteger position = [self positionForConversation:dialog]; + [self add:result]; - + TL_conversation *dialog = message.conversation; + + [self updateConversation:dialog withLastMessage:message update_real_date:update_real_date]; + + [dialog save]; + + [MessagesManager updateUnreadBadge]; + + [self add:@[dialog]]; + + + [self checkBotKeyboard:dialog forMessage:message notify:YES]; + + if(needUpdate) { + + NSUInteger position = [self positionForConversation:dialog]; + + if(dialog != nil) { + [Notification perform:DIALOG_MOVE_POSITION data:@{KEY_DIALOG:dialog, KEY_POSITION:@(position)}]; + [Notification perform:[Notification notificationNameByDialog:dialog action:@"message"] data:@{KEY_DIALOG:dialog,KEY_LAST_CONVRESATION_DATA:[MessagesUtils conversationLastData:dialog]}]; + } + + } - [Notification perform:DIALOG_MOVE_POSITION data:@{KEY_DIALOG:dialog, KEY_POSITION:@(position)}]; - [Notification perform:[Notification notificationNameByDialog:dialog action:@"message"] data:@{KEY_DIALOG:dialog,KEY_LAST_CONVRESATION_DATA:[MessagesUtils conversationLastData:dialog]}]; } + }]; }]; } - (void)markAllMessagesAsRead:(TL_conversation *)dialog { - [(MessagesManager *)[MessagesManager sharedManager] markAllInDialog:dialog callback:^(NSArray *ids) { - - if(ids.count > 0) { - - - [self.queue dispatchOnQueue:^{ - [Notification perform:MESSAGE_READ_EVENT data:@{KEY_MESSAGE_ID_LIST:ids}]; - [Notification perform:[Notification notificationNameByDialog:dialog action:@"unread_count"] data:@{KEY_DIALOG:dialog,KEY_LAST_CONVRESATION_DATA:[MessagesUtils conversationLastData:dialog]}]; - }]; - - - } - - - - }]; + [[Storage manager] markAllInConversation:dialog.peer_id max_id:dialog.top_message out:NO completeHandler:^(NSArray *ids) { + + }]; } -- (void) markAllMessagesAsRead:(TLPeer *)peer max_id:(int)max_id { +- (void) markAllMessagesAsRead:(TLPeer *)peer max_id:(int)max_id out:(BOOL)n_out { - TL_conversation *conversation = [[DialogsManager sharedManager] find:peer.peer_id]; + [[Storage manager] markAllInConversation:peer.peer_id max_id:max_id out:n_out completeHandler:^(NSArray *ids) { + [self.queue dispatchOnQueue:^{ + + TL_conversation *conversation = [self find:peer.peer_id]; + if(conversation != nil) { + [Notification performOnStageQueue:MESSAGE_READ_EVENT data:@{KEY_MESSAGE_ID_LIST:ids}]; + [Notification perform:[Notification notificationNameByDialog:conversation action:@"unread_count"] data:@{KEY_DIALOG:conversation,KEY_LAST_CONVRESATION_DATA:[MessagesUtils conversationLastData:conversation]}]; + + } + }]; + }]; - [(MessagesManager *)[MessagesManager sharedManager] markAllInConversation:conversation max_id:max_id callback:^(NSArray *ids) { - if(ids.count > 0) { - [Notification perform:MESSAGE_READ_EVENT data:@{KEY_MESSAGE_ID_LIST:ids}]; - } +} + +-(void)markChannelMessagesAsRead:(int)channel_id max_id:(int)max_id { + + [self.queue dispatchOnQueue:^{ + [[Storage manager] markChannelMessagesAsRead:channel_id max_id:max_id callback:^(int unread_count) { + + TL_conversation *conversation = [self find:-channel_id]; + + if(conversation) { + + conversation.unread_count = unread_count; + conversation.last_marked_message = max_id; + [conversation save]; + [Notification perform:[Notification notificationNameByDialog:conversation action:@"unread_count"] data:@{KEY_DIALOG:conversation,KEY_LAST_CONVRESATION_DATA:[MessagesUtils conversationLastData:conversation]}]; + } + + }]; + }]; } @@ -555,82 +664,145 @@ - (void)insertDialog:(TL_conversation *)dialog { [dialog save]; } -- (void)setTopMessagesToDialogs:(NSNotification *)notify { - NSArray *messages = [notify.userInfo objectForKey:KEY_MESSAGE_LIST]; - BOOL update_real_date = [[notify.userInfo objectForKey:@"update_real_date"] boolValue]; - NSMutableDictionary *last = [[NSMutableDictionary alloc] init]; +-(void)updateTopMessagesWithMessages:(NSArray *)messages { + [self.queue dispatchOnQueue:^{ - for (TL_localMessage *message in messages) { - TL_conversation *dialog = message.conversation; + + NSMutableDictionary *topMessages = [NSMutableDictionary dictionary]; + NSMutableDictionary *topImportantMessages = [NSMutableDictionary dictionary]; + + [messages enumerateObjectsUsingBlock:^(TL_localMessage *obj, NSUInteger idx, BOOL *stop) { - if(dialog && (dialog.top_message > TGMINFAKEID || dialog.top_message < message.n_id)) { - dialog.top_message = message.n_id; - - int last_real_date = dialog.last_real_message_date; + if(obj.isChannelMessage && (obj.isImportantMessage || obj.chat.isMegagroup)) { - dialog.last_message_date = message.date; + TL_localMessage *top_message = topImportantMessages[@(obj.peer_id)]; - if(update_real_date) { - dialog.last_real_message_date = last_real_date; + if(top_message.n_id < obj.peer_id) { + topImportantMessages[@(obj.peer_id)] = obj; } - if(dialog.last_marked_message == 0) { - dialog.last_marked_message = dialog.top_message; - dialog.last_marked_date = dialog.last_message_date; - } - - if((message.n_out|| !message.unread) && dialog.last_marked_message < message.n_id) { - dialog.last_marked_message = message.n_id; - dialog.last_marked_date = message.date; - } + } else { + TL_localMessage *top_message = topMessages[@(obj.peer_id)]; - if(!message.n_out && message.unread) { - dialog.unread_count++; + if(top_message.n_id < obj.peer_id) { + topMessages[@(obj.peer_id)] = obj; } - - dialog.lastMessage = message; - - - [dialog save]; - - } else { - [self updateTop:message needUpdate:NO update_real_date:NO]; - dialog = message.conversation; } - if(dialog) { - [last setObject:dialog forKey:@(dialog.peer.peer_id)]; - } + }]; + + [[Storage manager] updateTopMessagesWithMessages:topMessages topImportantMessages:topImportantMessages]; + + }]; +} + +-(BOOL)updateConversation:(TL_conversation *)dialog withLastMessage:(TL_localMessage *)message update_real_date:(BOOL)update_real_date { + + + int topMessageId = (dialog.type == DialogTypeChannel ? dialog.top_important_message : dialog.top_message); + + if(topMessageId != 0 && topMessageId != -1 && ((topMessageId > message.n_id && topMessageId < TGMINFAKEID))) + return NO; + + if(message.n_id > TGMINFAKEID && dialog.last_message_date > message.date) + return NO; + + if(message.unread && !message.n_out) { + dialog.unread_count++; + } + + if([message.action isKindOfClass:[TL_messageActionChatMigrateTo class]]) { + dialog.unread_count = 0; + } + + dialog.top_message = message.n_id; + + dialog.top_important_message = message.n_id; + + dialog.lastMessage = message; + + if(message.n_out) { + dialog.last_marked_message = message.n_id; + dialog.last_marked_date = message.date + 1; + } + if(dialog.last_marked_message == 0) { + dialog.last_marked_message = dialog.top_message; + dialog.last_marked_date = dialog.last_message_date; + } + + + if((message.n_out|| !message.unread) && dialog.last_marked_message < message.n_id) { + dialog.last_marked_message = message.n_id; + dialog.last_marked_date = message.date; + } + + int last_real_date = dialog.last_real_message_date; + + dialog.last_message_date = message.date; + + if(update_real_date) { + dialog.last_real_message_date = last_real_date; + } + + return YES; + +} + +- (void)setTopMessagesToDialogs:(NSNotification *)notify { + NSArray *messages = [notify.userInfo objectForKey:KEY_MESSAGE_LIST]; + BOOL update_real_date = [[notify.userInfo objectForKey:@"update_real_date"] boolValue]; + NSMutableDictionary *last = [[NSMutableDictionary alloc] init]; + + [self.queue dispatchOnQueue:^{ + + NSArray *unloaded = [self unloadedConversationsWithMessages:messages]; + + [[Storage manager] conversationsWithPeerIds:unloaded completeHandler:^(NSArray *conversations) { + + [self add:conversations]; - [last enumerateKeysAndObjectsUsingBlock:^(id key, TL_conversation *obj, BOOL *stop) { + [messages enumerateObjectsUsingBlock:^(TL_localMessage *message, NSUInteger idx, BOOL * _Nonnull stop) { + + TL_conversation *dialog = message.conversation; - BOOL needNotify = [self checkBotKeyboard:obj forMessage:obj.lastMessage notify:NO]; + BOOL res = [self updateConversation:dialog withLastMessage:message update_real_date:update_real_date]; - if(needNotify) { - [Notification perform:[Notification notificationNameByDialog:obj action:@"botKeyboard"] data:@{KEY_DIALOG:obj}]; + if(dialog && res) { + [last setObject:dialog forKey:@(dialog.peer_id)]; } + [last enumerateKeysAndObjectsUsingBlock:^(id key, TL_conversation *obj, BOOL *stop) { + + BOOL needNotify = [self checkBotKeyboard:obj forMessage:obj.lastMessage notify:NO]; + + if(needNotify) { + [Notification perform:[Notification notificationNameByDialog:obj action:@"botKeyboard"] data:@{KEY_DIALOG:obj}]; + } + + [dialog save]; + + }]; + + if([message.media isKindOfClass:[TL_messageMediaPhoto class]]) { + + PreviewObject *previewObject = [[PreviewObject alloc] initWithMsdId:message.n_id media:message peer_id:message.peer_id]; + + [Notification perform:MEDIA_RECEIVE data:@{KEY_PREVIEW_OBJECT:previewObject}]; + } + }]; - if([message.media isKindOfClass:[TL_messageMediaPhoto class]]) { - [[Storage manager] insertMedia:message]; - - PreviewObject *previewObject = [[PreviewObject alloc] initWithMsdId:message.n_id media:message peer_id:message.peer_id]; - - [Notification perform:MEDIA_RECEIVE data:@{KEY_PREVIEW_OBJECT:previewObject}]; - } + [self add:last.allValues]; - } - - - [self add:last.allValues]; + [MessagesManager updateUnreadBadge]; + + [Notification perform:DIALOGS_NEED_FULL_RESORT data:@{KEY_DIALOGS:self->list}]; + [Notification perform:MESSAGE_LIST_RECEIVE object:messages]; + + }]; - [MessagesManager updateUnreadBadge]; - - [Notification perform:DIALOGS_NEED_FULL_RESORT data:@{KEY_DIALOGS:self->list}]; - [Notification perform:MESSAGE_LIST_RECEIVE object:messages]; }]; } @@ -657,31 +829,27 @@ - (void)add:(NSArray *)all { [self.queue dispatchOnQueue:^{ [all enumerateObjectsUsingBlock:^(TL_conversation * dialog, NSUInteger idx, BOOL *stop) { - TL_conversation *current = [keys objectForKey:@(dialog.peer.peer_id)]; + TL_conversation *current = [keys objectForKey:@(dialog.peer_id)]; if(current) { - if(current.unread_count != dialog.unread_count) - current.unread_count = dialog.unread_count; - if(current.top_message != dialog.top_message) - current.top_message = dialog.top_message; - if(current.last_message_date != dialog.last_message_date) - current.last_message_date = dialog.last_message_date; - if(current.notify_settings != dialog.notify_settings) - current.notify_settings = dialog.notify_settings; - if(current.fake != dialog.fake) - current.fake = dialog.fake; - if(current.last_marked_message != dialog.last_marked_message) - current.last_marked_message = dialog.last_marked_message; - if(current.top_message_fake != dialog.top_message_fake) - current.top_message_fake = dialog.top_message_fake; - if(current.last_marked_date != dialog.last_marked_date) - current.last_marked_date = dialog.last_marked_date; - if(current.last_real_message_date != dialog.last_real_message_date) - current.last_real_message_date = dialog.last_real_message_date; - if(current.dstate != dialog.dstate) - current.dstate = dialog.dstate; + current.unread_count = dialog.unread_count; + current.top_message = dialog.top_message; + current.last_message_date = dialog.last_message_date; + current.notify_settings = dialog.notify_settings; + current.fake = dialog.fake; + current.last_marked_message = dialog.last_marked_message; + current.top_message_fake = dialog.top_message_fake; + current.last_marked_date = dialog.last_marked_date; + current.last_real_message_date = dialog.last_real_message_date; + current.dstate = dialog.dstate; + current.read_inbox_max_id = dialog.read_inbox_max_id; + current.top_important_message = dialog.top_important_message; + current.unread_important_count = dialog.unread_important_count; + current.pts = dialog.pts; + current.invisibleChannel = dialog.invisibleChannel; + current.lastMessage = dialog.lastMessage; } else { [self->list addObject:dialog]; - [self->keys setObject:dialog forKey:@(dialog.peer.peer_id)]; + [self->keys setObject:dialog forKey:@(dialog.peer_id)]; current = dialog; } diff --git a/TelegramTest/DocumentHistoryFilter.h b/TelegramTest/DocumentHistoryFilter.h index 681657e2..966d4cce 100644 --- a/TelegramTest/DocumentHistoryFilter.h +++ b/TelegramTest/DocumentHistoryFilter.h @@ -7,7 +7,7 @@ // #import "HistoryFilter.h" - -@interface DocumentHistoryFilter : HistoryFilter +#import "CommonMediaHistoryFilter.h" +@interface DocumentHistoryFilter : CommonMediaHistoryFilter @end diff --git a/TelegramTest/DocumentHistoryFilter.m b/TelegramTest/DocumentHistoryFilter.m index 0b76a4c1..779e180b 100644 --- a/TelegramTest/DocumentHistoryFilter.m +++ b/TelegramTest/DocumentHistoryFilter.m @@ -10,20 +10,6 @@ #import "ChatHistoryController.h" @implementation DocumentHistoryFilter -static NSMutableDictionary * messageItems; -static NSMutableDictionary * messageKeys; - --(id)initWithController:(ChatHistoryController *)controller { - if(self = [super initWithController:controller]) { - - } - - - - return self; -} - - -(int)type { return HistoryFilterDocuments; } @@ -32,87 +18,8 @@ +(int)type { return HistoryFilterDocuments; } -- (NSMutableDictionary *)messageKeys:(int)peer_id { - return [[self class] messageKeys:peer_id]; -} - -- (NSMutableArray *)messageItems:(int)peer_id { - return [[self class] messageItems:peer_id]; -} - -+ (NSMutableDictionary *)messageKeys:(int)peer_id { - - __block NSMutableDictionary *keys; - [ASQueue dispatchOnStageQueue:^{ - - keys = messageKeys[@(peer_id)]; - - if(!keys) - { - keys = [[NSMutableDictionary alloc] init]; - messageKeys[@(peer_id)] = keys; - } - - } synchronous:YES]; - - return keys; -} - -+ (NSMutableArray *)messageItems:(int)peer_id { - __block NSMutableArray *items; - - [ASQueue dispatchOnStageQueue:^{ - - items = messageItems[@(peer_id)]; - - if(!items) - { - items = [[NSMutableArray alloc] init]; - messageItems[@(peer_id)] = items; - } - - } synchronous:YES]; - - - - return items; -} - - -+(void)drop { - [ASQueue dispatchOnStageQueue:^{ - [messageKeys removeAllObjects]; - [messageItems removeAllObjects]; - }]; -} - - -+(void)initialize { - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - messageItems = [[NSMutableDictionary alloc] init]; - messageKeys = [[NSMutableDictionary alloc] init]; - - }); -} - --(void)remoteRequest:(BOOL)next peer_id:(int)peer_id callback:(void (^)(id response))callback { - - self.request = [RPCRequest sendRequest:[TLAPI_messages_search createWithPeer:[self.controller.conversation inputPeer] q:@"" filter:[TL_inputMessagesFilterDocument create] min_date:0 max_date:0 offset:0 max_id:self.controller.max_id limit:(int)self.controller.selectLimit] successHandler:^(RPCRequest *request, id response) { - - - if(callback && self != nil) { - callback(response); - } - - } errorHandler:^(RPCRequest *request, RpcError *error) { - - if(callback && self != nil) { - callback(nil); - } - - } timeout:10 queue:[ASQueue globalQueue].nativeQueue]; - +-(TLMessagesFilter *)messagesFilter { + return [TL_inputMessagesFilterDocument create]; } -(NSString *)description { diff --git a/TelegramTest/DocumentSenderItem.m b/TelegramTest/DocumentSenderItem.m index 0bc5e4e3..197b8fcb 100644 --- a/TelegramTest/DocumentSenderItem.m +++ b/TelegramTest/DocumentSenderItem.m @@ -35,7 +35,7 @@ -(void)setState:(MessageState)state { [super setState:state]; } -- (id)initWithPath:(NSString *)path forConversation:(TL_conversation *)conversation { +- (id)initWithPath:(NSString *)path forConversation:(TL_conversation *)conversation additionFlags:(int)additionFlags { if(self = [super init]) { self.mimeType = mimetypefromExtension([path pathExtension]); @@ -191,7 +191,9 @@ - (id)initWithPath:(NSString *)path forConversation:(TL_conversation *)conversat TL_messageMediaDocument *document = [TL_messageMediaDocument createWithDocument:[TL_outDocument createWithN_id:randomId access_hash:0 date:[[MTNetwork instance] getTime] mime_type:self.mimeType size:(int)fileSize(self.filePath) thumb:size dc_id:0 file_path:self.filePath attributes:attrs]]; self.message = [MessageSender createOutMessage:@"" media:document conversation:conversation]; - + + if(additionFlags & (1 << 4)) + self.message.from_id = 0; } return self; @@ -285,21 +287,24 @@ - (void)sendMessage { if(self.conversation.type == DialogTypeBroadcast) { request = [TLAPI_messages_sendBroadcast createWithContacts:[self.conversation.broadcast inputContacts] random_id:[self.conversation.broadcast generateRandomIds] message:@"" media:media]; } else { - request = [TLAPI_messages_sendMedia createWithFlags:self.message.reply_to_msg_id != 0 ? 1 : 0 peer:self.conversation.inputPeer reply_to_msg_id:self.message.reply_to_msg_id media:media random_id:self.message.randomId reply_markup:[TL_replyKeyboardMarkup createWithFlags:0 rows:[@[]mutableCopy]]]; + request = [TLAPI_messages_sendMedia createWithFlags:[self senderFlags] peer:self.conversation.inputPeer reply_to_msg_id:self.message.reply_to_msg_id media:media random_id:self.message.randomId reply_markup:[TL_replyKeyboardMarkup createWithFlags:0 rows:[@[]mutableCopy]]]; } weakify(); self.rpc_request = [RPCRequest sendRequest:request successHandler:^(RPCRequest *request, TLUpdates *response) { - if(response.updates.count < 2) + + [strongSelf updateMessageId:response]; + + TL_localMessage *msg = [TL_localMessage convertReceivedMessage:[[strongSelf updateNewMessageWithUpdates:response] message]]; + + if(msg == nil) { [strongSelf cancel]; return; } - TLMessage *msg = [TL_localMessage convertReceivedMessage:(TLMessage *) ( [response.updates[1] message])]; - if(strongSelf.conversation.type != DialogTypeBroadcast) { strongSelf.message.n_id = msg.n_id; @@ -333,13 +338,10 @@ - (void)sendMessage { message.media.document.size = [msg media].document.size; message.media.document.access_hash = [msg media].document.access_hash; message.media.document.n_id = [msg media].document.n_id; - + message.media.document.attributes = msg.media.document.attributes; - - - if(![message.media.document.thumb isKindOfClass:[TL_photoSizeEmpty class]]) { [message.media.document.thumb.bytes writeToFile:locationFilePath(message.media.document.thumb.location, @"tiff") atomically:NO]; diff --git a/TelegramTest/DownloadCacheDocumentItem.h b/TelegramTest/DownloadCacheDocumentItem.h new file mode 100644 index 00000000..cb295aa2 --- /dev/null +++ b/TelegramTest/DownloadCacheDocumentItem.h @@ -0,0 +1,13 @@ +// +// DownloadCacheDocumentItem.h +// Telegram +// +// Created by keepcoder on 20.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TGDownloadItem.h" + +@interface DownloadCacheDocumentItem : TGDownloadItem + +@end diff --git a/TelegramTest/DownloadCacheDocumentItem.m b/TelegramTest/DownloadCacheDocumentItem.m new file mode 100644 index 00000000..18c9503b --- /dev/null +++ b/TelegramTest/DownloadCacheDocumentItem.m @@ -0,0 +1,32 @@ +// +// DownloadCacheDocumentItem.m +// Telegram +// +// Created by keepcoder on 20.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "DownloadCacheDocumentItem.h" + +@implementation DownloadCacheDocumentItem + + +-(id)initWithObject:(TLDocument *)document { + if(self = [super initWithObject:document]) { + self.n_id = document.n_id; + self.path = document.path_with_cache; + self.fileType = DownloadFileDocument; + self.dc_id = document.dc_id; + self.size = document.size; + } + + return self; +} + +-(TLInputFileLocation *)input { + TLDocument *document = self.object; + + return [TL_inputDocumentFileLocation createWithN_id:document.n_id access_hash:document.access_hash]; +} + +@end diff --git a/TelegramTest/DownloadDocumentItem.m b/TelegramTest/DownloadDocumentItem.m index a4c3af70..1e887839 100644 --- a/TelegramTest/DownloadDocumentItem.m +++ b/TelegramTest/DownloadDocumentItem.m @@ -59,7 +59,7 @@ -(void)setDownloadState:(DownloadState)downloadState { ((TLMessageMedia *)[(TL_localMessage *)self.object media]).document = document; - [[Storage manager] updateMessages:@[self.object]]; + [(TL_localMessage *)self.object save:NO]; } [super setDownloadState:downloadState]; diff --git a/TelegramTest/DownloadItem.h b/TelegramTest/DownloadItem.h index dc2ad448..776cfc42 100644 --- a/TelegramTest/DownloadItem.h +++ b/TelegramTest/DownloadItem.h @@ -24,7 +24,7 @@ typedef void (^DownloadItemHandler)(DownloadItem *item); @interface DownloadEventListener : NSObject @property (atomic,copy) DownloadItemHandler progressHandler; -@property (atomic,strong) DownloadItemHandler completeHandler; +@property (atomic,copy) DownloadItemHandler completeHandler; @property (atomic,copy) DownloadItemHandler errorHandler; @@ -106,6 +106,7 @@ typedef enum { -(void)resetItem; -(TLInputFileLocation *)input; + -(int)partSize; -(id)initWithObject:(id)object size:(int)size; diff --git a/TelegramTest/DownloadItem.m b/TelegramTest/DownloadItem.m index 1cd36d7a..eb7c47ef 100644 --- a/TelegramTest/DownloadItem.m +++ b/TelegramTest/DownloadItem.m @@ -44,10 +44,28 @@ -(id)initWithObject:(id)object { _uniqueKey = ++futureUniqueKey; _downloadState = DownloadStateWaitingStart; self.events = [[NSMutableArray alloc] init]; + } return self; } +-(void)setN_id:(long)n_id { + _n_id = n_id; + + [self findAndFillAfterInit]; +} + +-(void)findAndFillAfterInit { + +// DownloadItem *item = [DownloadQueue find:self.n_id]; +// +// if(item) { +// _downloadState = item.downloadState; +// _progress = item.progress; +// [self start]; +// } +} + -(id)initWithObject:(id)object size:(int)size { if(self = [super init]) { self.object = object; diff --git a/TelegramTest/DownloadPhotoItem.m b/TelegramTest/DownloadPhotoItem.m index e1a2625a..c3a792dc 100644 --- a/TelegramTest/DownloadPhotoItem.m +++ b/TelegramTest/DownloadPhotoItem.m @@ -18,7 +18,6 @@ -(id)initWithObject:(TL_fileLocation *)object size:(int)size { if (!object) return nil; - self.isEncrypted = object.local_id == -1; self.path = [object path]; self.fileType = DownloadFileImage; @@ -26,6 +25,7 @@ -(id)initWithObject:(TL_fileLocation *)object size:(int)size { self.dc_id = object.dc_id; self.n_id = self.isEncrypted ? object.volume_id : object.secret; + } return self; } diff --git a/TelegramTest/DownloadQueue.mm b/TelegramTest/DownloadQueue.mm index 31fa1ce4..888acfd6 100644 --- a/TelegramTest/DownloadQueue.mm +++ b/TelegramTest/DownloadQueue.mm @@ -103,7 +103,7 @@ -(DownloadItem *)find:(long)key { std::map< long, DownloadItem * >::iterator it = _loading->find(key); if(it != _loading->end()) item = it->second; - }]; + } synchronous:YES]; return item; @@ -190,6 +190,9 @@ +(void)addAndStartItem:(DownloadItem *)item { if(!item) { [operation start:manager selector:@selector(operationComplete:)]; manager.loading->insert(std::pair< long, DownloadItem * >(operation.item.n_id,operation.item)); + } else { + operation.item.downloadState = item.downloadState; + operation.item.progress = item.progress; } }]; diff --git a/TelegramTest/DownloadVideoItem.m b/TelegramTest/DownloadVideoItem.m index 352c048b..c95b5d55 100644 --- a/TelegramTest/DownloadVideoItem.m +++ b/TelegramTest/DownloadVideoItem.m @@ -37,7 +37,7 @@ -(void)setDownloadState:(DownloadState)downloadState { TL_localMessage *msg = (TL_localMessage *)self.object; - NSSize size = NSMakeSize(250, msg.media.video.thumb.h + (250 - msg.media.video.thumb.w)); + NSSize size = NSMakeSize(msg.media.video.thumb.w * 3, msg.media.video.thumb.h * 3); __block NSImage *thumbImg; @@ -71,7 +71,7 @@ -(void)setDownloadState:(DownloadState)downloadState { msg.media.video.thumb = [TL_photoCachedSize createWithType:@"x" location:location w:size.width h:size.height bytes:jpegNormalizedData(thumbImg)]; - [[Storage manager] updateMessages:@[msg]]; + [msg save:NO]; } diff --git a/TelegramTest/DraggingItemView.m b/TelegramTest/DraggingItemView.m index 5d230d01..8ed40959 100644 --- a/TelegramTest/DraggingItemView.m +++ b/TelegramTest/DraggingItemView.m @@ -141,7 +141,7 @@ -(void)updateField { if(_title) { range = [str appendString:_title withColor:NSColorFromRGB(0xA1A1A1)]; - [str addAttributes:@{NSFontAttributeName:[NSFont fontWithName:@"HelveticaNeue" size:13]} range:range]; + [str addAttributes:@{NSFontAttributeName:TGSystemFont(13)} range:range]; [str setAlignment:NSCenterTextAlignment range:range]; } @@ -149,7 +149,7 @@ -(void)updateField { if(_subtitle) { range = [str appendString:[@"\n" stringByAppendingString:_subtitle] withColor:NSColorFromRGB(0x333333)]; - [str addAttributes:@{NSFontAttributeName:[NSFont fontWithName:@"HelveticaNeue" size:22]} range:range]; + [str addAttributes:@{NSFontAttributeName:TGSystemFont(22)} range:range]; [str setAlignment:NSCenterTextAlignment range:range]; } diff --git a/TelegramTest/EmojiViewController.h b/TelegramTest/EmojiViewController.h index e90e0fd3..fd8e6040 100644 --- a/TelegramTest/EmojiViewController.h +++ b/TelegramTest/EmojiViewController.h @@ -20,11 +20,15 @@ + (EmojiViewController *)instance; +@property (nonatomic,weak) MessagesViewController *messagesViewController; + +(void)reloadStickers; +(void)loadStickersIfNeeded; +(NSArray *)allStickers; +(NSArray *)allSets; ++(TL_stickerSet *)setWithId:(long)n_id; ++(NSArray *)stickersWithId:(long)n_id; -(void)saveModifier:(NSString *)modifier forEmoji:(NSString *)emoji; -(NSString *)emojiModifier:(NSString *)emoji; diff --git a/TelegramTest/EmojiViewController.m b/TelegramTest/EmojiViewController.m index b3401e8d..2e924104 100644 --- a/TelegramTest/EmojiViewController.m +++ b/TelegramTest/EmojiViewController.m @@ -52,8 +52,8 @@ - (id)initWithFrame:(NSRect)frameRect { for(int i = 0; i < EMOJI_COUNT_PER_ROW; i++) { EmojiButton *button = [[EmojiButton alloc] initWithFrame:NSMakeRect(34 * i, 0, 34, 34)]; - [button setTitleFont:[NSFont fontWithName:@"HelveticaNeue" size:17] forControlState:BTRControlStateNormal]; - [button addTarget:self action:@selector(emojiClick:) forControlEvents:BTRControlEventLeftClick]; + [button setTitleFont:TGSystemFont(17) forControlState:BTRControlStateNormal]; + [button addTarget:self action:@selector(emojiClick:) forControlEvents:BTRControlEventMouseDownInside]; if(floor(NSAppKitVersionNumber) >= 1347 ) { [button addTarget:self action:@selector(emojiLongClick:) forControlEvents:BTRControlEventLongLeftClick]; @@ -178,6 +178,7 @@ + (EmojiViewController *)instance { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ controller = [[EmojiViewController alloc] initWithFrame:NSMakeRect(0, 0, 350, 300)]; + [controller loadViewIfNeeded]; }); return controller; } @@ -201,21 +202,47 @@ - (id)initWithFrame:(NSRect)frame { NSString *emoji2; - if(floor(NSAppKitVersionNumber) >= 1347 ) { + if(NSAppKitVersionNumber >= 1404) { + emoji2 = @"😀 😬 😁 😂 😃 😄 😅 😆 😇 😉 😊 🙂 🙃 ☺️ 😋 😌 😍 😘 😗 😙 😚 😜 😝 😛 🤑 🤓 😎 🤗 😏 😶 😐 😑 😒 🙄 🤔 😳 😞 😟 😠 😡 😔 😕 🙁 ☹️ 😣 😖 😫 😩 😤 😮 😱 😨 😰 😯 😦 😧 😢 😥 😪 😓 😭 😵 😲 🤐 😷 🤒 🤕 😴 💤 💩 😈 👿 👹 👺 💀 👻 👽 🤖 😺 😸 😹 😻 😼 😽 🙀 😿 😾 🙌 👏 👋 👍 👎 👊 ✊ ✌️ 👌 ✋ 👐 💪 🙏 ☝️ 👆 👇 👈 🖕 🖐 🤘 🖖✍🏻 💅 👄 👅 👂 👃 👁 👀 👤 👥 🗣 👶 👦 👧 👨 👩 👱 👴 👵 👲 👳 👮 👷 💂 🕵 🎅 👼 👸 👰 🚶 🏃 💃 👯 👫 👬 👭 🙇 💁 🙅 🙆 🙋 🙎 🙍 💇 💆 💑 👩‍❤️‍👩 👨‍❤️‍👨 💏 👩‍❤️‍💋‍👩 👨‍❤️‍💋‍👨 👪 👨‍👩‍👧 👨‍👩‍👧‍👦 👨‍👩‍👦‍👦 👨‍👩‍👧‍👧 👩‍👩‍👦 👩‍👩‍👧 👩‍👩‍👧‍👦 👩‍👩‍👦‍👦 👩‍👩‍👧‍👧 👨‍👨‍👦 👨‍👨‍👧 👨‍👨‍👧‍👦 👨‍👨‍👦‍👦 👨‍👨‍👧‍👧 👚 👕 👖 👔 👗 👙 👘 💄 💋 👣 👠 👡 👢 👞 👟 👒 🎩 🎓 👑 ⛑ 🎒 👝 👛 👜 💼 👓 🕶 💍 🌂 ❤️ 💛 💚 💙 💜 💔 ❣ 💕 💞 💓 💗 💖 💘 💝"; + } else if(floor(NSAppKitVersionNumber) >= 1347 ) { emoji2 = @"😄 😃 😀 😊 ☺️ 😉 😍 😘 😚 😗 😙 😜 😝 😛 😳 😁 😔 😌 😒 😞 😣 😢 😂 😭 😪 😥 😰 😅 😓 😩 😫 😨 😱 😠 😡 😤 😖 😆 😋 😷 😎 😴 😵 😲 😟 😦 😧 😈 👿 😮 😬 😐 😕 😯 😶 😇 😏 😑 👲 👳 👮 👷 💂 👶 👦 👧 👨 👩 👴 👵 👱 👼 👸 😺 😸 😻 😽 😼 🙀 😿 😹 😾 👹 👺 🙈 🙉 🙊 💀 👽 💩 🔥 ✨ 🌟 💫 💥 💢 💦 💧 💤 💨 👂 👀 👃 👅 👄 👍 👎 👌 👊 ✊ ✌️ 👋 ✋ 👐 👆 👇 👉 👈 🙌 🙏 ☝️ 👏 💪 🚶 🏃 💃 👫 👬 👭 💏 💑 👪 👨‍👩‍👧 👨‍👩‍👧‍👦 👨‍👩‍👦‍👦 👨‍👩‍👧‍👧 👩‍👩‍👦 👩‍👩‍👧 👩‍👩‍👧‍👦 👩‍👩‍👦‍👦 👩‍👩‍👧‍👧 👨‍👨‍👦 👨‍👨‍👧 👨‍👨‍👧‍👦 👨‍👨‍👦‍👦 👨‍👨‍👧‍👧 👯 🙆 🙅 💁 🙋 💆 💇 💅 👰 🙎 🙍 🙇 🎩 👑 👒 👟 👞 👡 👠 👢 👕 👔 👚 👗 🎽 👖 👘 👙 💼 👜 👝 👛 👓 🎀 🌂 💄 💛 💙 💜 💚 ❤️ 💔 💗 💓 💕 💖 💞 💘 💌 💋 💍 💎 👤 👥 💬 👣 💭"; } else { emoji2 = @"😄 😃 😀 😊 ☺️ 😉 😍 😘 😚 😗 😙 😜 😝 😛 😳 😁 😔 😌 😒 😞 😣 😢 😂 😭 😪 😥 😰 😅 😓 😩 😫 😨 😱 😠 😡 😤 😖 😆 😋 😷 😎 😴 😵 😲 😟 😦 😧 😈 👿 😮 😬 😐 😕 😯 😶 😇 😏 😑 👲 👳 👮 👷 💂 👶 👦 👧 👨 👩 👴 👵 👱 👼 👸 😺 😸 😻 😽 😼 🙀 😿 😹 😾 👹 👺 🙈 🙉 🙊 💀 👽 💩 🔥 ✨ 🌟 💫 💥 💢 💦 💧 💤 💨 👂 👀 👃 👅 👄 👍 👎 👌 👊 ✊ ✌️ 👋 ✋ 👐 👆 ☝️ 👇 👉 👈 🙌 🙏 👏 💪 🚶 🏃 💃 👫 👪 👬 👭 💏 💑 👯 🙆 🙅 💁 🙋 💆 💇 💅 👰 🙎 🙍 🙇 🎩 👑 👒 👟 👞 👡 👠 👢 👕 👔 👚 👗 🎽 👖 👘 👙 💼 👜 👝 👛 👓 🎀 🌂 💄 💛 💙 💜 💚 ❤️ 💔 💗 💓 💕 💖 💞 💘 💌 💋 💍 💎 👤 👥 💬 👣 💭"; } - + NSString *emoji3; + + if(NSAppKitVersionNumber > 1404) { + emoji3 = @"🐶 🐱 🐭 🐹 🐰 🐻 🐼 🐨 🐯 🦁 🐮 🐷 🐽 🐸 🐙 🐵 🙈 🙉 🙊 🐒 🐔 🐧 🐦 🐤 🐣 🐥 🐺 🐗 🐴 🦄 🐝 🐛 🐌 🐞 🐜 🕷 🦂 🦀 🐍 🐢 🐠 🐟 🐡 🐬 🐳 🐋 🐊 🐆 🐅 🐃 🐂 🐄 🐪 🐫 🐘 🐐 🐏 🐑 🐎 🐖 🐀 🐁 🐓 🦃 🕊 🐕 🐩 🐈 🐇 🐿 🐾 🐉 🐲 🌵 🎄 🌲 🌳 🌴 🌱 🌿 ☘ 🍀 🎍 🎋 🍃 🍂 🍁 🌾 🌺 🌻 🌹 🌷 🌼 🌸 💐 🍄 🌰 🎃 🐚 🕸 🌎 🌍 🌏 🌕 🌖 🌗 🌘 🌑 🌒 🌓 🌔 🌚 🌝 🌛 🌜 🌞 🌙 ⭐️ 🌟 💫 ✨ ☄ ☀️ 🌤 ⛅️ 🌥 🌦 ☁️ 🌧 ⛈ 🌩 ⚡️ 🔥 💥 ❄️ 🌨 ☃ ⛄️ 🌬 💨 🌪 🌫 ☂ ☔️ 💧 💦 🌊"; + } else emoji3 = @"🐶 🐺 🐱 🐭 🐹 🐰 🐸 🐯 🐨 🐻 🐷 🐽 🐮 🐗 🐵 🐒 🐴 🐑 🐘 🐼 🐧 🐦 🐤 🐥 🐣 🐔 🐍 🐢 🐛 🐝 🐜 🐞 🐌 🐙 🐚 🐠 🐟 🐬 🐳 🐋 🐄 🐏 🐀 🐃 🐅 🐇 🐉 🐎 🐐 🐓 🐕 🐖 🐁 🐂 🐲 🐡 🐊 🐫 🐪 🐆 🐈 🐩 🐾 💐 🌸 🌷 🍀 🌹 🌵 🌻 🌺 🍁 🍃 🍂 🌿 🌾 🍄 🌵 🌴 🌲 🌳 🌰 🌱 🌼 🌐 🌞 🌝 🌚 🌑 🌒 🌓 🌔 🌕 🌖 🌗 🌘 🌜🌛 🌙 🌍 🌎 🌏 🌋 🌌 🌠 ⭐️ ☀️ ⛅️ ☁️ ⚡️ ☔️ ❄️ ⛄️ 🌀 🌁 🌈 🌊"; + - NSString *emoji3 = @"🐶 🐺 🐱 🐭 🐹 🐰 🐸 🐯 🐨 🐻 🐷 🐽 🐮 🐗 🐵 🐒 🐴 🐑 🐘 🐼 🐧 🐦 🐤 🐥 🐣 🐔 🐍 🐢 🐛 🐝 🐜 🐞 🐌 🐙 🐚 🐠 🐟 🐬 🐳 🐋 🐄 🐏 🐀 🐃 🐅 🐇 🐉 🐎 🐐 🐓 🐕 🐖 🐁 🐂 🐲 🐡 🐊 🐫 🐪 🐆 🐈 🐩 🐾 💐 🌸 🌷 🍀 🌹 🌵 🌻 🌺 🍁 🍃 🍂 🌿 🌾 🍄 🌵 🌴 🌲 🌳 🌰 🌱 🌼 🌐 🌞 🌝 🌚 🌑 🌒 🌓 🌔 🌕 🌖 🌗 🌘 🌜🌛 🌙 🌍 🌎 🌏 🌋 🌌 🌠 ⭐️ ☀️ ⛅️ ☁️ ⚡️ ☔️ ❄️ ⛄️ 🌀 🌁 🌈 🌊"; + NSString *emoji4; - NSString *emoji4 = @"🎍 💝 🎎 🎒 🎓 🎏 🎆 🎇 🎐 🎑 🎃 👻 🎅 🎄 🎁 🎋 🎉 🎊 🎈 🎌 🔮 🎥 📷 📹 📼 💿 📀 💽 💾 💻 📱 ☎️ 📞 📟 📠 📡 📺 📻 🔊 🔉 🔈 🔇 🔔 🔕 📢 📣 ⏳ ⌛️ ⏰ ⌚️ 🔓 🔒 🔏 🔐 🔑 🔎 💡 🔦 🔆 🔅 🔌 🔋 🔍 🛁 🛀 🚿 🚽 🔧 🔩 🔨 🚪 🚬 💣 🔫 🔪 💊 💉 💰 💴 💵 💷 💶 💳 💸 📲 📧 📥 📤 ✉️ 📩 📨 📯 📫 📪 📬 📭 📮 📦 📝 📄 📃 📑 📊 📈 📉 📜 📋 📅 📆 📇 📁 📂 ✂️ 📌 📎 ✒️ ✏️ 📏 📐 📕 📗 📘 📙 📓 📔 📒 📚 📖 🔖 📛 🔬 🔭 📰 🎨 🎬 🎤 🎧 🎼 🎵 🎶 🎹 🎻 🎺 🎷 🎸 👾 🎮 🃏 🎴 🀄️ 🎲 🎯 🏈 🏀 ⚽️ ⚾️ 🎾 🎱 🏉 🎳 ⛳️ 🚵 🚴 🏁 🏇 🏆 🎿 🏂 🏊 🏄 🎣 ☕️ 🍵 🍶 🍼 🍺 🍻 🍸 🍹 🍷 🍴 🍕 🍔 🍟 🍗 🍖 🍝 🍛 🍤 🍱 🍣 🍥 🍙 🍘 🍚 🍜 🍲 🍢 🍡 🍳 🍞 🍩 🍮 🍦 🍨 🍧 🎂 🍰 🍪 🍫 🍬 🍭 🍯 🍎 🍏 🍊 🍋 🍒 🍇 🍉 🍓 🍑 🍈 🍌 🍐 🍍 🍠 🍆 🍅 🌽"; + if(NSAppKitVersionNumber >= 1404) { + emoji4 = @"🍏 🍎 🍐 🍊 🍋 🍌 🍉 🍇 🍓 🍈 🍒 🍑 🍍 🍅 🍆 🌶 🌽 🍠 🍯 🍞 🧀 🍗 🍖 🍤 🍳 🍔 🍟 🌭 🍕 🍝 🌮 🌯 🍜 🍲 🍥 🍣 🍱 🍛 🍙 🍚 🍘 🍢 🍡 🍧 🍨 🍦 🍰 🎂 🍮 🍬 🍭 🍫 🍿 🍩 🍪 🍺 🍻 🍷 🍸 🍹 🍾 🍶 🍵 ☕️ 🍼 🍴 🍽 ⚽️ 🏀 🏈 ⚾️ 🎾 🏐 🏉 🎱 ⛳️ 🏌 🏓 🏸 🏒 🏑 🏏 🎿 ⛷ 🏂 ⛸ 🏹 🎣 🚣 🚣🏻 🚣🏼 🚣🏽 🚣🏾 🚣🏿 🏊 🏊🏻 🏊🏼 🏊🏽 🏊🏾 🏊🏿 🏄 🏄🏻 🏄🏼 🏄🏽 🏄🏾 🏄🏿 🛀 🛀🏻 🛀🏼 🛀🏽 🛀🏾 🛀🏿 ⛹ ⛹🏻 ⛹🏼 ⛹🏽 ⛹🏾 ⛹🏿 🏋 🏋🏻 🏋🏼 🏋🏽 🏋🏾 🏋🏿 🚴 🚴🏻 🚴🏼 🚴🏽 🚴🏾 🚴🏿 🚵 🚵🏻 🚵🏼 🚵🏽 🚵🏾 🚵🏿 🏇 🏇🏻 🏇🏼 🏇🏽 🏇🏾 🏇🏿 🕴 🏆 🎽 🏅 🎖 🎗 🏵 🎫 🎟 🎭 🎨 🎪 🎤 🎧 🎼 🎹 🎷 🎺 🎸 🎻 🎬 🎮 👾 🎯 🎲 🎰 🎳 ⌚️ 📱 📲 💻 ⌨ 🖥 🖨 🖱 🖲 🕹 🗜 💽 💾 💿 📀 📼 📷 📸 📹 🎥 📽 🎞 📞 ☎️ 📟 🎛 ⏱ ⏲ ⏰ 🕰 ⏳ ⌛️ 📡 🔋 🔌 💡 🔦 🕯 🗑 🛢 💸 💵 💴 💶 💷 💰 💳 💎 ⚖ 🔧 🔨 ⚒ 🛠 ⛏ 🔩 ⚙ ⛓ 🔫 💣 🔪 🗡 ⚔ 🛡 🚬 ☠ ⚰ ⚱ 🏺 🔮 📿 💈 ⚗ 🔭 🔬 🕳 💊 💉 🌡 🏷 🔖 🚽 🚿 🛁 🔑 🗝 🛋 🛌 🛏 🚪 🛎 🖼 🗺 ⛱ 🗿 🛍 🎈 🎏 🎀 🎁 🎊 🎉 🎎 🎐 🎌 🏮 ✉️ 📩 📨 📧 💌 📮 📪 📫 📬 📭 📦 📯 📥 📤 📜 📃 📑 📊 📈 📉 📄 📅 📆 🗓 📇 🗃 🗳 🗄 📋 🗒 📁 📂 🗂 🗞 📰 📓 📕 📗 📘 📙 📔 📒 📚 📖 🔗 📎 🖇 ✂️ 📐 📏 📌 📍 🚩 🏳 🏴 🔐 🔒 🔓 🔏 🖊 🖋 ✒️ 📝 ✏️ 🖍 🖌 🔍 🔎"; + } else { + emoji4 = @"🎍 💝 🎎 🎒 🎓 🎏 🎆 🎇 🎐 🎑 🎃 👻 🎅 🎄 🎁 🎋 🎉 🎊 🎈 🎌 🔮 🎥 📷 📹 📼 💿 📀 💽 💾 💻 📱 ☎️ 📞 📟 📠 📡 📺 📻 🔊 🔉 🔈 🔇 🔔 🔕 📢 📣 ⏳ ⌛️ ⏰ ⌚️ 🔓 🔒 🔏 🔐 🔑 🔎 💡 🔦 🔆 🔅 🔌 🔋 🔍 🛁 🛀 🚿 🚽 🔧 🔩 🔨 🚪 🚬 💣 🔫 🔪 💊 💉 💰 💴 💵 💷 💶 💳 💸 📲 📧 📥 📤 ✉️ 📩 📨 📯 📫 📪 📬 📭 📮 📦 📝 📄 📃 📑 📊 📈 📉 📜 📋 📅 📆 📇 📁 📂 ✂️ 📌 📎 ✒️ ✏️ 📏 📐 📕 📗 📘 📙 📓 📔 📒 📚 📖 🔖 📛 🔬 🔭 📰 🎨 🎬 🎤 🎧 🎼 🎵 🎶 🎹 🎻 🎺 🎷 🎸 👾 🎮 🃏 🎴 🀄️ 🎲 🎯 🏈 🏀 ⚽️ ⚾️ 🎾 🎱 🏉 🎳 ⛳️ 🚵 🚴 🏁 🏇 🏆 🎿 🏂 🏊 🏄 🎣 ☕️ 🍵 🍶 🍼 🍺 🍻 🍸 🍹 🍷 🍴 🍕 🍔 🍟 🍗 🍖 🍝 🍛 🍤 🍱 🍣 🍥 🍙 🍘 🍚 🍜 🍲 🍢 🍡 🍳 🍞 🍩 🍮 🍦 🍨 🍧 🎂 🍰 🍪 🍫 🍬 🍭 🍯 🍎 🍏 🍊 🍋 🍒 🍇 🍉 🍓 🍑 🍈 🍌 🍐 🍍 🍠 🍆 🍅 🌽"; + } - NSString *emoji5 = @"🏠 🏡 🏫 🏢 🏣 🏥 🏦 🏪 🏩 🏨 💒 ⛪️ 🏬 🏤 🌇 🌆 🏯 🏰 ⛺️ 🏭 🗼 🗾 🗻 🌄 🌅 🌃 🗽 🌉 🎠 🎡 ⛲️ 🎢 🚢 ⛵️ 🚤 🚣 ⚓️ 🚀 ✈️ 💺 🚁 🚂 🚊 🚉 🚞 🚆 🚄 🚅 🚈 🚇 🚝 🚋 🚃 🚎 🚌 🚍 🚙 🚘 🚗 🚕 🚖 🚛 🚚 🚨 🚓 🚔 🚒 🚑 🚐 🚲 🚡 🚟 🚠 🚜 💈 🚏 🎫 🚦 🚥 ⚠️ 🚧 🔰 ⛽️ 🏮 🎰 ♨️ 🗿 🎪 🎭 📍 🚩 🇯🇵 🇰🇷 🇩🇪 🇨🇳 🇺🇸 🇫🇷 🇪🇸 🇮🇹 🇷🇺 🇬🇧"; - NSString *emoji6 = @"1️⃣ 2️⃣ 3️⃣ 4️⃣ 5️⃣ 6️⃣ 7️⃣ 8️⃣ 9️⃣ 0️⃣ 🔟 🔢 #️⃣ 🔣 ⬆️ ⬇️ ⬅️ ➡️ 🔠 🔡 🔤 ↗️ ↖️ ↘️ ↙️ ↔️ ↕️ 🔄 ◀️ ▶️ 🔼 🔽 ↩️ ↪️ ℹ️ ⏪ ⏩ ⏫ ⏬ ⤵️ ⤴️ 🆗 🔀 🔁 🔂 🆕 🆙 🆒 🆓 🆖 📶 🎦 🈁 🈯️ 🈳 🈵 🈴 🈲 🉐 🈹 🈺 🈶 🈚️ 🚻 🚹 🚺 🚼 🚾 🚰 🚮 🅿️ ♿️ 🚭 🈷 🈸 🈂 Ⓜ️ 🛂 🛄 🛅 🛃 🉑 ㊙️ ㊗️ 🆑 🆘 🆔 🚫 🔞 📵 🚯 🚱 🚳 🚷 🚸 ⛔️ ✳️ ❇️ ❎ ✅ ✴️ 💟 🆚 📳 📴 🅰 🅱 🆎 🅾 💠 ➿ ♻️ ♈️ ♉️ ♊️ ♋️ ♌️ ♍️ ♎️ ♏️ ♐️ ♑️ ♒️ ♓️ ⛎ 🔯 🏧 💹 💲 💱 © ® ™ ❌ ‼️ ⁉️ ❗️ ❓ ❕ ❔ ⭕️ 🔝 🔚 🔙 🔛 🔜 🔃 🕛 🕧 🕐 🕜 🕑 🕝 🕒 🕞 🕓 🕟 🕔 🕠 🕕 🕖 🕗 🕘 🕙 🕚 🕡 🕢 🕣 🕤 🕥 🕦 ✖️ ➕ ➖ ➗ ♠️ ♥️ ♣️ ♦️ 💮 💯 ✔️ ☑️ 🔘 🔗 ➰ 〰 〽️ 🔱 ◼️ ◻️ ◾️ ◽️ ▪️ ▫️ 🔺 🔲 🔳 ⚫️ ⚪️ 🔴 🔵 🔻 ⬜️ ⬛️ 🔶 🔷 🔸 🔹"; + NSString *emoji5; + + if(NSAppKitVersionNumber >= 1404) { + emoji5 = @"🚗 🚕 🚙 🚌 🚎 🏎 🚓 🚑 🚒 🚐 🚚 🚛 🚜 🏍 🚲 🚨 🚔 🚍 🚘 🚖 🚡 🚠 🚟 🚃 🚋 🚝 🚄 🚅 🚈 🚞 🚂 🚆 🚇 🚊 🚉 🚁 🛩 ✈️ 🛫 🛬 ⛵️ 🛥 🚤 ⛴ 🛳 🚀 🛰 💺 ⚓️ 🚧 ⛽️ 🚏 🚦 🚥 🏁 🚢 🎡 🎢 🎠 🏗 🌁 🗼 🏭 ⛲️ 🎑 ⛰ 🏔 🗻 🌋 🗾 🏕 ⛺️ 🏞 🛣 🛤 🌅 🌄 🏜 🏖 🏝 🌇 🌆 🏙 🌃 🌉 🌌 🌠 🎇 🎆 🌈 🏘 🏰 🏯 🏟 🗽 🏠 🏡 🏚 🏢 🏬 🏣 🏤 🏥 🏦 🏨 🏪 🏫 🏩 💒 🏛 ⛪️ 🕌 🕍 🕋 ⛩ 🇦🇺 🇦🇹 🇦🇿 🇦🇽 🇦🇱 🇩🇿 🇦🇸 🇦🇮 🇦🇴 🇦🇩 🇦🇶 🇦🇬 🇦🇷 🇦🇲 🇦🇼 🇦🇫 🇧🇸 🇧🇩 🇧🇧 🇧🇭 🇧🇾 🇧🇿 🇧🇪 🇧🇯 🇧🇲 🇧🇬 🇧🇴 🇧🇶 🇧🇦 🇧🇼 🇧🇷 🇮🇴 🇧🇳 🇧🇫 🇧🇮 🇧🇹 🇻🇺 🇻🇦 🇬🇧 🇭🇺 🇻🇪 🇻🇬 🇻🇮 🇹🇱 🇻🇳 🇬🇦 🇭🇹 🇬🇾 🇬🇲 🇬🇭 🇬🇵 🇬🇹 🇬🇳 🇬🇼 🇩🇪 🇬🇬 🇬🇮 🇭🇳 🇭🇰 🇬🇩 🇬🇱 🇬🇷 🇬🇪 🇬🇺 🇩🇰 🇯🇪 🇩🇯 🇩🇲 🇩🇴 🇪🇺 🇪🇬 🇿🇲 🇪🇭 🇿🇼 🇮🇱 🇮🇳 🇮🇩 🇯🇴 🇮🇶 🇮🇷 🇮🇪 🇮🇸 🇪🇸 🇮🇹 🇾🇪 🇨🇻 🇰🇿 🇰🇾 🇰🇭 🇨🇲 🇨🇦 🇮🇨 🇶🇦 🇰🇪 🇨🇾 🇰🇬 🇰🇮 🇨🇳 🇰🇵 🇨🇨 🇨🇴 🇰🇲 🇨🇬 🇨🇩 🇽🇰 🇨🇷 🇨🇮 🇨🇺 🇰🇼 🇨🇼 🇱🇦 🇱🇻 🇱🇸 🇱🇷 🇱🇧 🇱🇾 🇱🇹 🇱🇮 🇱🇺 🇲🇺 🇲🇷 🇲🇬 🇾🇹 🇲🇴 🇲🇰 🇲🇼 🇲🇾 🇲🇱 🇲🇻 🇲🇹 🇲🇦 🇲🇶 🇲🇭 🇲🇽 🇫🇲 🇲🇿 🇲🇩 🇲🇨 🇲🇳 🇲🇸 🇲🇲 🇳🇦 🇳🇷 🇳🇵 🇳🇪 🇳🇬 🇳🇱 🇳🇮 🇳🇺 🇳🇿 🇳🇨 🇳🇴 🇮🇲 🇳🇫 🇨🇽 🇸🇭 🇨🇰 🇹🇨 🇦🇪 🇴🇲 🇵🇰 🇵🇼 🇵🇸 🇵🇦 🇵🇬 🇵🇾 🇵🇪 🇵🇳 🇵🇱 🇵🇹 🇵🇷 🇰🇷 🇷🇪 🇷🇺 🇷🇼 🇷🇴 🇸🇻 🇼🇸 🇸🇲 🇸🇹 🇸🇦 🇸🇿 🇲🇵 🇸🇨 🇧🇱 🇵🇲 🇸🇳 🇻🇨 🇰🇳 🇱🇨 🇷🇸 🇸🇬 🇸🇽 🇸🇾 🇸🇰 🇸🇮 🇺🇸 🇸🇧 🇸🇴 🇸🇩 🇸🇷 🇸🇱 🇹🇯 🇹🇭 🇹🇼 🇹🇿 🇹🇬 🇹🇰 🇹🇴 🇹🇹 🇹🇻 🇹🇳 🇹🇲 🇹🇷 🇺🇬 🇺🇿 🇺🇦 🇼🇫 🇺🇾 🇫🇴 🇫🇯 🇵🇭 🇫🇮 🇫🇰 🇫🇷 🇬🇫 🇵🇫 🇹🇫 🇭🇷 🇨🇫 🇹🇩 🇲🇪 🇨🇿 🇨🇱 🇨🇭 🇸🇪 🇱🇰 🇪🇨 🇬🇶 🇪🇷 🇪🇪 🇪🇹 🇿🇦 🇬🇸 🇸🇸 🇯🇲 🇯🇵"; + } else { + emoji5 = @"🏠 🏡 🏫 🏢 🏣 🏥 🏦 🏪 🏩 🏨 💒 ⛪️ 🏬 🏤 🌇 🌆 🏯 🏰 ⛺️ 🏭 🗼 🗾 🗻 🌄 🌅 🌃 🗽 🌉 🎠 🎡 ⛲️ 🎢 🚢 ⛵️ 🚤 🚣 ⚓️ 🚀 ✈️ 💺 🚁 🚂 🚊 🚉 🚞 🚆 🚄 🚅 🚈 🚇 🚝 🚋 🚃 🚎 🚌 🚍 🚙 🚘 🚗 🚕 🚖 🚛 🚚 🚨 🚓 🚔 🚒 🚑 🚐 🚲 🚡 🚟 🚠 🚜 💈 🚏 🎫 🚦 🚥 ⚠️ 🚧 🔰 ⛽️ 🏮 🎰 ♨️ 🗿 🎪 🎭 📍 🚩 🇯🇵 🇰🇷 🇩🇪 🇨🇳 🇺🇸 🇫🇷 🇪🇸 🇮🇹 🇷🇺 🇬🇧"; + } + + NSString *emoji6; + + if(NSAppKitVersionNumber >= 1404) { + emoji6 = @"💟 ☮ ✝ ☪ 🕉 ☸ ✡ 🔯 🕎 ☯ ☦ 🛐 ⛎ ♈️ ♉️ ♊️ ♋️ ♌️ ♍️ ♎️ ♏️ ♐️ ♑️ ♒️ ♓️ 🆔 ⚛ 🈳 🈹 ☢ ☣ 📴 📳 🈶 🈚️ 🈸 🈺 🈷 ✴️ 🆚 🉑 💮 🉐 ㊙️ ㊗️ 🈴 🈵 🈲 🅰 🅱 🆎 🆑 🅾 🆘 ⛔️ 📛 🚫 ❌ ⭕️ 💢 ♨️ 🚷 🚯 🚳 🚱 🔞 📵 ❗️ ❕ ❓ ❔ ‼️ ⁉️ 💯 🔅 🔆 🔱 ⚜ 〽️ ⚠️ 🚸 🔰 ♻️ 🈯️ 💹 ❇️ ✳️ ❎ ✅ 💠 🌀 ➿ 🌐 Ⓜ️ 🏧 🈂 🛂 🛃 🛄 🛅 ♿️ 🚭 🚾 🅿️ 🚰 🚹 🚺 🚼 🚻 🚮 🎦 📶 🈁 🆖 🆗 🆙 🆒 🆕 🆓 0️⃣ 1️⃣ 2️⃣ 3️⃣ 4️⃣ 5️⃣ 6️⃣ 7️⃣ 8️⃣ 9️⃣ 🔟 🔢 ▶️ ⏸ ⏯ ⏹ ⏺ ⏭ ⏮ ⏩ ⏪ 🔀 🔁 🔂 ◀️ 🔼 🔽 ⏫ ⏬ ➡️ ⬅️ ⬆️ ⬇️ ↗️ ↘️ ↙️ ↖️ ↕️ ↔️ 🔄 ↪️ ↩️ ⤴️ ⤵️ #️⃣ *️⃣ ℹ️ 🔤 🔡 🔠 🔣 🎵 🎶 〰 ➰ ✔️ 🔃 ➕ ➖ ➗ ✖️ 💲 💱 © ® ™ 🔚 🔙 🔛 🔝 🔜 ☑️ 🔘 ⚪️ ⚫️ 🔴 🔵 🔸 🔹 🔶 🔷 🔺 ▪️ ▫️ ⬛️ ⬜️ 🔻 ◼️ ◻️ ◾️ ◽️ 🔲 🔳 🔈 🔉 🔊 🔇 📣 📢 🔔 🔕 🃏 🀄️ ♠️ ♣️ ♥️ ♦️ 🎴 👁‍🗨 💭 🗯 💬 🕐 🕑 🕒 🕓 🕔 🕕 🕖 🕗 🕘 🕙 🕚 🕛 🕜 🕝 🕞 🕟 🕠 🕡 🕢 🕣 🕤 🕥 🕦 🕧"; + } else { + emoji6 = @"↗️ ↖️ ↘️ ↙️ ↔️ ↕️ 🔄 ◀️ ▶️ 🔼 🔽 ↩️ ↪️ ℹ️ ⏪ ⏩ ⏫ ⏬ ⤵️ ⤴️ 🆗 🔀 🔁 🔂 🆕 🆙 🆒 🆓 🆖 📶 🎦 🈁 🈯️ 🈳 🈵 🈴 🈲 🉐 🈹 🈺 🈶 🈚️ 🚻 🚹 🚺 🚼 🚾 🚰 🚮 🅿️ ♿️ 🚭 🈷 🈸 🈂 Ⓜ️ 🛂 🛄 🛅 🛃 🉑 ㊙️ ㊗️ 🆑 🆘 🆔 🚫 🔞 📵 🚯 🚱 🚳 🚷 🚸 ⛔️ ✳️ ❇️ ❎ ✅ ✴️ 💟 🆚 📳 📴 🅰 🅱 🆎 🅾 💠 ➿ ♻️ ♈️ ♉️ ♊️ ♋️ ♌️ ♍️ ♎️ ♏️ ♐️ ♑️ ♒️ ♓️ ⛎ 🔯 🏧 💹 💲 💱 © ® ™ ❌ ‼️ ⁉️ ❗️ ❓ ❕ ❔ ⭕️ 🔝 🔚 🔙 🔛 🔜 🔃 🕛 🕧 🕐 🕜 🕑 🕝 🕒 🕞 🕓 🕟 🕔 🕠 🕕 🕖 🕗 🕘 🕙 🕚 🕡 🕢 🕣 🕤 🕥 🕦 ✖️ ➕ ➖ ➗ ♠️ ♥️ ♣️ ♦️ 💮 💯 ✔️ ☑️ 🔘 🔗 ➰ 〰 〽️ 🔱 ◼️ ◻️ ◾️ ◽️ ▪️ ▫️ 🔺 🔲 🔳 ⚫️ ⚪️ 🔴 🔵 🔻 ⬜️ ⬛️ 🔶 🔷 🔸 🔹"; + } + + self.segments = @[self.userEmoji, [emoji2 componentsSeparatedByString:@" "], [emoji3 componentsSeparatedByString:@" "], [emoji4 componentsSeparatedByString:@" "], [emoji5 componentsSeparatedByString:@" "], [emoji6 componentsSeparatedByString:@" "]]; } @@ -223,6 +250,7 @@ - (id)initWithFrame:(NSRect)frame { } +(void)reloadStickers { + [self instance]; [[self instance].stickersTableView.stickers load:YES]; } @@ -234,6 +262,41 @@ +(NSArray *)allSets { return [[self instance].stickersTableView.stickers sets]; } ++(TL_stickerSet *)setWithId:(long)n_id { + NSArray *sets = [self allSets]; + + __block TL_stickerSet *set; + + [sets enumerateObjectsUsingBlock:^(TL_stickerSet *obj, NSUInteger idx, BOOL * _Nonnull stop) { + + if(obj.n_id == n_id) { + set = obj; + *stop = YES; + } + + }]; + + return set; +} + ++(NSArray *)stickersWithId:(long)n_id { + NSArray *stickers = [self allStickers]; + + __block NSMutableArray *s = [NSMutableArray array]; + + [stickers enumerateObjectsUsingBlock:^(TLDocument *obj, NSUInteger idx, BOOL * _Nonnull stop) { + + TL_documentAttributeSticker *attr = (TL_documentAttributeSticker *) [obj attributeWithClass:TL_documentAttributeSticker.class]; + + if(attr.stickerset.n_id == n_id) { + [s addObject:obj]; + } + + }]; + + return s; +} + +(void)loadStickersIfNeeded { [[self instance].stickersTableView.stickers load:NO]; } @@ -312,7 +375,7 @@ - (void)loadView { self.noRecentsTextField = [[TMTextField alloc] initWithFrame:NSZeroRect]; [self.noRecentsTextField setStringValue:NSLocalizedString(@"Emoji.NoRecents", nil)]; - [self.noRecentsTextField setFont:[NSFont fontWithName:@"Helvetica-Light" size:12]]; + [self.noRecentsTextField setFont:TGSystemLightFont(12)]; [self.noRecentsTextField setTextColor:NSColorFromRGB(0xaeaeae)]; [self.noRecentsTextField sizeToFit]; [self.noRecentsTextField setDrawsBackground:NO]; @@ -386,6 +449,7 @@ - (void)showPopovers { - (void)close { [[Telegram rightViewController].messagesViewController.bottomView.smilePopover close]; + [self.stickersTableView removeAllItems]; } - (void)bottomButtonClick:(EmojiBottomButton *)button { @@ -413,14 +477,14 @@ - (void)bottomButtonClick:(EmojiBottomButton *)button { if(self.currentButton.index == 7) { [self.stickersTableView reload]; - + } else { + [self.stickersTableView removeAllItems]; } [self.tableView.containerView setHidden:self.currentButton.index == 7]; [self.stickersTableView setHidden:self.currentButton.index != 7]; - } - (void)insertEmoji:(NSString *)emoji { diff --git a/TelegramTest/EncryptedKeyViewController.m b/TelegramTest/EncryptedKeyViewController.m index deb93e34..d39a4e61 100644 --- a/TelegramTest/EncryptedKeyViewController.m +++ b/TelegramTest/EncryptedKeyViewController.m @@ -23,7 +23,7 @@ -(void)loadView { TMButton *center = [[TMButton alloc] initWithFrame:NSMakeRect(0, 0, 400, 200)]; - [center setTextFont:[NSFont fontWithName:@"HelveticaNeue" size:14]]; + [center setTextFont:TGSystemFont(14)]; [center setText:NSLocalizedString(@"EncryptionKey.EncryptionKey", nil)]; [center setTarget:self selector:@selector(navigationGoBack)]; self.centerNavigationBarView = center; @@ -56,7 +56,7 @@ -(void)loadView { self.textField.url_delegate = self; - [self.textField setFont:[NSFont fontWithName:@"HelveticaNeue" size:14]]; + [self.textField setFont:TGSystemFont(14)]; [self.textField setEditable:NO]; [self.textField setSelectable:NO]; @@ -97,9 +97,9 @@ - (void)showForChat:(TL_encryptedChat *)chat { NSString *baseText = [[NSString alloc] initWithFormat:textFormat, _userName, _userName]; - NSDictionary *attrs = [NSDictionary dictionaryWithObjectsAndKeys:[NSFont fontWithName:@"HelveticaNeue" size:14], NSFontAttributeName, nil]; + NSDictionary *attrs = [NSDictionary dictionaryWithObjectsAndKeys:TGSystemFont(14), NSFontAttributeName, nil]; - NSDictionary *subAttrs = [NSDictionary dictionaryWithObjectsAndKeys:[NSFont fontWithName:@"HelveticaNeue-Medium" size:14], NSFontAttributeName, nil]; + NSDictionary *subAttrs = [NSDictionary dictionaryWithObjectsAndKeys:TGSystemMediumFont(14), NSFontAttributeName, nil]; NSDictionary *linkAtts = @{NSForegroundColorAttributeName: BLUE_UI_COLOR, NSLinkAttributeName:@"telegram.org"}; diff --git a/TelegramTest/EncryptedKeyWindow.m b/TelegramTest/EncryptedKeyWindow.m index 46c62e15..70e7f89c 100644 --- a/TelegramTest/EncryptedKeyWindow.m +++ b/TelegramTest/EncryptedKeyWindow.m @@ -36,7 +36,7 @@ -(id)init { self.textField.url_delegate = self; - [self.textField setFont:[NSFont fontWithName:@"HelveticaNeue" size:14]]; + [self.textField setFont:TGSystemFont(14)]; [self.textField setEditable:NO]; [self.textField setSelectable:NO]; diff --git a/TelegramTest/FMDatabase.h b/TelegramTest/FMDatabase.h index 90d304ee..8bec2999 100755 --- a/TelegramTest/FMDatabase.h +++ b/TelegramTest/FMDatabase.h @@ -248,6 +248,10 @@ @return `YES` if everything succeeds, `NO` on failure. */ + + +- (void)updatePath:(NSString *)path; + - (BOOL)goodConnection; diff --git a/TelegramTest/FMDatabase.m b/TelegramTest/FMDatabase.m index 8edfb6ca..9c65b899 100755 --- a/TelegramTest/FMDatabase.m +++ b/TelegramTest/FMDatabase.m @@ -3,7 +3,7 @@ #import #define DBLog(fmt, ...) //MTLog((@"db %s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__); - +#define EDBLog(fmt, ...) MTLog((@"db %s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__); @interface FMDatabase () - (FMResultSet *)executeQuery:(NSString *)sql withArgumentsInArray:(NSArray*)arrayArgs orDictionary:(NSDictionary *)dictionaryArgs orVAList:(va_list)args; @@ -96,7 +96,7 @@ - (BOOL)open { int err = sqlite3_open([self sqlitePath], &_db ); if(err != SQLITE_OK) { - DBLog(@"error opening!: %d", err); + EDBLog(@"error opening!: %d", err); return NO; } @@ -107,7 +107,7 @@ - (BOOL)open { - (BOOL)openWithFlags:(int)flags { int err = sqlite3_open_v2([self sqlitePath], &_db, flags, NULL /* Name of VFS module to use */); if(err != SQLITE_OK) { - DBLog(@"error opening!: %d", err); + EDBLog(@"error opening!: %d", err); return NO; } return YES; @@ -139,8 +139,8 @@ - (BOOL)close { usleep(20); if (_busyRetryTimeout && (numberOfRetries++ > _busyRetryTimeout)) { - DBLog(@"%s:%d", __FUNCTION__, __LINE__); - DBLog(@"Database busy, unable to close"); + EDBLog(@"%s:%d", __FUNCTION__, __LINE__); + EDBLog(@"Database busy, unable to close"); return NO; } @@ -148,13 +148,13 @@ - (BOOL)close { triedFinalizingOpenStatements = YES; sqlite3_stmt *pStmt; while ((pStmt = sqlite3_next_stmt(_db, 0x00)) !=0) { - DBLog(@"Closing leaked statement"); + EDBLog(@"Closing leaked statement"); sqlite3_finalize(pStmt); } } } else if (SQLITE_OK != rc) { - DBLog(@"error closing!: %d", rc); + EDBLog(@"error closing!: %d", rc); } } while (retry); @@ -163,6 +163,14 @@ - (BOOL)close { return YES; } +- (void)updatePath:(NSString *)path { + + [self close]; + _databasePath = [path copy]; + [self open]; + +} + - (void)clearCachedStatements { for (NSMutableSet *statements in [_cachedStatements objectEnumerator]) { @@ -241,8 +249,8 @@ - (BOOL)rekeyWithData:(NSData *)keyData { int rc = sqlite3_rekey(_db, [keyData bytes], (int)[keyData length]); if (rc != SQLITE_OK) { - DBLog(@"error on rekey: %d", rc); - DBLog(@"%@", [self lastErrorMessage]); + EDBLog(@"error on rekey: %d", rc); + EDBLog(@"%@", [self lastErrorMessage]); } return (rc == SQLITE_OK); @@ -316,7 +324,7 @@ - (BOOL)goodConnection { } - (void)warnInUse { - DBLog(@"The FMDatabase %@ is currently in use.", self); + EDBLog(@"The FMDatabase %@ is currently in use.", self); #ifndef NS_BLOCK_ASSERTIONS if (_crashOnErrors) { @@ -330,7 +338,7 @@ - (BOOL)databaseExists { if (!_db) { - DBLog(@"The FMDatabase %@ is not open.", self); + EDBLog(@"The FMDatabase %@ is not open.", self); #ifndef NS_BLOCK_ASSERTIONS if (_crashOnErrors) { @@ -620,8 +628,8 @@ - (FMResultSet *)executeQuery:(NSString *)sql withArgumentsInArray:(NSArray*)arr usleep(20); if (_busyRetryTimeout && (numberOfRetries++ > _busyRetryTimeout)) { - DBLog(@"%s:%d Database busy (%@)", __FUNCTION__, __LINE__, [self databasePath]); - DBLog(@"Database busy"); + EDBLog(@"%s:%d Database busy (%@)", __FUNCTION__, __LINE__, [self databasePath]); + EDBLog(@"Database busy"); sqlite3_finalize(pStmt); _isExecutingStatement = NO; return nil; @@ -630,9 +638,9 @@ - (FMResultSet *)executeQuery:(NSString *)sql withArgumentsInArray:(NSArray*)arr else if (SQLITE_OK != rc) { if (_logsErrors) { - DBLog(@"DB Error: %d \"%@\"", [self lastErrorCode], [self lastErrorMessage]); - DBLog(@"DB Query: %@", sql); - DBLog(@"DB Path: %@", _databasePath); + EDBLog(@"DB Error: %d \"%@\"", [self lastErrorCode], [self lastErrorMessage]); + EDBLog(@"DB Query: %@", sql); + EDBLog(@"DB Path: %@", _databasePath); #ifndef NS_BLOCK_ASSERTIONS if (_crashOnErrors) { abort(); @@ -673,7 +681,7 @@ - (FMResultSet *)executeQuery:(NSString *)sql withArgumentsInArray:(NSArray*)arr idx++; } else { - DBLog(@"Could not find index for %@", dictionaryKey); + EDBLog(@"Could not find index for %@", dictionaryKey); } } } @@ -694,10 +702,10 @@ - (FMResultSet *)executeQuery:(NSString *)sql withArgumentsInArray:(NSArray*)arr if (_traceExecution) { if ([obj isKindOfClass:[NSData class]]) { - DBLog(@"data: %ld bytes", (unsigned long)[(NSData*)obj length]); + EDBLog(@"data: %ld bytes", (unsigned long)[(NSData*)obj length]); } else { - DBLog(@"obj: %@", obj); + EDBLog(@"obj: %@", obj); } } @@ -708,7 +716,7 @@ - (FMResultSet *)executeQuery:(NSString *)sql withArgumentsInArray:(NSArray*)arr } if (idx != queryCount) { - DBLog(@"Error: the bind count is not correct for the # of variables (executeQuery)"); + EDBLog(@"Error: the bind count is not correct for the # of variables (executeQuery)"); sqlite3_finalize(pStmt); _isExecutingStatement = NO; return nil; @@ -817,8 +825,8 @@ - (BOOL)executeUpdate:(NSString*)sql error:(NSError**)outErr withArgumentsInArra usleep(20); if (_busyRetryTimeout && (numberOfRetries++ > _busyRetryTimeout)) { - DBLog(@"%s:%d Database busy (%@)", __FUNCTION__, __LINE__, [self databasePath]); - DBLog(@"Database busy"); + EDBLog(@"%s:%d Database busy (%@)", __FUNCTION__, __LINE__, [self databasePath]); + EDBLog(@"Database busy"); sqlite3_finalize(pStmt); _isExecutingStatement = NO; return NO; @@ -827,9 +835,9 @@ - (BOOL)executeUpdate:(NSString*)sql error:(NSError**)outErr withArgumentsInArra else if (SQLITE_OK != rc) { if (_logsErrors) { - DBLog(@"DB Error: %d \"%@\"", [self lastErrorCode], [self lastErrorMessage]); - DBLog(@"DB Query: %@", sql); - DBLog(@"DB Path: %@", _databasePath); + EDBLog(@"DB Error: %d \"%@\"", [self lastErrorCode], [self lastErrorMessage]); + EDBLog(@"DB Query: %@", sql); + EDBLog(@"DB Path: %@", _databasePath); #ifndef NS_BLOCK_ASSERTIONS if (_crashOnErrors) { abort(); @@ -876,7 +884,7 @@ - (BOOL)executeUpdate:(NSString*)sql error:(NSError**)outErr withArgumentsInArra idx++; } else { - DBLog(@"Could not find index for %@", dictionaryKey); + EDBLog(@"Could not find index for %@", dictionaryKey); } } } @@ -897,10 +905,10 @@ - (BOOL)executeUpdate:(NSString*)sql error:(NSError**)outErr withArgumentsInArra if (_traceExecution) { if ([obj isKindOfClass:[NSData class]]) { - DBLog(@"data: %ld bytes", (unsigned long)[(NSData*)obj length]); + EDBLog(@"data: %ld bytes", (unsigned long)[(NSData*)obj length]); } else { - DBLog(@"obj: %@", obj); + EDBLog(@"obj: %@", obj); } } @@ -912,7 +920,7 @@ - (BOOL)executeUpdate:(NSString*)sql error:(NSError**)outErr withArgumentsInArra if (idx != queryCount) { - DBLog(@"Error: the bind count (%d) is not correct for the # of variables in the query (%d) (%@) (executeUpdate)", idx, queryCount, sql); + EDBLog(@"Error: the bind count (%d) is not correct for the # of variables in the query (%d) (%@) (executeUpdate)", idx, queryCount, sql); sqlite3_finalize(pStmt); _isExecutingStatement = NO; return NO; @@ -934,14 +942,14 @@ - (BOOL)executeUpdate:(NSString*)sql error:(NSError**)outErr withArgumentsInArra if (SQLITE_LOCKED == rc) { rc = sqlite3_reset(pStmt); if (rc != SQLITE_LOCKED) { - DBLog(@"Unexpected result from sqlite3_reset (%d) eu", rc); + EDBLog(@"Unexpected result from sqlite3_reset (%d) eu", rc); } } usleep(20); if (_busyRetryTimeout && (numberOfRetries++ > _busyRetryTimeout)) { - DBLog(@"%s:%d Database busy (%@)", __FUNCTION__, __LINE__, [self databasePath]); - DBLog(@"Database busy"); + EDBLog(@"%s:%d Database busy (%@)", __FUNCTION__, __LINE__, [self databasePath]); + EDBLog(@"Database busy"); retry = NO; } } @@ -950,22 +958,22 @@ - (BOOL)executeUpdate:(NSString*)sql error:(NSError**)outErr withArgumentsInArra } else if (SQLITE_ERROR == rc) { if (_logsErrors) { - DBLog(@"Error calling sqlite3_step (%d: %s) SQLITE_ERROR", rc, sqlite3_errmsg(_db)); - DBLog(@"DB Query: %@", sql); + EDBLog(@"Error calling sqlite3_step (%d: %s) SQLITE_ERROR", rc, sqlite3_errmsg(_db)); + EDBLog(@"DB Query: %@", sql); } } else if (SQLITE_MISUSE == rc) { // uh oh. if (_logsErrors) { - DBLog(@"Error calling sqlite3_step (%d: %s) SQLITE_MISUSE", rc, sqlite3_errmsg(_db)); - DBLog(@"DB Query: %@", sql); + EDBLog(@"Error calling sqlite3_step (%d: %s) SQLITE_MISUSE", rc, sqlite3_errmsg(_db)); + EDBLog(@"DB Query: %@", sql); } } else { // wtf? if (_logsErrors) { - DBLog(@"Unknown error calling sqlite3_step (%d: %s) eu", rc, sqlite3_errmsg(_db)); - DBLog(@"DB Query: %@", sql); + EDBLog(@"Unknown error calling sqlite3_step (%d: %s) eu", rc, sqlite3_errmsg(_db)); + EDBLog(@"DB Query: %@", sql); } } @@ -1000,8 +1008,8 @@ - (BOOL)executeUpdate:(NSString*)sql error:(NSError**)outErr withArgumentsInArra if (closeErrorCode != SQLITE_OK) { if (_logsErrors) { - DBLog(@"Unknown error finalizing or resetting statement (%d: %s)", closeErrorCode, sqlite3_errmsg(_db)); - DBLog(@"DB Query: %@", sql); + EDBLog(@"Unknown error finalizing or resetting statement (%d: %s)", closeErrorCode, sqlite3_errmsg(_db)); + EDBLog(@"DB Query: %@", sql); } } @@ -1014,7 +1022,7 @@ - (BOOL)executeUpdate:(NSString*)sql, ... { va_list args; va_start(args, sql); - DBLog(@"%@",sql); + DBLog(@"%@",sql); BOOL result = [self executeUpdate:sql error:nil withArgumentsInArray:nil orDictionary:nil orVAList:args]; diff --git a/TelegramTest/FMDatabaseQueue.m b/TelegramTest/FMDatabaseQueue.m index 82cf702b..565f7b72 100755 --- a/TelegramTest/FMDatabaseQueue.m +++ b/TelegramTest/FMDatabaseQueue.m @@ -139,34 +139,44 @@ - (void)inDatabase:(void (^)(FMDatabase *db))block { // } FMDBRetain(self); - dispatch_async(_queue, ^() { -// MTLog(@"DB[#%lu]: %@", (unsigned long)hash, string); - - FMDatabase *db = [self database]; - block(db); - - if ([db hasOpenResultSets]) { - MTLog(@"Warning: there is at least one open result set around after performing [FMDatabaseQueue inDatabase:]"); - } - -// MTLog(@"DB[#%lu] end", hash); - }); + + dispatch_block_t b = ^{ + FMDatabase *db = [self database]; + block(db); + + if ([db hasOpenResultSets]) { + MTLog(@"Warning: there is at least one open result set around after performing [FMDatabaseQueue inDatabase:]"); + } + }; + + + + if(dispatch_get_current_queue() != _queue) + dispatch_async(_queue, b); + else + b(); + FMDBRelease(self); } - (void)inDatabaseWithDealocing:(void (^)(FMDatabase *db))block { FMDBRetain(self); - dispatch_sync(_queue, ^() { - + + dispatch_block_t eblock = ^{ FMDatabase *db = [self database]; block(db); if ([db hasOpenResultSets]) { MTLog(@"Warning: there is at least one open result set around after performing [FMDatabaseQueue inDatabase:]"); } - - }); + }; + + if(dispatch_get_current_queue() == _queue) { + eblock(); + } else { + dispatch_sync(_queue, eblock); + } FMDBRelease(self); } diff --git a/TelegramTest/FileSecretSenderItem.m b/TelegramTest/FileSecretSenderItem.m index b7ac14bb..95f740da 100644 --- a/TelegramTest/FileSecretSenderItem.m +++ b/TelegramTest/FileSecretSenderItem.m @@ -17,6 +17,7 @@ #import "SelfDestructionController.h" #import "DeleteRandomMessagesSenderItem.h" #import "TGCache.h" +#import "NSData+Extensions.h" @interface FileSecretSenderItem () //@property (nonatomic,strong) NSImage *thumb; //@property (nonatomic,strong) NSData *thumbData; @@ -57,6 +58,8 @@ - (void)initializeWithImage:(NSImage *)image filePath:(NSString *)filePath uploa self.message = [TL_destructMessage createWithN_id:0 flags:TGOUTUNREADMESSAGE from_id:[UsersManager currentUserId] to_id:[TL_peerSecret createWithChat_id:self.conversation.peer.chat_id] date:[[MTNetwork instance] getTime] message:@"" media:media destruction_time:0 randomId:rand_long() fakeId:[MessageSender getFakeMessageId] ttl_seconds:ttl == -1 ? 0 : ttl out_seq_no:-1 dstate:DeliveryStatePending]; + self.mimeType = mimetypefromExtension([self.filePath pathExtension]); + if(self.uploadType == UploadImageType) { image = prettysize(image); @@ -65,7 +68,7 @@ - (void)initializeWithImage:(NSImage *)image filePath:(NSString *)filePath uploa NSImage *thumb = strongResize(image, 90); - NSData *thumbData = jpegNormalizedData(thumb); + NSData *thumbData = compressImage(jpegNormalizedData(thumb), 0.1); NSSize origin = image.size; @@ -80,7 +83,7 @@ - (void)initializeWithImage:(NSImage *)image filePath:(NSString *)filePath uploa [sizes addObject:cachedSize]; [sizes addObject:photoSize]; - media = [TL_messageMediaPhoto createWithPhoto:[TL_photo createWithN_id:self.uploader.identify access_hash:0 user_id:0 date:[[MTNetwork instance] getTime] geo:[TL_geoPointEmpty create] sizes:sizes] caption:@""]; + media = [TL_messageMediaPhoto createWithPhoto:[TL_photo createWithN_id:self.uploader.identify access_hash:0 date:[[MTNetwork instance] getTime] sizes:sizes] caption:@""]; [TGCache cacheImage:renderedImage(image, maxSize) forKey:photoSize.location.cacheKey groups:@[IMGCACHE]]; @@ -109,7 +112,7 @@ - (void)initializeWithImage:(NSImage *)image filePath:(NSString *)filePath uploa TL_photoCachedSize *photoSize = [TL_photoCachedSize createWithType:@"x" location:[TL_fileLocation createWithDc_id:0 volume_id:rand_long() local_id:0 secret:0] w:image.size.width h:image.size.height bytes:thumbData]; - media = [TL_messageMediaVideo createWithVideo:[TL_video createWithN_id:self.uploader.identify access_hash:0 user_id:[UsersManager currentUserId] date:[[MTNetwork instance] getTime] duration:duration size:0 thumb:photoSize dc_id:0 w:size.width h:size.height] caption:@""]; + media = [TL_messageMediaVideo createWithVideo:[TL_video createWithN_id:self.uploader.identify access_hash:0 date:[[MTNetwork instance] getTime] duration:duration mime_type:self.mimeType size:0 thumb:photoSize dc_id:0 w:size.width h:size.height] caption:@""]; } else if(self.uploadType == UploadDocumentType) { @@ -130,7 +133,7 @@ - (void)initializeWithImage:(NSImage *)image filePath:(NSString *)filePath uploa size = [TL_photoSizeEmpty createWithType:@"x"]; } - self.mimeType = mimetypefromExtension([self.filePath pathExtension]); + @@ -139,7 +142,7 @@ - (void)initializeWithImage:(NSImage *)image filePath:(NSString *)filePath uploa NSTimeInterval duration = [TGOpusAudioPlayerAU durationFile:filePath]; - media = [TL_messageMediaAudio createWithAudio:[TL_audio createWithN_id:0 access_hash:0 user_id:[UsersManager currentUserId] date:(int)[[MTNetwork instance] getTime] duration:roundf(duration) mime_type:@"opus" size:(int)fileSize(filePath) dc_id:0]]; + media = [TL_messageMediaAudio createWithAudio:[TL_audio createWithN_id:0 access_hash:0 date:(int)[[MTNetwork instance] getTime] duration:roundf(duration) mime_type:@"opus" size:(int)fileSize(filePath) dc_id:0]]; } @@ -267,7 +270,7 @@ -(void)performRequest { } else if(strongSelf.params.layer == 20) { strongSelf.media = [Secret20_DecryptedMessageMedia decryptedMessageMediaDocumentWithThumb:strongSelf.message.media.document.thumb.bytes thumb_w:@(msg.media.document.thumb.w) thumb_h:@(msg.media.document.thumb.h) file_name:[strongSelf.filePath lastPathComponent] mime_type:strongSelf.mimeType size:@(uploader.total_size) key:strongSelf.key iv:strongSelf.iv]; } else if(strongSelf.params.layer == 23) { - strongSelf.media = [Secret23_DecryptedMessageMedia decryptedMessageMediaDocumentWithThumb:strongSelf.message.media.document.thumb.bytes thumb_w:@(msg.media.document.thumb.w) thumb_h:@(msg.media.document.thumb.h) file_name:[strongSelf.filePath lastPathComponent] mime_type:strongSelf.mimeType size:@(uploader.total_size) key:strongSelf.key iv:strongSelf.iv]; + strongSelf.media = [Secret23_DecryptedMessageMedia decryptedMessageMediaDocumentWithThumb:strongSelf.message.media.document.thumb.bytes == nil ? [[NSData alloc] initWithEmptyBytes:16] : strongSelf.message.media.document.thumb.bytes thumb_w:@(msg.media.document.thumb.w) thumb_h:@(msg.media.document.thumb.h) file_name:[strongSelf.filePath lastPathComponent] mime_type:strongSelf.mimeType size:@(uploader.total_size) key:strongSelf.key iv:strongSelf.iv]; } } @@ -361,7 +364,6 @@ -(void)performRequest { [TGCache cacheImage:renderedImage(image, strongsizeWithMinMax(image.size, MIN_IMG_SIZE.height, MIN_IMG_SIZE.width)) forKey:newLocation.cacheKey groups:@[IMGCACHE]]; - [[Storage manager] insertMedia:strongSelf.message]; PreviewObject *previewObject = [[PreviewObject alloc] initWithMsdId:strongSelf.message.n_id media:strongSelf.message peer_id:strongSelf.message.peer_id]; diff --git a/TelegramTest/FileUtils.h b/TelegramTest/FileUtils.h index c64d5537..7d331ec0 100644 --- a/TelegramTest/FileUtils.h +++ b/TelegramTest/FileUtils.h @@ -8,7 +8,7 @@ #import #import - +#import "TelegramWindow.h" @interface OpenWithObject : NSObject @property (nonatomic, strong,readonly) NSString *fullname; @property (nonatomic, strong,readonly) NSURL *app; @@ -30,6 +30,7 @@ extern NSString *const TLHashTagPrefix; extern NSString *const TLBotCommandPrefix; extern NSString *const TGJoinGroupPrefix; extern NSString *const TGStickerPackPrefix; +extern NSString *const TGImportShareLinkPrefix; unsigned long fileSize(NSString *path); + (void)showPanelWithTypes:(NSArray *)types completionHandler:(void (^)(NSArray * result))handler; @@ -52,12 +53,13 @@ NSString* dp(); +(NSString *)documentName:(TLDocument *)document; + (NSString *)dataMD5:(NSData *)data; +TelegramWindow *appWindow(); NSArray * soundsList(); void playSentMessage(BOOL play); void open_link(NSString *link); void open_card(NSString *link); - +void share_link(NSString *url, NSString *text); NSString *exportPath(long randomId,NSString *extension); diff --git a/TelegramTest/FileUtils.m b/TelegramTest/FileUtils.m index a644aca4..ce87466d 100644 --- a/TelegramTest/FileUtils.m +++ b/TelegramTest/FileUtils.m @@ -18,6 +18,7 @@ #import "NSData+Extensions.h" #import "TGStickerPackModalView.h" #import "ComposeActionAddUserToGroupBehavior.h" +#import "TGHeadChatPanel.h" @implementation OpenWithObject -(id)initWithFullname:(NSString *)fullname app:(NSURL *)app icon:(NSImage *)icon { @@ -44,6 +45,7 @@ @implementation FileUtils NSString *const TGImagePType = @"TGImagePasteType"; NSString *const TGImportCardPrefix = @"tg://resolve?domain="; +NSString *const TGImportShareLinkPrefix = @"tg://msg_url?url="; NSString *const TGJoinGroupPrefix = @"tg://join?invite="; NSString *const TGStickerPackPrefix = @"tg://addstickers?set="; NSString *const TLUserNamePrefix = @"@"; @@ -122,7 +124,7 @@ + (void)showChooseFolderPanel:(void (^)(NSString * result))handler forWindow:(NS + (void)showPanelWithTypes:(NSArray *)types completionHandler:(void (^)(NSArray * paths))handler { - [self showPanelWithTypes:types completionHandler:handler forWindow:[NSApp mainWindow]]; + [self showPanelWithTypes:types completionHandler:handler forWindow:[NSApp keyWindow]]; } @@ -250,7 +252,7 @@ void alert(NSString *text, NSString *info) { [alert setAlertStyle:NSInformationalAlertStyle]; [alert setMessageText:text.length > 0 ? text : appName()]; [alert setInformativeText:info]; - [alert beginSheetModalForWindow:[[NSApp delegate] mainWindow] modalDelegate:nil didEndSelector:nil contextInfo:nil]; + [alert beginSheetModalForWindow:[NSApp keyWindow] modalDelegate:nil didEndSelector:nil contextInfo:nil]; }]; } @@ -330,14 +332,14 @@ + (NSString *)dataMD5:(NSData *)data { } void playSentMessage(BOOL play) { - static ASQueue *queue; +// static ASQueue *queue; +// +// static dispatch_once_t onceToken; +// dispatch_once(&onceToken, ^{ +// queue = [[ASQueue alloc] initWithName:"soundQueue"]; +// }); - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - queue = [[ASQueue alloc] initWithName:"soundQueue"]; - }); - - [queue dispatchOnQueue:^{ + // [queue dispatchOnQueue:^{ static NSSound *sound ; static dispatch_once_t onceToken; @@ -348,7 +350,7 @@ void playSentMessage(BOOL play) { }); if(play && [SettingsArchiver checkMaskedSetting:SoundEffects]) [sound play]; - }]; + // }]; } @@ -358,9 +360,26 @@ void playSentMessage(BOOL play) { } - - - +TelegramWindow *appWindow() { + + TelegramWindow *window = (TelegramWindow *) [NSApp keyWindow]; + + if(!window) + { + window = (TelegramWindow *)[Telegram delegate].mainWindow; + } + + if(![window isKindOfClass:[TelegramWindow class]]) { + window = [window respondsToSelector:@selector(window)] ? [window performSelector:@selector(window)] : window; + + if(![window isKindOfClass:[TelegramWindow class]]) { + window = (TelegramWindow *)[Telegram delegate].mainWindow; + } + + } + + return window; +} void open_card(NSString *link) { @@ -379,7 +398,12 @@ void open_card(NSString *link) { if(![response isKindOfClass:[TL_userEmpty class]]) { [[UsersManager sharedManager] add:@[response]]; - [[Telegram rightViewController] showUserInfoPage:[[UsersManager sharedManager] find:[(TLUser *)response n_id]]]; + + TLUser *user = [[UsersManager sharedManager] find:[(TLUser *)response n_id]]; + + [appWindow().navigationController showInfoPage:user.dialog]; + + } else { alert(NSLocalizedString(@"CardImport.ErrorTextUserNotExist", nil), NSLocalizedString(@"CardImport.ErrorDescUserNotExist", nil)); } @@ -413,8 +437,9 @@ void join_group_by_hash(NSString * hash) { if([response isKindOfClass:[TL_chatInviteAlready class]] && ![(TLChat *)[response chat] left]) { - [[Telegram rightViewController] showByDialog:[[DialogsManager sharedManager] findByChatId:[[response chat] n_id]] sender:nil]; - + [appWindow().navigationController showMessagesViewController:[[DialogsManager sharedManager] findByChatId:[[response chat] n_id]]]; + + [TMViewController hideModalProgress]; } else if([response isKindOfClass:[TL_chatInvite class]]) { @@ -430,9 +455,9 @@ void join_group_by_hash(NSString * hash) { if([response chats].count > 0) { TLChat *chat = [response chats][0]; - TL_conversation *conversation = [[DialogsManager sharedManager] createDialogForChat:chat]; + TL_conversation *conversation = chat.dialog; - [[Telegram rightViewController] showByDialog:conversation sender:nil]; + [appWindow().navigationController showMessagesViewController:conversation]; dispatch_after_seconds(0.2, ^{ @@ -483,9 +508,10 @@ void add_sticker_pack_by_name(TLInputStickerSet *set) { dispatch_after_seconds(0.2, ^{ TGStickerPackModalView *stickerModalView = [[TGStickerPackModalView alloc] init]; - [stickerModalView show:[Telegram delegate].mainWindow animated:YES]; - [stickerModalView setStickerPack:response]; + + [stickerModalView show:[Telegram delegate].mainWindow animated:YES]; + }); @@ -500,26 +526,39 @@ void add_sticker_pack_by_name(TLInputStickerSet *set) { void open_user_by_name(NSDictionary *params) { - __block TLUser *user = [UsersManager findUserByName:params[@"domain"]]; + __block id obj = [Telegram findObjectWithName:params[@"domain"]]; dispatch_block_t showConversation = ^ { - if(user.isBot && params[@"start"]) { - [[Telegram rightViewController] showByDialog:user.dialog sender:nil]; - [[Telegram rightViewController].messagesViewController showBotStartButton:params[@"start"] bot:user]; - } else if(user.isBot && params[@"startgroup"] && (user.flags & TGBOTGROUPBLOCKED) == 0) { - [[Telegram rightViewController] showComposeAddUserToGroup:[[ComposeAction alloc] initWithBehaviorClass:[ComposeActionAddUserToGroupBehavior class] filter:nil object:user reservedObjects:@[params]]]; - } else if(params[@"open_profile"]) { - [[Telegram rightViewController] showUserInfoPage:user]; + if([obj isKindOfClass:[TLUser class]]) { + + TLUser *user = obj; + + if(user.isBot && params[@"start"]) { + [appWindow().navigationController showMessagesViewController:user.dialog]; + [appWindow().navigationController.messagesViewController showBotStartButton:params[@"start"] bot:user]; + } else if(user.isBot && params[@"startgroup"] && (user.flags & TGBOTGROUPBLOCKED) == 0) { + [[Telegram rightViewController] showComposeAddUserToGroup:[[ComposeAction alloc] initWithBehaviorClass:[ComposeActionAddUserToGroupBehavior class] filter:nil object:user reservedObjects:@[params]]]; + } else if(params[@"open_profile"]) { + [appWindow().navigationController showInfoPage:user.dialog]; + } else { + [appWindow().navigationController showMessagesViewController:user.dialog]; + } } else { - [[Telegram rightViewController] showByDialog:user.dialog sender:nil]; + [appWindow().navigationController showMessagesViewController:((TLChat *)obj).dialog]; } + + }; - dispatch_block_t showInfo = ^ { - [[Telegram rightViewController] showUserInfoPage:user]; + + dispatch_block_t showInfo = ^{ + + [appWindow().navigationController showInfoPage:[obj dialog]]; + }; + dispatch_block_t perform = ^ { if(params[@"showProfile"]) @@ -529,27 +568,29 @@ void open_user_by_name(NSDictionary *params) { }; - if(user) { + if(obj) { perform(); } else { [TMViewController showModalProgress]; - [RPCRequest sendRequest:[TLAPI_contacts_resolveUsername createWithUsername:params[@"domain"]] successHandler:^(RPCRequest *request, TLUser *response) { + [RPCRequest sendRequest:[TLAPI_contacts_resolveUsername createWithUsername:params[@"domain"]] successHandler:^(RPCRequest *request, TL_contacts_resolvedPeer *response) { [TMViewController hideModalProgress]; + [SharedManager proccessGlobalResponse:response]; + dispatch_after_seconds(0.2,^ { - if(![response isKindOfClass:[TL_userEmpty class]]) { - - [[UsersManager sharedManager] add:@[response] withCustomKey:@"n_id" update:YES]; - - user = [[UsersManager sharedManager] find:response.n_id]; - - perform(); - + if([response.peer isKindOfClass:[TL_peerChannel class]]) { + obj = [response.chats firstObject]; + } else if([response.peer isKindOfClass:[TL_peerUser class]]) { + obj = [response.users firstObject]; + } + + if(obj) { + perform(); } else { alert(NSLocalizedString(@"UserNameExport.UserNameNotFound", nil), NSLocalizedString(@"UserNameExport.UserNameNotFoundDescription", nil)); } @@ -574,6 +615,10 @@ void open_user_by_name(NSDictionary *params) { } +void share_link(NSString *url, NSString *text) { + [[Telegram rightViewController] showShareLinkModalView:url text:text]; +} + void determinateURLLink(NSString *link) { @@ -584,6 +629,18 @@ void determinateURLLink(NSString *link) { return; } + if([link hasPrefix:TGImportShareLinkPrefix]) { + NSDictionary *vars = getUrlVars(link); + + if([vars[@"url"] length] > 0 && [vars[@"text"] length] > 0) { + share_link([vars[@"url"] stringByDecodingURLFormat], [vars[@"text"] stringByDecodingURLFormat]); + + [[NSApplication sharedApplication] activateIgnoringOtherApps:YES]; + [[[Telegram delegate] mainWindow] deminiaturize:[Telegram delegate]]; + return; + } + } + if([link hasPrefix:TGJoinGroupPrefix]) { join_group_by_hash([link substringFromIndex:TGJoinGroupPrefix.length]); [[NSApplication sharedApplication] activateIgnoringOtherApps:YES]; @@ -605,9 +662,31 @@ void open_link(NSString *link) { if([link hasPrefix:@"USER_PROFILE:"]) { - TLUser *user = [[UsersManager sharedManager] find:[[link substringFromIndex:@"USER_PROFILE:".length] intValue]]; + [TMInAppLinks parseUrlAndDo:link]; + + return; + } + + if([link hasPrefix:@"openWithPeer:"]) { - [[Telegram rightViewController] showUserInfoPage:user]; + NSString *peer_str = [link substringFromIndex:@"openWithPeer:".length]; + int peer_id = [[peer_str substringFromIndex:[peer_str rangeOfString:@":"].location+1] intValue]; + Class peer = NSClassFromString([peer_str substringToIndex:[peer_str rangeOfString:@":"].location]); + if(peer == [TL_peerUser class]) { + + TLUser *user = [[UsersManager sharedManager] find:peer_id]; + + TL_conversation *conversation = user.dialog; + + [appWindow().navigationController showInfoPage:conversation]; + + } else if(peer == [TL_peerChat class] || peer == [TL_peerChannel class]) { + + TLChat *chat = [[ChatsManager sharedManager] find:abs(peer_id)]; + + [appWindow().navigationController showMessagesViewController:chat.dialog]; + + } return; } @@ -650,7 +729,7 @@ void open_link(NSString *link) { if([link hasPrefix:TLBotCommandPrefix]) { - [[Telegram rightViewController].messagesViewController sendMessage:link forConversation:[Telegram conversation]]; + [appWindow().navigationController.messagesViewController sendMessage:link forConversation:[appWindow().navigationController.messagesViewController conversation]]; return; } diff --git a/TelegramTest/ForwardSenterItem.h b/TelegramTest/ForwardSenterItem.h index d2c7aee1..2fc93d4d 100644 --- a/TelegramTest/ForwardSenterItem.h +++ b/TelegramTest/ForwardSenterItem.h @@ -13,5 +13,5 @@ @property (nonatomic,strong) NSArray *tableItems; @property (nonatomic,strong) NSArray *fakes; @property (nonatomic,strong) NSArray *msg_ids; --(id)initWithMessages:(NSArray *)msgs forConversation:(TL_conversation *)conversation; +-(id)initWithMessages:(NSArray *)msgs forConversation:(TL_conversation *)conversation additionFlags:(int)additionFlags; @end diff --git a/TelegramTest/ForwardSenterItem.m b/TelegramTest/ForwardSenterItem.m index ad41ce3f..50efcca8 100644 --- a/TelegramTest/ForwardSenterItem.m +++ b/TelegramTest/ForwardSenterItem.m @@ -9,13 +9,13 @@ #import "ForwardSenterItem.h" #import "NSArray+BlockFiltering.h" #import "MessageTableItem.h" - +#import "TLPeer+Extensions.h" @interface ForwardSenterItem () - +@property (nonatomic,strong) TLInputPeer *from_peer; @end @@ -26,7 +26,7 @@ -(void)setState:(MessageState)state { } --(id)initWithMessages:(NSArray *)msgs forConversation:(TL_conversation *)conversation { +-(id)initWithMessages:(NSArray *)msgs forConversation:(TL_conversation *)conversation additionFlags:(int)additionFlags { if(self = [super init]) { self.conversation = conversation; @@ -44,11 +44,22 @@ -(id)initWithMessages:(NSArray *)msgs forConversation:(TL_conversation *)convers long random = rand_long(); - TLMessage *f = copy[i]; + TL_localMessage *f = copy[i]; + + [ids addObject:@([f n_id])]; - TL_localMessage *fake = [TL_localMessage createWithN_id:0 flags:TGOUTUNREADMESSAGE | TGFWDMESSAGE from_id:[UsersManager currentUserId] to_id:conversation.peer fwd_from_id:f.fwd_from_id == 0 ? f.from_id : f.fwd_from_id fwd_date:f.date reply_to_msg_id:0 date:[[MTNetwork instance] getTime] message:f.message media:f.media fakeId:[MessageSender getFakeMessageId] randomId:random reply_markup:nil state:DeliveryStatePending]; + TL_localMessage *fake = [TL_localMessage createWithN_id:0 flags:TGOUTUNREADMESSAGE | TGFWDMESSAGE from_id:[UsersManager currentUserId] to_id:conversation.peer fwd_from_id:[f.to_id isKindOfClass:[TL_peerChannel class]] && !f.chat.isMegagroup ? f.to_id : [f.fwd_from_id isKindOfClass:[TL_peerChannel class]] && !f.chat.isMegagroup ? f.fwd_from_id : [TL_peerUser createWithUser_id:f.fwd_from_id.user_id != 0 ? f.fwd_from_id.user_id : f.from_id] fwd_date:f.date reply_to_msg_id:0 date:[[MTNetwork instance] getTime] message:f.message media:f.media fakeId:[MessageSender getFakeMessageId] randomId:random reply_markup:nil entities:f.entities views:f.views isViewed:NO state:DeliveryStatePending]; + + + if([f.fwd_from_id isKindOfClass:[TL_peerChannel class]] || ([f.to_id isKindOfClass:[TL_peerChannel class]] && f.chat.isMegagroup)) { + _from_peer = [f.to_id inputPeer]; + } + + + if(additionFlags & (1 << 4)) + fake.from_id = 0; [fake save:i == copy.count-1]; @@ -67,6 +78,7 @@ -(id)initWithMessages:(NSArray *)msgs forConversation:(TL_conversation *)convers } + -(void)setTableItems:(NSArray *)tableItems { self->_tableItems = tableItems; for (MessageTableItem *item in tableItems) { @@ -83,11 +95,18 @@ -(void)performRequest { NSMutableArray *random_ids = [[NSMutableArray alloc] init]; + __block TLInputPeer *from_peer = _from_peer; + [self.fakes enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(TL_localMessage *obj, NSUInteger idx, BOOL *stop) { [random_ids addObject:@(obj.randomId)]; + + if(!from_peer) { + from_peer = [obj.fwd_from_id inputPeer]; + } + }]; - TLAPI_messages_forwardMessages *request = [TLAPI_messages_forwardMessages createWithPeer:self.conversation.inputPeer n_id:[self.msg_ids mutableCopy] random_id:random_ids]; + TLAPI_messages_forwardMessages *request = [TLAPI_messages_forwardMessages createWithFlags:[self senderFlags] from_peer:from_peer n_id:[self.msg_ids mutableCopy] random_id:random_ids to_peer:self.conversation.inputPeer]; self.rpc_request = [RPCRequest sendRequest:request successHandler:^(RPCRequest *request, TLUpdates *response) { @@ -102,7 +121,7 @@ -(void)performRequest { [response.updates enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - if([obj isKindOfClass:[TL_updateNewMessage class]]) { + if([obj isKindOfClass:[TL_updateNewMessage class]] || [obj isKindOfClass:[TL_updateNewChannelMessage class]]) { [messages addObject:[TL_localMessage convertReceivedMessage:(TL_localMessage *)[obj message]]]; } @@ -121,10 +140,6 @@ -(void)performRequest { fake.n_id = stated.n_id; fake.dstate = DeliveryStateNormal; - if([fake.media isKindOfClass:[TL_messageMediaPhoto class]] || [fake.media isKindOfClass:[TL_messageMediaVideo class]]) { - [[Storage manager] insertMedia:fake]; - } - [fake save:i == 0]; } @@ -138,4 +153,25 @@ -(void)performRequest { } +-(int)senderFlags { + + if(self.fakes.count > 0) { + + TL_localMessage *msg = [self.fakes firstObject]; + + int flags = 0; + + flags|=msg.from_id == 0 ? 1 << 4 : 0; + + return flags; + + } else + return [super senderFlags]; + +} + +-(void)updateMessageId:(TLUpdates *)updates { + +} + @end diff --git a/TelegramTest/FullChatManager.h b/TelegramTest/FullChatManager.h index 7993ee5a..902ff4e7 100644 --- a/TelegramTest/FullChatManager.h +++ b/TelegramTest/FullChatManager.h @@ -19,6 +19,7 @@ @property (nonatomic,assign) BOOL isLoad; @property (nonatomic,copy) void (^loadHandler)(void); +-(void)loadParticipantsWithMegagroupId:(int)chat_id; - (void)loadStored; diff --git a/TelegramTest/FullChatManager.m b/TelegramTest/FullChatManager.m index eccc6d88..ade340d0 100644 --- a/TelegramTest/FullChatManager.m +++ b/TelegramTest/FullChatManager.m @@ -160,34 +160,9 @@ - (void)loadStored { self.isLoad = YES; if(self.loadHandler) self.loadHandler(); - - [self loadChatFull]; }]; } -- (void)loadChatFull { -// [self.queue dispatchOnQueue:^{ -// NSArray *array =[[ChatsManager sharedManager] all]; -// NSMutableArray *needToLoad = [[NSMutableArray alloc] init]; -// for(TLChat *chat in array) { -// if([chat isKindOfClass:[TL_chat class]]) { -// if(![self find:chat.n_id]) { -// [needToLoad addObject:@(chat.n_id)]; -// } -// } -// } -// -// MTLog(@"need to load full chats%@", needToLoad); -// [self loadFullChats:needToLoad]; -// }]; -} - -- (void)loadFullChats:(NSArray *)array { - for(NSNumber *number in array) { - int chat_id = [number intValue]; - [self loadFullChatByChatId:chat_id force:NO]; - } -} - (void) loadIfNeed:(int)chat_id force:(BOOL)force { if(!self.isLoad) @@ -211,7 +186,7 @@ - (void)loadFullChatByChatId:(int)chat_id force:(BOOL)force callback:(void (^)(T TLChatFull *fullChat = [self find:chat_id]; if(fullChat ) { - if(callback != nil) + if(callback != nil && !force) callback(fullChat); if( (fullChat.lastUpdateTime + 300 > [[MTNetwork instance] getTime]) && !force) { return; @@ -219,8 +194,24 @@ - (void)loadFullChatByChatId:(int)chat_id force:(BOOL)force callback:(void (^)(T } + + TLChat *chat = [[ChatsManager sharedManager] find:chat_id]; + + if([chat isKindOfClass:[TL_channelForbidden class]] || [chat isKindOfClass:[TL_chatForbidden class]]) + return; + + id request; + + if([chat isKindOfClass:[TL_channel class]]) { + request = [TLAPI_channels_getFullChannel createWithChannel:chat.inputPeer]; + } else { + request = [TLAPI_messages_getFullChat createWithChat_id:chat.n_id]; + } + + + [RPCRequest sendRequest:request successHandler:^(RPCRequest *request, TL_messages_chatFull *result) { - [RPCRequest sendRequest:[TLAPI_messages_getFullChat createWithChat_id:chat_id] successHandler:^(RPCRequest *request, TL_messages_chatFull *result) { + [SharedManager proccessGlobalResponse:result]; if([result isKindOfClass:[TL_messages_chatFull class]]) { TL_conversation *conversation = [[DialogsManager sharedManager] findByChatId:chat_id]; @@ -230,33 +221,40 @@ - (void)loadFullChatByChatId:(int)chat_id force:(BOOL)force callback:(void (^)(T [conversation save]; } - [SharedManager proccessGlobalResponse:result]; - - [self.queue dispatchOnQueue:^{ - - [self add:@[[result full_chat]]]; - - TLChatFull *current = [self find:chat_id]; - - - - [current setLastLayerUpdated:YES]; - - [[Storage manager] insertFullChat:[result full_chat] completeHandler:nil]; - - + if(![result full_chat]) { [ASQueue dispatchOnMainQueue:^{ if(callback) callback([result full_chat]); }]; - + + return; + } + + + + [self add:@[[result full_chat]]]; + + TLChatFull *current = [self find:chat_id]; + + + + [current setLastLayerUpdated:YES]; + + [[Storage manager] insertFullChat:[result full_chat] completeHandler:nil]; + + + [ASQueue dispatchOnMainQueue:^{ + if(callback) + callback([result full_chat]); }]; } errorHandler:^(RPCRequest *request, RpcError *error) { ELog(@"fullchat loading error %@", error.error_msg); - if(callback) - callback(nil); - }]; + [ASQueue dispatchOnMainQueue:^{ + if(callback) + callback(fullChat); + }]; + } timeout:0 queue:self.queue.nativeQueue]; } @@ -273,7 +271,7 @@ - (int)getOnlineCount:(int)chat_id { FullChatMembersChecker *checker = [self.membersCheker objectForKey:@(chat_id)]; if(!checker) { TLChatFull *chatFull = [[FullChatManager sharedManager] find:chat_id]; - if(chatFull) { + if(chatFull && ![chatFull isKindOfClass:[TL_channelFull class]]) { checker = [[FullChatMembersChecker alloc] initWithFullChat:chatFull queue:self.queue]; [self.membersCheker setObject:checker forKey:@(chat_id)]; } @@ -294,7 +292,7 @@ - (void) add:(NSArray *)all { TLChatFull *currentChat = [self->keys objectForKey:@(newChatFull.n_id)]; if(currentChat) { - if(currentChat.participants.participants.count != newChatFull.participants.participants.count) { + if([currentChat isKindOfClass:[TL_chatFull class]] && currentChat.participants.participants.count != newChatFull.participants.participants.count) { currentChat.participants = newChatFull.participants; [Notification perform:CHAT_UPDATE_PARTICIPANTS data:@{KEY_CHAT_ID: @(currentChat.n_id), KEY_PARTICIPANTS: currentChat.participants}]; } @@ -302,25 +300,55 @@ - (void) add:(NSArray *)all { currentChat.lastUpdateTime = [[MTNetwork instance] getTime]; currentChat.exported_invite = newChatFull.exported_invite; currentChat.bot_info = newChatFull.bot_info; - + currentChat.migrated_from_chat_id = newChatFull.migrated_from_chat_id; + currentChat.migrated_from_max_id = newChatFull.migrated_from_max_id; + + if([currentChat isKindOfClass:[TL_channelFull class]] && (currentChat.participants_count != newChatFull.participants_count || currentChat.admins_count != newChatFull.admins_count || currentChat.kicked_count != newChatFull.kicked_count)) { + + currentChat.participants_count = newChatFull.participants_count; + currentChat.kicked_count = newChatFull.kicked_count; + currentChat.admins_count = newChatFull.admins_count; + + [Notification perform:CHAT_STATUS data:@{KEY_CHAT_ID: @(currentChat.n_id)}]; + + if(currentChat.chat) + [Notification perform:CHAT_UPDATE_PARTICIPANTS data:@{KEY_CHAT:currentChat.chat}]; + } + + } else { [self->keys setObject:newChatFull forKey:@(newChatFull.n_id)]; + [self->list addObject:newChatFull]; + + currentChat = newChatFull; + + if([currentChat isKindOfClass:[TL_channelFull class]]) { + [Notification perform:CHAT_STATUS data:@{KEY_CHAT_ID: @(currentChat.n_id)}]; + + if(currentChat.chat) + [Notification perform:CHAT_UPDATE_PARTICIPANTS data:@{KEY_CHAT:currentChat.chat}]; + } + if(currentChat.lastUpdateTime == 0) currentChat.lastUpdateTime = [[MTNetwork instance] getTime]; } - NSArray *copy = [currentChat.participants.participants copy]; - - for (TL_chatParticipant *user in copy) { - TLUser *find = [[UsersManager sharedManager] find:user.user_id]; + if([currentChat isKindOfClass:[TL_chatFull class]]) { + NSArray *copy = [currentChat.participants.participants copy]; - if([find isKindOfClass:[TL_userEmpty class]] || !find) { - [currentChat.participants.participants removeObject:user]; + for (TL_chatParticipant *user in copy) { + TLUser *find = [[UsersManager sharedManager] find:user.user_id]; + + if([find isKindOfClass:[TL_userEmpty class]] || !find) { + [currentChat.participants.participants removeObject:user]; + } } } + + if([newChatFull.participants isKindOfClass:[TL_chatParticipantsForbidden class]]) { } @@ -330,4 +358,33 @@ - (void) add:(NSArray *)all { } +-(void)loadParticipantsWithMegagroupId:(int)chat_id { + + + + TLChatFull *chatFull = [self find:chat_id]; + + if(chatFull.chat.isMegagroup && chatFull.chat.type != TLChatTypeForbidden) { + if(!chatFull.participants) + chatFull.participants = [TL_chatParticipants createWithChat_id:chat_id participants:[NSMutableArray array] version:0]; + + if(chatFull) { + int offset = (int) chatFull.participants.participants.count; + + [RPCRequest sendRequest:[TLAPI_channels_getParticipants createWithChannel:chatFull.chat.inputPeer filter:[TL_channelParticipantsRecent create] offset:offset limit:500] successHandler:^(id request, TL_channels_channelParticipants *response) { + + [SharedManager proccessGlobalResponse:response]; + + [chatFull.participants.participants addObjectsFromArray:response.participants]; + + + } errorHandler:^(id request, RpcError *error) { + + }]; + } + } + + +} + @end diff --git a/TelegramTest/FullUsersManager.m b/TelegramTest/FullUsersManager.m index 9b2c0fac..3bcaeee5 100644 --- a/TelegramTest/FullUsersManager.m +++ b/TelegramTest/FullUsersManager.m @@ -26,35 +26,30 @@ -(void)loadUserFull:(TL_user *)user callback:(void (^)(TL_userFull *userFull))ca TL_userFull *userFull = [self find:user.n_id]; if(userFull) { - // [ASQueue dispatchOnMainQueue:^{ - callback(userFull); - // }]; - if(![user needFullUpdate]) + if(user.bot_info_version == userFull.bot_info.version) { + if(callback != nil) + callback(userFull); return; + } else { + [self removeObjectWithKey:@(user.n_id)]; + } } - [ASQueue dispatchOnStageQueue:^{ + [RPCRequest sendRequest:[TLAPI_users_getFullUser createWithN_id:user.inputUser] successHandler:^(id request, id response) { - [RPCRequest sendRequest:[TLAPI_users_getFullUser createWithN_id:user.inputUser] successHandler:^(id request, id response) { - - - if(![response isKindOfClass:[TL_userEmpty class]]) { - [self add:@[response] withCustomKey:@"n_id"]; - - - } - - - [ASQueue dispatchOnMainQueue:^{ - [user fullUpdated]; - callback(response); - }]; - - } errorHandler:^(id request, RpcError *error) { - - } timeout:10 queue:[ASQueue globalQueue].nativeQueue]; + if(![response isKindOfClass:[TL_userEmpty class]]) { + [self add:@[response] withCustomKey:@"n_id"]; + } - }]; + [ASQueue dispatchOnMainQueue:^{ + [user fullUpdated]; + if(callback != nil) + callback(response); + }]; + + } errorHandler:^(id request, RpcError *error) { + + } timeout:10 queue:[ASQueue globalQueue].nativeQueue]; } diff --git a/TelegramTest/GeneralSettingsBlockHeaderView.h b/TelegramTest/GeneralSettingsBlockHeaderView.h index acf9e2dd..4388533f 100644 --- a/TelegramTest/GeneralSettingsBlockHeaderView.h +++ b/TelegramTest/GeneralSettingsBlockHeaderView.h @@ -7,11 +7,17 @@ // #import "TMRowView.h" - -@interface GeneralSettingsBlockHeaderItem : TMRowItem +#import "TGGeneralRowItem.h" +@interface GeneralSettingsBlockHeaderItem : TGGeneralRowItem @property (nonatomic,strong,readonly) NSAttributedString *header; -@property (nonatomic,assign) int height; @property (nonatomic,assign) BOOL isFlipped; +@property (nonatomic,assign) BOOL autoHeight; + +-(void)setTextColor:(NSColor *)textColor; +-(void)setFont:(NSFont *)font; +-(void)setAligment:(NSTextAlignment)aligment; + +-(id)initWithString:(NSString *)header height:(int)height flipped:(BOOL)flipped; @end diff --git a/TelegramTest/GeneralSettingsBlockHeaderView.m b/TelegramTest/GeneralSettingsBlockHeaderView.m index ab566939..22186fdd 100644 --- a/TelegramTest/GeneralSettingsBlockHeaderView.m +++ b/TelegramTest/GeneralSettingsBlockHeaderView.m @@ -9,30 +9,72 @@ #import "GeneralSettingsBlockHeaderView.h" @interface GeneralSettingsBlockHeaderItem () -@property (nonatomic,assign,readonly) int rand; + @end @implementation GeneralSettingsBlockHeaderItem --(id)initWithObject:(id)object { - if(self = [super initWithObject:object]) { - + + + + +-(id)initWithString:(NSString *)header height:(int)height flipped:(BOOL)flipped { + if(self = [super init]) { NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] init]; - [attr appendString:object withColor:GRAY_TEXT_COLOR]; - [attr setFont:[NSFont fontWithName:@"HelveticaNeue" size:12] forRange:attr.range]; + [attr appendString:header withColor:GRAY_TEXT_COLOR]; + [attr setFont:TGSystemFont(12) forRange:attr.range]; _header = attr; - _rand = arc4random(); + self.height = height; + _isFlipped = flipped; + self.drawsSeparator = NO; } return self; } --(NSUInteger)hash { - return _rand; +-(void)setAligment:(NSTextAlignment)aligment { + NSMutableAttributedString *attr = [_header mutableCopy]; + + [attr setAlignment:aligment range:attr.range]; + + _header = attr; } +-(void)setTextColor:(NSColor *)textColor { + NSMutableAttributedString *attr = [_header mutableCopy]; + + [attr addAttribute:NSForegroundColorAttributeName value:textColor range:attr.range]; + + _header = attr; +} + +-(void)setFont:(NSFont *)font { + NSMutableAttributedString *attr = [_header mutableCopy]; + + [attr addAttribute:NSFontAttributeName value:font range:attr.range]; + + _header = attr; + +} + +-(BOOL)updateItemHeightWithWidth:(int)width { + + if(_autoHeight) { + self.height = [_header sizeForTextFieldForWidth:width - (self.xOffset * 2)].height; + + return YES; + } + + return NO; +} + +-(Class)viewClass { + return [GeneralSettingsBlockHeaderView class]; +} + + @end @@ -61,12 +103,23 @@ -(id)initWithFrame:(NSRect)frameRect { return self; } +-(void)mouseDown:(NSEvent *)theEvent { + TGGeneralRowItem *item = (TGGeneralRowItem *) [self rowItem]; + + if(item.callback != nil) { + item.callback(item); + } + +} + + -(void)redrawRow { GeneralSettingsBlockHeaderItem *item = (GeneralSettingsBlockHeaderItem *)[self rowItem]; [self.textField setAttributedStringValue:item.header]; + } -(void)setFrameSize:(NSSize)newSize { @@ -74,15 +127,22 @@ -(void)setFrameSize:(NSSize)newSize { GeneralSettingsBlockHeaderItem *item = (GeneralSettingsBlockHeaderItem *)[self rowItem]; - NSSize s = [item.header sizeForTextFieldForWidth:NSWidth(self.frame) - 200]; + NSSize s = [item.header sizeForTextFieldForWidth:NSWidth(self.frame) - item.xOffset*2]; - [self.textField setFrameSize:NSMakeSize(NSWidth(self.frame) - 200, s.height )]; - [self.textField setFrameOrigin:NSMakePoint(100, item.isFlipped ? NSHeight(self.frame) - s.height : 0 )]; + [self.textField setFrameSize:NSMakeSize(NSWidth(self.frame) - item.xOffset*2, s.height )]; + [self.textField setFrameOrigin:NSMakePoint(item.xOffset - 2, item.isFlipped ? NSHeight(self.frame) - s.height : 2 )]; } - (void)drawRect:(NSRect)dirtyRect { [super drawRect:dirtyRect]; + GeneralSettingsBlockHeaderItem *item = (GeneralSettingsBlockHeaderItem *)[self rowItem]; + + if(item.drawsSeparator) { + [DIALOG_BORDER_COLOR set]; + NSRectFill(NSMakeRect(item.xOffset, 0, NSWidth(dirtyRect) - item.xOffset*2, DIALOG_BORDER_WIDTH)); + } + // Drawing code here. } diff --git a/TelegramTest/GeneralSettingsRowItem.h b/TelegramTest/GeneralSettingsRowItem.h index c5ae6026..326f4692 100644 --- a/TelegramTest/GeneralSettingsRowItem.h +++ b/TelegramTest/GeneralSettingsRowItem.h @@ -7,34 +7,28 @@ // #import "TMRowItem.h" +#import "TGGeneralRowItem.h" +@interface GeneralSettingsRowItem : TGGeneralRowItem -@interface GeneralSettingsRowItem : TMRowItem -typedef enum -{ - SettingsRowItemTypeSwitch, - SettingsRowItemTypeChoice, - SettingsRowItemTypeNext, - SettingsRowItemTypeSelected -} SettingsRowItemType; -@property (nonatomic,assign,readonly) SettingsRowItemType type; -@property (nonatomic,strong,readonly) void (^callback)(GeneralSettingsRowItem *item); -@property (nonatomic,strong,readonly) id (^stateback)(GeneralSettingsRowItem *item); +@property (nonatomic,strong) NSColor *textColor; @property (nonatomic,strong) NSMenu *menu; +@property (nonatomic,assign, getter=isEnabled) BOOL enabled; @property (nonatomic,strong,readonly,getter=description) NSString *desc; @property (nonatomic,strong) NSString *subdesc; -@property (nonatomic,assign) int height; + @property (nonatomic,assign) BOOL locked; --(id)initWithType:(SettingsRowItemType)type callback:(void (^)(GeneralSettingsRowItem *item))callback description:(NSString *)description height:(int)height stateback:(id (^)(GeneralSettingsRowItem *item))stateback; +-(id)initWithType:(SettingsRowItemType)type callback:(void (^)(TGGeneralRowItem *item))callback description:(NSString *)description height:(int)height stateback:(id (^)(TGGeneralRowItem *item))stateback; + +-(id)initWithType:(SettingsRowItemType)type callback:(void (^)(TGGeneralRowItem *item))callback description:(NSString *)description subdesc:(NSString *)subdesc height:(int)height stateback:(id (^)(TGGeneralRowItem *item))stateback; --(id)initWithType:(SettingsRowItemType)type callback:(void (^)(GeneralSettingsRowItem *item))callback description:(NSString *)description subdesc:(NSString *)subdesc height:(int)height stateback:(id (^)(GeneralSettingsRowItem *item))stateback; @end diff --git a/TelegramTest/GeneralSettingsRowItem.m b/TelegramTest/GeneralSettingsRowItem.m index 8eba2c5e..727455b0 100644 --- a/TelegramTest/GeneralSettingsRowItem.m +++ b/TelegramTest/GeneralSettingsRowItem.m @@ -10,26 +10,25 @@ #import "GeneralSettingsRowItem.h" @interface GeneralSettingsRowItem () -@property (nonatomic,assign) int rand; @end @implementation GeneralSettingsRowItem --(id)initWithType:(SettingsRowItemType)type callback:(void (^)(GeneralSettingsRowItem *item))callback description:(NSString *)description height:(int)height stateback:(id (^)(GeneralSettingsRowItem *item))stateback { - if(self = [super init]) { - _type = type; - _callback = callback; + +-(id)initWithType:(SettingsRowItemType)type callback:(void (^)(TGGeneralRowItem *item))callback description:(NSString *)description height:(int)height stateback:(id (^)(TGGeneralRowItem *item))stateback { + if(self = [super initWithHeight:height]) { + self.type = type; + self.callback = callback; _desc = description; - _height = height; - _rand = arc4random(); - _stateback = stateback; + self.stateback = stateback; + _enabled = YES; } return self; } --(id)initWithType:(SettingsRowItemType)type callback:(void (^)(GeneralSettingsRowItem *item))callback description:(NSString *)description subdesc:(NSString *)subdesc height:(int)height stateback:(id (^)(GeneralSettingsRowItem *item))stateback { +-(id)initWithType:(SettingsRowItemType)type callback:(void (^)(TGGeneralRowItem *item))callback description:(NSString *)description subdesc:(NSString *)subdesc height:(int)height stateback:(id (^)(TGGeneralRowItem *item))stateback { if(self = [self initWithType:type callback:callback description:description height:height stateback:stateback]) { _subdesc = subdesc; } @@ -38,8 +37,8 @@ -(id)initWithType:(SettingsRowItemType)type callback:(void (^)(GeneralSettingsRo } --(NSUInteger)hash { - return _rand; +-(Class)viewClass { + return NSClassFromString(@"GeneralSettingsRowView"); } @end diff --git a/TelegramTest/GeneralSettingsRowView.m b/TelegramTest/GeneralSettingsRowView.m index 405e766c..700a4968 100644 --- a/TelegramTest/GeneralSettingsRowView.m +++ b/TelegramTest/GeneralSettingsRowView.m @@ -30,13 +30,13 @@ -(id)initWithFrame:(NSRect)frameRect { self.subdescField = [[BTRButton alloc] initWithFrame:NSMakeRect(0, 0, 200, 20)]; self.nextDesc = [TMTextField defaultTextField]; - [self.nextDesc setFont:[NSFont fontWithName:@"HelveticaNeue-Light" size:14]]; + [self.nextDesc setFont:TGSystemLightFont(14)]; self.nextDesc.textColor = GRAY_TEXT_COLOR; + _nextDesc.alignment = NSRightTextAlignment; - - [self.descriptionField setFont:[NSFont fontWithName:@"HelveticaNeue-Light" size:14]]; - [self.subdescField setTitleFont:[NSFont fontWithName:@"HelveticaNeue" size:14] forControlState:BTRControlStateNormal]; + [self.descriptionField setFont:TGSystemLightFont(14)]; + [self.subdescField setTitleFont:TGSystemFont(14) forControlState:BTRControlStateNormal]; self.descriptionField.textColor = DARK_BLACK; @@ -85,12 +85,18 @@ -(id)initWithFrame:(NSRect)frameRect { return self; } +-(void)mouseUp:(NSEvent *)theEvent { + [super mouseUp:theEvent]; +} + + -(void)mouseDown:(NSEvent *)theEvent { - GeneralSettingsRowItem *item = (GeneralSettingsRowItem *) [self rowItem]; + TGGeneralRowItem *item = (GeneralSettingsRowItem *) [self rowItem]; - if(item.type == SettingsRowItemTypeNext || item.type == SettingsRowItemTypeSelected) { + if(item.type == SettingsRowItemTypeNext || item.type == SettingsRowItemTypeSelected || item.type == SettingsRowItemTypeNone) { item.callback(item); } + } @@ -100,11 +106,13 @@ -(void)redrawRow { [self.descriptionField setStringValue:item.description]; + [self.descriptionField setTextColor:item.textColor ? item.textColor : TEXT_COLOR]; + [self.nextDesc setStringValue:item.subdesc]; [self.nextDesc sizeToFit]; - + [self.switchControl setEnabled:item.isEnabled]; [self.switchControl setDidChangeHandler:^(BOOL isOn) { item.callback(item); @@ -140,7 +148,14 @@ -(void)redrawRow { [self.switchControl setHidden:YES]; [self.nextImage setHidden:YES]; [self.selectedImageView setHidden:![item.stateback(item) boolValue] || item.locked]; - [self.nextDesc setHidden:YES]; + [self.nextDesc setHidden:YES]; + break; + case SettingsRowItemTypeNone: + [self.subdescField setHidden:YES]; + [self.switchControl setHidden:YES]; + [self.nextImage setHidden:YES]; + [self.selectedImageView setHidden:YES]; + [self.nextDesc setHidden:YES]; default: break; } @@ -156,35 +171,57 @@ -(void)redrawRow { [self.descriptionField sizeToFit]; [self.subdescField.titleLabel sizeToFit]; [self.subdescField setFrameSize:self.subdescField.titleLabel.frame.size]; - + [_nextDesc sizeToFit]; } -(void)setFrameSize:(NSSize)newSize { [super setFrameSize:newSize]; - [self.subdescField setFrameOrigin:NSMakePoint(NSWidth(self.frame) - 100 - NSWidth(self.subdescField.frame), 10)]; - [self.switchControl setFrameOrigin:NSMakePoint(NSWidth(self.frame) - 100 - NSWidth(self.switchControl.frame), 10)]; + TGGeneralRowItem *item = (TGGeneralRowItem *) [self rowItem]; - [self.selectedImageView setFrameOrigin:NSMakePoint(NSWidth(self.frame) - 100 - NSWidth(self.selectedImageView.frame), 10)]; + [self.descriptionField setFrameOrigin:NSMakePoint( item.xOffset - 2, 12)]; - [self.nextImage setFrameOrigin:NSMakePoint(NSWidth(self.frame) - 100 - image_ArrowGrey().size.width - 4, 14)]; + [self.subdescField setFrameOrigin:NSMakePoint(NSWidth(self.frame) - item.xOffset - NSWidth(self.subdescField.frame), 13)]; - [self.nextDesc setFrameOrigin:NSMakePoint(NSWidth(self.frame) - 100 - NSWidth(self.nextImage.frame) - NSWidth(self.nextDesc.frame) - 8, 13)]; + [self.switchControl setFrameOrigin:NSMakePoint(NSWidth(self.frame) - item.xOffset - NSWidth(self.switchControl.frame), 10)]; - [self.lockedIndicator setFrameOrigin:NSMakePoint(NSWidth(self.frame) - 100 - NSWidth(self.lockedIndicator.frame), 10)]; + [self.selectedImageView setFrameOrigin:NSMakePoint(NSWidth(self.frame) - item.xOffset - NSWidth(self.selectedImageView.frame), 10)]; - [self.descriptionField setFrameSize:NSMakeSize(NSWidth(self.frame) - 250, NSHeight(self.descriptionField.frame))]; + [self.nextImage setFrameOrigin:NSMakePoint(NSWidth(self.frame) - item.xOffset - image_ArrowGrey().size.width - 4, 14)]; + + [self.lockedIndicator setFrameOrigin:NSMakePoint(NSWidth(self.frame) - item.xOffset - NSWidth(self.lockedIndicator.frame), 10)]; + + [self.descriptionField setFrameSize:NSMakeSize(MIN(NSWidth(self.descriptionField.frame), NSWidth(self.frame) - (item.xOffset * 2 + 100) ), NSHeight(self.descriptionField.frame))]; + + + [self.nextDesc setFrameSize:NSMakeSize(NSWidth(self.frame) - (item.xOffset * 2 + 50 + NSWidth(_descriptionField.frame)), NSHeight(self.nextDesc.frame))]; + [self.nextDesc setFrameOrigin:NSMakePoint(NSWidth(self.frame) - item.xOffset - NSWidth(self.nextImage.frame) - NSWidth(self.nextDesc.frame) - 8, 13)]; } - (void)drawRect:(NSRect)dirtyRect { [super drawRect:dirtyRect]; - [NSColorFromRGB(0xe0e0e0) setFill]; - NSRectFill(NSMakeRect(100, 0, NSWidth(self.frame) - 200, 1)); + + TGGeneralRowItem *item = (TGGeneralRowItem *) [self rowItem]; + + if(item.drawsSeparator) { + [NSColorFromRGB(0xe0e0e0) setFill]; + + NSRectFill(NSMakeRect(item.xOffset, 0, NSWidth(self.frame) - item.xOffset * 2, 1)); + } + + if(item.type == SettingsRowItemTypeNext && item.stateback != nil) { + NSImage *image = item.stateback(item); + + if([image isKindOfClass:[NSImage class]]) { + [image drawInRect:NSMakeRect(NSWidth(self.frame) - item.xOffset - image_ArrowGrey().size.width - image.size.width - 8, 13 , image.size.width, image.size.height) fromRect:NSZeroRect operation:NSCompositeHighlight fraction:1]; + } + } + } @end diff --git a/TelegramTest/GeneralSettingsViewController.m b/TelegramTest/GeneralSettingsViewController.m index c2a7226a..34df65a1 100644 --- a/TelegramTest/GeneralSettingsViewController.m +++ b/TelegramTest/GeneralSettingsViewController.m @@ -39,154 +39,127 @@ -(void)loadView { [SettingsArchiver addEventListener:self]; - - GeneralSettingsBlockHeaderItem *autoPhotoHeader = [[GeneralSettingsBlockHeaderItem alloc] initWithObject:NSLocalizedString(@"GeneralSettings.AutoVideoDownloadHeader", nil)]; - - autoPhotoHeader.height = 61; - - [self.tableView insert:autoPhotoHeader atIndex:self.tableView.list.count tableRedraw:NO]; - - - - GeneralSettingsRowItem *autoPhotoDownloadGroup = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSwitch callback:^(GeneralSettingsRowItem *item) { - - [SettingsArchiver addOrRemoveSetting:AutoGroupVideo]; - - } description:NSLocalizedString(@"Settings.Groups", nil) height:42 stateback:^id(GeneralSettingsRowItem *item) { - return @([SettingsArchiver checkMaskedSetting:AutoGroupVideo]); - }]; - - [self.tableView insert:autoPhotoDownloadGroup atIndex:self.tableView.list.count tableRedraw:NO]; - - - GeneralSettingsRowItem *autoPhotoDownloadPrivate = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSwitch callback:^(GeneralSettingsRowItem *item) { - - [SettingsArchiver addOrRemoveSetting:AutoPrivateVideo]; - - } description:NSLocalizedString(@"Settings.PrivateChats", nil) height:42 stateback:^id(GeneralSettingsRowItem *item) { - return @([SettingsArchiver checkMaskedSetting:AutoPrivateVideo]); - }]; - - [self.tableView insert:autoPhotoDownloadPrivate atIndex:self.tableView.list.count tableRedraw:NO]; - - - //photo end - - - - //audio - - GeneralSettingsBlockHeaderItem *autoAudioHeader = [[GeneralSettingsBlockHeaderItem alloc] initWithObject:NSLocalizedString(@"GeneralSettings.AutoAudioDownloadHeader", nil)]; - - autoAudioHeader.height = 51; - - [self.tableView insert:autoAudioHeader atIndex:self.tableView.list.count tableRedraw:NO]; - - - - - GeneralSettingsRowItem *autoAudioDownloadGroup = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSwitch callback:^(GeneralSettingsRowItem *item) { - - [SettingsArchiver addOrRemoveSetting:AutoGroupAudio]; - - } description:NSLocalizedString(@"Settings.Groups", nil) height:42 stateback:^id(GeneralSettingsRowItem *item) { - return @([SettingsArchiver checkMaskedSetting:AutoGroupAudio]); - }]; - - [self.tableView insert:autoAudioDownloadGroup atIndex:self.tableView.list.count tableRedraw:NO]; - - - GeneralSettingsRowItem *autoAudioDownloadPrivate = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSwitch callback:^(GeneralSettingsRowItem *item) { - - [SettingsArchiver addOrRemoveSetting:AutoPrivateAudio]; - - } description:NSLocalizedString(@"Settings.PrivateChats", nil) height:42 stateback:^id(GeneralSettingsRowItem *item) { - return @([SettingsArchiver checkMaskedSetting:AutoPrivateAudio]); - }]; - - [self.tableView insert:autoAudioDownloadPrivate atIndex:self.tableView.list.count tableRedraw:NO]; - - - GeneralSettingsBlockHeaderItem *notificationsHeader = [[GeneralSettingsBlockHeaderItem alloc] initWithObject:NSLocalizedString(@"Settings.MessageNotificationsHeader", nil)]; - - notificationsHeader.height = 61; - - [self.tableView insert:notificationsHeader atIndex:self.tableView.list.count tableRedraw:NO]; - - GeneralSettingsRowItem *soundEffects = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(GeneralSettingsRowItem *item) { - - //[SettingsArchiver addOrRemoveSetting:PushNotifications]; - - [[Telegram rightViewController] showNotificationSettingsViewController]; - - - } description:NSLocalizedString(@"Notifications", nil) height:42 stateback:^id(GeneralSettingsRowItem *item) { - return @([SettingsArchiver checkMaskedSetting:PushNotifications]); - }]; - - [self.tableView insert:soundEffects atIndex:self.tableView.list.count tableRedraw:NO]; - - -// GeneralSettingsRowItem *soundNotification = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeChoice callback:^(GeneralSettingsRowItem *item) { +// +// GeneralSettingsBlockHeaderItem *autoPhotoHeader = [[GeneralSettingsBlockHeaderItem alloc] initWithObject:NSLocalizedString(@"GeneralSettings.AutoVideoDownloadHeader", nil)]; +// +// autoPhotoHeader.height = 61; +// +// [self.tableView insert:autoPhotoHeader atIndex:self.tableView.list.count tableRedraw:NO]; +// +// +// +// GeneralSettingsRowItem *autoPhotoDownloadGroup = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSwitch callback:^(TGGeneralRowItem *item) { // -// } description:NSLocalizedString(@"Settings.NotificationTone", nil) height:42 stateback:^id(GeneralSettingsRowItem *item) { -// return NSLocalizedString([SettingsArchiver soundNotification], nil); +// [SettingsArchiver addOrRemoveSetting:AutoGroupVideo]; +// +// } description:NSLocalizedString(@"Settings.Groups", nil) height:42 stateback:^id(TGGeneralRowItem *item) { +// return @([SettingsArchiver checkMaskedSetting:AutoGroupVideo]); // }]; // +// [self.tableView insert:autoPhotoDownloadGroup atIndex:self.tableView.list.count tableRedraw:NO]; +// +// +// GeneralSettingsRowItem *autoPhotoDownloadPrivate = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSwitch callback:^(TGGeneralRowItem *item) { +// +// [SettingsArchiver addOrRemoveSetting:AutoPrivateVideo]; +// +// } description:NSLocalizedString(@"Settings.PrivateChats", nil) height:42 stateback:^id(TGGeneralRowItem *item) { +// return @([SettingsArchiver checkMaskedSetting:AutoPrivateVideo]); +// }]; // +// [self.tableView insert:autoPhotoDownloadPrivate atIndex:self.tableView.list.count tableRedraw:NO]; // // +// //photo end // // -// NSMenu *menu = [[NSMenu alloc] initWithTitle:@""]; // -// NSArray *list = soundsList(); +// //audio // -// for (int i = 0; i < list.count; i++) { +// GeneralSettingsBlockHeaderItem *autoAudioHeader = [[GeneralSettingsBlockHeaderItem alloc] initWithObject:NSLocalizedString(@"GeneralSettings.AutoAudioDownloadHeader", nil)]; +// +// autoAudioHeader.height = 51; +// +// [self.tableView insert:autoAudioHeader atIndex:self.tableView.list.count tableRedraw:NO]; +// +// +// +// +// GeneralSettingsRowItem *autoAudioDownloadGroup = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSwitch callback:^(TGGeneralRowItem *item) { // -// NSMenuItem *item = [NSMenuItem menuItemWithTitle:NSLocalizedString(list[i], nil) withBlock:^(NSMenuItem *sender) { -// -// if([sender.title isEqualToString:NSLocalizedString(@"DefaultSoundName", nil)]) -// [SettingsArchiver setSoundNotification:@"DefaultSoundName"]; -// else -// [SettingsArchiver setSoundNotification:sender.title]; -// -// [self.tableView reloadData]; -// -// }]; +// [SettingsArchiver addOrRemoveSetting:AutoGroupAudio]; // +// } description:NSLocalizedString(@"Settings.Groups", nil) height:42 stateback:^id(TGGeneralRowItem *item) { +// return @([SettingsArchiver checkMaskedSetting:AutoGroupAudio]); +// }]; +// +// [self.tableView insert:autoAudioDownloadGroup atIndex:self.tableView.list.count tableRedraw:NO]; +// +// +// GeneralSettingsRowItem *autoAudioDownloadPrivate = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSwitch callback:^(TGGeneralRowItem *item) { // +// [SettingsArchiver addOrRemoveSetting:AutoPrivateAudio]; // -// [menu addItem:item]; -// } +// } description:NSLocalizedString(@"Settings.PrivateChats", nil) height:42 stateback:^id(TGGeneralRowItem *item) { +// return @([SettingsArchiver checkMaskedSetting:AutoPrivateAudio]); +// }]; // -// soundNotification.menu = menu; +// [self.tableView insert:autoAudioDownloadPrivate atIndex:self.tableView.list.count tableRedraw:NO]; + + +// GeneralSettingsBlockHeaderItem *notificationsHeader = [[GeneralSettingsBlockHeaderItem alloc] initWithObject:NSLocalizedString(@"Settings.MessageNotificationsHeader", nil)]; +// +// notificationsHeader.height = 61; +// +// [self.tableView insert:notificationsHeader atIndex:self.tableView.list.count tableRedraw:NO]; +// + // -// [self.tableView insert:soundNotification atIndex:self.tableView.list.count tableRedraw:NO]; + GeneralSettingsBlockHeaderItem *chatSettingsHeader = [[GeneralSettingsBlockHeaderItem alloc] initWithObject:NSLocalizedString(@"Settings.ChatSettingsHeader", nil)]; - chatSettingsHeader.height = 61; + chatSettingsHeader.height = 42; [self.tableView insert:chatSettingsHeader atIndex:self.tableView.list.count tableRedraw:NO]; - //audio end - GeneralSettingsRowItem *emojiReplaces = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSwitch callback:^(GeneralSettingsRowItem *item) { - [SettingsArchiver addOrRemoveSetting:EmojiReplaces]; - } description:NSLocalizedString(@"Settings.EmojiReplaces", nil) height:42 stateback:^id(GeneralSettingsRowItem *item) { - return @([SettingsArchiver checkMaskedSetting:EmojiReplaces]); + + + + + GeneralSettingsRowItem *soundNotification = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSwitch callback:^(TGGeneralRowItem *item) { + + + [SettingsArchiver addOrRemoveSetting:SoundEffects]; + + } description:NSLocalizedString(@"Settings.SoundEffects", nil) height:42 stateback:^id(TGGeneralRowItem *item) { + return @([SettingsArchiver checkMaskedSetting:SoundEffects]); }]; - [self.tableView insert:emojiReplaces atIndex:self.tableView.list.count tableRedraw:NO]; + + + [self.tableView insert:soundNotification atIndex:self.tableView.list.count tableRedraw:NO]; + + //audio end +// +// GeneralSettingsRowItem *emojiReplaces = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSwitch callback:^(TGGeneralRowItem *item) { +// [SettingsArchiver addOrRemoveSetting:EmojiReplaces]; +// } description:NSLocalizedString(@"Settings.EmojiReplaces", nil) height:42 stateback:^id(TGGeneralRowItem *item) { +// return @([SettingsArchiver checkMaskedSetting:EmojiReplaces]); +// }]; +// +// [self.tableView insert:emojiReplaces atIndex:self.tableView.list.count tableRedraw:NO]; +// + - GeneralSettingsRowItem *bigFong = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSwitch callback:^(GeneralSettingsRowItem *item) { + GeneralSettingsRowItem *bigFong = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSwitch callback:^(TGGeneralRowItem *item) { [SettingsArchiver addOrRemoveSetting:BigFontSetting]; [[Telegram rightViewController].messagesViewController reloadData]; - } description:NSLocalizedString(@"Settings.BigFont", nil) height:42 stateback:^id(GeneralSettingsRowItem *item) { + } description:NSLocalizedString(@"Settings.BigFont", nil) height:42 stateback:^id(TGGeneralRowItem *item) { return @([SettingsArchiver checkMaskedSetting:BigFontSetting]); }]; @@ -196,58 +169,73 @@ -(void)loadView { - GeneralSettingsRowItem *stickers = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(GeneralSettingsRowItem *item) { + GeneralSettingsRowItem *stickers = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(TGGeneralRowItem *item) { [[Telegram rightViewController] showStickerSettingsController]; // [[Telegram mainViewController].settingsWindowController showWindowWithAction:SettingsWindowActionChatSettings]; - } description:NSLocalizedString(@"Settings.Stickers", nil) height:42 stateback:^id(GeneralSettingsRowItem *item) { + } description:NSLocalizedString(@"Settings.Stickers", nil) height:42 stateback:^id(TGGeneralRowItem *item) { return nil; }]; [self.tableView insert:stickers atIndex:self.tableView.list.count tableRedraw:NO]; + + + + GeneralSettingsBlockHeaderItem *advancedHeader = [[GeneralSettingsBlockHeaderItem alloc] initWithObject:NSLocalizedString(@"Settings.AdvancedSettingsHeader", nil)]; + + advancedHeader.height = 61; + + [self.tableView insert:advancedHeader atIndex:self.tableView.list.count tableRedraw:NO]; - GeneralSettingsRowItem *cache = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(GeneralSettingsRowItem *item) { + + + + + + GeneralSettingsRowItem *advancedSettings = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(TGGeneralRowItem *item) { + + [[Telegram mainViewController].settingsWindowController showWindowWithAction:SettingsWindowActionChatSettings]; + + } description:NSLocalizedString(@"Settings.AdvancedSettings", nil) height:42 stateback:^id(TGGeneralRowItem *item) { + return nil; + }]; + + [self.tableView insert:advancedSettings atIndex:self.tableView.list.count tableRedraw:NO]; + + + GeneralSettingsRowItem *cache = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(TGGeneralRowItem *item) { [[Telegram rightViewController] showCacheSettingsViewController]; - } description:NSLocalizedString(@"Settings.Cache", nil) height:42 stateback:^id(GeneralSettingsRowItem *item) { + } description:NSLocalizedString(@"Settings.Cache", nil) height:42 stateback:^id(TGGeneralRowItem *item) { return nil; }]; [self.tableView insert:cache atIndex:self.tableView.list.count tableRedraw:NO]; -// GeneralSettingsRowItem *securitySettings = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(GeneralSettingsRowItem *item) { -// -// [[Telegram rightViewController] showSecuritySettings]; -// -// } description:NSLocalizedString(@"Settings.SecuritySettings", nil) height:42 stateback:^id(GeneralSettingsRowItem *item) { -// return nil; -// }]; -// -// [self.tableView insert:securitySettings atIndex:self.tableView.list.count tableRedraw:NO]; - - - GeneralSettingsRowItem *advancedSettings = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(GeneralSettingsRowItem *item) { + GeneralSettingsRowItem *mutedChatsInUnreadCount = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSwitch callback:^(TGGeneralRowItem *item) { - [[Telegram mainViewController].settingsWindowController showWindowWithAction:SettingsWindowActionChatSettings]; + [SettingsArchiver addOrRemoveSetting:IncludeMutedUnreadCount]; - } description:NSLocalizedString(@"Settings.AdvancedSettings", nil) height:42 stateback:^id(GeneralSettingsRowItem *item) { - return nil; + [MessagesManager updateUnreadBadge]; + + } description:NSLocalizedString(@"Settings.IncludeMutedUnread", nil) height:42 stateback:^id(TGGeneralRowItem *item) { + return @([SettingsArchiver checkMaskedSetting:IncludeMutedUnreadCount]); }]; - [self.tableView insert:advancedSettings atIndex:self.tableView.list.count tableRedraw:NO]; + [self.tableView insert:mutedChatsInUnreadCount atIndex:self.tableView.list.count tableRedraw:NO]; #ifdef TGDEBUG - GeneralSettingsRowItem *sendLogs = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(GeneralSettingsRowItem *item) { + GeneralSettingsRowItem *sendLogs = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(TGGeneralRowItem *item) { - confirm(appName(), @"Are You sure to send logs developer? Please, don't press 'ok', if you not have problems with application", ^{ + confirm(appName(), @"Are you sure you want to send your logs to the developer? Please do this only if you have a problem with the application and a support volunteer asked you to send logs.", ^{ [Telegram sendLogs]; @@ -255,18 +243,46 @@ -(void)loadView { }); - - - - - - } description:@"Send logs" height:42 stateback:^id(GeneralSettingsRowItem *item) { + } description:@"Send logs" height:42 stateback:^id(TGGeneralRowItem *item) { return nil; }]; [self.tableView insert:sendLogs atIndex:self.tableView.list.count tableRedraw:NO]; + + if(ACCEPT_FEATURE) { + + GeneralSettingsRowItem *switchBackend = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(TGGeneralRowItem *item) { + + + confirm(appName(), @"Are You sure to switch backend?", ^{ + + dispatch_async(dispatch_get_main_queue(), ^{ + BOOL value = [[NSUserDefaults standardUserDefaults] boolForKey:@"test-backend"]; + + [[NSUserDefaults standardUserDefaults] setBool:!value forKey:@"test-backend"]; + + NSMutableArray *array = [NSMutableArray array]; + + array[1] = array[2]; + }); + + + }, ^{ + + }); + + } description:@"Switch backend" height:42 stateback:^id(TGGeneralRowItem *item) { + return nil; + }]; + + [self.tableView insert:switchBackend atIndex:self.tableView.list.count tableRedraw:NO]; + + + } + + #endif [self.tableView reloadData]; diff --git a/TelegramTest/HistoryFilter.h b/TelegramTest/HistoryFilter.h index 66a2a6ce..9469ad54 100644 --- a/TelegramTest/HistoryFilter.h +++ b/TelegramTest/HistoryFilter.h @@ -7,6 +7,8 @@ // #import +#import "TLPeer+Extensions.h" + @class ChatHistoryController; @@ -24,33 +26,79 @@ typedef enum { HistoryFilterContact = 1 << 8, HistoryFilterSearch = 1 << 9, HistoryFilterAudioDocument = 1 << 10, - HistoryFilterSharedLink = 1 << 11 + HistoryFilterSharedLink = 1 << 11, + HistoryFilterChannelMessage = 1 << 12, + HistoryFilterImportantChannelMessage = 1 << 13 } HistoryFilterType; +typedef enum { + ChatHistoryStateCache = 0, + ChatHistoryStateLocal = 1, + ChatHistoryStateRemote = 2, + ChatHistoryStateFull = 3 +} ChatHistoryState; + + + +@property (nonatomic,assign) ChatHistoryState prevState; +@property (nonatomic,assign) ChatHistoryState nextState; + @property (nonatomic,weak) ChatHistoryController *controller; +@property (nonatomic,strong,readonly) TLPeer *peer; + +-(id)initWithController:(ChatHistoryController *)controller peer:(TLPeer *)peer; + +-(int)max_id; +-(int)min_id; +-(int)server_max_id; +-(int)server_min_id; +-(int)minDate; +-(int)maxDate; --(id)initWithController:(ChatHistoryController *)controller; +-(int)selectLimit; -- (NSMutableDictionary *)messageKeys:(int)peer_id; -- (NSMutableArray *)messageItems:(int)peer_id; +-(NSArray *)filterAndAdd:(NSArray *)items latest:(BOOL)latest; +-(NSArray *)proccessResponse:(NSArray *)result state:(ChatHistoryState)state next:(BOOL)next; -+ (NSMutableDictionary *)messageKeys:(int)peer_id; -+ (NSMutableArray *)messageItems:(int)peer_id; +-(TGMessageHole *)holeWithNext:(BOOL)next; +-(void)setHole:(TGMessageHole *)hole withNext:(BOOL)next; -+(NSArray *)removeItems:(NSArray *)messageIds; -+(void)removeAllItems:(int)peerId; +-(NSMutableArray *)messageItems; +-(NSMutableDictionary *)messageKeys; -+(NSArray *)items:(NSArray *)messageIds; +-(NSArray *)selectAllItems; +-(NSArray *)sortItems:(NSArray *)sort; +-(int)posAtMessage:(TL_localMessage *)message; -(int)type; +(int)type; -+(void)drop; +-(BOOL)checkState:(ChatHistoryState)state next:(BOOL)next; +-(ChatHistoryState)stateWithNext:(BOOL)next; +-(void)setState:(ChatHistoryState)state next:(BOOL)next; +-(int)additionSenderFlags; + +-(int)peer_id; + +-(TGMessageHole *)proccessAndGetHoleWithHole:(TGMessageHole *)hole next:(BOOL)next messages:(NSArray *)messages; + +-(BOOL)confirmHoleWithNext:(BOOL)next; + + +-(NSArray *)storageRequest:(BOOL)next state:(ChatHistoryState *)state; + +-(void)remoteRequest:(BOOL)next hole:(TGMessageHole *)hole callback:(void (^)(id response,ChatHistoryState state))callback; +-(void)remoteRequest:(BOOL)next max_id:(int)max_id hole:(TGMessageHole *)hole callback:(void (^)(id response,ChatHistoryState state))callback; +-(void)request:(BOOL)next callback:(void (^)(NSArray *response, ChatHistoryState state))callback; + + +-(void)fillGroupHoles:(NSArray *)messages bottom:(BOOL)bottom; +-(TLMessagesFilter *)messagesFilter; +-(BOOL)checkAcceptResult:(NSArray *)result; --(void)storageRequest:(BOOL)next callback:(void (^)(NSArray *result))callback; --(void)remoteRequest:(BOOL)next peer_id:(int)peer_id callback:(void (^)(id response))callback; +-(void)clear; @end diff --git a/TelegramTest/HistoryFilter.m b/TelegramTest/HistoryFilter.m index ca80529a..a2877ed9 100644 --- a/TelegramTest/HistoryFilter.m +++ b/TelegramTest/HistoryFilter.m @@ -15,25 +15,35 @@ #import "DocumentHistoryFilter.h" #import "AudioHistoryFilter.h" #import "MP3HistoryFilter.h" -#import "MessageTableItem.h" +#import "SharedLinksHistoryFilter.h" +#import "ChannelImportantFilter.h" +#import "ChannelFilter.h" +#import "ChannelCommonFilter.h" +#import "SelfDestructionController.h" +@interface HistoryFilter () +@property (nonatomic,strong,readonly) TGMessageHole *botHole; +@property (nonatomic,strong,readonly) TGMessageHole *topHole; -@interface HistoryFilter () -{ - BOOL _de_alloc; -} +@property (nonatomic,strong) NSMutableArray *messageItems; +@property (nonatomic,strong) NSMutableDictionary *messageKeys; @end @implementation HistoryFilter -static NSMutableDictionary * messageItems; -static NSMutableDictionary * messageKeys; --(id)initWithController:(ChatHistoryController *)controller { + +-(id)initWithController:(ChatHistoryController *)controller peer:(TLPeer *)peer { if(self = [super init]) { - self.controller = controller; + _controller = controller; + _peer = peer; + _messageItems = [[NSMutableArray alloc] init]; + _messageKeys = [[NSMutableDictionary alloc] init]; + + _nextState = ChatHistoryStateLocal; + _prevState = ChatHistoryStateLocal; } return self; @@ -41,219 +51,466 @@ -(id)initWithController:(ChatHistoryController *)controller { -+(NSArray *)removeItems:(NSArray *)messageIds { +-(int)type { + return HistoryFilterNone; +} + ++(int)type { + return HistoryFilterNone; +} + + +-(BOOL)checkState:(ChatHistoryState)state next:(BOOL)next { + return next ? _nextState == state : _prevState == state; +} + +-(ChatHistoryState)stateWithNext:(BOOL)next { + return next ? _nextState : _prevState; +} + + +-(void)setState:(ChatHistoryState)state next:(BOOL)next { + if(next) + _nextState = state; + else + _prevState = state; +} + + + +-(int)min_id { + + NSArray *allItems = [self selectAllItems]; - NSMutableArray *items = [[NSMutableArray alloc] init]; + if(allItems.count == 0) + return INT32_MAX; - [ASQueue dispatchOnStageQueue:^{ + + __block TL_localMessage *lastObject; + + [allItems enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(TL_localMessage *obj, NSUInteger idx, BOOL *stop) { - [messageIds enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - - TL_localMessage *msg = [[MessagesManager sharedManager] find:[obj intValue]]; - - if(msg) - { - NSArray *f = [[self messageItems:msg.peer_id] filteredArrayUsingPredicate:[NSPredicate predicateWithFormat: @"self.message.n_id IN %@", messageIds]]; - - [items addObjectsFromArray:f]; - - [[self messageItems:msg.peer_id] removeObjectsInArray:f]; - - [[self messageKeys:msg.peer_id] removeObjectsForKeys:messageIds]; - } - - }]; + if(obj.n_id > 0) + { + lastObject = obj; + *stop = YES; + } - } synchronous:YES]; + }]; - return items; + return lastObject.n_id; } -+(NSArray *)items:(NSArray *)msgIds { +-(int)minDate { + NSArray *allItems = [self selectAllItems]; - + if(allItems.count == 0) + return INT32_MAX; - NSMutableArray *messageIds = [msgIds mutableCopy]; - NSMutableArray *items = [[NSMutableArray alloc] init]; + __block TL_localMessage *lastObject; - [ASQueue dispatchOnStageQueue:^{ - [messageKeys enumerateKeysAndObjectsUsingBlock:^(id key, NSMutableDictionary *obj, BOOL *stop) { - - - NSMutableArray *finded = [[NSMutableArray alloc] init]; - - [messageIds enumerateObjectsUsingBlock:^(NSNumber *msgId, NSUInteger idx, BOOL *stop) { - - if(obj[msgId] != nil) { - [items addObject:obj[msgId]]; - [finded addObject:msgId]; - } - - }]; - - [messageIds removeObjectsInArray:finded]; - - if(messageIds.count == 0) - *stop = YES; - - - }]; + [allItems enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(TL_localMessage *obj, NSUInteger idx, BOOL *stop) { - } synchronous:YES]; - + if(obj.n_id > 0) + { + lastObject = obj; + *stop = YES; + } + + }]; + return lastObject.date; - return items; } -+(void)removeAllItems:(int)peerId { + + +-(int)max_id { + + NSArray *allItems = [self selectAllItems]; + + + if(allItems.count == 0) + return 0; - [ASQueue dispatchOnStageQueue:^{ - [[self messageKeys:peerId] removeAllObjects]; - [[self messageItems:peerId] removeAllObjects]; + __block TL_localMessage *firstObject; + + [allItems enumerateObjectsWithOptions:0 usingBlock:^(TL_localMessage *obj, NSUInteger idx, BOOL *stop) { + + if(obj.n_id > 0) + { + firstObject = obj; + *stop = YES; + } + }]; + return firstObject.n_id; } -- (NSMutableDictionary *)messageKeys:(int)peer_id { - return [[self class] messageKeys:peer_id]; -} - -- (NSMutableArray *)messageItems:(int)peer_id { - return [[self class] messageItems:peer_id]; +-(int)maxDate { + NSArray *allItems = [self selectAllItems]; + + if(allItems.count == 0) { + return 0; + } + + + __block TL_localMessage *firstObject; + + [allItems enumerateObjectsWithOptions:0 usingBlock:^(TL_localMessage *obj, NSUInteger idx, BOOL *stop) { + + if(obj.n_id > 0) + { + firstObject = obj; + *stop = YES; + } + + }]; + + return firstObject.date; } -+ (NSMutableDictionary *)messageKeys:(int)peer_id { +-(int)server_min_id { + + NSArray *allItems = [self selectAllItems]; + - __block NSMutableDictionary *keys; - [ASQueue dispatchOnStageQueue:^{ + __block int msgId = INT32_MAX; + + [allItems enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(TL_localMessage *obj, NSUInteger idx, BOOL *stop) { - keys = messageKeys[@(peer_id)]; - if(!keys) + if(obj.n_id > 0 && obj.n_id < TGMINFAKEID) { - keys = [[NSMutableDictionary alloc] init]; - messageKeys[@(peer_id)] = keys; + msgId = obj.n_id; + *stop = YES; } - - } synchronous:YES]; + + }]; + + return msgId; - return keys; } -+ (NSMutableArray *)messageItems:(int)peer_id { - __block NSMutableArray *items; +-(int)server_max_id { + + NSArray *allItems = [self selectAllItems]; + - [ASQueue dispatchOnStageQueue:^{ + __block int msgId = 1; + + [allItems enumerateObjectsWithOptions:0 usingBlock:^(TL_localMessage *obj, NSUInteger idx, BOOL *stop) { - items = messageItems[@(peer_id)]; - if(!items) + if(obj.n_id > 0 && obj.n_id < TGMINFAKEID) { - items = [[NSMutableArray alloc] init]; - messageItems[@(peer_id)] = items; + msgId = obj.n_id; + *stop = YES; } - } synchronous:YES]; + }]; + return msgId; +} + + +-(NSArray *)selectAllItems { + + NSArray *memory = [self sortItems:_messageItems]; - return items; + return memory; } -+(void)initialize { - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - messageItems = [[NSMutableDictionary alloc] init]; - messageKeys = [[NSMutableDictionary alloc] init]; + +-(NSArray *)sortItems:(NSArray *)sort { + + return [sort sortedArrayUsingComparator:^NSComparisonResult(TL_localMessage *obj1, TL_localMessage *obj2) { - }); + return (obj1.date < obj2.date ? NSOrderedDescending : (obj1.date > obj2.date ? NSOrderedAscending : (obj1.n_id < obj2.n_id ? NSOrderedDescending : NSOrderedAscending))); + }]; } --(int)type { - return HistoryFilterNone; +-(int)posAtMessage:(TL_localMessage *)message { + + + NSArray *memoryItems = [self selectAllItems]; + + + int pos = 0; + if(memoryItems.count > 0) { + pos = [self posInArray:memoryItems date:message.date n_id:message.n_id]; + } + + return pos; } -+(int)type { - return HistoryFilterNone; +-(int)selectLimit { + return (int) _controller.selectLimit; +} + +-(int)posInArray:(NSArray *)list date:(int)date n_id:(int)n_id { + int pos = 0; + + + while (pos+1 < list.count && + ([(TL_localMessage *)list[pos] date] > date || + ([(TL_localMessage *)list[pos] date] == date && [(TL_localMessage *)list[pos] n_id] > n_id))) + pos++; + + return pos; +} + + +-(NSArray *)proccessResponse:(NSArray *)result state:(ChatHistoryState)state next:(BOOL)next { + + NSArray *converted = [self filterAndAdd:result latest:NO]; + + converted = [self sortItems:converted]; + + state = next && state == ChatHistoryStateRemote && (self.controller.conversation.type == DialogTypeSecretChat || self.controller.conversation.type == DialogTypeBroadcast) ? ChatHistoryStateFull : state; + + + [self setState:state next:next]; + + [SelfDestructionController addMessages:converted]; + + TL_conversation *conversation = [[DialogsManager sharedManager] find:self.peer_id]; + + if(self.prevState != ChatHistoryStateFull && (conversation.top_message <= self.server_max_id || conversation.top_message == 0)) + [self setState:ChatHistoryStateFull next:NO]; + + return converted; } -+(void)drop { - [ASQueue dispatchOnStageQueue:^{ - [messageKeys removeAllObjects]; - [messageItems removeAllObjects]; + +-(NSArray *)filterAndAdd:(NSArray *)items latest:(BOOL)latest { + + __block NSMutableArray *filtred = [[NSMutableArray alloc] init]; + + [items enumerateObjectsUsingBlock:^(TL_localMessage *obj, NSUInteger idx, BOOL *stop) { + NSMutableArray *filterItems = [self messageItems]; + NSMutableDictionary *filterKeys = [self messageKeys]; - [PhotoHistoryFilter drop]; - [DocumentHistoryFilter drop]; - [VideoHistoryFilter drop]; - [PhotoVideoHistoryFilter drop]; - [AudioHistoryFilter drop]; - [MP3HistoryFilter drop]; + BOOL needAdd = [filterItems indexOfObject:obj] == NSNotFound; + if((obj.peer_id == self.peer_id) && ((obj.filterType & [self type]) > 0 && (_prevState == ChatHistoryStateFull || !latest))) { + + if(obj.n_id != 0) { + id saved = filterKeys[@(obj.n_id)]; + if(!saved) { + filterKeys[@(obj.n_id)] = obj; + + } else { + needAdd = NO; + } + } + + if(needAdd) { + [filterItems addObject:obj]; + + [filtred addObject:obj]; + } + } }]; + + return filtred; +} + + +-(NSArray *)storageRequest:(BOOL)next state:(ChatHistoryState *)state { + + + int maxId = next ? self.min_id : INT32_MAX; + int minId = next ? 0 : self.max_id; + + int maxDate = next ? self.minDate : INT32_MAX; + int minDate = next ? 0 : self.maxDate; + TGHistoryResponse *response = [[Storage manager] loadMessages:self.peer_id min_id:minId max_id:maxId minDate:minDate maxDate:maxDate limit:(int)self.selectLimit next:next filterMask:[self type] isChannel:[self.peer isKindOfClass:[TL_peerChannel class]]]; + + [self setHole:response.hole withNext:next]; + + + *state = response.result.count < self.selectLimit || [self confirmHoleWithNext:next] ? ChatHistoryStateRemote : ChatHistoryStateLocal; + + return response.result; } --(void)storageRequest:(BOOL)next callback:(void (^)(NSArray *result))callback { - int source_id = next ? _controller.max_id : _controller.min_id; - int maxDate = next ? _controller.maxDate : _controller.minDate; - - [[Storage manager] loadMessages:_controller.conversation.peer.peer_id localMaxId:source_id limit:(int)_controller.selectLimit next:next maxDate:maxDate filterMask:[self type] completeHandler:^(NSArray *result) { +-(void)request:(BOOL)next callback:(void (^)(NSArray *response,ChatHistoryState state))callback { + + if([self checkState:ChatHistoryStateRemote next:next]) { + [self remoteRequest:next hole:[self holeWithNext:next] callback:callback]; - if(callback && self != nil) { - callback(result); - } + } else { - }]; + ChatHistoryState state; + + callback([self storageRequest:next state:&state],state); + + } } - --(void)remoteRequest:(BOOL)next peer_id:(int)peer_id callback:(void (^)(id response))callback { +-(void)remoteRequest:(BOOL)next hole:(TGMessageHole *)hole callback:(void (^)(id response,ChatHistoryState state))callback { - int source_id = next ? _controller.server_max_id : _controller.server_min_id; + int maxId = next ? self.server_min_id : self.server_max_id; - if(!_controller) - return; + if(hole != nil && !next) { + maxId = hole.min_id; + } else if(hole != nil && next) { + maxId = hole.max_id; + } - // NSLog(@"start %@ : %@",self,[NSThread currentThread]); + [self remoteRequest:next max_id:maxId hole:hole callback:callback]; +} + +-(void)remoteRequest:(BOOL)next max_id:(int)max_id hole:(TGMessageHole *)hole callback:(void (^)(id response,ChatHistoryState state))callback { + + int source_id = next ? self.server_min_id : self.server_max_id; - self.request = [RPCRequest sendRequest:[TLAPI_messages_getHistory createWithPeer:[[_controller.controller conversation] inputPeer] offset:next || source_id == 0 ? 0 : -(int)_controller.selectLimit max_id:source_id limit:(int)_controller.selectLimit] successHandler:^(RPCRequest *request, id response) { + if(!_controller) + return; + + self.request = [RPCRequest sendRequest:[TLAPI_messages_getHistory createWithPeer:[_peer inputPeer] offset_id:source_id add_offset:next || source_id == 0 ? 0 : -(int)self.selectLimit limit:(int)self.selectLimit max_id:next ? 0 : INT32_MAX min_id:0] successHandler:^(RPCRequest *request, TL_messages_channelMessages * response) { + + + [SharedManager proccessGlobalResponse:response]; + + + NSArray *messages = [[response messages] copy]; + + [self fillGroupHoles:messages bottom:!next]; + + [self setHole:[self proccessAndGetHoleWithHole:hole next:next messages:messages] withNext:next]; if(callback) { - callback(response); + ChatHistoryState state = hole && ![self holeWithNext:next] ? ChatHistoryStateLocal : messages.count < self.selectLimit && !hole && ![self holeWithNext:next] ? ChatHistoryStateFull : ChatHistoryStateRemote; + + callback(messages,state); } } errorHandler:^(RPCRequest *request, RpcError *error) { - if(callback && _controller) { - callback(nil); + if(callback && self.controller) { + callback(nil,ChatHistoryStateFull); } - } timeout:10 queue:[ASQueue globalQueue].nativeQueue]; + } timeout:0 queue:[ASQueue globalQueue].nativeQueue]; } +-(BOOL)confirmHoleWithNext:(BOOL)next { + return [self holeWithNext:next] && ( next ? [self holeWithNext:next].max_id <= self.max_id : [self holeWithNext:next].max_id > [self holeWithNext:next].max_id); +} + +-(int)additionSenderFlags { + return 0 ; +} + + +-(int)peer_id { + return _peer.peer_id; +} + +-(TGMessageHole *)holeWithNext:(BOOL)next { + return next ? _topHole : _botHole; +} + +-(void)setHole:(TGMessageHole *)hole withNext:(BOOL)next { + if(next) + _topHole = hole; + else + _botHole = hole; +} + +-(TGMessageHole *)proccessAndGetHoleWithHole:(TGMessageHole *)hole next:(BOOL)next messages:(NSArray *)messages { + + TGMessageHole *nHole; + + + if(hole != nil) { + + int min = hole.min_id; + int max = hole.max_id; + + if(messages.count > 0) + { + TL_localMessage *first = [messages firstObject]; + TL_localMessage *last = [messages lastObject]; + + max = first.n_id; + min = last.n_id; + } + + + + nHole = [[TGMessageHole alloc] initWithUniqueId:hole.uniqueId peer_id:hole.peer_id min_id:next ? hole.min_id : max max_id:next ? min : hole.max_id date:hole.date count:0]; + + + if(nHole.min_id >= nHole.max_id) { + + [nHole remove]; + nHole = nil; + } else + [nHole save]; + + + } + + return nHole; +} + + +-(void)fillGroupHoles:(NSArray *)messages bottom:(BOOL)bottom { + +} -(void)dealloc { - _de_alloc = YES; + if(self.request != nil) { + [self.request cancelRequest]; + self.request = nil; + } + +} + +-(TLMessagesFilter *)messagesFilter { + return [TL_inputMessagesFilterEmpty create]; +} + + +-(BOOL)checkAcceptResult:(NSArray *)result { - // NSLog(@"dealloc %@ : %@",self,[NSThread currentThread]); + __block BOOL accept = YES; + [result enumerateObjectsUsingBlock:^(TL_localMessage *messageItem, NSUInteger idx, BOOL * _Nonnull stop) { + + if(self.peer_id != messageItem.peer_id) { + accept = NO; + *stop = YES; + } + + }]; + - [self.request cancelRequest]; - self.request = nil; + return accept; +} + +-(void)clear { + [_messageItems removeAllObjects]; + [_messageKeys removeAllObjects]; } @end diff --git a/TelegramTest/ITSwitch.h b/TelegramTest/ITSwitch.h index 5e202fda..e038fed5 100755 --- a/TelegramTest/ITSwitch.h +++ b/TelegramTest/ITSwitch.h @@ -28,6 +28,7 @@ typedef void(^changeHandler)(BOOL isOn); @property (nonatomic, strong) NSColor *tintColor; @property(nonatomic, copy) changeHandler didChangeHandler; + - (void)setOn:(BOOL)on animated:(BOOL)animated; @end diff --git a/TelegramTest/ITSwitch.m b/TelegramTest/ITSwitch.m index 8455e15f..17d4fc8f 100755 --- a/TelegramTest/ITSwitch.m +++ b/TelegramTest/ITSwitch.m @@ -178,7 +178,7 @@ - (void)updateLayer { // _backgroundLayer.borderWidth = (YES || self.isActive || self.isOn) ? NSHeight(_backgroundLayer.bounds) / 2 : kBorderLineWidth; // ------------------------------- Animate Colors - if ((self.hasDragged && self.isDraggingTowardsOn) || (!self.hasDragged && self.isOn)) { + if ((self.hasDragged && self.isDraggingTowardsOn && self.isEnabled) || (!self.hasDragged && self.isOn && self.isEnabled)) { _backgroundLayer.borderColor = self.tintColor.CGColor; _backgroundLayer.backgroundColor = self.tintColor.CGColor; } else { @@ -235,6 +235,7 @@ - (BOOL)acceptsFirstResponder { } - (void)mouseDown:(NSEvent *)theEvent { + self.isActive = YES; [self updateLayer]; @@ -250,6 +251,12 @@ - (void)mouseDragged:(NSEvent *)theEvent { } - (void)mouseUp:(NSEvent *)theEvent { + + [super mouseUp:theEvent]; + + if(!self.isEnabled) + return; + self.isActive = NO; BOOL isOn = (!self.hasDragged) ? !self.isOn : self.isDraggingTowardsOn; @@ -286,6 +293,12 @@ - (void)setAction:(SEL)aSelector { _action = aSelector; } +-(void)setEnabled:(BOOL)enabled { + [super setEnabled:enabled]; + + +} + // ---------------------------------------------------- @@ -318,6 +331,8 @@ - (void)setTintColor:(NSColor *)tintColor { } - (void)setOn:(BOOL)on animated:(BOOL)animated { + + _animationDuration = animated ? kAnimationDuration : 0; [self setOn:on]; diff --git a/TelegramTest/ImageAttachSenderItem.h b/TelegramTest/ImageAttachSenderItem.h index f7b88344..04e9ea81 100644 --- a/TelegramTest/ImageAttachSenderItem.h +++ b/TelegramTest/ImageAttachSenderItem.h @@ -10,6 +10,6 @@ #import "TGAttachObject.h" @interface ImageAttachSenderItem : SenderItem --(id)initWithConversation:(TL_conversation *)conversation attachObject:(TGAttachObject *)attach; +-(id)initWithConversation:(TL_conversation *)conversation attachObject:(TGAttachObject *)attach additionFlags:(int)additionFlags; @end diff --git a/TelegramTest/ImageAttachSenderItem.m b/TelegramTest/ImageAttachSenderItem.m index 3a2ff745..5d3d29c8 100644 --- a/TelegramTest/ImageAttachSenderItem.m +++ b/TelegramTest/ImageAttachSenderItem.m @@ -19,7 +19,7 @@ @interface ImageAttachSenderItem () @implementation ImageAttachSenderItem --(id)initWithConversation:(TL_conversation *)conversation attachObject:(TGAttachObject *)attach { +-(id)initWithConversation:(TL_conversation *)conversation attachObject:(TGAttachObject *)attach additionFlags:(int)additionFlags { if(self = [super initWithConversation:conversation]) { @@ -38,14 +38,16 @@ -(id)initWithConversation:(TL_conversation *)conversation attachObject:(TGAttach [sizes addObject:size]; [sizes addObject:size1]; - TL_messageMediaPhoto *photo = [TL_messageMediaPhoto createWithPhoto:[TL_photo createWithN_id:attach.unique_id access_hash:0 user_id:0 date:(int)[[MTNetwork instance] getTime] geo:[TL_geoPointEmpty create] sizes:sizes] caption:attach.caption]; + TL_messageMediaPhoto *photo = [TL_messageMediaPhoto createWithPhoto:[TL_photo createWithN_id:attach.unique_id access_hash:0 date:(int)[[MTNetwork instance] getTime] sizes:sizes] caption:attach.caption]; [TGCache cacheImage:attach.image forKey:size.location.cacheKey groups:@[IMGCACHE]]; self.message = [MessageSender createOutMessage:@"" media:photo conversation:conversation]; - + if(additionFlags & (1 << 4)) + self.message.from_id = 0; + [[NSFileManager defaultManager] copyItemAtPath:path toPath:mediaFilePath(self.message.media) error:nil]; [self.message save:YES]; @@ -75,22 +77,22 @@ -(void)didEndUploading:(id)uploadedFile { if(self.conversation.type == DialogTypeBroadcast) { request = [TLAPI_messages_sendBroadcast createWithContacts:[self.conversation.broadcast inputContacts] random_id:[self.conversation.broadcast generateRandomIds] message:@"" media:media]; } else { - request = [TLAPI_messages_sendMedia createWithFlags:self.message.reply_to_msg_id != 0 ? 1 : 0 peer:self.conversation.inputPeer reply_to_msg_id:self.message.reply_to_msg_id media:media random_id:self.message.randomId reply_markup:[TL_replyKeyboardMarkup createWithFlags:0 rows:[@[]mutableCopy]]] ; + request = [TLAPI_messages_sendMedia createWithFlags:[self senderFlags] peer:self.conversation.inputPeer reply_to_msg_id:self.message.reply_to_msg_id media:media random_id:self.message.randomId reply_markup:[TL_replyKeyboardMarkup createWithFlags:0 rows:[@[]mutableCopy]]] ; } self.rpc_request = [RPCRequest sendRequest:request successHandler:^(RPCRequest *request, TLUpdates *response) { + [self updateMessageId:response]; + TL_localMessage *msg = [TL_localMessage convertReceivedMessage:[[self updateNewMessageWithUpdates:response] message]]; - if(response.updates.count < 2) + if(msg == nil) { [self cancel]; return; } - TL_localMessage *msg = [TL_localMessage convertReceivedMessage:(TLMessage *) ( [response.updates[1] message])]; - [[Storage manager] setFileInfo:[TL_inputPhoto createWithN_id:msg.media.photo.n_id access_hash:msg.media.photo.access_hash] forPathHash:fileMD5(self.filePath)]; @@ -121,9 +123,7 @@ -(void)didEndUploading:(id)uploadedFile { self.message.dstate = DeliveryStateNormal; [self.message save:YES]; - - [[Storage manager] insertMedia:self.message]; - + [[NSFileManager defaultManager] moveItemAtPath:self.filePath toPath:mediaFilePath(self.message.media) error:nil]; diff --git a/TelegramTest/ImageSenderItem.h b/TelegramTest/ImageSenderItem.h index 1fdf6a1a..29cb25cc 100644 --- a/TelegramTest/ImageSenderItem.h +++ b/TelegramTest/ImageSenderItem.h @@ -10,6 +10,6 @@ @interface ImageSenderItem : SenderItem -- (id)initWithImage:(NSImage *)image jpegData:(NSData *)jpegData forConversation:(TL_conversation *)conversation; +- (id)initWithImage:(NSImage *)image jpegData:(NSData *)jpegData forConversation:(TL_conversation *)conversation additionFlags:(int)additionFlags; @end diff --git a/TelegramTest/ImageSenderItem.m b/TelegramTest/ImageSenderItem.m index 20393870..a4f8814c 100644 --- a/TelegramTest/ImageSenderItem.m +++ b/TelegramTest/ImageSenderItem.m @@ -28,7 +28,7 @@ -(void)setState:(MessageState)state { [super setState:state]; } -- (id)initWithImage:(NSImage *)image jpegData:(NSData *)jpegData forConversation:(TL_conversation *)conversation { +- (id)initWithImage:(NSImage *)image jpegData:(NSData *)jpegData forConversation:(TL_conversation *)conversation additionFlags:(int)additionFlags { if(self = [super initWithConversation:conversation]) { @@ -64,13 +64,17 @@ - (id)initWithImage:(NSImage *)image jpegData:(NSData *)jpegData forConversation [sizes addObject:size]; [sizes addObject:size1]; - TL_messageMediaPhoto *photo = [TL_messageMediaPhoto createWithPhoto:[TL_photo createWithN_id:rand_long() access_hash:0 user_id:0 date:(int)[[MTNetwork instance] getTime] geo:[TL_geoPointEmpty create] sizes:sizes] caption:@""]; + TL_messageMediaPhoto *photo = [TL_messageMediaPhoto createWithPhoto:[TL_photo createWithN_id:rand_long() access_hash:0 date:(int)[[MTNetwork instance] getTime] sizes:sizes] caption:@""]; [TGCache cacheImage:renderedImage([[NSImage alloc] initWithData:jpegNormalizedData(image)], maxSize) forKey:size.location.cacheKey groups:@[IMGCACHE]]; self.message = [MessageSender createOutMessage:@"" media:photo conversation:conversation]; + + if(additionFlags & (1 << 4)) + self.message.from_id = 0; + [jpegData writeToFile:mediaFilePath(self.message.media) atomically:YES]; [self.message save:YES]; @@ -106,21 +110,21 @@ -(void)performRequest { if(strongSelf.conversation.type == DialogTypeBroadcast) { request = [TLAPI_messages_sendBroadcast createWithContacts:[strongSelf.conversation.broadcast inputContacts] random_id:[strongSelf.conversation.broadcast generateRandomIds] message:@"" media:media]; } else { - request = [TLAPI_messages_sendMedia createWithFlags:strongSelf.message.reply_to_msg_id != 0 ? 1 : 0 peer:strongSelf.conversation.inputPeer reply_to_msg_id:strongSelf.message.reply_to_msg_id media:media random_id:strongSelf.message.randomId reply_markup:[TL_replyKeyboardMarkup createWithFlags:0 rows:[@[]mutableCopy]]]; + request = [TLAPI_messages_sendMedia createWithFlags:[strongSelf senderFlags] peer:strongSelf.conversation.inputPeer reply_to_msg_id:strongSelf.message.reply_to_msg_id media:media random_id:strongSelf.message.randomId reply_markup:[TL_replyKeyboardMarkup createWithFlags:0 rows:[@[]mutableCopy]]]; } strongSelf.rpc_request = [RPCRequest sendRequest:request successHandler:^(RPCRequest *request, TLUpdates *response) { + [strongSelf updateMessageId:response]; + TL_localMessage *msg = [TL_localMessage convertReceivedMessage:[[strongSelf updateNewMessageWithUpdates:response] message]]; - if(response.updates.count < 2) + if(msg == nil) { [strongSelf cancel]; return; } - TL_localMessage *msg = [TL_localMessage convertReceivedMessage:(TLMessage *) ( [response.updates[1] message])]; - [[Storage manager] setFileInfo:[TL_inputPhoto createWithN_id:msg.media.photo.n_id access_hash:msg.media.photo.access_hash] forPathHash:fileMD5(strongSelf.filePath)]; @@ -159,9 +163,7 @@ -(void)performRequest { strongSelf.message.dstate = DeliveryStateNormal; [strongSelf.message save:YES]; - - [[Storage manager] insertMedia:strongSelf.message]; - + [[NSFileManager defaultManager] moveItemAtPath:strongSelf.filePath toPath:mediaFilePath(strongSelf.message.media) error:nil]; diff --git a/TelegramTest/ImageUtils.h b/TelegramTest/ImageUtils.h index c92889de..e9a7eb0d 100644 --- a/TelegramTest/ImageUtils.h +++ b/TelegramTest/ImageUtils.h @@ -103,8 +103,8 @@ CACHE_IMAGE(newConversationBroadcast) CACHE_IMAGE(PlayButtonBig) CACHE_IMAGE(ArrowWhite) CACHE_IMAGE(ArrowGrey) - - +CACHE_IMAGE(Verify) +CACHE_IMAGE(VerifyWhite) CACHE_IMAGE(DownloadIconGrey) CACHE_IMAGE(DownloadIconWhite) CACHE_IMAGE(DownloadPauseIconGrey) @@ -201,6 +201,28 @@ CACHE_IMAGE(SearchUpDisabled); CACHE_IMAGE(SearchDownDisabled); CACHE_IMAGE(SearchUp); CACHE_IMAGE(SearchDown); + +CACHE_IMAGE(ZoomIn); +CACHE_IMAGE(ZoomOut); +CACHE_IMAGE(Camera); + +CACHE_IMAGE(ChannelMessageAsAdmin); +CACHE_IMAGE(ChannelMessageAsAdminHighlighted); +CACHE_IMAGE(ChannelViews); + +CACHE_IMAGE(PinConversation); +CACHE_IMAGE(PinnedConversation); + +CACHE_IMAGE(ModernConversationSecretAccessoryTimer); + +CACHE_IMAGE(ChannelShare); + +CACHE_IMAGE(ModernMenuDeleteIcon); +CACHE_IMAGE(EditPhotoCamera); +CACHE_IMAGE(NoSharedLinks); + +CACHE_IMAGE(StickerSettings); + @interface ImageUtils : NSObject diff --git a/TelegramTest/ImageUtils.m b/TelegramTest/ImageUtils.m index 417d8872..0d2d5804 100644 --- a/TelegramTest/ImageUtils.m +++ b/TelegramTest/ImageUtils.m @@ -106,11 +106,12 @@ CACHE_IMAGE(VoiceMicHighlighted) CACHE_IMAGE(VoiceMicHighlighted2) CACHE_IMAGE(TelegramNotifications) +CACHE_IMAGE(newConversationBroadcast) CACHE_IMAGE(PlayButtonBig) CACHE_IMAGE(ArrowWhite) CACHE_IMAGE(ArrowGrey) - - +CACHE_IMAGE(Verify) +CACHE_IMAGE(VerifyWhite) CACHE_IMAGE(DownloadIconGrey) CACHE_IMAGE(DownloadIconWhite) CACHE_IMAGE(DownloadPauseIconGrey) @@ -210,6 +211,29 @@ CACHE_IMAGE(SearchUp); CACHE_IMAGE(SearchDown); + +CACHE_IMAGE(ZoomIn); +CACHE_IMAGE(ZoomOut); +CACHE_IMAGE(Camera); + +CACHE_IMAGE(ChannelMessageAsAdmin); +CACHE_IMAGE(ChannelMessageAsAdminHighlighted); +CACHE_IMAGE(ChannelViews); + +CACHE_IMAGE(PinConversation); +CACHE_IMAGE(PinnedConversation); + + +CACHE_IMAGE(ModernConversationSecretAccessoryTimer); + +CACHE_IMAGE(ChannelShare); + +CACHE_IMAGE(ModernMenuDeleteIcon); + +CACHE_IMAGE(EditPhotoCamera); +CACHE_IMAGE(NoSharedLinks); +CACHE_IMAGE(StickerSettings); + @implementation ImageUtils NSImage *previewImageForDocument(NSString *path) { @@ -779,68 +803,44 @@ + (NSImage *)imageResize:(NSImage*)anImage newSize:(NSSize)newSize { layer = [CALayer layer]; } - @try { - [CATransaction begin]; - } - @catch (NSException *exception) { - - } - @finally { - - } NSImage *image = nil; - @autoreleasepool { - CGFloat displayScale = [[NSScreen mainScreen] backingScaleFactor]; + CGFloat displayScale = [[NSScreen mainScreen] backingScaleFactor]; + + size.width *= displayScale; + size.height *= displayScale; + + CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)[oldImage TIFFRepresentation], NULL); + + if(source != NULL) { + CGImageRef maskRef = CGImageSourceCreateImageAtIndex(source, 0, NULL); + CFRelease(source); - size.width *= displayScale; - size.height *= displayScale; + CGContextRef context = CGBitmapContextCreate(NULL/*data - pass NULL to let CG allocate the memory*/, + size.width, + size.height, + 8 /*bitsPerComponent*/, + 0 /*bytesPerRow - CG will calculate it for you if it's allocating the data. This might get padded out a bit for better alignment*/, + [[NSColorSpace genericRGBColorSpace] CGColorSpace], + kCGBitmapByteOrder32Host|kCGImageAlphaPremultipliedFirst); - CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)[oldImage TIFFRepresentation], NULL); - if(source != NULL) { - CGImageRef maskRef = CGImageSourceCreateImageAtIndex(source, 0, NULL); - CFRelease(source); - - [layer setContents:(__bridge id)(maskRef)]; - [layer setFrame:NSMakeRect(0, 0, size.width, size.height)]; - [layer setBounds:NSMakeRect(0, 0, size.width, size.height)]; - [layer setMasksToBounds:YES]; - - - CGContextRef context = CGBitmapContextCreate(NULL/*data - pass NULL to let CG allocate the memory*/, - size.width, - size.height, - 8 /*bitsPerComponent*/, - 0 /*bytesPerRow - CG will calculate it for you if it's allocating the data. This might get padded out a bit for better alignment*/, - [[NSColorSpace genericRGBColorSpace] CGColorSpace], - kCGBitmapByteOrder32Host|kCGImageAlphaPremultipliedFirst); - [layer renderInContext:context]; - - - CGImageRef cgImage = CGBitmapContextCreateImage(context); - - - CGContextRelease(context); - - - - image = [[NSImage alloc] initWithCGImage:cgImage size:size]; - CGImageRelease(cgImage); - CGImageRelease(maskRef); - } - } - - @try { - [CATransaction commit]; - } - @catch (NSException *exception) { + CGContextDrawImage(context, CGRectMake(0, 0, size.width, size.height), maskRef); - } - @finally { + CGImageRef cgImage = CGBitmapContextCreateImage(context); + + + CGContextRelease(context); + + + + image = [[NSImage alloc] initWithCGImage:cgImage size:size]; + CGImageRelease(cgImage); + CGImageRelease(maskRef); } + diff --git a/TelegramTest/Images.xcassets/.DS_Store b/TelegramTest/Images.xcassets/.DS_Store index 37f8520a..e327c611 100644 Binary files a/TelegramTest/Images.xcassets/.DS_Store and b/TelegramTest/Images.xcassets/.DS_Store differ diff --git a/TelegramTest/Images.xcassets/Camera.imageset/Camera.png b/TelegramTest/Images.xcassets/Camera.imageset/Camera.png new file mode 100644 index 00000000..b44952db Binary files /dev/null and b/TelegramTest/Images.xcassets/Camera.imageset/Camera.png differ diff --git a/TelegramTest/Images.xcassets/Camera.imageset/Camera@2x.png b/TelegramTest/Images.xcassets/Camera.imageset/Camera@2x.png new file mode 100644 index 00000000..7b0b6124 Binary files /dev/null and b/TelegramTest/Images.xcassets/Camera.imageset/Camera@2x.png differ diff --git a/TelegramTest/Images.xcassets/Camera.imageset/Contents.json b/TelegramTest/Images.xcassets/Camera.imageset/Contents.json new file mode 100644 index 00000000..7bf38dbc --- /dev/null +++ b/TelegramTest/Images.xcassets/Camera.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "Camera.png" + }, + { + "idiom" : "universal", + "scale" : "2x", + "filename" : "Camera@2x.png" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/TelegramTest/Images.xcassets/ChannelMessageAsAdmin.imageset/Contents.json b/TelegramTest/Images.xcassets/ChannelMessageAsAdmin.imageset/Contents.json new file mode 100644 index 00000000..d42e34db --- /dev/null +++ b/TelegramTest/Images.xcassets/ChannelMessageAsAdmin.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "postasuser.png" + }, + { + "idiom" : "universal", + "scale" : "2x", + "filename" : "postasuser@2x.png" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/TelegramTest/Images.xcassets/ChannelMessageAsAdmin.imageset/postasuser.png b/TelegramTest/Images.xcassets/ChannelMessageAsAdmin.imageset/postasuser.png new file mode 100644 index 00000000..c4b4829a Binary files /dev/null and b/TelegramTest/Images.xcassets/ChannelMessageAsAdmin.imageset/postasuser.png differ diff --git a/TelegramTest/Images.xcassets/ChannelMessageAsAdmin.imageset/postasuser@2x.png b/TelegramTest/Images.xcassets/ChannelMessageAsAdmin.imageset/postasuser@2x.png new file mode 100644 index 00000000..35c82f78 Binary files /dev/null and b/TelegramTest/Images.xcassets/ChannelMessageAsAdmin.imageset/postasuser@2x.png differ diff --git a/TelegramTest/Images.xcassets/ChannelMessageAsAdminHighlighted.imageset/Contents.json b/TelegramTest/Images.xcassets/ChannelMessageAsAdminHighlighted.imageset/Contents.json new file mode 100644 index 00000000..c9af07de --- /dev/null +++ b/TelegramTest/Images.xcassets/ChannelMessageAsAdminHighlighted.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "postaschannel.png" + }, + { + "idiom" : "universal", + "scale" : "2x", + "filename" : "postaschannel@2x.png" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/TelegramTest/Images.xcassets/ChannelMessageAsAdminHighlighted.imageset/postaschannel.png b/TelegramTest/Images.xcassets/ChannelMessageAsAdminHighlighted.imageset/postaschannel.png new file mode 100644 index 00000000..ffba8d78 Binary files /dev/null and b/TelegramTest/Images.xcassets/ChannelMessageAsAdminHighlighted.imageset/postaschannel.png differ diff --git a/TelegramTest/Images.xcassets/ChannelMessageAsAdminHighlighted.imageset/postaschannel@2x.png b/TelegramTest/Images.xcassets/ChannelMessageAsAdminHighlighted.imageset/postaschannel@2x.png new file mode 100644 index 00000000..bbad941b Binary files /dev/null and b/TelegramTest/Images.xcassets/ChannelMessageAsAdminHighlighted.imageset/postaschannel@2x.png differ diff --git a/TelegramTest/Images.xcassets/ChannelViews.imageset/Contents.json b/TelegramTest/Images.xcassets/ChannelViews.imageset/Contents.json new file mode 100644 index 00000000..86dde21b --- /dev/null +++ b/TelegramTest/Images.xcassets/ChannelViews.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "eye.png" + }, + { + "idiom" : "universal", + "scale" : "2x", + "filename" : "eye@2x.png" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/TelegramTest/Images.xcassets/ChannelViews.imageset/eye.png b/TelegramTest/Images.xcassets/ChannelViews.imageset/eye.png new file mode 100644 index 00000000..5ffb3bc2 Binary files /dev/null and b/TelegramTest/Images.xcassets/ChannelViews.imageset/eye.png differ diff --git a/TelegramTest/Images.xcassets/ChannelViews.imageset/eye@2x.png b/TelegramTest/Images.xcassets/ChannelViews.imageset/eye@2x.png new file mode 100644 index 00000000..93cdd64a Binary files /dev/null and b/TelegramTest/Images.xcassets/ChannelViews.imageset/eye@2x.png differ diff --git a/TelegramTest/Images.xcassets/Contents.json b/TelegramTest/Images.xcassets/Contents.json new file mode 100644 index 00000000..da4a164c --- /dev/null +++ b/TelegramTest/Images.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/TelegramTest/Images.xcassets/ModernConversationSecretAccessoryTimer.imageset/Contents.json b/TelegramTest/Images.xcassets/ModernConversationSecretAccessoryTimer.imageset/Contents.json new file mode 100644 index 00000000..9fb5e59f --- /dev/null +++ b/TelegramTest/Images.xcassets/ModernConversationSecretAccessoryTimer.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "ModernConversationSecretAccessoryTimer@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "ModernConversationSecretAccessoryTimer@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/TelegramTest/Images.xcassets/ModernConversationSecretAccessoryTimer.imageset/ModernConversationSecretAccessoryTimer@2x.png b/TelegramTest/Images.xcassets/ModernConversationSecretAccessoryTimer.imageset/ModernConversationSecretAccessoryTimer@2x.png new file mode 100644 index 00000000..d2bc78b0 Binary files /dev/null and b/TelegramTest/Images.xcassets/ModernConversationSecretAccessoryTimer.imageset/ModernConversationSecretAccessoryTimer@2x.png differ diff --git a/TelegramTest/Images.xcassets/ModernConversationSecretAccessoryTimer.imageset/ModernConversationSecretAccessoryTimer@3x.png b/TelegramTest/Images.xcassets/ModernConversationSecretAccessoryTimer.imageset/ModernConversationSecretAccessoryTimer@3x.png new file mode 100644 index 00000000..0e7ae225 Binary files /dev/null and b/TelegramTest/Images.xcassets/ModernConversationSecretAccessoryTimer.imageset/ModernConversationSecretAccessoryTimer@3x.png differ diff --git a/TelegramTest/Images.xcassets/StickerSettings.imageset/Contents.json b/TelegramTest/Images.xcassets/StickerSettings.imageset/Contents.json new file mode 100644 index 00000000..de3a8d17 --- /dev/null +++ b/TelegramTest/Images.xcassets/StickerSettings.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "Shape@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/TelegramTest/Images.xcassets/Verify.imageset/Check@2x.png b/TelegramTest/Images.xcassets/Verify.imageset/Check@2x.png new file mode 100644 index 00000000..2fba6732 Binary files /dev/null and b/TelegramTest/Images.xcassets/Verify.imageset/Check@2x.png differ diff --git a/TelegramTest/Images.xcassets/Verify.imageset/Contents.json b/TelegramTest/Images.xcassets/Verify.imageset/Contents.json new file mode 100644 index 00000000..501b29ab --- /dev/null +++ b/TelegramTest/Images.xcassets/Verify.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "Check.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "Check@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/TelegramTest/Images.xcassets/VerifyWhite.imageset/CheckWhite.png b/TelegramTest/Images.xcassets/VerifyWhite.imageset/CheckWhite.png new file mode 100644 index 00000000..db70fd33 Binary files /dev/null and b/TelegramTest/Images.xcassets/VerifyWhite.imageset/CheckWhite.png differ diff --git a/TelegramTest/Images.xcassets/VerifyWhite.imageset/CheckWhite@2x.png b/TelegramTest/Images.xcassets/VerifyWhite.imageset/CheckWhite@2x.png new file mode 100644 index 00000000..389ea51a Binary files /dev/null and b/TelegramTest/Images.xcassets/VerifyWhite.imageset/CheckWhite@2x.png differ diff --git a/TelegramTest/Images.xcassets/VerifyWhite.imageset/Contents.json b/TelegramTest/Images.xcassets/VerifyWhite.imageset/Contents.json new file mode 100644 index 00000000..10546883 --- /dev/null +++ b/TelegramTest/Images.xcassets/VerifyWhite.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "CheckWhite.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "CheckWhite@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/TelegramTest/Images.xcassets/ZoomIn.imageset/Contents.json b/TelegramTest/Images.xcassets/ZoomIn.imageset/Contents.json new file mode 100644 index 00000000..ffa32cf9 --- /dev/null +++ b/TelegramTest/Images.xcassets/ZoomIn.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "ZoomIn.png" + }, + { + "idiom" : "universal", + "scale" : "2x", + "filename" : "ZoomIn@2x.png" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/TelegramTest/Images.xcassets/ZoomIn.imageset/ZoomIn.png b/TelegramTest/Images.xcassets/ZoomIn.imageset/ZoomIn.png new file mode 100644 index 00000000..478974ba Binary files /dev/null and b/TelegramTest/Images.xcassets/ZoomIn.imageset/ZoomIn.png differ diff --git a/TelegramTest/Images.xcassets/ZoomIn.imageset/ZoomIn@2x.png b/TelegramTest/Images.xcassets/ZoomIn.imageset/ZoomIn@2x.png new file mode 100644 index 00000000..0f43e0a4 Binary files /dev/null and b/TelegramTest/Images.xcassets/ZoomIn.imageset/ZoomIn@2x.png differ diff --git a/TelegramTest/Images.xcassets/ZoomOut.imageset/Contents.json b/TelegramTest/Images.xcassets/ZoomOut.imageset/Contents.json new file mode 100644 index 00000000..cf792ec7 --- /dev/null +++ b/TelegramTest/Images.xcassets/ZoomOut.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "ZoomOut.png" + }, + { + "idiom" : "universal", + "scale" : "2x", + "filename" : "ZoomOut@2x.png" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/TelegramTest/Images.xcassets/ZoomOut.imageset/ZoomOut.png b/TelegramTest/Images.xcassets/ZoomOut.imageset/ZoomOut.png new file mode 100644 index 00000000..c0393ce8 Binary files /dev/null and b/TelegramTest/Images.xcassets/ZoomOut.imageset/ZoomOut.png differ diff --git a/TelegramTest/Images.xcassets/ZoomOut.imageset/ZoomOut@2x.png b/TelegramTest/Images.xcassets/ZoomOut.imageset/ZoomOut@2x.png new file mode 100644 index 00000000..7c0c9753 Binary files /dev/null and b/TelegramTest/Images.xcassets/ZoomOut.imageset/ZoomOut@2x.png differ diff --git a/TelegramTest/InstagramServiceDescription.m b/TelegramTest/InstagramServiceDescription.m index f3470c78..1751450f 100644 --- a/TelegramTest/InstagramServiceDescription.m +++ b/TelegramTest/InstagramServiceDescription.m @@ -33,7 +33,7 @@ -(id)initWithSocialURL:(NSString *)url item:(MessageTableItem *)tableItem { NSString *urlString = url.length > 25 ? [[url substringToIndex:25] stringByAppendingString:@"..."] : url; [title appendString:urlString withColor:[NSColor whiteColor]]; - [title setFont:[NSFont fontWithName:@"HelveticaNeue" size:13] forRange:title.range]; + [title setFont:TGSystemFont(13) forRange:title.range]; _title = title; _titleSize = [title size]; _titleSize.width = ceil(_titleSize.width + 14); @@ -43,7 +43,7 @@ -(id)initWithSocialURL:(NSString *)url item:(MessageTableItem *)tableItem { NSMutableAttributedString *serviceName = [[NSMutableAttributedString alloc] init]; [serviceName appendString:@"Instagram" withColor:[NSColor whiteColor]]; - [serviceName setFont:[NSFont fontWithName:@"HelveticaNeue" size:13] forRange:serviceName.range]; + [serviceName setFont:TGSystemFont(13) forRange:serviceName.range]; _serviceName = serviceName; _serviceNameSize = [serviceName size]; _serviceNameSize.width = ceil(_serviceNameSize.width + 14); diff --git a/TelegramTest/LeftViewController.h b/TelegramTest/LeftViewController.h index e02a5d36..0c6bd7a2 100644 --- a/TelegramTest/LeftViewController.h +++ b/TelegramTest/LeftViewController.h @@ -9,7 +9,6 @@ #import #import "RightViewController.h" #import "TelegramPopover.h" -#import "NewConversationViewController.h" #import "TGWindowArchiver.h" #import "TGConversationsViewController.h" diff --git a/TelegramTest/LeftViewController.m b/TelegramTest/LeftViewController.m index b5ea9202..490b7656 100644 --- a/TelegramTest/LeftViewController.m +++ b/TelegramTest/LeftViewController.m @@ -8,7 +8,6 @@ #import "LeftViewController.h" #import "SearchViewController.h" -#import "NewConversationViewController.h" #import "RBLPopover.h" #import "TMTabViewController.h" #import "AccountSettingsViewController.h" @@ -232,9 +231,35 @@ -(void)setUnreadCount:(int)count { [self.tabController setUnreadCount:count]; } +static TMViewController *changedController; + -(void)tabItemDidChanged:(TMTabItem *)item index:(NSUInteger)index { + + if([Telegram mainViewController].isMinimisze && index != 1) + return; + [self.tabViewController showControllerByIndex:index]; + if(![Telegram isSingleLayout]) { + if([self.tabViewController.currentController isKindOfClass:[AccountSettingsViewController class]]) { + + changedController = [Telegram rightViewController].navigationViewController.currentController; + + [[Telegram rightViewController] showGeneralSettings]; + } else if([[Telegram rightViewController].navigationViewController.viewControllerStack indexOfObject:changedController] != NSNotFound) { + + NSUInteger idx = [[Telegram rightViewController].navigationViewController.viewControllerStack indexOfObject:changedController]; + + [[Telegram rightViewController].navigationViewController.viewControllerStack removeObjectsInRange:NSMakeRange(idx, [Telegram rightViewController].navigationViewController.viewControllerStack.count - idx)]; + + [[Telegram rightViewController].navigationViewController pushViewController:changedController animated:changedController != [[Telegram rightViewController] currentEmptyController]]; + changedController = nil; + + } + } + + + [self setCenterBarViewText:item.title]; } @@ -250,8 +275,10 @@ -(void)updateSize { [self.tabController setFrameSize:NSMakeSize(NSWidth(self.view.frame), NSHeight(self.tabController.frame))]; + dispatch_async(dispatch_get_main_queue(), ^{ + [self.conversationsViewController viewWillAppear:NO]; + }); - [self.conversationsViewController viewWillAppear:NO]; // // self.tabController.selectedIndex = self.tabController.selectedIndex; } @@ -273,6 +300,10 @@ -(BOOL)becomeFirstResponder { return [[self currentTabController] becomeFirstResponder]; } +-(BOOL)resignFirstResponder { + return [[self currentTabController] resignFirstResponder]; +} + - (NSResponder *)firstResponder { return self.searchTextField; } diff --git a/TelegramTest/LocationSenderItem.h b/TelegramTest/LocationSenderItem.h index 2316299e..868cea10 100644 --- a/TelegramTest/LocationSenderItem.h +++ b/TelegramTest/LocationSenderItem.h @@ -10,6 +10,6 @@ #import @interface LocationSenderItem : SenderItem --(id)initWithCoordinates:(CLLocationCoordinate2D)coordinates conversation:(TL_conversation *)conversation; +-(id)initWithCoordinates:(CLLocationCoordinate2D)coordinates conversation:(TL_conversation *)conversation additionFlags:(int)additionFlags; @end diff --git a/TelegramTest/LocationSenderItem.m b/TelegramTest/LocationSenderItem.m index f71fe057..7025884c 100644 --- a/TelegramTest/LocationSenderItem.m +++ b/TelegramTest/LocationSenderItem.m @@ -11,7 +11,7 @@ @implementation LocationSenderItem --(id)initWithCoordinates:(CLLocationCoordinate2D)coordinates conversation:(TL_conversation *)conversation +-(id)initWithCoordinates:(CLLocationCoordinate2D)coordinates conversation:(TL_conversation *)conversation additionFlags:(int)additionFlags { if(self = [super init]) { @@ -19,6 +19,10 @@ -(id)initWithCoordinates:(CLLocationCoordinate2D)coordinates conversation:(TL_co self.message = [MessageSender createOutMessage:@"" media:[TL_messageMediaGeo createWithGeo:[TL_geoPoint createWithN_long:coordinates.longitude lat:coordinates.latitude]] conversation:conversation]; + if(additionFlags & (1 << 4)) + self.message.from_id = 0; + + [self.message save:YES]; } @@ -29,19 +33,21 @@ -(id)initWithCoordinates:(CLLocationCoordinate2D)coordinates conversation:(TL_co -(void)performRequest { - TLAPI_messages_sendMedia *request = [TLAPI_messages_sendMedia createWithFlags:self.message.reply_to_msg_id != 0 ? 1 : 0 peer:[self.conversation inputPeer] reply_to_msg_id:self.message.reply_to_msg_id media:[TL_inputMediaGeoPoint createWithGeo_point:[TL_inputGeoPoint createWithLat:self.message.media.geo.lat n_long:self.message.media.geo.n_long]] random_id:self.message.randomId reply_markup:[TL_replyKeyboardMarkup createWithFlags:0 rows:[@[]mutableCopy]]]; + TLAPI_messages_sendMedia *request = [TLAPI_messages_sendMedia createWithFlags:[self senderFlags] peer:[self.conversation inputPeer] reply_to_msg_id:self.message.reply_to_msg_id media:[TL_inputMediaGeoPoint createWithGeo_point:[TL_inputGeoPoint createWithLat:self.message.media.geo.lat n_long:self.message.media.geo.n_long]] random_id:self.message.randomId reply_markup:[TL_replyKeyboardMarkup createWithFlags:0 rows:[@[]mutableCopy]]]; self.rpc_request = [RPCRequest sendRequest:request successHandler:^(RPCRequest *request, TLUpdates * response) { - if(response.updates.count < 2) + [self updateMessageId:response]; + + + TL_localMessage *msg = [TL_localMessage convertReceivedMessage:[[self updateNewMessageWithUpdates:response] message]]; + + if(msg == nil) { [self cancel]; return; } - TL_localMessage *msg = [TL_localMessage convertReceivedMessage:(TLMessage *) ( [response.updates[1] message])]; - - ((TL_localMessage *)self.message).n_id = msg.n_id; ((TL_localMessage *)self.message).date = msg.date; ((TL_localMessage *)self.message).dstate = DeliveryStateNormal; diff --git a/TelegramTest/LoginBottomView.m b/TelegramTest/LoginBottomView.m index 1b148a32..5c94c868 100644 --- a/TelegramTest/LoginBottomView.m +++ b/TelegramTest/LoginBottomView.m @@ -26,7 +26,7 @@ - (id)initWithFrame:(NSRect)frame [self.callTextField setAlignment:NSCenterTextAlignment]; [self.callTextField setDrawsBackground:NO]; [self.callTextField setTextColor:NSColorFromRGB(0xaeaeae)]; - [self.callTextField setFont:[NSFont fontWithName:@"HelveticaNeue" size:13]]; + [self.callTextField setFont:TGSystemFont(13)]; [self addSubview:self.callTextField]; [self.callTextField setUrl_delegate:self]; diff --git a/TelegramTest/LoginButtonAndErrorView.m b/TelegramTest/LoginButtonAndErrorView.m index bb1d522a..2a8b8fac 100644 --- a/TelegramTest/LoginButtonAndErrorView.m +++ b/TelegramTest/LoginButtonAndErrorView.m @@ -22,13 +22,13 @@ - (id)initWithFrame:(NSRect)frame { [self.errorTextField setEditable:NO]; [self.errorTextField setWantsLayer:IS_RETINA]; [self.errorTextField setFrameOrigin:NSMakePoint(0, 0)]; - [self.errorTextField setFont:[NSFont fontWithName:@"HelveticaNeue" size:13]]; + [self.errorTextField setFont:TGSystemFont(13)]; [self.errorTextField setTextColor:[NSColor redColor]]; self.errorTextField.layer.opacity = 0; [self addSubview:self.errorTextField]; self.textButton = [[TMTextButton alloc] initWithFrame:NSMakeRect(0, 0, 0, 0)]; - [self.textButton setFont:[NSFont fontWithName:@"HelveticaNeue" size:15]]; + [self.textButton setFont:TGSystemFont(15)]; [self.textButton setDisableColor:NSColorFromRGB(0xaeaeae)]; [self.textButton setTextColor:BLUE_UI_COLOR]; [self.textButton setWantsLayer:IS_RETINA]; diff --git a/TelegramTest/LoginCountrySelectorView.m b/TelegramTest/LoginCountrySelectorView.m index d0f677c6..5b6efbc4 100644 --- a/TelegramTest/LoginCountrySelectorView.m +++ b/TelegramTest/LoginCountrySelectorView.m @@ -35,12 +35,12 @@ - (id)initWithFrame:(NSRect)frame{ self.countryCodeTextField.drawsBackground = NO; self.countryCodeTextField.delegate = self; - NSAttributedString *placeHolder = [[NSAttributedString alloc] initWithString:@"+" attributes:@{NSFontAttributeName: [NSFont fontWithName:@"Helvetica-Light" size:15], NSForegroundColorAttributeName: NSColorFromRGB(0xaeaeae)}]; + NSAttributedString *placeHolder = [[NSAttributedString alloc] initWithString:@"+" attributes:@{NSFontAttributeName: TGSystemLightFont(15), NSForegroundColorAttributeName: NSColorFromRGB(0xaeaeae)}]; [self.countryCodeTextField.cell setPlaceholderAttributedString:placeHolder]; // [self.countryCodeTextField setPlaceholderAttributedString:placeHolder]; [self.countryCodeTextField setPlaceholderPoint:NSMakePoint(2, 0)]; - self.countryCodeTextField.font = [NSFont fontWithName:@"Helvetica-Light" size:15]; + self.countryCodeTextField.font = TGSystemLightFont(15); self.countryCodeTextField.focusRingType = NSFocusRingTypeNone; [self.countryCodeTextField setBordered:NO]; @@ -53,13 +53,13 @@ - (id)initWithFrame:(NSRect)frame{ self.numberTextField.drawsBackground = NO; self.numberTextField.delegate = self; - placeHolder = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"Login.phoneNumber", nil) attributes:@{NSFontAttributeName: [NSFont fontWithName:@"Helvetica-Light" size:15], NSForegroundColorAttributeName: NSColorFromRGB(0xaeaeae)}]; + placeHolder = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"Login.phoneNumber", nil) attributes:@{NSFontAttributeName: TGSystemLightFont(15), NSForegroundColorAttributeName: NSColorFromRGB(0xaeaeae)}]; [self.numberTextField.cell setPlaceholderAttributedString:placeHolder]; // [self.numberTextField setPlaceholderAttributedString:placeHolder]; [self.numberTextField.cell setUsesSingleLineMode:YES]; // [self.numberTextField setPlaceholderPoint:NSMakePoint(2, 1)]; - [self.numberTextField setFont:[NSFont fontWithName:@"Helvetica-Light" size:15]]; + [self.numberTextField setFont:TGSystemLightFont(15)]; self.numberTextField.focusRingType = NSFocusRingTypeNone; [self.numberTextField setBordered:NO]; [self.numberTextField setTarget:self]; @@ -78,7 +78,7 @@ - (id)initWithFrame:(NSRect)frame{ self.editTextButton = [[TMTextButton alloc] init]; // [self.editTextButton setDisable:YES]; self.editTextButton.stringValue = NSLocalizedString(@"Profile.edit", nil); - [self.editTextButton setFont:[NSFont fontWithName:@"HelveticaNeue" size:14]]; + [self.editTextButton setFont:TGSystemFont(14)]; [self.editTextButton setWantsLayer:IS_RETINA]; [self.editTextButton setTextColor:BLUE_UI_COLOR]; [self.editTextButton sizeToFit]; @@ -111,7 +111,7 @@ - (id)initWithFrame:(NSRect)frame{ // self.countryNameTextField = [CountrySelectTextField defaultTextField]; // [self.countryCodeTextField setEditable:NO]; // self.countryCodeTextField.frame = NSMakeRect(110, 60, 360, 16); - // self.countryCodeTextField.font = [NSFont fontWithName:@"Helvetica-Light" size:15]; + // self.countryCodeTextField.font = TGSystemLightFont(15); // self.countryCodeTextField.stringValue = NSLocalizedString(@"Choose coutry", nil); // [self addSubview:self.countryCodeTextField]; @@ -434,7 +434,7 @@ - (void)controlTextDidChange:(NSNotification *)notification { NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] init]; [attr appendString:format withColor:NSColorFromRGB(0x000000)]; - [attr setFont:[NSFont fontWithName:@"Helvetica-Light" size:15] forRange:NSMakeRange(0, format.length)]; + [attr setFont:TGSystemLightFont(15) forRange:NSMakeRange(0, format.length)]; [attr addAttribute:NSForegroundColorAttributeName value:NSColorFromRGB(0xaeaeae) range:NSMakeRange(xpos, format.length-xpos)]; @@ -448,7 +448,7 @@ - (void)controlTextDidChange:(NSNotification *)notification { NSMutableAttributedString *xCheck = [[NSMutableAttributedString alloc] init]; [xCheck appendString:xFormat]; - [xCheck setFont:[NSFont fontWithName:@"Helvetica-Light" size:15] forRange:NSMakeRange(0, format.length)]; + [xCheck setFont:TGSystemLightFont(15) forRange:NSMakeRange(0, format.length)]; [xCheck addAttribute:(NSString *) kCTKernAttributeName value:@(0) range:NSMakeRange(0, xFormat.length)]; @@ -503,9 +503,9 @@ - (void)drawRect:(NSRect)dirtyRect { NSAttributedString *youCountryAttributedString; if(self.selectedCountry) { - youCountryAttributedString = [[NSAttributedString alloc] initWithString:self.selectedCountry.shortCountryName attributes:@{NSFontAttributeName: [NSFont fontWithName:@"Helvetica-Light" size:15], NSForegroundColorAttributeName: self.countryCodeTextField.isEnabled ? NSColorFromRGB(0x000000) : NSColorFromRGB(0xc3c3c3)}]; + youCountryAttributedString = [[NSAttributedString alloc] initWithString:self.selectedCountry.shortCountryName attributes:@{NSFontAttributeName: TGSystemLightFont(15), NSForegroundColorAttributeName: self.countryCodeTextField.isEnabled ? NSColorFromRGB(0x000000) : NSColorFromRGB(0xc3c3c3)}]; } else { - youCountryAttributedString = [[NSAttributedString alloc] initWithString:self.countryCodeTextField.stringValue.length ? NSLocalizedString(@"Login.InvalidCountry", nil) : NSLocalizedString(@"Registration.ChooseCountry", nil) attributes:@{NSFontAttributeName: [NSFont fontWithName:@"Helvetica-Light" size:15], NSForegroundColorAttributeName: NSColorFromRGB(0xaeaeae)}]; + youCountryAttributedString = [[NSAttributedString alloc] initWithString:self.countryCodeTextField.stringValue.length ? NSLocalizedString(@"Login.InvalidCountry", nil) : NSLocalizedString(@"Registration.ChooseCountry", nil) attributes:@{NSFontAttributeName: TGSystemLightFont(15), NSForegroundColorAttributeName: NSColorFromRGB(0xaeaeae)}]; } // NSSize size = [youCountryAttributedString size]; @@ -612,7 +612,7 @@ - (NSString *)phoneNumber { static NSDictionary *dictionary; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - dictionary = @{NSFontAttributeName: [NSFont fontWithName:@"HelveticaNeue" size:13], NSForegroundColorAttributeName: NSColorFromRGB(0xc8c8c8)}; + dictionary = @{NSFontAttributeName: TGSystemFont(13), NSForegroundColorAttributeName: NSColorFromRGB(0xc8c8c8)}; }); return dictionary; } diff --git a/TelegramTest/LoginSMSCodeView.m b/TelegramTest/LoginSMSCodeView.m index dac3f55b..2d4547f9 100644 --- a/TelegramTest/LoginSMSCodeView.m +++ b/TelegramTest/LoginSMSCodeView.m @@ -22,11 +22,11 @@ - (id)initWithFrame:(NSRect)frame { self = [super initWithFrame:frame]; if (self) { - self.smsCodeTextField = [[TMTextField alloc] initWithFrame:NSMakeRect(120, 20, self.bounds.size.width, 20)]; + self.smsCodeTextField = [[TMTextField alloc] initWithFrame:NSMakeRect(120, 20, self.bounds.size.width, 20)]; self.smsCodeTextField.drawsBackground = NO; self.smsCodeTextField.delegate = self; [self.smsCodeTextField setPlaceholderPoint:NSMakePoint(2, 1)]; - self.smsCodeTextField.font = [NSFont fontWithName:@"Helvetica-Light" size:15]; + self.smsCodeTextField.font = TGSystemLightFont(15); self.smsCodeTextField.focusRingType = NSFocusRingTypeNone; [self.smsCodeTextField setBordered:NO]; [self addSubview:self.smsCodeTextField]; @@ -40,7 +40,7 @@ - (id)initWithFrame:(NSRect)frame { // [self.callTextField setEditable:NO]; // [self.callTextField setDrawsBackground:NO]; // [self.callTextField setTextColor:NSColorFromRGB(0xaeaeae)]; -// [self.callTextField setFont:[NSFont fontWithName:@"HelveticaNeue" size:13]]; +// [self.callTextField setFont:TGSystemFont(13)]; // [self addSubview:self.callTextField]; // // [self.callTextField setHardXOffset:44]; @@ -139,7 +139,7 @@ - (void)performSlideDownWithDuration:(float)duration { dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(duration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - NSAttributedString *placeHolder = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"Login.code",nil) attributes:@{NSFontAttributeName: [NSFont fontWithName:@"Helvetica-Light" size:15], NSForegroundColorAttributeName: NSColorFromRGB(0xaeaeae)}]; + NSAttributedString *placeHolder = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"Login.code",nil) attributes:@{NSFontAttributeName: TGSystemLightFont(15), NSForegroundColorAttributeName: NSColorFromRGB(0xaeaeae)}]; [self.smsCodeTextField.cell setPlaceholderAttributedString:placeHolder]; // [self.smsCodeTextField setPlaceholderAttributedString:placeHolder]; [self.smsCodeTextField.window makeFirstResponder:self.smsCodeTextField]; diff --git a/TelegramTest/MP3HistoryFilter.h b/TelegramTest/MP3HistoryFilter.h index 783da595..3e3e7e57 100644 --- a/TelegramTest/MP3HistoryFilter.h +++ b/TelegramTest/MP3HistoryFilter.h @@ -7,7 +7,7 @@ // #import "HistoryFilter.h" - -@interface MP3HistoryFilter : HistoryFilter +#import "CommonMediaHistoryFilter.h" +@interface MP3HistoryFilter : CommonMediaHistoryFilter @end diff --git a/TelegramTest/MP3HistoryFilter.m b/TelegramTest/MP3HistoryFilter.m index 1b981908..5bd59553 100644 --- a/TelegramTest/MP3HistoryFilter.m +++ b/TelegramTest/MP3HistoryFilter.m @@ -10,27 +10,6 @@ #import "ChatHistoryController.h" @implementation MP3HistoryFilter -static NSMutableDictionary * messageItems; -static NSMutableDictionary * messageKeys; - --(id)initWithController:(ChatHistoryController *)controller { - if(self = [super initWithController:controller]) { - - } - - return self; -} - - -+(void)initialize { - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - messageItems = [[NSMutableDictionary alloc] init]; - messageKeys = [[NSMutableDictionary alloc] init]; - - }); -} - -(int)type { return HistoryFilterAudioDocument; @@ -40,79 +19,8 @@ +(int)type { return HistoryFilterAudioDocument; } -- (NSMutableDictionary *)messageKeys:(int)peer_id { - return [[self class] messageKeys:peer_id]; -} - -- (NSMutableArray *)messageItems:(int)peer_id { - return [[self class] messageItems:peer_id]; -} - -+ (NSMutableDictionary *)messageKeys:(int)peer_id { - - __block NSMutableDictionary *keys; - [ASQueue dispatchOnStageQueue:^{ - - keys = messageKeys[@(peer_id)]; - - if(!keys) - { - keys = [[NSMutableDictionary alloc] init]; - messageKeys[@(peer_id)] = keys; - } - - } synchronous:YES]; - - return keys; -} - -+ (NSMutableArray *)messageItems:(int)peer_id { - __block NSMutableArray *items; - - [ASQueue dispatchOnStageQueue:^{ - - items = messageItems[@(peer_id)]; - - if(!items) - { - items = [[NSMutableArray alloc] init]; - messageItems[@(peer_id)] = items; - } - - } synchronous:YES]; - - - - return items; -} - - -+(void)drop { - [ASQueue dispatchOnStageQueue:^{ - [messageKeys removeAllObjects]; - [messageItems removeAllObjects]; - }]; -} - - - --(void)remoteRequest:(BOOL)next peer_id:(int)peer_id callback:(void (^)(id response))callback { - - self.request = [RPCRequest sendRequest:[TLAPI_messages_search createWithPeer:[self.controller.conversation inputPeer] q:@"" filter:[TL_inputMessagesFilterAudioDocuments create] min_date:0 max_date:0 offset:0 max_id:self.controller.max_id limit:(int)self.controller.selectLimit] successHandler:^(RPCRequest *request, id response) { - - - if(callback && self != nil) { - callback(response); - } - - } errorHandler:^(RPCRequest *request, RpcError *error) { - - if(callback) { - callback(nil); - } - - } timeout:10 queue:[ASQueue globalQueue].nativeQueue]; - +-(TLMessagesFilter *)messagesFilter { + return [TL_inputMessagesFilterAudioDocuments create]; } -(NSString *)description { diff --git a/TelegramTest/MTNetwork.h b/TelegramTest/MTNetwork.h index 8ca08218..3fbfa23d 100644 --- a/TelegramTest/MTNetwork.h +++ b/TelegramTest/MTNetwork.h @@ -28,10 +28,12 @@ -(int)currentDatacenter; -(void)setDatacenter:(int)dc_id; -(void)cancelRequest:(RPCRequest *)request; - +-(void)cancelRequestWithInternalId:(id)internalId; -(void)setUserId:(int)userId; -(int)getUserId; +-(void)addRequest:(MTRequest *)request; + - (TGUpdateMessageService *)updateService; -(void)startNetwork; @@ -40,6 +42,10 @@ -(void)update; ++(void)pause; ++(void)resume; +-(NSString *)updateEncryptionKey; + -(MTQueue *)queue; -(void)updatePasscode:(NSData *)md5Hash; diff --git a/TelegramTest/MTNetwork.m b/TelegramTest/MTNetwork.m index 6d92eafa..09f51c6a 100644 --- a/TelegramTest/MTNetwork.m +++ b/TelegramTest/MTNetwork.m @@ -18,10 +18,12 @@ #import "SSKeychain.h" #import "TGTLSerialization.h" #import "TGPasslock.h" +#import @implementation MTRequest (LegacyTL) - (void)setBody:(TLApiObject *)body { + [self setPayload:[TGTLSerialization serializeMessage:body] metadata:body responseParser:^id(NSData *data) { return [TGTLSerialization parseResponse:data request:body]; @@ -143,23 +145,37 @@ - (instancetype)init } synchronous:YES]; if(acceptHash) { - - [_queue dispatchOnQueue:^{ - - [self startWithKeychain:_keychain]; - [self initConnectionWithId:_masterDatacenter]; - + + + [_queue dispatchOnQueue:^{ + + [self updateStorageEncryptionKey]; + [Storage updateOldEncryptionKey:md5Hash]; + + [Storage initManagerWithCallback:^{ + + [self startWithKeychain:_keychain]; + [self initConnectionWithId:_masterDatacenter]; + + + [ASQueue dispatchOnMainQueue:^{ + [Telegram initializeDatabase]; + + if(![self isAuth]) { + [[Telegram delegate] logoutWithForce:YES]; + } else { + [TGPasslock appIncomeActive]; + } + }]; + + }]; + }]; - }]; - [Telegram initializeDatabase]; + + - if(![self isAuth]) { - [[Telegram delegate] logoutWithForce:YES]; - } else { - [TGPasslock appIncomeActive]; - } - } + } return acceptHash; @@ -176,6 +192,9 @@ - (instancetype)init } else { + + [self updateStorageEncryptionKey]; + [self startWithKeychain:_keychain]; if(![self isAuth]) { @@ -201,7 +220,6 @@ -(void)moveAndEncryptKeychain { NSString *applicationSupportPath = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES)[0]; NSString *applicationName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"]; NSString * odirectory = [[applicationSupportPath stringByAppendingPathComponent:applicationName] stringByAppendingPathComponent:@"mtkeychain"]; - BOOL isset = NO; @@ -220,10 +238,10 @@ -(void)moveAndEncryptKeychain { [keychain updatePasscodeHash:[[NSData alloc] initWithEmptyBytes:32] save:YES]; [[NSFileManager defaultManager] removeItemAtPath:odirectory error:nil]; - } } + } @@ -231,22 +249,35 @@ -(MTQueue *)queue { return [_mtProto messageServiceQueue]; } + +// NSString * ndirectory = [[NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES)[0] stringByAppendingPathComponent:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"]] stringByAppendingPathComponent:@"encrypt-mtkeychain"]; +// +// if([[NSFileManager defaultManager] fileExistsAtPath:ndirectory]) { +// +// TGKeychain *keychain = [TGKeychain unencryptedKeychainWithName:BUNDLE_IDENTIFIER]; +// +// keychain->_encrypted = YES; +// +// [keychain storeAllKeychain]; +// +// [[NSFileManager defaultManager] removeItemAtPath:ndirectory error:nil]; +// +// } + + -(TGKeychain *)nKeychain { - + #ifndef TGDEBUG - // if(NSAppKitVersionNumber >= NSAppKitVersionNumber10_9) - // return [TGKeychain keychainWithName:BUNDLE_IDENTIFIER]; - // else - return [TGKeychain unencryptedKeychainWithName:BUNDLE_IDENTIFIER]; -#else + if(NSAppKitVersionNumber >= NSAppKitVersionNumber10_9) + return [TGKeychain keychainWithName:BUNDLE_IDENTIFIER]; -// if([[UsersManager currentUser].username isEqualToString:@"vihor"] && !isTestServer()) { -// return [TGKeychain keychainWithName:BUNDLE_IDENTIFIER]; -// } + return [TGKeychain unencryptedKeychainWithName:BUNDLE_IDENTIFIER]; + +#else if(isTestServer()) { return [TGKeychain unencryptedKeychainWithName:@"org.telegram.test"]; @@ -308,11 +339,22 @@ -(BOOL)passcodeIsEnabled { } +-(void)updateStorageEncryptionKey { + + NSString *key = [_keychain objectForKey:@"e_key" group:@"persistent"]; + + if(!key) + [self updateEncryptionKey]; + else + [Storage updateEncryptionKey:key]; +} + -(void)startWithKeychain:(TGKeychain *)keychain { [_context setKeychain:keychain]; + [_context addChangeListener:self]; @@ -362,16 +404,26 @@ -(void)startWithKeychain:(TGKeychain *)keychain { } - (TGUpdateMessageService *)updateService { - return _updateService; + __block TGUpdateMessageService *s; + + [_queue dispatchOnQueue:^{ + + s = _updateService; + + } synchronous:YES]; + + return s; } -(void)startNetwork { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - [self initConnectionWithId:_masterDatacenter]; - - [_datacenterWatchdog execute:nil]; + [_queue dispatchOnQueue:^{ + [self initConnectionWithId:_masterDatacenter]; + + [_datacenterWatchdog execute:nil]; + }]; }); } @@ -380,6 +432,13 @@ -(void)update { [_mtProto resume]; } ++(void)pause { + [[self instance]->_mtProto pause]; +} ++(void)resume { + [[self instance]->_mtProto resume]; +} + static int MAX_WORKER_POLL = 5; -(void)resetWorkers { @@ -407,6 +466,7 @@ -(void)resetWorkers { -(void)initConnectionWithId:(NSInteger)dc_id { + dc_id = dc_id == -1 ? _masterDatacenter : dc_id; [_queue dispatchOnQueue:^{ @@ -432,29 +492,55 @@ -(void)initConnectionWithId:(NSInteger)dc_id { -(void)drop { - [_context removeAllAuthTokens]; - [[NSUserDefaults standardUserDefaults] removeObjectForKey:kDefaultDatacenter]; - NSString *appDomain = [[NSBundle mainBundle] bundleIdentifier]; - [[NSUserDefaults standardUserDefaults] removePersistentDomainForName:appDomain]; - - - NSString *applicationSupportPath = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES)[0]; - NSString *applicationName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"]; + [_queue dispatchOnQueue:^{ + [_context removeAllAuthTokens]; + [[NSUserDefaults standardUserDefaults] removeObjectForKey:kDefaultDatacenter]; + NSString *appDomain = [[NSBundle mainBundle] bundleIdentifier]; + [[NSUserDefaults standardUserDefaults] removePersistentDomainForName:appDomain]; + + + NSString *applicationSupportPath = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES)[0]; + NSString *applicationName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"]; + + NSString * mtkeychain = [[applicationSupportPath stringByAppendingPathComponent:applicationName] stringByAppendingPathComponent:@"encrypt-mtkeychain"]; + + [[NSFileManager defaultManager] removeItemAtPath:mtkeychain error:nil]; + + [SSKeychain deletePasswordForService:appName() account:@"authkeys"]; + + [_keychain cleanup]; + [_keychain loadIfNeeded]; + + [_keychain updatePasscodeHash:[[NSData alloc] initWithEmptyBytes:32] save:YES]; + + [self.updateService drop]; + [self setDatacenter:isTestServer() ? 1 : 2]; + + + [self updateEncryptionKey]; + + + + } synchronous:YES]; - NSString * mtkeychain = [[applicationSupportPath stringByAppendingPathComponent:applicationName] stringByAppendingPathComponent:@"encrypt-mtkeychain"]; - [[NSFileManager defaultManager] removeItemAtPath:mtkeychain error:nil]; +} + +-(NSString *)updateEncryptionKey { + uint8_t secKey[32]; + SecRandomCopyBytes(kSecRandomDefault, 32, secKey); - [SSKeychain deletePasswordForService:@"Telegram" account:@"authkeys"]; + NSString *key = [[[NSString alloc] initWithData:[[NSData alloc] initWithBytes:secKey length:32] encoding:NSASCIIStringEncoding] md5]; - [_keychain updatePasscodeHash:[[NSData alloc] initWithEmptyBytes:32] save:YES]; + [_keychain setObject:key forKey:@"e_key" group:@"persistent"]; - [self.updateService drop]; - [self setDatacenter:1]; + [Storage updateEncryptionKey:key]; - [self initConnectionWithId:_masterDatacenter]; + return key; } + + -(int)getTime { return [_context globalTime]; @@ -468,6 +554,7 @@ -(void)setDatacenter:(int)dc_id { _masterDatacenter = dc_id; [_keychain setObject:@(dc_id) forKey:@"dc_id" group:@"persistent"]; + } -(void)setUserId:(int)userId { @@ -487,8 +574,12 @@ -(void)cancelRequest:(RPCRequest *)request { [_queue dispatchOnQueue:^{ [_requestService removeRequestByInternalId:request.mtrequest.internalId]; }]; - - +} + +-(void)cancelRequestWithInternalId:(id)internalId { + [_queue dispatchOnQueue:^{ + [_requestService removeRequestByInternalId:internalId]; + }]; } -(void)sendRequest:(RPCRequest *)request forDatacenter:(int)datacenterId { @@ -574,6 +665,13 @@ -(MTRequest *)constructRequest:(RPCRequest *)request { }]; + + if(request.alwayContinueWithErrorContext) { + [mtrequest setShouldContinueExecutionWithErrorContext:^bool(MTRequestErrorContext *errorContext) { + return false; + }]; + } + return mtrequest; } @@ -593,6 +691,16 @@ -(void)sendRequest:(RPCRequest *)request { }]; } +-(void)addRequest:(MTRequest *)request { + [_queue dispatchOnQueue:^{ + + if([self isAuth]) { + [_requestService addRequest:request]; + } + + }]; +} + -(void)successAuthForDatacenter:(int)dc_id { [_queue dispatchOnQueue:^{ [_context updateAuthTokenForDatacenterWithId:dc_id authToken:@(dc_id)]; diff --git a/TelegramTest/MTProto.h b/TelegramTest/MTProto.h index 23907807..4634680e 100644 --- a/TelegramTest/MTProto.h +++ b/TelegramTest/MTProto.h @@ -2,13 +2,16 @@ // MTProto.h // Telegram // -// Auto created by Mikhail Filimonov on 24.07.15. +// Auto created by Mikhail Filimonov on 27.11.15. // Copyright (c) 2013 Telegram for OS X. All rights reserved. // #import #import "TLObject.h" +@interface TLTrue : TLObject +@end + @interface TLInputPeer : TLObject @end @@ -132,6 +135,9 @@ @interface TLWallPaper : TLObject @end +@interface TLReportReason : TLObject +@end + @interface TLUserFull : TLObject @end @@ -150,9 +156,6 @@ @interface TLContactStatus : TLObject @end -@interface TLChatLocated : TLObject -@end - @interface TLcontacts_Link : TLObject @end @@ -174,12 +177,6 @@ @interface TLmessages_Messages : TLObject @end -@interface TLmessages_Message : TLObject -@end - -@interface TLmessages_SentMessage : TLObject -@end - @interface TLmessages_Chats : TLObject @end @@ -228,21 +225,6 @@ @interface TLhelp_InviteText : TLObject @end -@interface TLInputGeoChat : TLObject -@end - -@interface TLGeoChatMessage : TLObject -@end - -@interface TLgeochats_StatedMessage : TLObject -@end - -@interface TLgeochats_Located : TLObject -@end - -@interface TLgeochats_Messages : TLObject -@end - @interface TLEncryptedChat : TLObject @end @@ -285,9 +267,6 @@ @interface TLSendMessageAction : TLObject @end -@interface TLContactFound : TLObject -@end - @interface TLcontacts_Found : TLObject @end @@ -387,6 +366,48 @@ @interface TLReplyMarkup : TLObject @end +@interface TLhelp_AppChangelog : TLObject +@end + +@interface TLMessageEntity : TLObject +@end + +@interface TLInputChannel : TLObject +@end + +@interface TLcontacts_ResolvedPeer : TLObject +@end + +@interface TLMessageRange : TLObject +@end + +@interface TLMessageGroup : TLObject +@end + +@interface TLupdates_ChannelDifference : TLObject +@end + +@interface TLChannelMessagesFilter : TLObject +@end + +@interface TLChannelParticipant : TLObject +@end + +@interface TLChannelParticipantsFilter : TLObject +@end + +@interface TLChannelParticipantRole : TLObject +@end + +@interface TLchannels_ChannelParticipants : TLObject +@end + +@interface TLchannels_ChannelParticipant : TLObject +@end + +@interface TLhelp_TermsOfService : TLObject +@end + @interface TLProtoMessage : TLObject @end @@ -475,10 +496,19 @@ +@interface TLTrue() + +@end + +@interface TL_true : TLTrue ++(TL_true*)create; +@end + @interface TLInputPeer() +@property int chat_id; @property int user_id; @property long access_hash; -@property int chat_id; +@property int channel_id; @end @interface TL_inputPeerEmpty : TLInputPeer @@ -487,15 +517,15 @@ @interface TL_inputPeerSelf : TLInputPeer +(TL_inputPeerSelf*)create; @end -@interface TL_inputPeerContact : TLInputPeer -+(TL_inputPeerContact*)createWithUser_id:(int)user_id; -@end -@interface TL_inputPeerForeign : TLInputPeer -+(TL_inputPeerForeign*)createWithUser_id:(int)user_id access_hash:(long)access_hash; -@end @interface TL_inputPeerChat : TLInputPeer +(TL_inputPeerChat*)createWithChat_id:(int)chat_id; @end +@interface TL_inputPeerUser : TLInputPeer ++(TL_inputPeerUser*)createWithUser_id:(int)user_id access_hash:(long)access_hash; +@end +@interface TL_inputPeerChannel : TLInputPeer ++(TL_inputPeerChannel*)createWithChannel_id:(int)channel_id access_hash:(long)access_hash; +@end @interface TLInputUser() @property int user_id; @@ -508,11 +538,8 @@ @interface TL_inputUserSelf : TLInputUser +(TL_inputUserSelf*)create; @end -@interface TL_inputUserContact : TLInputUser -+(TL_inputUserContact*)createWithUser_id:(int)user_id; -@end -@interface TL_inputUserForeign : TLInputUser -+(TL_inputUserForeign*)createWithUser_id:(int)user_id access_hash:(long)access_hash; +@interface TL_inputUser : TLInputUser ++(TL_inputUser*)createWithUser_id:(int)user_id access_hash:(long)access_hash; @end @interface TLInputContact() @@ -551,8 +578,8 @@ @property int duration; @property int w; @property int h; -@property (nonatomic, strong) TLInputFile* thumb; @property (nonatomic, strong) NSString* mime_type; +@property (nonatomic, strong) TLInputFile* thumb; @property (nonatomic, strong) NSMutableArray* attributes; @property (nonatomic, strong) NSString* title; @property (nonatomic, strong) NSString* address; @@ -576,10 +603,10 @@ +(TL_inputMediaContact*)createWithPhone_number:(NSString*)phone_number first_name:(NSString*)first_name last_name:(NSString*)last_name; @end @interface TL_inputMediaUploadedVideo : TLInputMedia -+(TL_inputMediaUploadedVideo*)createWithFile:(TLInputFile*)file duration:(int)duration w:(int)w h:(int)h caption:(NSString*)caption; ++(TL_inputMediaUploadedVideo*)createWithFile:(TLInputFile*)file duration:(int)duration w:(int)w h:(int)h mime_type:(NSString*)mime_type caption:(NSString*)caption; @end @interface TL_inputMediaUploadedThumbVideo : TLInputMedia -+(TL_inputMediaUploadedThumbVideo*)createWithFile:(TLInputFile*)file thumb:(TLInputFile*)thumb duration:(int)duration w:(int)w h:(int)h caption:(NSString*)caption; ++(TL_inputMediaUploadedThumbVideo*)createWithFile:(TLInputFile*)file thumb:(TLInputFile*)thumb duration:(int)duration w:(int)w h:(int)h mime_type:(NSString*)mime_type caption:(NSString*)caption; @end @interface TL_inputMediaVideo : TLInputMedia +(TL_inputMediaVideo*)createWithN_id:(TLInputVideo*)n_id caption:(NSString*)caption; @@ -602,6 +629,12 @@ @interface TL_inputMediaVenue : TLInputMedia +(TL_inputMediaVenue*)createWithGeo_point:(TLInputGeoPoint*)geo_point title:(NSString*)title address:(NSString*)address provider:(NSString*)provider venue_id:(NSString*)venue_id; @end +@interface TL_inputMediaUploadedVideo_old34 : TLInputMedia ++(TL_inputMediaUploadedVideo_old34*)createWithFile:(TLInputFile*)file duration:(int)duration w:(int)w h:(int)h caption:(NSString*)caption; +@end +@interface TL_inputMediaUploadedThumbVideo_old32 : TLInputMedia ++(TL_inputMediaUploadedThumbVideo_old32*)createWithFile:(TLInputFile*)file thumb:(TLInputFile*)thumb duration:(int)duration w:(int)w h:(int)h caption:(NSString*)caption; +@end @interface TLInputChatPhoto() @property (nonatomic, strong) TLInputFile* file; @@ -706,6 +739,7 @@ @interface TLPeer() @property int user_id; @property int chat_id; +@property int channel_id; @end @interface TL_peerUser : TLPeer @@ -714,6 +748,9 @@ @interface TL_peerChat : TLPeer +(TL_peerChat*)createWithChat_id:(int)chat_id; @end +@interface TL_peerChannel : TLPeer ++(TL_peerChannel*)createWithChannel_id:(int)channel_id; +@end @interface TLstorage_FileType() @@ -767,6 +804,14 @@ @interface TLUser() @property int n_id; @property int flags; +@property (nonatomic,assign,readonly) BOOL isSelf; +@property (nonatomic,assign,readonly) BOOL isContact; +@property (nonatomic,assign,readonly) BOOL isMutual_contact; +@property (nonatomic,assign,readonly) BOOL isDeleted; +@property (nonatomic,assign,readonly) BOOL isBot; +@property (nonatomic,assign,readonly) BOOL isBot_chat_history; +@property (nonatomic,assign,readonly) BOOL isBot_nochats; +@property (nonatomic,assign,readonly) BOOL isVerified; @property long access_hash; @property (nonatomic, strong) NSString* first_name; @property (nonatomic, strong) NSString* last_name; @@ -781,7 +826,7 @@ +(TL_userEmpty*)createWithN_id:(int)n_id; @end @interface TL_user : TLUser -+(TL_user*)createWithFlags:(int)flags n_id:(int)n_id access_hash:(long)access_hash first_name:(NSString*)first_name last_name:(NSString*)last_name username:(NSString*)username phone:(NSString*)phone photo:(TLUserProfilePhoto*)photo status:(TLUserStatus*)status bot_info_version:(int)bot_info_version; ++(TL_user*)createWithFlags:(int)flags n_id:(int)n_id access_hash:(long)access_hash first_name:(NSString*)first_name last_name:(NSString*)last_name username:(NSString*)username phone:(NSString*)phone photo:(TLUserProfilePhoto*)photo status:(TLUserStatus*)status bot_info_version:(int)bot_info_version; @end @interface TL_userSelf : TLUser +(TL_userSelf*)createWithN_id:(int)n_id first_name:(NSString*)first_name last_name:(NSString*)last_name username:(NSString*)username phone:(NSString*)phone photo:(TLUserProfilePhoto*)photo status:(TLUserStatus*)status; @@ -838,30 +883,51 @@ @interface TLChat() @property int n_id; +@property int flags; +@property (nonatomic,assign,readonly) BOOL isCreator; +@property (nonatomic,assign,readonly) BOOL isKicked; +@property Boolean left; +@property (nonatomic,assign,readonly) BOOL isAdmins_enabled; +@property (nonatomic,assign,readonly) BOOL isAdmin; +@property (nonatomic,assign,readonly) BOOL isDeactivated; @property (nonatomic, strong) NSString* title; @property (nonatomic, strong) TLChatPhoto* photo; @property int participants_count; @property int date; -@property Boolean left; @property int version; +@property (nonatomic, strong) TLInputChannel* migrated_to; +@property (nonatomic,assign,readonly) BOOL isEditor; +@property (nonatomic,assign,readonly) BOOL isModerator; +@property (nonatomic,assign,readonly) BOOL isBroadcast; +@property (nonatomic,assign,readonly) BOOL isVerified; +@property (nonatomic,assign,readonly) BOOL isMegagroup; @property long access_hash; -@property (nonatomic, strong) NSString* address; -@property (nonatomic, strong) NSString* venue; -@property (nonatomic, strong) TLGeoPoint* geo; -@property Boolean checked_in; +@property (nonatomic, strong) NSString* username; @end @interface TL_chatEmpty : TLChat +(TL_chatEmpty*)createWithN_id:(int)n_id; @end @interface TL_chat : TLChat -+(TL_chat*)createWithN_id:(int)n_id title:(NSString*)title photo:(TLChatPhoto*)photo participants_count:(int)participants_count date:(int)date left:(Boolean)left version:(int)version; ++(TL_chat*)createWithFlags:(int)flags n_id:(int)n_id title:(NSString*)title photo:(TLChatPhoto*)photo participants_count:(int)participants_count date:(int)date version:(int)version migrated_to:(TLInputChannel*)migrated_to; @end @interface TL_chatForbidden : TLChat -+(TL_chatForbidden*)createWithN_id:(int)n_id title:(NSString*)title date:(int)date; ++(TL_chatForbidden*)createWithN_id:(int)n_id title:(NSString*)title; +@end +@interface TL_channel : TLChat ++(TL_channel*)createWithFlags:(int)flags n_id:(int)n_id access_hash:(long)access_hash title:(NSString*)title username:(NSString*)username photo:(TLChatPhoto*)photo date:(int)date version:(int)version; +@end +@interface TL_channelForbidden : TLChat ++(TL_channelForbidden*)createWithN_id:(int)n_id access_hash:(long)access_hash title:(NSString*)title; +@end +@interface TL_chat_old34 : TLChat ++(TL_chat_old34*)createWithN_id:(int)n_id title:(NSString*)title photo:(TLChatPhoto*)photo participants_count:(int)participants_count date:(int)date left:(Boolean)left version:(int)version; +@end +@interface TL_chatForbidden_old34 : TLChat ++(TL_chatForbidden_old34*)createWithN_id:(int)n_id title:(NSString*)title date:(int)date; @end -@interface TL_geoChat : TLChat -+(TL_geoChat*)createWithN_id:(int)n_id access_hash:(long)access_hash title:(NSString*)title address:(NSString*)address venue:(NSString*)venue geo:(TLGeoPoint*)geo photo:(TLChatPhoto*)photo participants_count:(int)participants_count date:(int)date checked_in:(Boolean)checked_in version:(int)version; +@interface TL_chat_old38 : TLChat ++(TL_chat_old38*)createWithFlags:(int)flags n_id:(int)n_id title:(NSString*)title photo:(TLChatPhoto*)photo participants_count:(int)participants_count date:(int)date version:(int)version; @end @interface TLChatFull() @@ -871,14 +937,31 @@ @property (nonatomic, strong) TLPeerNotifySettings* notify_settings; @property (nonatomic, strong) TLExportedChatInvite* exported_invite; @property (nonatomic, strong) NSMutableArray* bot_info; +@property int flags; +@property (nonatomic,assign,readonly) BOOL isCan_view_participants; +@property (nonatomic, strong) NSString* about; +@property int participants_count; +@property int admins_count; +@property int kicked_count; +@property int read_inbox_max_id; +@property int unread_count; +@property int unread_important_count; +@property int migrated_from_chat_id; +@property int migrated_from_max_id; @end @interface TL_chatFull : TLChatFull +(TL_chatFull*)createWithN_id:(int)n_id participants:(TLChatParticipants*)participants chat_photo:(TLPhoto*)chat_photo notify_settings:(TLPeerNotifySettings*)notify_settings exported_invite:(TLExportedChatInvite*)exported_invite bot_info:(NSMutableArray*)bot_info; @end +@interface TL_channelFull : TLChatFull ++(TL_channelFull*)createWithFlags:(int)flags n_id:(int)n_id about:(NSString*)about participants_count:(int)participants_count admins_count:(int)admins_count kicked_count:(int)kicked_count read_inbox_max_id:(int)read_inbox_max_id unread_count:(int)unread_count unread_important_count:(int)unread_important_count chat_photo:(TLPhoto*)chat_photo notify_settings:(TLPeerNotifySettings*)notify_settings exported_invite:(TLExportedChatInvite*)exported_invite bot_info:(NSMutableArray*)bot_info migrated_from_chat_id:(int)migrated_from_chat_id migrated_from_max_id:(int)migrated_from_max_id; +@end @interface TL_chatFull_old29 : TLChatFull +(TL_chatFull_old29*)createWithN_id:(int)n_id participants:(TLChatParticipants*)participants chat_photo:(TLPhoto*)chat_photo notify_settings:(TLPeerNotifySettings*)notify_settings exported_invite:(TLExportedChatInvite*)exported_invite; @end +@interface TL_channelFull_old39 : TLChatFull ++(TL_channelFull_old39*)createWithFlags:(int)flags n_id:(int)n_id about:(NSString*)about participants_count:(int)participants_count admins_count:(int)admins_count kicked_count:(int)kicked_count read_inbox_max_id:(int)read_inbox_max_id unread_count:(int)unread_count unread_important_count:(int)unread_important_count chat_photo:(TLPhoto*)chat_photo notify_settings:(TLPeerNotifySettings*)notify_settings exported_invite:(TLExportedChatInvite*)exported_invite; +@end @interface TLChatParticipant() @property int user_id; @@ -889,19 +972,36 @@ @interface TL_chatParticipant : TLChatParticipant +(TL_chatParticipant*)createWithUser_id:(int)user_id inviter_id:(int)inviter_id date:(int)date; @end +@interface TL_chatParticipantCreator : TLChatParticipant ++(TL_chatParticipantCreator*)createWithUser_id:(int)user_id; +@end +@interface TL_chatParticipantAdmin : TLChatParticipant ++(TL_chatParticipantAdmin*)createWithUser_id:(int)user_id inviter_id:(int)inviter_id date:(int)date; +@end @interface TLChatParticipants() +@property int flags; @property int chat_id; -@property int admin_id; +@property (nonatomic, strong) TLChatParticipant* self_participant; @property (nonatomic, strong) NSMutableArray* participants; @property int version; +@property int admin_id; @end @interface TL_chatParticipantsForbidden : TLChatParticipants -+(TL_chatParticipantsForbidden*)createWithChat_id:(int)chat_id; ++(TL_chatParticipantsForbidden*)createWithFlags:(int)flags chat_id:(int)chat_id self_participant:(TLChatParticipant*)self_participant; @end @interface TL_chatParticipants : TLChatParticipants -+(TL_chatParticipants*)createWithChat_id:(int)chat_id admin_id:(int)admin_id participants:(NSMutableArray*)participants version:(int)version; ++(TL_chatParticipants*)createWithChat_id:(int)chat_id participants:(NSMutableArray*)participants version:(int)version; +@end +@interface TL_chatParticipantsForbidden_old34 : TLChatParticipants ++(TL_chatParticipantsForbidden_old34*)createWithChat_id:(int)chat_id; +@end +@interface TL_chatParticipants_old38 : TLChatParticipants ++(TL_chatParticipants_old38*)createWithChat_id:(int)chat_id admin_id:(int)admin_id participants:(NSMutableArray*)participants version:(int)version; +@end +@interface TL_chatParticipants_old39 : TLChatParticipants ++(TL_chatParticipants_old39*)createWithChat_id:(int)chat_id admin_id:(int)admin_id participants:(NSMutableArray*)participants version:(int)version; @end @interface TLChatPhoto() @@ -919,15 +1019,21 @@ @interface TLMessage() @property int n_id; @property int flags; +@property (nonatomic,assign,readonly) BOOL isUnread; +@property (nonatomic,assign,readonly) BOOL isN_out; +@property (nonatomic,assign,readonly) BOOL isMentioned; +@property (nonatomic,assign,readonly) BOOL isMedia_unread; @property int from_id; @property (nonatomic, strong) TLPeer* to_id; -@property int fwd_from_id; +@property (nonatomic, strong) TLPeer* fwd_from_id; @property int fwd_date; @property int reply_to_msg_id; @property int date; @property (nonatomic, strong) NSString* message; @property (nonatomic, strong) TLMessageMedia* media; @property (nonatomic, strong) TLReplyMarkup* reply_markup; +@property (nonatomic, strong) NSMutableArray* entities; +@property int views; @property (nonatomic, strong) TLMessageAction* action; @end @@ -935,10 +1041,10 @@ +(TL_messageEmpty*)createWithN_id:(int)n_id; @end @interface TL_message : TLMessage -+(TL_message*)createWithFlags:(int)flags n_id:(int)n_id from_id:(int)from_id to_id:(TLPeer*)to_id fwd_from_id:(int)fwd_from_id fwd_date:(int)fwd_date reply_to_msg_id:(int)reply_to_msg_id date:(int)date message:(NSString*)message media:(TLMessageMedia*)media reply_markup:(TLReplyMarkup*)reply_markup; ++(TL_message*)createWithFlags:(int)flags n_id:(int)n_id from_id:(int)from_id to_id:(TLPeer*)to_id fwd_from_id:(TLPeer*)fwd_from_id fwd_date:(int)fwd_date reply_to_msg_id:(int)reply_to_msg_id date:(int)date message:(NSString*)message media:(TLMessageMedia*)media reply_markup:(TLReplyMarkup*)reply_markup entities:(NSMutableArray*)entities views:(int)views; @end @interface TL_messageService : TLMessage -+(TL_messageService*)createWithFlags:(int)flags n_id:(int)n_id from_id:(int)from_id to_id:(TLPeer*)to_id date:(int)date action:(TLMessageAction*)action; ++(TL_messageService*)createWithFlags:(int)flags n_id:(int)n_id from_id:(int)from_id to_id:(TLPeer*)to_id date:(int)date action:(TLMessageAction*)action; @end @interface TLMessageMedia() @@ -995,8 +1101,9 @@ @property (nonatomic, strong) NSMutableArray* users; @property (nonatomic, strong) TLPhoto* photo; @property int user_id; -@property (nonatomic, strong) NSString* address; @property int inviter_id; +@property int channel_id; +@property int chat_id; @end @interface TL_messageActionEmpty : TLMessageAction @@ -1015,20 +1122,26 @@ +(TL_messageActionChatDeletePhoto*)create; @end @interface TL_messageActionChatAddUser : TLMessageAction -+(TL_messageActionChatAddUser*)createWithUser_id:(int)user_id; ++(TL_messageActionChatAddUser*)createWithUsers:(NSMutableArray*)users; @end @interface TL_messageActionChatDeleteUser : TLMessageAction +(TL_messageActionChatDeleteUser*)createWithUser_id:(int)user_id; @end -@interface TL_messageActionGeoChatCreate : TLMessageAction -+(TL_messageActionGeoChatCreate*)createWithTitle:(NSString*)title address:(NSString*)address; -@end -@interface TL_messageActionGeoChatCheckin : TLMessageAction -+(TL_messageActionGeoChatCheckin*)create; -@end @interface TL_messageActionChatJoinedByLink : TLMessageAction +(TL_messageActionChatJoinedByLink*)createWithInviter_id:(int)inviter_id; @end +@interface TL_messageActionChannelCreate : TLMessageAction ++(TL_messageActionChannelCreate*)createWithTitle:(NSString*)title; +@end +@interface TL_messageActionChatMigrateTo : TLMessageAction ++(TL_messageActionChatMigrateTo*)createWithChannel_id:(int)channel_id; +@end +@interface TL_messageActionChannelMigrateFrom : TLMessageAction ++(TL_messageActionChannelMigrateFrom*)createWithTitle:(NSString*)title chat_id:(int)chat_id; +@end +@interface TL_messageActionChatAddUser_old40 : TLMessageAction ++(TL_messageActionChatAddUser_old40*)createWithUser_id:(int)user_id; +@end @interface TLDialog() @property (nonatomic, strong) TLPeer* peer; @@ -1036,26 +1149,35 @@ @property int read_inbox_max_id; @property int unread_count; @property (nonatomic, strong) TLPeerNotifySettings* notify_settings; +@property int top_important_message; +@property int unread_important_count; +@property int pts; @end @interface TL_dialog : TLDialog +(TL_dialog*)createWithPeer:(TLPeer*)peer top_message:(int)top_message read_inbox_max_id:(int)read_inbox_max_id unread_count:(int)unread_count notify_settings:(TLPeerNotifySettings*)notify_settings; @end +@interface TL_dialogChannel : TLDialog ++(TL_dialogChannel*)createWithPeer:(TLPeer*)peer top_message:(int)top_message top_important_message:(int)top_important_message read_inbox_max_id:(int)read_inbox_max_id unread_count:(int)unread_count unread_important_count:(int)unread_important_count notify_settings:(TLPeerNotifySettings*)notify_settings pts:(int)pts; +@end @interface TLPhoto() @property long n_id; @property long access_hash; -@property int user_id; @property int date; -@property (nonatomic, strong) TLGeoPoint* geo; @property (nonatomic, strong) NSMutableArray* sizes; +@property int user_id; +@property (nonatomic, strong) TLGeoPoint* geo; @end @interface TL_photoEmpty : TLPhoto +(TL_photoEmpty*)createWithN_id:(long)n_id; @end @interface TL_photo : TLPhoto -+(TL_photo*)createWithN_id:(long)n_id access_hash:(long)access_hash user_id:(int)user_id date:(int)date geo:(TLGeoPoint*)geo sizes:(NSMutableArray*)sizes; ++(TL_photo*)createWithN_id:(long)n_id access_hash:(long)access_hash date:(int)date sizes:(NSMutableArray*)sizes; +@end +@interface TL_photo_old31 : TLPhoto ++(TL_photo_old31*)createWithN_id:(long)n_id access_hash:(long)access_hash user_id:(int)user_id date:(int)date geo:(TLGeoPoint*)geo sizes:(NSMutableArray*)sizes; @end @interface TLPhotoSize() @@ -1080,21 +1202,25 @@ @interface TLVideo() @property long n_id; @property long access_hash; -@property int user_id; @property int date; @property int duration; +@property (nonatomic, strong) NSString* mime_type; @property int size; @property (nonatomic, strong) TLPhotoSize* thumb; @property int dc_id; @property int w; @property int h; +@property int user_id; @end @interface TL_videoEmpty : TLVideo +(TL_videoEmpty*)createWithN_id:(long)n_id; @end @interface TL_video : TLVideo -+(TL_video*)createWithN_id:(long)n_id access_hash:(long)access_hash user_id:(int)user_id date:(int)date duration:(int)duration size:(int)size thumb:(TLPhotoSize*)thumb dc_id:(int)dc_id w:(int)w h:(int)h; ++(TL_video*)createWithN_id:(long)n_id access_hash:(long)access_hash date:(int)date duration:(int)duration mime_type:(NSString*)mime_type size:(int)size thumb:(TLPhotoSize*)thumb dc_id:(int)dc_id w:(int)w h:(int)h; +@end +@interface TL_video_old29 : TLVideo ++(TL_video_old29*)createWithN_id:(long)n_id access_hash:(long)access_hash user_id:(int)user_id date:(int)date duration:(int)duration size:(int)size thumb:(TLPhotoSize*)thumb dc_id:(int)dc_id w:(int)w h:(int)h; @end @interface TLGeoPoint() @@ -1149,7 +1275,7 @@ @end @interface TLInputNotifyPeer() -@property (nonatomic, strong) TLInputGeoChat* peer; +@property (nonatomic, strong) TLInputPeer* peer; @end @interface TL_inputNotifyPeer : TLInputNotifyPeer @@ -1164,9 +1290,6 @@ @interface TL_inputNotifyAll : TLInputNotifyPeer +(TL_inputNotifyAll*)create; @end -@interface TL_inputNotifyGeoChatPeer : TLInputNotifyPeer -+(TL_inputNotifyGeoChatPeer*)createWithPeer:(TLInputGeoChat*)peer; -@end @interface TLInputPeerNotifyEvents() @@ -1230,6 +1353,23 @@ +(TL_wallPaperSolid*)createWithN_id:(int)n_id title:(NSString*)title bg_color:(int)bg_color color:(int)color; @end +@interface TLReportReason() +@property (nonatomic, strong) NSString* text; +@end + +@interface TL_inputReportReasonSpam : TLReportReason ++(TL_inputReportReasonSpam*)create; +@end +@interface TL_inputReportReasonViolence : TLReportReason ++(TL_inputReportReasonViolence*)create; +@end +@interface TL_inputReportReasonPornography : TLReportReason ++(TL_inputReportReasonPornography*)create; +@end +@interface TL_inputReportReasonOther : TLReportReason ++(TL_inputReportReasonOther*)createWithText:(NSString*)text; +@end + @interface TLUserFull() @property (nonatomic, strong) TLUser* user; @property (nonatomic, strong) TLcontacts_Link* link; @@ -1288,15 +1428,6 @@ +(TL_contactStatus*)createWithUser_id:(int)user_id status:(TLUserStatus*)status; @end -@interface TLChatLocated() -@property int chat_id; -@property int distance; -@end - -@interface TL_chatLocated : TLChatLocated -+(TL_chatLocated*)createWithChat_id:(int)chat_id distance:(int)distance; -@end - @interface TLcontacts_Link() @property (nonatomic, strong) TLContactLink* my_link; @property (nonatomic, strong) TLContactLink* foreign_link; @@ -1371,6 +1502,9 @@ @property (nonatomic, strong) NSMutableArray* chats; @property (nonatomic, strong) NSMutableArray* users; @property int n_count; +@property int flags; +@property int pts; +@property (nonatomic, strong) NSMutableArray* collapsed; @end @interface TL_messages_messages : TLmessages_Messages @@ -1379,30 +1513,8 @@ @interface TL_messages_messagesSlice : TLmessages_Messages +(TL_messages_messagesSlice*)createWithN_count:(int)n_count messages:(NSMutableArray*)messages chats:(NSMutableArray*)chats users:(NSMutableArray*)users; @end - -@interface TLmessages_Message() - -@end - -@interface TL_messages_messageEmpty : TLmessages_Message -+(TL_messages_messageEmpty*)create; -@end - -@interface TLmessages_SentMessage() -@property int n_id; -@property int date; -@property (nonatomic, strong) TLMessageMedia* media; -@property int pts; -@property int pts_count; -@property (nonatomic, strong) NSMutableArray* links; -@property int seq; -@end - -@interface TL_messages_sentMessage : TLmessages_SentMessage -+(TL_messages_sentMessage*)createWithN_id:(int)n_id date:(int)date media:(TLMessageMedia*)media pts:(int)pts pts_count:(int)pts_count; -@end -@interface TL_messages_sentMessageLink : TLmessages_SentMessage -+(TL_messages_sentMessageLink*)createWithN_id:(int)n_id date:(int)date media:(TLMessageMedia*)media pts:(int)pts pts_count:(int)pts_count links:(NSMutableArray*)links seq:(int)seq; +@interface TL_messages_channelMessages : TLmessages_Messages ++(TL_messages_channelMessages*)createWithFlags:(int)flags pts:(int)pts n_count:(int)n_count messages:(NSMutableArray*)messages collapsed:(NSMutableArray*)collapsed chats:(NSMutableArray*)chats users:(NSMutableArray*)users; @end @interface TLmessages_Chats() @@ -1466,7 +1578,7 @@ @end @interface TLUpdate() -@property (nonatomic, strong) NSString* message; +@property (nonatomic, strong) TLMessage* message; @property int pts; @property int pts_count; @property int n_id; @@ -1505,6 +1617,13 @@ @property (nonatomic, strong) NSString* phone; @property int max_id; @property (nonatomic, strong) TLWebPage* webpage; +@property int channel_id; +@property (nonatomic, strong) TLMessageGroup* group; +@property int views; +@property Boolean enabled; +@property Boolean is_admin; +@property (nonatomic, strong) TLmessages_StickerSet* stickerset; +@property (nonatomic, strong) NSMutableArray* order; @end @interface TL_updateNewMessage : TLUpdate @@ -1543,9 +1662,6 @@ @interface TL_updateNewAuthorization : TLUpdate +(TL_updateNewAuthorization*)createWithAuth_key_id:(long)auth_key_id date:(int)date device:(NSString*)device location:(NSString*)location; @end -@interface TL_updateNewGeoChatMessage : TLUpdate -+(TL_updateNewGeoChatMessage*)createWithMessage:(TLGeoChatMessage*)message; -@end @interface TL_updateNewEncryptedMessage : TLUpdate +(TL_updateNewEncryptedMessage*)createWithMessage:(TLEncryptedMessage*)message qts:(int)qts; @end @@ -1559,7 +1675,7 @@ +(TL_updateEncryptedMessagesRead*)createWithChat_id:(int)chat_id max_date:(int)max_date date:(int)date; @end @interface TL_updateChatParticipantAdd : TLUpdate -+(TL_updateChatParticipantAdd*)createWithChat_id:(int)chat_id user_id:(int)user_id inviter_id:(int)inviter_id version:(int)version; ++(TL_updateChatParticipantAdd*)createWithChat_id:(int)chat_id user_id:(int)user_id inviter_id:(int)inviter_id date:(int)date version:(int)version; @end @interface TL_updateChatParticipantDelete : TLUpdate +(TL_updateChatParticipantDelete*)createWithChat_id:(int)chat_id user_id:(int)user_id version:(int)version; @@ -1589,11 +1705,47 @@ +(TL_updateReadHistoryOutbox*)createWithPeer:(TLPeer*)peer max_id:(int)max_id pts:(int)pts pts_count:(int)pts_count; @end @interface TL_updateWebPage : TLUpdate -+(TL_updateWebPage*)createWithWebpage:(TLWebPage*)webpage; ++(TL_updateWebPage*)createWithWebpage:(TLWebPage*)webpage pts:(int)pts pts_count:(int)pts_count; @end @interface TL_updateReadMessagesContents : TLUpdate +(TL_updateReadMessagesContents*)createWithMessages:(NSMutableArray*)messages pts:(int)pts pts_count:(int)pts_count; @end +@interface TL_updateChannelTooLong : TLUpdate ++(TL_updateChannelTooLong*)createWithChannel_id:(int)channel_id; +@end +@interface TL_updateChannel : TLUpdate ++(TL_updateChannel*)createWithChannel_id:(int)channel_id; +@end +@interface TL_updateChannelGroup : TLUpdate ++(TL_updateChannelGroup*)createWithChannel_id:(int)channel_id group:(TLMessageGroup*)group; +@end +@interface TL_updateNewChannelMessage : TLUpdate ++(TL_updateNewChannelMessage*)createWithMessage:(TLMessage*)message pts:(int)pts pts_count:(int)pts_count; +@end +@interface TL_updateReadChannelInbox : TLUpdate ++(TL_updateReadChannelInbox*)createWithChannel_id:(int)channel_id max_id:(int)max_id; +@end +@interface TL_updateDeleteChannelMessages : TLUpdate ++(TL_updateDeleteChannelMessages*)createWithChannel_id:(int)channel_id messages:(NSMutableArray*)messages pts:(int)pts pts_count:(int)pts_count; +@end +@interface TL_updateChannelMessageViews : TLUpdate ++(TL_updateChannelMessageViews*)createWithChannel_id:(int)channel_id n_id:(int)n_id views:(int)views; +@end +@interface TL_updateChatAdmins : TLUpdate ++(TL_updateChatAdmins*)createWithChat_id:(int)chat_id enabled:(Boolean)enabled version:(int)version; +@end +@interface TL_updateChatParticipantAdmin : TLUpdate ++(TL_updateChatParticipantAdmin*)createWithChat_id:(int)chat_id user_id:(int)user_id is_admin:(Boolean)is_admin version:(int)version; +@end +@interface TL_updateNewStickerSet : TLUpdate ++(TL_updateNewStickerSet*)createWithStickerset:(TLmessages_StickerSet*)stickerset; +@end +@interface TL_updateStickerSetsOrder : TLUpdate ++(TL_updateStickerSetsOrder*)createWithOrder:(NSMutableArray*)order; +@end +@interface TL_updateStickerSets : TLUpdate ++(TL_updateStickerSets*)create; +@end @interface TLupdates_State() @property int pts; @@ -1631,15 +1783,20 @@ @interface TLUpdates() @property int flags; +@property (nonatomic,assign,readonly) BOOL isUnread; +@property (nonatomic,assign,readonly) BOOL isN_out; +@property (nonatomic,assign,readonly) BOOL isMentioned; +@property (nonatomic,assign,readonly) BOOL isMedia_unread; @property int n_id; @property int user_id; @property (nonatomic, strong) NSString* message; @property int pts; @property int pts_count; @property int date; -@property int fwd_from_id; +@property (nonatomic, strong) TLPeer* fwd_from_id; @property int fwd_date; @property int reply_to_msg_id; +@property (nonatomic, strong) NSMutableArray* entities; @property int from_id; @property int chat_id; @property (nonatomic, strong) TLUpdate* update; @@ -1648,16 +1805,17 @@ @property (nonatomic, strong) NSMutableArray* chats; @property int seq_start; @property int seq; +@property (nonatomic, strong) TLMessageMedia* media; @end @interface TL_updatesTooLong : TLUpdates +(TL_updatesTooLong*)create; @end @interface TL_updateShortMessage : TLUpdates -+(TL_updateShortMessage*)createWithFlags:(int)flags n_id:(int)n_id user_id:(int)user_id message:(NSString*)message pts:(int)pts pts_count:(int)pts_count date:(int)date fwd_from_id:(int)fwd_from_id fwd_date:(int)fwd_date reply_to_msg_id:(int)reply_to_msg_id; ++(TL_updateShortMessage*)createWithFlags:(int)flags n_id:(int)n_id user_id:(int)user_id message:(NSString*)message pts:(int)pts pts_count:(int)pts_count date:(int)date fwd_from_id:(TLPeer*)fwd_from_id fwd_date:(int)fwd_date reply_to_msg_id:(int)reply_to_msg_id entities:(NSMutableArray*)entities; @end @interface TL_updateShortChatMessage : TLUpdates -+(TL_updateShortChatMessage*)createWithFlags:(int)flags n_id:(int)n_id from_id:(int)from_id chat_id:(int)chat_id message:(NSString*)message pts:(int)pts pts_count:(int)pts_count date:(int)date fwd_from_id:(int)fwd_from_id fwd_date:(int)fwd_date reply_to_msg_id:(int)reply_to_msg_id; ++(TL_updateShortChatMessage*)createWithFlags:(int)flags n_id:(int)n_id from_id:(int)from_id chat_id:(int)chat_id message:(NSString*)message pts:(int)pts pts_count:(int)pts_count date:(int)date fwd_from_id:(TLPeer*)fwd_from_id fwd_date:(int)fwd_date reply_to_msg_id:(int)reply_to_msg_id entities:(NSMutableArray*)entities; @end @interface TL_updateShort : TLUpdates +(TL_updateShort*)createWithUpdate:(TLUpdate*)update date:(int)date; @@ -1668,6 +1826,9 @@ @interface TL_updates : TLUpdates +(TL_updates*)createWithUpdates:(NSMutableArray*)updates users:(NSMutableArray*)users chats:(NSMutableArray*)chats date:(int)date seq:(int)seq; @end +@interface TL_updateShortSentMessage : TLUpdates ++(TL_updateShortSentMessage*)createWithFlags:(int)flags n_id:(int)n_id pts:(int)pts pts_count:(int)pts_count date:(int)date media:(TLMessageMedia*)media entities:(NSMutableArray*)entities; +@end @interface TLphotos_Photos() @property (nonatomic, strong) NSMutableArray* photos; @@ -1703,13 +1864,15 @@ @interface TLDcOption() @property int flags; +@property (nonatomic,assign,readonly) BOOL isIpv6; +@property (nonatomic,assign,readonly) BOOL isMedia_only; @property int n_id; @property (nonatomic, strong) NSString* ip_address; @property int port; @end @interface TL_dcOption : TLDcOption -+(TL_dcOption*)createWithFlags:(int)flags n_id:(int)n_id ip_address:(NSString*)ip_address port:(int)port; ++(TL_dcOption*)createWithFlags:(int)flags n_id:(int)n_id ip_address:(NSString*)ip_address port:(int)port; @end @interface TLConfig() @@ -1719,7 +1882,7 @@ @property int this_dc; @property (nonatomic, strong) NSMutableArray* dc_options; @property int chat_size_max; -@property int broadcast_size_max; +@property int megagroup_size_max; @property int forwarded_count_max; @property int online_update_period_ms; @property int offline_blur_timeout_ms; @@ -1734,7 +1897,7 @@ @end @interface TL_config : TLConfig -+(TL_config*)createWithDate:(int)date expires:(int)expires test_mode:(Boolean)test_mode this_dc:(int)this_dc dc_options:(NSMutableArray*)dc_options chat_size_max:(int)chat_size_max broadcast_size_max:(int)broadcast_size_max forwarded_count_max:(int)forwarded_count_max online_update_period_ms:(int)online_update_period_ms offline_blur_timeout_ms:(int)offline_blur_timeout_ms offline_idle_timeout_ms:(int)offline_idle_timeout_ms online_cloud_timeout_ms:(int)online_cloud_timeout_ms notify_cloud_delay_ms:(int)notify_cloud_delay_ms notify_default_delay_ms:(int)notify_default_delay_ms chat_big_size:(int)chat_big_size push_chat_period_ms:(int)push_chat_period_ms push_chat_limit:(int)push_chat_limit disabled_features:(NSMutableArray*)disabled_features; ++(TL_config*)createWithDate:(int)date expires:(int)expires test_mode:(Boolean)test_mode this_dc:(int)this_dc dc_options:(NSMutableArray*)dc_options chat_size_max:(int)chat_size_max megagroup_size_max:(int)megagroup_size_max forwarded_count_max:(int)forwarded_count_max online_update_period_ms:(int)online_update_period_ms offline_blur_timeout_ms:(int)offline_blur_timeout_ms offline_idle_timeout_ms:(int)offline_idle_timeout_ms online_cloud_timeout_ms:(int)online_cloud_timeout_ms notify_cloud_delay_ms:(int)notify_cloud_delay_ms notify_default_delay_ms:(int)notify_default_delay_ms chat_big_size:(int)chat_big_size push_chat_period_ms:(int)push_chat_period_ms push_chat_limit:(int)push_chat_limit disabled_features:(NSMutableArray*)disabled_features; @end @interface TLNearestDc() @@ -1769,71 +1932,6 @@ +(TL_help_inviteText*)createWithMessage:(NSString*)message; @end -@interface TLInputGeoChat() -@property int chat_id; -@property long access_hash; -@end - -@interface TL_inputGeoChat : TLInputGeoChat -+(TL_inputGeoChat*)createWithChat_id:(int)chat_id access_hash:(long)access_hash; -@end - -@interface TLGeoChatMessage() -@property int chat_id; -@property int n_id; -@property int from_id; -@property int date; -@property (nonatomic, strong) NSString* message; -@property (nonatomic, strong) TLMessageMedia* media; -@property (nonatomic, strong) TLMessageAction* action; -@end - -@interface TL_geoChatMessageEmpty : TLGeoChatMessage -+(TL_geoChatMessageEmpty*)createWithChat_id:(int)chat_id n_id:(int)n_id; -@end -@interface TL_geoChatMessage : TLGeoChatMessage -+(TL_geoChatMessage*)createWithChat_id:(int)chat_id n_id:(int)n_id from_id:(int)from_id date:(int)date message:(NSString*)message media:(TLMessageMedia*)media; -@end -@interface TL_geoChatMessageService : TLGeoChatMessage -+(TL_geoChatMessageService*)createWithChat_id:(int)chat_id n_id:(int)n_id from_id:(int)from_id date:(int)date action:(TLMessageAction*)action; -@end - -@interface TLgeochats_StatedMessage() -@property (nonatomic, strong) TLGeoChatMessage* message; -@property (nonatomic, strong) NSMutableArray* chats; -@property (nonatomic, strong) NSMutableArray* users; -@property int seq; -@end - -@interface TL_geochats_statedMessage : TLgeochats_StatedMessage -+(TL_geochats_statedMessage*)createWithMessage:(TLGeoChatMessage*)message chats:(NSMutableArray*)chats users:(NSMutableArray*)users seq:(int)seq; -@end - -@interface TLgeochats_Located() -@property (nonatomic, strong) NSMutableArray* results; -@property (nonatomic, strong) NSMutableArray* messages; -@property (nonatomic, strong) NSMutableArray* chats; -@property (nonatomic, strong) NSMutableArray* users; -@end - -@interface TL_geochats_located : TLgeochats_Located -+(TL_geochats_located*)createWithResults:(NSMutableArray*)results messages:(NSMutableArray*)messages chats:(NSMutableArray*)chats users:(NSMutableArray*)users; -@end - -@interface TLgeochats_Messages() -@property (nonatomic, strong) NSMutableArray* messages; -@property (nonatomic, strong) NSMutableArray* chats; -@property (nonatomic, strong) NSMutableArray* users; -@property int n_count; -@end - -@interface TL_geochats_messages : TLgeochats_Messages -+(TL_geochats_messages*)createWithMessages:(NSMutableArray*)messages chats:(NSMutableArray*)chats users:(NSMutableArray*)users; -@end -@interface TL_geochats_messagesSlice : TLgeochats_Messages -+(TL_geochats_messagesSlice*)createWithN_count:(int)n_count messages:(NSMutableArray*)messages chats:(NSMutableArray*)chats users:(NSMutableArray*)users; -@end - @interface TLEncryptedChat() @property int n_id; @property long access_hash; @@ -1974,19 +2072,22 @@ @interface TLAudio() @property long n_id; @property long access_hash; -@property int user_id; @property int date; @property int duration; @property (nonatomic, strong) NSString* mime_type; @property int size; @property int dc_id; +@property int user_id; @end @interface TL_audioEmpty : TLAudio +(TL_audioEmpty*)createWithN_id:(long)n_id; @end @interface TL_audio : TLAudio -+(TL_audio*)createWithN_id:(long)n_id access_hash:(long)access_hash user_id:(int)user_id date:(int)date duration:(int)duration mime_type:(NSString*)mime_type size:(int)size dc_id:(int)dc_id; ++(TL_audio*)createWithN_id:(long)n_id access_hash:(long)access_hash date:(int)date duration:(int)duration mime_type:(NSString*)mime_type size:(int)size dc_id:(int)dc_id; +@end +@interface TL_audio_old29 : TLAudio ++(TL_audio_old29*)createWithN_id:(long)n_id access_hash:(long)access_hash user_id:(int)user_id date:(int)date duration:(int)duration mime_type:(NSString*)mime_type size:(int)size dc_id:(int)dc_id; @end @interface TLDocument() @@ -2068,21 +2169,14 @@ +(TL_sendMessageChooseContactAction*)create; @end -@interface TLContactFound() -@property int user_id; -@end - -@interface TL_contactFound : TLContactFound -+(TL_contactFound*)createWithUser_id:(int)user_id; -@end - @interface TLcontacts_Found() @property (nonatomic, strong) NSMutableArray* results; +@property (nonatomic, strong) NSMutableArray* chats; @property (nonatomic, strong) NSMutableArray* users; @end @interface TL_contacts_found : TLcontacts_Found -+(TL_contacts_found*)createWithResults:(NSMutableArray*)results users:(NSMutableArray*)users; ++(TL_contacts_found*)createWithResults:(NSMutableArray*)results chats:(NSMutableArray*)chats users:(NSMutableArray*)users; @end @interface TLInputPrivacyKey() @@ -2228,7 +2322,7 @@ @end @interface TLmessages_AllStickers() -@property (nonatomic, strong) NSString* n_hash; +@property int n_hash; @property (nonatomic, strong) NSMutableArray* sets; @end @@ -2236,7 +2330,7 @@ +(TL_messages_allStickersNotModified*)create; @end @interface TL_messages_allStickers : TLmessages_AllStickers -+(TL_messages_allStickers*)createWithN_hash:(NSString*)n_hash sets:(NSMutableArray*)sets; ++(TL_messages_allStickers*)createWithN_hash:(int)n_hash sets:(NSMutableArray*)sets; @end @interface TLDisabledFeature() @@ -2291,6 +2385,7 @@ @property int embed_height; @property int duration; @property (nonatomic, strong) NSString* author; +@property (nonatomic, strong) TLDocument* document; @end @interface TL_webPageEmpty : TLWebPage @@ -2300,7 +2395,10 @@ +(TL_webPagePending*)createWithN_id:(long)n_id date:(int)date; @end @interface TL_webPage : TLWebPage -+(TL_webPage*)createWithFlags:(int)flags n_id:(long)n_id url:(NSString*)url display_url:(NSString*)display_url type:(NSString*)type site_name:(NSString*)site_name title:(NSString*)title n_description:(NSString*)n_description photo:(TLPhoto*)photo embed_url:(NSString*)embed_url embed_type:(NSString*)embed_type embed_width:(int)embed_width embed_height:(int)embed_height duration:(int)duration author:(NSString*)author; ++(TL_webPage*)createWithFlags:(int)flags n_id:(long)n_id url:(NSString*)url display_url:(NSString*)display_url type:(NSString*)type site_name:(NSString*)site_name title:(NSString*)title n_description:(NSString*)n_description photo:(TLPhoto*)photo embed_url:(NSString*)embed_url embed_type:(NSString*)embed_type embed_width:(int)embed_width embed_height:(int)embed_height duration:(int)duration author:(NSString*)author document:(TLDocument*)document; +@end +@interface TL_webPage_old34 : TLWebPage ++(TL_webPage_old34*)createWithFlags:(int)flags n_id:(long)n_id url:(NSString*)url display_url:(NSString*)display_url type:(NSString*)type site_name:(NSString*)site_name title:(NSString*)title n_description:(NSString*)n_description photo:(TLPhoto*)photo embed_url:(NSString*)embed_url embed_type:(NSString*)embed_type embed_width:(int)embed_width embed_height:(int)embed_height duration:(int)duration author:(NSString*)author; @end @interface TLAuthorization() @@ -2396,6 +2494,11 @@ @interface TLChatInvite() @property (nonatomic, strong) TLChat* chat; +@property int flags; +@property (nonatomic,assign,readonly) BOOL isChannel; +@property (nonatomic,assign,readonly) BOOL isBroadcast; +@property (nonatomic,assign,readonly) BOOL isPublic; +@property (nonatomic,assign,readonly) BOOL isMegagroup; @property (nonatomic, strong) NSString* title; @end @@ -2403,7 +2506,7 @@ +(TL_chatInviteAlready*)createWithChat:(TLChat*)chat; @end @interface TL_chatInvite : TLChatInvite -+(TL_chatInvite*)createWithTitle:(NSString*)title; ++(TL_chatInvite*)createWithFlags:(int)flags title:(NSString*)title; @end @interface TLInputStickerSet() @@ -2424,6 +2527,9 @@ @interface TLStickerSet() @property int flags; +@property (nonatomic,assign,readonly) BOOL isInstalled; +@property (nonatomic,assign,readonly) BOOL isDisabled; +@property (nonatomic,assign,readonly) BOOL isOfficial; @property long n_id; @property long access_hash; @property (nonatomic, strong) NSString* title; @@ -2433,7 +2539,7 @@ @end @interface TL_stickerSet : TLStickerSet -+(TL_stickerSet*)createWithFlags:(int)flags n_id:(long)n_id access_hash:(long)access_hash title:(NSString*)title short_name:(NSString*)short_name n_count:(int)n_count n_hash:(int)n_hash; ++(TL_stickerSet*)createWithFlags:(int)flags n_id:(long)n_id access_hash:(long)access_hash title:(NSString*)title short_name:(NSString*)short_name n_count:(int)n_count n_hash:(int)n_hash; @end @interface TLmessages_StickerSet() @@ -2488,17 +2594,242 @@ @interface TLReplyMarkup() @property int flags; +@property (nonatomic,assign,readonly) BOOL isSelective; +@property (nonatomic,assign,readonly) BOOL isSingle_use; +@property (nonatomic,assign,readonly) BOOL isResize; @property (nonatomic, strong) NSMutableArray* rows; @end @interface TL_replyKeyboardHide : TLReplyMarkup -+(TL_replyKeyboardHide*)createWithFlags:(int)flags; ++(TL_replyKeyboardHide*)createWithFlags:(int)flags ; @end @interface TL_replyKeyboardForceReply : TLReplyMarkup -+(TL_replyKeyboardForceReply*)createWithFlags:(int)flags; ++(TL_replyKeyboardForceReply*)createWithFlags:(int)flags ; @end @interface TL_replyKeyboardMarkup : TLReplyMarkup -+(TL_replyKeyboardMarkup*)createWithFlags:(int)flags rows:(NSMutableArray*)rows; ++(TL_replyKeyboardMarkup*)createWithFlags:(int)flags rows:(NSMutableArray*)rows; +@end + +@interface TLhelp_AppChangelog() +@property (nonatomic, strong) NSString* text; +@end + +@interface TL_help_appChangelogEmpty : TLhelp_AppChangelog ++(TL_help_appChangelogEmpty*)create; +@end +@interface TL_help_appChangelog : TLhelp_AppChangelog ++(TL_help_appChangelog*)createWithText:(NSString*)text; +@end + +@interface TLMessageEntity() +@property int offset; +@property int length; +@property (nonatomic, strong) NSString* language; +@property (nonatomic, strong) NSString* url; +@end + +@interface TL_messageEntityUnknown : TLMessageEntity ++(TL_messageEntityUnknown*)createWithOffset:(int)offset length:(int)length; +@end +@interface TL_messageEntityMention : TLMessageEntity ++(TL_messageEntityMention*)createWithOffset:(int)offset length:(int)length; +@end +@interface TL_messageEntityHashtag : TLMessageEntity ++(TL_messageEntityHashtag*)createWithOffset:(int)offset length:(int)length; +@end +@interface TL_messageEntityBotCommand : TLMessageEntity ++(TL_messageEntityBotCommand*)createWithOffset:(int)offset length:(int)length; +@end +@interface TL_messageEntityUrl : TLMessageEntity ++(TL_messageEntityUrl*)createWithOffset:(int)offset length:(int)length; +@end +@interface TL_messageEntityEmail : TLMessageEntity ++(TL_messageEntityEmail*)createWithOffset:(int)offset length:(int)length; +@end +@interface TL_messageEntityBold : TLMessageEntity ++(TL_messageEntityBold*)createWithOffset:(int)offset length:(int)length; +@end +@interface TL_messageEntityItalic : TLMessageEntity ++(TL_messageEntityItalic*)createWithOffset:(int)offset length:(int)length; +@end +@interface TL_messageEntityCode : TLMessageEntity ++(TL_messageEntityCode*)createWithOffset:(int)offset length:(int)length; +@end +@interface TL_messageEntityPre : TLMessageEntity ++(TL_messageEntityPre*)createWithOffset:(int)offset length:(int)length language:(NSString*)language; +@end +@interface TL_messageEntityTextUrl : TLMessageEntity ++(TL_messageEntityTextUrl*)createWithOffset:(int)offset length:(int)length url:(NSString*)url; +@end + +@interface TLInputChannel() +@property int channel_id; +@property long access_hash; +@end + +@interface TL_inputChannelEmpty : TLInputChannel ++(TL_inputChannelEmpty*)create; +@end +@interface TL_inputChannel : TLInputChannel ++(TL_inputChannel*)createWithChannel_id:(int)channel_id access_hash:(long)access_hash; +@end + +@interface TLcontacts_ResolvedPeer() +@property (nonatomic, strong) TLPeer* peer; +@property (nonatomic, strong) NSMutableArray* chats; +@property (nonatomic, strong) NSMutableArray* users; +@end + +@interface TL_contacts_resolvedPeer : TLcontacts_ResolvedPeer ++(TL_contacts_resolvedPeer*)createWithPeer:(TLPeer*)peer chats:(NSMutableArray*)chats users:(NSMutableArray*)users; +@end + +@interface TLMessageRange() +@property int min_id; +@property int max_id; +@end + +@interface TL_messageRange : TLMessageRange ++(TL_messageRange*)createWithMin_id:(int)min_id max_id:(int)max_id; +@end + +@interface TLMessageGroup() +@property int min_id; +@property int max_id; +@property int n_count; +@property int date; +@end + +@interface TL_messageGroup : TLMessageGroup ++(TL_messageGroup*)createWithMin_id:(int)min_id max_id:(int)max_id n_count:(int)n_count date:(int)date; +@end + +@interface TLupdates_ChannelDifference() +@property int flags; +@property (nonatomic,assign,readonly) BOOL isFinal; +@property int pts; +@property int timeout; +@property int top_message; +@property int top_important_message; +@property int read_inbox_max_id; +@property int unread_count; +@property int unread_important_count; +@property (nonatomic, strong) NSMutableArray* messages; +@property (nonatomic, strong) NSMutableArray* chats; +@property (nonatomic, strong) NSMutableArray* users; +@property (nonatomic, strong) NSMutableArray* n_messages; +@property (nonatomic, strong) NSMutableArray* other_updates; +@end + +@interface TL_updates_channelDifferenceEmpty : TLupdates_ChannelDifference ++(TL_updates_channelDifferenceEmpty*)createWithFlags:(int)flags pts:(int)pts timeout:(int)timeout; +@end +@interface TL_updates_channelDifferenceTooLong : TLupdates_ChannelDifference ++(TL_updates_channelDifferenceTooLong*)createWithFlags:(int)flags pts:(int)pts timeout:(int)timeout top_message:(int)top_message top_important_message:(int)top_important_message read_inbox_max_id:(int)read_inbox_max_id unread_count:(int)unread_count unread_important_count:(int)unread_important_count messages:(NSMutableArray*)messages chats:(NSMutableArray*)chats users:(NSMutableArray*)users; +@end +@interface TL_updates_channelDifference : TLupdates_ChannelDifference ++(TL_updates_channelDifference*)createWithFlags:(int)flags pts:(int)pts timeout:(int)timeout n_messages:(NSMutableArray*)n_messages other_updates:(NSMutableArray*)other_updates chats:(NSMutableArray*)chats users:(NSMutableArray*)users; +@end + +@interface TLChannelMessagesFilter() +@property int flags; +@property (nonatomic,assign,readonly) BOOL isImportant_only; +@property (nonatomic,assign,readonly) BOOL isExclude_new_messages; +@property (nonatomic, strong) NSMutableArray* ranges; +@end + +@interface TL_channelMessagesFilterEmpty : TLChannelMessagesFilter ++(TL_channelMessagesFilterEmpty*)create; +@end +@interface TL_channelMessagesFilter : TLChannelMessagesFilter ++(TL_channelMessagesFilter*)createWithFlags:(int)flags ranges:(NSMutableArray*)ranges; +@end +@interface TL_channelMessagesFilterCollapsed : TLChannelMessagesFilter ++(TL_channelMessagesFilterCollapsed*)create; +@end + +@interface TLChannelParticipant() +@property int user_id; +@property int date; +@property int inviter_id; +@property int kicked_by; +@end + +@interface TL_channelParticipant : TLChannelParticipant ++(TL_channelParticipant*)createWithUser_id:(int)user_id date:(int)date; +@end +@interface TL_channelParticipantSelf : TLChannelParticipant ++(TL_channelParticipantSelf*)createWithUser_id:(int)user_id inviter_id:(int)inviter_id date:(int)date; +@end +@interface TL_channelParticipantModerator : TLChannelParticipant ++(TL_channelParticipantModerator*)createWithUser_id:(int)user_id inviter_id:(int)inviter_id date:(int)date; +@end +@interface TL_channelParticipantEditor : TLChannelParticipant ++(TL_channelParticipantEditor*)createWithUser_id:(int)user_id inviter_id:(int)inviter_id date:(int)date; +@end +@interface TL_channelParticipantKicked : TLChannelParticipant ++(TL_channelParticipantKicked*)createWithUser_id:(int)user_id kicked_by:(int)kicked_by date:(int)date; +@end +@interface TL_channelParticipantCreator : TLChannelParticipant ++(TL_channelParticipantCreator*)createWithUser_id:(int)user_id; +@end + +@interface TLChannelParticipantsFilter() + +@end + +@interface TL_channelParticipantsRecent : TLChannelParticipantsFilter ++(TL_channelParticipantsRecent*)create; +@end +@interface TL_channelParticipantsAdmins : TLChannelParticipantsFilter ++(TL_channelParticipantsAdmins*)create; +@end +@interface TL_channelParticipantsKicked : TLChannelParticipantsFilter ++(TL_channelParticipantsKicked*)create; +@end +@interface TL_channelParticipantsBots : TLChannelParticipantsFilter ++(TL_channelParticipantsBots*)create; +@end + +@interface TLChannelParticipantRole() + +@end + +@interface TL_channelRoleEmpty : TLChannelParticipantRole ++(TL_channelRoleEmpty*)create; +@end +@interface TL_channelRoleModerator : TLChannelParticipantRole ++(TL_channelRoleModerator*)create; +@end +@interface TL_channelRoleEditor : TLChannelParticipantRole ++(TL_channelRoleEditor*)create; +@end + +@interface TLchannels_ChannelParticipants() +@property int n_count; +@property (nonatomic, strong) NSMutableArray* participants; +@property (nonatomic, strong) NSMutableArray* users; +@end + +@interface TL_channels_channelParticipants : TLchannels_ChannelParticipants ++(TL_channels_channelParticipants*)createWithN_count:(int)n_count participants:(NSMutableArray*)participants users:(NSMutableArray*)users; +@end + +@interface TLchannels_ChannelParticipant() +@property (nonatomic, strong) TLChannelParticipant* participant; +@property (nonatomic, strong) NSMutableArray* users; +@end + +@interface TL_channels_channelParticipant : TLchannels_ChannelParticipant ++(TL_channels_channelParticipant*)createWithParticipant:(TLChannelParticipant*)participant users:(NSMutableArray*)users; +@end + +@interface TLhelp_TermsOfService() +@property (nonatomic, strong) NSString* text; +@end + +@interface TL_help_termsOfService : TLhelp_TermsOfService ++(TL_help_termsOfService*)createWithText:(NSString*)text; @end @interface TLProtoMessage() diff --git a/TelegramTest/MTProto.m b/TelegramTest/MTProto.m index 528e80d8..755ee6d7 100644 --- a/TelegramTest/MTProto.m +++ b/TelegramTest/MTProto.m @@ -2,7 +2,7 @@ // MTProto.m // Telegram // -// Auto created by Mikhail Filimonov on 24.07.15. +// Auto created by Mikhail Filimonov on 27.11.15. // Copyright (c) 2013 Telegram for OS X. All rights reserved. // @@ -39,10 +39,55 @@ -(void)unserialize:(SerializedData*)stream { @end +@implementation TLTrue -@implementation TLInputPeer @end + +@implementation TL_true ++(TL_true*)create { + TL_true* obj = [[TL_true alloc] init]; + + return obj; +} +-(void)serialize:(SerializedData*)stream { + +} +-(void)unserialize:(SerializedData*)stream { + +} + +-(TL_true *)copy { + + TL_true *objc = [[TL_true alloc] init]; + + + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TLInputPeer +@end + @implementation TL_inputPeerEmpty +(TL_inputPeerEmpty*)create { TL_inputPeerEmpty* obj = [[TL_inputPeerEmpty alloc] init]; @@ -64,6 +109,8 @@ -(TL_inputPeerEmpty *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -77,7 +124,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -104,6 +150,8 @@ -(TL_inputPeerSelf *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -117,33 +165,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_inputPeerContact -+(TL_inputPeerContact*)createWithUser_id:(int)user_id { - TL_inputPeerContact* obj = [[TL_inputPeerContact alloc] init]; - obj.user_id = user_id; +@implementation TL_inputPeerChat ++(TL_inputPeerChat*)createWithChat_id:(int)chat_id { + TL_inputPeerChat* obj = [[TL_inputPeerChat alloc] init]; + obj.chat_id = chat_id; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.user_id]; + [stream writeInt:self.chat_id]; } -(void)unserialize:(SerializedData*)stream { - self.user_id = [stream readInt]; + super.chat_id = [stream readInt]; } --(TL_inputPeerContact *)copy { +-(TL_inputPeerChat *)copy { - TL_inputPeerContact *objc = [[TL_inputPeerContact alloc] init]; + TL_inputPeerChat *objc = [[TL_inputPeerChat alloc] init]; - objc.user_id = self.user_id; + objc.chat_id = self.chat_id; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -157,15 +206,14 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_inputPeerForeign -+(TL_inputPeerForeign*)createWithUser_id:(int)user_id access_hash:(long)access_hash { - TL_inputPeerForeign* obj = [[TL_inputPeerForeign alloc] init]; +@implementation TL_inputPeerUser ++(TL_inputPeerUser*)createWithUser_id:(int)user_id access_hash:(long)access_hash { + TL_inputPeerUser* obj = [[TL_inputPeerUser alloc] init]; obj.user_id = user_id; obj.access_hash = access_hash; return obj; @@ -175,19 +223,21 @@ -(void)serialize:(SerializedData*)stream { [stream writeLong:self.access_hash]; } -(void)unserialize:(SerializedData*)stream { - self.user_id = [stream readInt]; - self.access_hash = [stream readLong]; + super.user_id = [stream readInt]; + super.access_hash = [stream readLong]; } --(TL_inputPeerForeign *)copy { +-(TL_inputPeerUser *)copy { - TL_inputPeerForeign *objc = [[TL_inputPeerForeign alloc] init]; + TL_inputPeerUser *objc = [[TL_inputPeerUser alloc] init]; objc.user_id = self.user_id; objc.access_hash = self.access_hash; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -201,33 +251,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_inputPeerChat -+(TL_inputPeerChat*)createWithChat_id:(int)chat_id { - TL_inputPeerChat* obj = [[TL_inputPeerChat alloc] init]; - obj.chat_id = chat_id; +@implementation TL_inputPeerChannel ++(TL_inputPeerChannel*)createWithChannel_id:(int)channel_id access_hash:(long)access_hash { + TL_inputPeerChannel* obj = [[TL_inputPeerChannel alloc] init]; + obj.channel_id = channel_id; + obj.access_hash = access_hash; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.chat_id]; + [stream writeInt:self.channel_id]; + [stream writeLong:self.access_hash]; } -(void)unserialize:(SerializedData*)stream { - self.chat_id = [stream readInt]; + super.channel_id = [stream readInt]; + super.access_hash = [stream readLong]; } --(TL_inputPeerChat *)copy { +-(TL_inputPeerChannel *)copy { - TL_inputPeerChat *objc = [[TL_inputPeerChat alloc] init]; + TL_inputPeerChannel *objc = [[TL_inputPeerChannel alloc] init]; - objc.chat_id = self.chat_id; + objc.channel_id = self.channel_id; + objc.access_hash = self.access_hash; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -241,16 +296,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLInputUser -@end +@end + @implementation TL_inputUserEmpty +(TL_inputUserEmpty*)create { TL_inputUserEmpty* obj = [[TL_inputUserEmpty alloc] init]; @@ -272,6 +326,8 @@ -(TL_inputUserEmpty *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -285,7 +341,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -312,46 +367,8 @@ -(TL_inputUserSelf *)copy { return objc; } - --(id)initWithCoder:(NSCoder *)aDecoder { - - if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { - - } - - return self; -} - --(void)encodeWithCoder:(NSCoder *)aCoder { - [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; -} - - - -@end -@implementation TL_inputUserContact -+(TL_inputUserContact*)createWithUser_id:(int)user_id { - TL_inputUserContact* obj = [[TL_inputUserContact alloc] init]; - obj.user_id = user_id; - return obj; -} --(void)serialize:(SerializedData*)stream { - [stream writeInt:self.user_id]; -} --(void)unserialize:(SerializedData*)stream { - self.user_id = [stream readInt]; -} - --(TL_inputUserContact *)copy { - - TL_inputUserContact *objc = [[TL_inputUserContact alloc] init]; - - objc.user_id = self.user_id; - - return objc; -} -(id)initWithCoder:(NSCoder *)aDecoder { @@ -365,15 +382,14 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_inputUserForeign -+(TL_inputUserForeign*)createWithUser_id:(int)user_id access_hash:(long)access_hash { - TL_inputUserForeign* obj = [[TL_inputUserForeign alloc] init]; +@implementation TL_inputUser ++(TL_inputUser*)createWithUser_id:(int)user_id access_hash:(long)access_hash { + TL_inputUser* obj = [[TL_inputUser alloc] init]; obj.user_id = user_id; obj.access_hash = access_hash; return obj; @@ -383,19 +399,21 @@ -(void)serialize:(SerializedData*)stream { [stream writeLong:self.access_hash]; } -(void)unserialize:(SerializedData*)stream { - self.user_id = [stream readInt]; - self.access_hash = [stream readLong]; + super.user_id = [stream readInt]; + super.access_hash = [stream readLong]; } --(TL_inputUserForeign *)copy { +-(TL_inputUser *)copy { - TL_inputUserForeign *objc = [[TL_inputUserForeign alloc] init]; + TL_inputUser *objc = [[TL_inputUser alloc] init]; objc.user_id = self.user_id; objc.access_hash = self.access_hash; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -409,16 +427,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLInputContact -@end +@end + @implementation TL_inputPhoneContact +(TL_inputPhoneContact*)createWithClient_id:(long)client_id phone:(NSString*)phone first_name:(NSString*)first_name last_name:(NSString*)last_name { TL_inputPhoneContact* obj = [[TL_inputPhoneContact alloc] init]; @@ -435,10 +452,10 @@ -(void)serialize:(SerializedData*)stream { [stream writeString:self.last_name]; } -(void)unserialize:(SerializedData*)stream { - self.client_id = [stream readLong]; - self.phone = [stream readString]; - self.first_name = [stream readString]; - self.last_name = [stream readString]; + super.client_id = [stream readLong]; + super.phone = [stream readString]; + super.first_name = [stream readString]; + super.last_name = [stream readString]; } -(TL_inputPhoneContact *)copy { @@ -452,6 +469,8 @@ -(TL_inputPhoneContact *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -465,16 +484,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLInputFile -@end +@end + @implementation TL_inputFile +(TL_inputFile*)createWithN_id:(long)n_id parts:(int)parts name:(NSString*)name md5_checksum:(NSString*)md5_checksum { TL_inputFile* obj = [[TL_inputFile alloc] init]; @@ -491,10 +509,10 @@ -(void)serialize:(SerializedData*)stream { [stream writeString:self.md5_checksum]; } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readLong]; - self.parts = [stream readInt]; - self.name = [stream readString]; - self.md5_checksum = [stream readString]; + super.n_id = [stream readLong]; + super.parts = [stream readInt]; + super.name = [stream readString]; + super.md5_checksum = [stream readString]; } -(TL_inputFile *)copy { @@ -508,6 +526,8 @@ -(TL_inputFile *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -521,7 +541,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -541,9 +560,9 @@ -(void)serialize:(SerializedData*)stream { [stream writeString:self.name]; } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readLong]; - self.parts = [stream readInt]; - self.name = [stream readString]; + super.n_id = [stream readLong]; + super.parts = [stream readInt]; + super.name = [stream readString]; } -(TL_inputFileBig *)copy { @@ -556,6 +575,8 @@ -(TL_inputFileBig *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -569,16 +590,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLInputMedia -@end +@end + @implementation TL_inputMediaEmpty +(TL_inputMediaEmpty*)create { TL_inputMediaEmpty* obj = [[TL_inputMediaEmpty alloc] init]; @@ -600,6 +620,8 @@ -(TL_inputMediaEmpty *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -613,7 +635,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -632,7 +653,7 @@ -(void)serialize:(SerializedData*)stream { } -(void)unserialize:(SerializedData*)stream { self.file = [ClassStore TLDeserialize:stream]; - self.caption = [stream readString]; + super.caption = [stream readString]; } -(TL_inputMediaUploadedPhoto *)copy { @@ -644,6 +665,8 @@ -(TL_inputMediaUploadedPhoto *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -657,7 +680,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -676,7 +698,7 @@ -(void)serialize:(SerializedData*)stream { } -(void)unserialize:(SerializedData*)stream { self.n_id = [ClassStore TLDeserialize:stream]; - self.caption = [stream readString]; + super.caption = [stream readString]; } -(TL_inputMediaPhoto *)copy { @@ -688,6 +710,8 @@ -(TL_inputMediaPhoto *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -701,7 +725,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -728,6 +751,8 @@ -(TL_inputMediaGeoPoint *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -741,7 +766,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -761,9 +785,9 @@ -(void)serialize:(SerializedData*)stream { [stream writeString:self.last_name]; } -(void)unserialize:(SerializedData*)stream { - self.phone_number = [stream readString]; - self.first_name = [stream readString]; - self.last_name = [stream readString]; + super.phone_number = [stream readString]; + super.first_name = [stream readString]; + super.last_name = [stream readString]; } -(TL_inputMediaContact *)copy { @@ -776,6 +800,8 @@ -(TL_inputMediaContact *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -789,19 +815,19 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end @implementation TL_inputMediaUploadedVideo -+(TL_inputMediaUploadedVideo*)createWithFile:(TLInputFile*)file duration:(int)duration w:(int)w h:(int)h caption:(NSString*)caption { ++(TL_inputMediaUploadedVideo*)createWithFile:(TLInputFile*)file duration:(int)duration w:(int)w h:(int)h mime_type:(NSString*)mime_type caption:(NSString*)caption { TL_inputMediaUploadedVideo* obj = [[TL_inputMediaUploadedVideo alloc] init]; obj.file = file; obj.duration = duration; obj.w = w; obj.h = h; + obj.mime_type = mime_type; obj.caption = caption; return obj; } @@ -810,14 +836,16 @@ -(void)serialize:(SerializedData*)stream { [stream writeInt:self.duration]; [stream writeInt:self.w]; [stream writeInt:self.h]; + [stream writeString:self.mime_type]; [stream writeString:self.caption]; } -(void)unserialize:(SerializedData*)stream { self.file = [ClassStore TLDeserialize:stream]; - self.duration = [stream readInt]; - self.w = [stream readInt]; - self.h = [stream readInt]; - self.caption = [stream readString]; + super.duration = [stream readInt]; + super.w = [stream readInt]; + super.h = [stream readInt]; + super.mime_type = [stream readString]; + super.caption = [stream readString]; } -(TL_inputMediaUploadedVideo *)copy { @@ -828,10 +856,13 @@ -(TL_inputMediaUploadedVideo *)copy { objc.duration = self.duration; objc.w = self.w; objc.h = self.h; + objc.mime_type = self.mime_type; objc.caption = self.caption; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -845,20 +876,20 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end @implementation TL_inputMediaUploadedThumbVideo -+(TL_inputMediaUploadedThumbVideo*)createWithFile:(TLInputFile*)file thumb:(TLInputFile*)thumb duration:(int)duration w:(int)w h:(int)h caption:(NSString*)caption { ++(TL_inputMediaUploadedThumbVideo*)createWithFile:(TLInputFile*)file thumb:(TLInputFile*)thumb duration:(int)duration w:(int)w h:(int)h mime_type:(NSString*)mime_type caption:(NSString*)caption { TL_inputMediaUploadedThumbVideo* obj = [[TL_inputMediaUploadedThumbVideo alloc] init]; obj.file = file; obj.thumb = thumb; obj.duration = duration; obj.w = w; obj.h = h; + obj.mime_type = mime_type; obj.caption = caption; return obj; } @@ -868,15 +899,17 @@ -(void)serialize:(SerializedData*)stream { [stream writeInt:self.duration]; [stream writeInt:self.w]; [stream writeInt:self.h]; + [stream writeString:self.mime_type]; [stream writeString:self.caption]; } -(void)unserialize:(SerializedData*)stream { self.file = [ClassStore TLDeserialize:stream]; self.thumb = [ClassStore TLDeserialize:stream]; - self.duration = [stream readInt]; - self.w = [stream readInt]; - self.h = [stream readInt]; - self.caption = [stream readString]; + super.duration = [stream readInt]; + super.w = [stream readInt]; + super.h = [stream readInt]; + super.mime_type = [stream readString]; + super.caption = [stream readString]; } -(TL_inputMediaUploadedThumbVideo *)copy { @@ -888,10 +921,13 @@ -(TL_inputMediaUploadedThumbVideo *)copy { objc.duration = self.duration; objc.w = self.w; objc.h = self.h; + objc.mime_type = self.mime_type; objc.caption = self.caption; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -905,7 +941,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -924,7 +959,7 @@ -(void)serialize:(SerializedData*)stream { } -(void)unserialize:(SerializedData*)stream { self.n_id = [ClassStore TLDeserialize:stream]; - self.caption = [stream readString]; + super.caption = [stream readString]; } -(TL_inputMediaVideo *)copy { @@ -936,6 +971,8 @@ -(TL_inputMediaVideo *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -949,7 +986,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -970,8 +1006,8 @@ -(void)serialize:(SerializedData*)stream { } -(void)unserialize:(SerializedData*)stream { self.file = [ClassStore TLDeserialize:stream]; - self.duration = [stream readInt]; - self.mime_type = [stream readString]; + super.duration = [stream readInt]; + super.mime_type = [stream readString]; } -(TL_inputMediaUploadedAudio *)copy { @@ -984,6 +1020,8 @@ -(TL_inputMediaUploadedAudio *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -997,7 +1035,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -1024,6 +1061,8 @@ -(TL_inputMediaAudio *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -1037,7 +1076,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -1067,7 +1105,7 @@ -(void)serialize:(SerializedData*)stream { } -(void)unserialize:(SerializedData*)stream { self.file = [ClassStore TLDeserialize:stream]; - self.mime_type = [stream readString]; + super.mime_type = [stream readString]; //UNS FullVector [stream readInt]; { @@ -1094,6 +1132,8 @@ -(TL_inputMediaUploadedDocument *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -1107,7 +1147,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -1140,7 +1179,7 @@ -(void)serialize:(SerializedData*)stream { -(void)unserialize:(SerializedData*)stream { self.file = [ClassStore TLDeserialize:stream]; self.thumb = [ClassStore TLDeserialize:stream]; - self.mime_type = [stream readString]; + super.mime_type = [stream readString]; //UNS FullVector [stream readInt]; { @@ -1168,6 +1207,8 @@ -(TL_inputMediaUploadedThumbDocument *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -1181,7 +1222,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -1208,6 +1248,8 @@ -(TL_inputMediaDocument *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -1221,7 +1263,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -1246,10 +1287,10 @@ -(void)serialize:(SerializedData*)stream { } -(void)unserialize:(SerializedData*)stream { self.geo_point = [ClassStore TLDeserialize:stream]; - self.title = [stream readString]; - self.address = [stream readString]; - self.provider = [stream readString]; - self.venue_id = [stream readString]; + super.title = [stream readString]; + super.address = [stream readString]; + super.provider = [stream readString]; + super.venue_id = [stream readString]; } -(TL_inputMediaVenue *)copy { @@ -1264,6 +1305,8 @@ -(TL_inputMediaVenue *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -1277,37 +1320,50 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLInputChatPhoto -@end - -@implementation TL_inputChatPhotoEmpty -+(TL_inputChatPhotoEmpty*)create { - TL_inputChatPhotoEmpty* obj = [[TL_inputChatPhotoEmpty alloc] init]; - +@implementation TL_inputMediaUploadedVideo_old34 ++(TL_inputMediaUploadedVideo_old34*)createWithFile:(TLInputFile*)file duration:(int)duration w:(int)w h:(int)h caption:(NSString*)caption { + TL_inputMediaUploadedVideo_old34* obj = [[TL_inputMediaUploadedVideo_old34 alloc] init]; + obj.file = file; + obj.duration = duration; + obj.w = w; + obj.h = h; + obj.caption = caption; return obj; } -(void)serialize:(SerializedData*)stream { - + [ClassStore TLSerialize:self.file stream:stream]; + [stream writeInt:self.duration]; + [stream writeInt:self.w]; + [stream writeInt:self.h]; + [stream writeString:self.caption]; } -(void)unserialize:(SerializedData*)stream { - + self.file = [ClassStore TLDeserialize:stream]; + super.duration = [stream readInt]; + super.w = [stream readInt]; + super.h = [stream readInt]; + super.caption = [stream readString]; } --(TL_inputChatPhotoEmpty *)copy { - - TL_inputChatPhotoEmpty *objc = [[TL_inputChatPhotoEmpty alloc] init]; +-(TL_inputMediaUploadedVideo_old34 *)copy { + TL_inputMediaUploadedVideo_old34 *objc = [[TL_inputMediaUploadedVideo_old34 alloc] init]; + objc.file = [self.file copy]; + objc.duration = self.duration; + objc.w = self.w; + objc.h = self.h; + objc.caption = self.caption; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -1321,37 +1377,54 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_inputChatUploadedPhoto -+(TL_inputChatUploadedPhoto*)createWithFile:(TLInputFile*)file crop:(TLInputPhotoCrop*)crop { - TL_inputChatUploadedPhoto* obj = [[TL_inputChatUploadedPhoto alloc] init]; +@implementation TL_inputMediaUploadedThumbVideo_old32 ++(TL_inputMediaUploadedThumbVideo_old32*)createWithFile:(TLInputFile*)file thumb:(TLInputFile*)thumb duration:(int)duration w:(int)w h:(int)h caption:(NSString*)caption { + TL_inputMediaUploadedThumbVideo_old32* obj = [[TL_inputMediaUploadedThumbVideo_old32 alloc] init]; obj.file = file; - obj.crop = crop; + obj.thumb = thumb; + obj.duration = duration; + obj.w = w; + obj.h = h; + obj.caption = caption; return obj; } -(void)serialize:(SerializedData*)stream { [ClassStore TLSerialize:self.file stream:stream]; - [ClassStore TLSerialize:self.crop stream:stream]; + [ClassStore TLSerialize:self.thumb stream:stream]; + [stream writeInt:self.duration]; + [stream writeInt:self.w]; + [stream writeInt:self.h]; + [stream writeString:self.caption]; } -(void)unserialize:(SerializedData*)stream { self.file = [ClassStore TLDeserialize:stream]; - self.crop = [ClassStore TLDeserialize:stream]; + self.thumb = [ClassStore TLDeserialize:stream]; + super.duration = [stream readInt]; + super.w = [stream readInt]; + super.h = [stream readInt]; + super.caption = [stream readString]; } --(TL_inputChatUploadedPhoto *)copy { +-(TL_inputMediaUploadedThumbVideo_old32 *)copy { - TL_inputChatUploadedPhoto *objc = [[TL_inputChatUploadedPhoto alloc] init]; + TL_inputMediaUploadedThumbVideo_old32 *objc = [[TL_inputMediaUploadedThumbVideo_old32 alloc] init]; objc.file = [self.file copy]; - objc.crop = [self.crop copy]; + objc.thumb = [self.thumb copy]; + objc.duration = self.duration; + objc.w = self.w; + objc.h = self.h; + objc.caption = self.caption; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -1365,18 +1438,107 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_inputChatPhoto -+(TL_inputChatPhoto*)createWithN_id:(TLInputPhoto*)n_id crop:(TLInputPhotoCrop*)crop { - TL_inputChatPhoto* obj = [[TL_inputChatPhoto alloc] init]; - obj.n_id = n_id; - obj.crop = crop; - return obj; +@implementation TLInputChatPhoto + +@end + +@implementation TL_inputChatPhotoEmpty ++(TL_inputChatPhotoEmpty*)create { + TL_inputChatPhotoEmpty* obj = [[TL_inputChatPhotoEmpty alloc] init]; + + return obj; +} +-(void)serialize:(SerializedData*)stream { + +} +-(void)unserialize:(SerializedData*)stream { + +} + +-(TL_inputChatPhotoEmpty *)copy { + + TL_inputChatPhotoEmpty *objc = [[TL_inputChatPhotoEmpty alloc] init]; + + + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_inputChatUploadedPhoto ++(TL_inputChatUploadedPhoto*)createWithFile:(TLInputFile*)file crop:(TLInputPhotoCrop*)crop { + TL_inputChatUploadedPhoto* obj = [[TL_inputChatUploadedPhoto alloc] init]; + obj.file = file; + obj.crop = crop; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [ClassStore TLSerialize:self.file stream:stream]; + [ClassStore TLSerialize:self.crop stream:stream]; +} +-(void)unserialize:(SerializedData*)stream { + self.file = [ClassStore TLDeserialize:stream]; + self.crop = [ClassStore TLDeserialize:stream]; +} + +-(TL_inputChatUploadedPhoto *)copy { + + TL_inputChatUploadedPhoto *objc = [[TL_inputChatUploadedPhoto alloc] init]; + + objc.file = [self.file copy]; + objc.crop = [self.crop copy]; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_inputChatPhoto ++(TL_inputChatPhoto*)createWithN_id:(TLInputPhoto*)n_id crop:(TLInputPhotoCrop*)crop { + TL_inputChatPhoto* obj = [[TL_inputChatPhoto alloc] init]; + obj.n_id = n_id; + obj.crop = crop; + return obj; } -(void)serialize:(SerializedData*)stream { [ClassStore TLSerialize:self.n_id stream:stream]; @@ -1396,6 +1558,8 @@ -(TL_inputChatPhoto *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -1409,16 +1573,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLInputGeoPoint -@end +@end + @implementation TL_inputGeoPointEmpty +(TL_inputGeoPointEmpty*)create { TL_inputGeoPointEmpty* obj = [[TL_inputGeoPointEmpty alloc] init]; @@ -1440,6 +1603,8 @@ -(TL_inputGeoPointEmpty *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -1453,7 +1618,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -1471,8 +1635,8 @@ -(void)serialize:(SerializedData*)stream { [stream writeDouble:self.n_long]; } -(void)unserialize:(SerializedData*)stream { - self.lat = [stream readDouble]; - self.n_long = [stream readDouble]; + super.lat = [stream readDouble]; + super.n_long = [stream readDouble]; } -(TL_inputGeoPoint *)copy { @@ -1484,6 +1648,8 @@ -(TL_inputGeoPoint *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -1497,16 +1663,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLInputPhoto -@end +@end + @implementation TL_inputPhotoEmpty +(TL_inputPhotoEmpty*)create { TL_inputPhotoEmpty* obj = [[TL_inputPhotoEmpty alloc] init]; @@ -1528,6 +1693,8 @@ -(TL_inputPhotoEmpty *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -1541,7 +1708,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -1559,8 +1725,8 @@ -(void)serialize:(SerializedData*)stream { [stream writeLong:self.access_hash]; } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readLong]; - self.access_hash = [stream readLong]; + super.n_id = [stream readLong]; + super.access_hash = [stream readLong]; } -(TL_inputPhoto *)copy { @@ -1572,6 +1738,8 @@ -(TL_inputPhoto *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -1585,16 +1753,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLInputVideo -@end +@end + @implementation TL_inputVideoEmpty +(TL_inputVideoEmpty*)create { TL_inputVideoEmpty* obj = [[TL_inputVideoEmpty alloc] init]; @@ -1616,6 +1783,8 @@ -(TL_inputVideoEmpty *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -1629,7 +1798,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -1647,8 +1815,8 @@ -(void)serialize:(SerializedData*)stream { [stream writeLong:self.access_hash]; } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readLong]; - self.access_hash = [stream readLong]; + super.n_id = [stream readLong]; + super.access_hash = [stream readLong]; } -(TL_inputVideo *)copy { @@ -1660,6 +1828,8 @@ -(TL_inputVideo *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -1673,16 +1843,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLInputFileLocation -@end +@end + @implementation TL_inputFileLocation +(TL_inputFileLocation*)createWithVolume_id:(long)volume_id local_id:(int)local_id secret:(long)secret { TL_inputFileLocation* obj = [[TL_inputFileLocation alloc] init]; @@ -1697,9 +1866,9 @@ -(void)serialize:(SerializedData*)stream { [stream writeLong:self.secret]; } -(void)unserialize:(SerializedData*)stream { - self.volume_id = [stream readLong]; - self.local_id = [stream readInt]; - self.secret = [stream readLong]; + super.volume_id = [stream readLong]; + super.local_id = [stream readInt]; + super.secret = [stream readLong]; } -(TL_inputFileLocation *)copy { @@ -1712,6 +1881,8 @@ -(TL_inputFileLocation *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -1725,7 +1896,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -1743,8 +1913,8 @@ -(void)serialize:(SerializedData*)stream { [stream writeLong:self.access_hash]; } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readLong]; - self.access_hash = [stream readLong]; + super.n_id = [stream readLong]; + super.access_hash = [stream readLong]; } -(TL_inputVideoFileLocation *)copy { @@ -1756,6 +1926,8 @@ -(TL_inputVideoFileLocation *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -1769,7 +1941,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -1787,8 +1958,8 @@ -(void)serialize:(SerializedData*)stream { [stream writeLong:self.access_hash]; } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readLong]; - self.access_hash = [stream readLong]; + super.n_id = [stream readLong]; + super.access_hash = [stream readLong]; } -(TL_inputEncryptedFileLocation *)copy { @@ -1800,6 +1971,8 @@ -(TL_inputEncryptedFileLocation *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -1813,7 +1986,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -1831,8 +2003,8 @@ -(void)serialize:(SerializedData*)stream { [stream writeLong:self.access_hash]; } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readLong]; - self.access_hash = [stream readLong]; + super.n_id = [stream readLong]; + super.access_hash = [stream readLong]; } -(TL_inputAudioFileLocation *)copy { @@ -1844,6 +2016,8 @@ -(TL_inputAudioFileLocation *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -1857,7 +2031,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -1875,8 +2048,8 @@ -(void)serialize:(SerializedData*)stream { [stream writeLong:self.access_hash]; } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readLong]; - self.access_hash = [stream readLong]; + super.n_id = [stream readLong]; + super.access_hash = [stream readLong]; } -(TL_inputDocumentFileLocation *)copy { @@ -1888,6 +2061,8 @@ -(TL_inputDocumentFileLocation *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -1901,16 +2076,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLInputPhotoCrop -@end +@end + @implementation TL_inputPhotoCropAuto +(TL_inputPhotoCropAuto*)create { TL_inputPhotoCropAuto* obj = [[TL_inputPhotoCropAuto alloc] init]; @@ -1932,6 +2106,8 @@ -(TL_inputPhotoCropAuto *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -1945,7 +2121,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -1965,9 +2140,9 @@ -(void)serialize:(SerializedData*)stream { [stream writeDouble:self.crop_width]; } -(void)unserialize:(SerializedData*)stream { - self.crop_left = [stream readDouble]; - self.crop_top = [stream readDouble]; - self.crop_width = [stream readDouble]; + super.crop_left = [stream readDouble]; + super.crop_top = [stream readDouble]; + super.crop_width = [stream readDouble]; } -(TL_inputPhotoCrop *)copy { @@ -1980,6 +2155,8 @@ -(TL_inputPhotoCrop *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -1993,16 +2170,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLInputAppEvent -@end +@end + @implementation TL_inputAppEvent +(TL_inputAppEvent*)createWithTime:(double)time type:(NSString*)type peer:(long)peer data:(NSString*)data { TL_inputAppEvent* obj = [[TL_inputAppEvent alloc] init]; @@ -2019,10 +2195,10 @@ -(void)serialize:(SerializedData*)stream { [stream writeString:self.data]; } -(void)unserialize:(SerializedData*)stream { - self.time = [stream readDouble]; - self.type = [stream readString]; - self.peer = [stream readLong]; - self.data = [stream readString]; + super.time = [stream readDouble]; + super.type = [stream readString]; + super.peer = [stream readLong]; + super.data = [stream readString]; } -(TL_inputAppEvent *)copy { @@ -2036,6 +2212,8 @@ -(TL_inputAppEvent *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -2049,16 +2227,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLPeer -@end +@end + @implementation TL_peerUser +(TL_peerUser*)createWithUser_id:(int)user_id { TL_peerUser* obj = [[TL_peerUser alloc] init]; @@ -2069,7 +2246,7 @@ -(void)serialize:(SerializedData*)stream { [stream writeInt:self.user_id]; } -(void)unserialize:(SerializedData*)stream { - self.user_id = [stream readInt]; + super.user_id = [stream readInt]; } -(TL_peerUser *)copy { @@ -2080,6 +2257,8 @@ -(TL_peerUser *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -2093,7 +2272,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -2109,7 +2287,7 @@ -(void)serialize:(SerializedData*)stream { [stream writeInt:self.chat_id]; } -(void)unserialize:(SerializedData*)stream { - self.chat_id = [stream readInt]; + super.chat_id = [stream readInt]; } -(TL_peerChat *)copy { @@ -2120,6 +2298,8 @@ -(TL_peerChat *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -2133,16 +2313,56 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TL_peerChannel ++(TL_peerChannel*)createWithChannel_id:(int)channel_id { + TL_peerChannel* obj = [[TL_peerChannel alloc] init]; + obj.channel_id = channel_id; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeInt:self.channel_id]; +} +-(void)unserialize:(SerializedData*)stream { + super.channel_id = [stream readInt]; +} + +-(TL_peerChannel *)copy { + + TL_peerChannel *objc = [[TL_peerChannel alloc] init]; + + objc.channel_id = self.channel_id; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { -@implementation TLstorage_FileType + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + @end +@implementation TLstorage_FileType + +@end + @implementation TL_storage_fileUnknown +(TL_storage_fileUnknown*)create { TL_storage_fileUnknown* obj = [[TL_storage_fileUnknown alloc] init]; @@ -2164,6 +2384,8 @@ -(TL_storage_fileUnknown *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -2177,7 +2399,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -2204,6 +2425,8 @@ -(TL_storage_fileJpeg *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -2217,7 +2440,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -2244,6 +2466,8 @@ -(TL_storage_fileGif *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -2257,7 +2481,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -2284,6 +2507,8 @@ -(TL_storage_filePng *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -2297,7 +2522,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -2324,6 +2548,8 @@ -(TL_storage_filePdf *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -2337,7 +2563,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -2364,6 +2589,8 @@ -(TL_storage_fileMp3 *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -2377,7 +2604,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -2404,6 +2630,8 @@ -(TL_storage_fileMov *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -2417,7 +2645,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -2444,6 +2671,8 @@ -(TL_storage_filePartial *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -2457,7 +2686,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -2484,6 +2712,8 @@ -(TL_storage_fileMp4 *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -2497,7 +2727,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -2524,6 +2753,8 @@ -(TL_storage_fileWebp *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -2537,16 +2768,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLFileLocation -@end +@end + @implementation TL_fileLocationUnavailable +(TL_fileLocationUnavailable*)createWithVolume_id:(long)volume_id local_id:(int)local_id secret:(long)secret { TL_fileLocationUnavailable* obj = [[TL_fileLocationUnavailable alloc] init]; @@ -2561,9 +2791,9 @@ -(void)serialize:(SerializedData*)stream { [stream writeLong:self.secret]; } -(void)unserialize:(SerializedData*)stream { - self.volume_id = [stream readLong]; - self.local_id = [stream readInt]; - self.secret = [stream readLong]; + super.volume_id = [stream readLong]; + super.local_id = [stream readInt]; + super.secret = [stream readLong]; } -(TL_fileLocationUnavailable *)copy { @@ -2576,6 +2806,8 @@ -(TL_fileLocationUnavailable *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -2589,7 +2821,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -2611,10 +2842,10 @@ -(void)serialize:(SerializedData*)stream { [stream writeLong:self.secret]; } -(void)unserialize:(SerializedData*)stream { - self.dc_id = [stream readInt]; - self.volume_id = [stream readLong]; - self.local_id = [stream readInt]; - self.secret = [stream readLong]; + super.dc_id = [stream readInt]; + super.volume_id = [stream readLong]; + super.local_id = [stream readInt]; + super.secret = [stream readLong]; } -(TL_fileLocation *)copy { @@ -2628,6 +2859,8 @@ -(TL_fileLocation *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -2641,16 +2874,31 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLUser + +-(BOOL)isSelf {return NO;} + +-(BOOL)isContact {return NO;} + +-(BOOL)isMutual_contact {return NO;} + +-(BOOL)isDeleted {return NO;} + +-(BOOL)isBot {return NO;} + +-(BOOL)isBot_chat_history {return NO;} + +-(BOOL)isBot_nochats {return NO;} + +-(BOOL)isVerified {return NO;} + @end - + @implementation TL_userEmpty +(TL_userEmpty*)createWithN_id:(int)n_id { TL_userEmpty* obj = [[TL_userEmpty alloc] init]; @@ -2661,7 +2909,7 @@ -(void)serialize:(SerializedData*)stream { [stream writeInt:self.n_id]; } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readInt]; + super.n_id = [stream readInt]; } -(TL_userEmpty *)copy { @@ -2672,6 +2920,8 @@ -(TL_userEmpty *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -2685,16 +2935,23 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end @implementation TL_user -+(TL_user*)createWithFlags:(int)flags n_id:(int)n_id access_hash:(long)access_hash first_name:(NSString*)first_name last_name:(NSString*)last_name username:(NSString*)username phone:(NSString*)phone photo:(TLUserProfilePhoto*)photo status:(TLUserStatus*)status bot_info_version:(int)bot_info_version { ++(TL_user*)createWithFlags:(int)flags n_id:(int)n_id access_hash:(long)access_hash first_name:(NSString*)first_name last_name:(NSString*)last_name username:(NSString*)username phone:(NSString*)phone photo:(TLUserProfilePhoto*)photo status:(TLUserStatus*)status bot_info_version:(int)bot_info_version { TL_user* obj = [[TL_user alloc] init]; obj.flags = flags; + + + + + + + + obj.n_id = n_id; obj.access_hash = access_hash; obj.first_name = first_name; @@ -2708,27 +2965,43 @@ +(TL_user*)createWithFlags:(int)flags n_id:(int)n_id access_hash:(long)access_ha } -(void)serialize:(SerializedData*)stream { [stream writeInt:self.flags]; + + + + + + + + [stream writeInt:self.n_id]; - if(self.flags & (1 << 0)) [stream writeLong:self.access_hash]; - if(self.flags & (1 << 1)) [stream writeString:self.first_name]; - if(self.flags & (1 << 2)) [stream writeString:self.last_name]; - if(self.flags & (1 << 3)) [stream writeString:self.username]; - if(self.flags & (1 << 4)) [stream writeString:self.phone]; - if(self.flags & (1 << 5)) [ClassStore TLSerialize:self.photo stream:stream]; - if(self.flags & (1 << 6)) [ClassStore TLSerialize:self.status stream:stream]; - if(self.flags & (1 << 14)) [stream writeInt:self.bot_info_version]; -} --(void)unserialize:(SerializedData*)stream { - self.flags = [stream readInt]; - self.n_id = [stream readInt]; - if(self.flags & (1 << 0)) self.access_hash = [stream readLong]; - if(self.flags & (1 << 1)) self.first_name = [stream readString]; - if(self.flags & (1 << 2)) self.last_name = [stream readString]; - if(self.flags & (1 << 3)) self.username = [stream readString]; - if(self.flags & (1 << 4)) self.phone = [stream readString]; - if(self.flags & (1 << 5)) self.photo = [ClassStore TLDeserialize:stream]; - if(self.flags & (1 << 6)) self.status = [ClassStore TLDeserialize:stream]; - if(self.flags & (1 << 14)) self.bot_info_version = [stream readInt]; + if(self.flags & (1 << 0)) {[stream writeLong:self.access_hash];} + if(self.flags & (1 << 1)) {[stream writeString:self.first_name];} + if(self.flags & (1 << 2)) {[stream writeString:self.last_name];} + if(self.flags & (1 << 3)) {[stream writeString:self.username];} + if(self.flags & (1 << 4)) {[stream writeString:self.phone];} + if(self.flags & (1 << 5)) {[ClassStore TLSerialize:self.photo stream:stream];} + if(self.flags & (1 << 6)) {[ClassStore TLSerialize:self.status stream:stream];} + if(self.flags & (1 << 14)) {[stream writeInt:self.bot_info_version];} +} +-(void)unserialize:(SerializedData*)stream { + super.flags = [stream readInt]; + + + + + + + + + super.n_id = [stream readInt]; + if(self.flags & (1 << 0)) {super.access_hash = [stream readLong];} + if(self.flags & (1 << 1)) {super.first_name = [stream readString];} + if(self.flags & (1 << 2)) {super.last_name = [stream readString];} + if(self.flags & (1 << 3)) {super.username = [stream readString];} + if(self.flags & (1 << 4)) {super.phone = [stream readString];} + if(self.flags & (1 << 5)) {self.photo = [ClassStore TLDeserialize:stream];} + if(self.flags & (1 << 6)) {self.status = [ClassStore TLDeserialize:stream];} + if(self.flags & (1 << 14)) {super.bot_info_version = [stream readInt];} } -(TL_user *)copy { @@ -2736,6 +3009,14 @@ -(TL_user *)copy { TL_user *objc = [[TL_user alloc] init]; objc.flags = self.flags; + + + + + + + + objc.n_id = self.n_id; objc.access_hash = self.access_hash; objc.first_name = self.first_name; @@ -2748,6 +3029,8 @@ -(TL_user *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -2761,56 +3044,71 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - - + +-(BOOL)isSelf {return (self.flags & (1 << 10)) > 0;} + +-(BOOL)isContact {return (self.flags & (1 << 11)) > 0;} + +-(BOOL)isMutual_contact {return (self.flags & (1 << 12)) > 0;} + +-(BOOL)isDeleted {return (self.flags & (1 << 13)) > 0;} + +-(BOOL)isBot {return (self.flags & (1 << 14)) > 0;} + +-(BOOL)isBot_chat_history {return (self.flags & (1 << 15)) > 0;} + +-(BOOL)isBot_nochats {return (self.flags & (1 << 16)) > 0;} + +-(BOOL)isVerified {return (self.flags & (1 << 17)) > 0;} + -(void)setAccess_hash:(long)access_hash { - [super setAccess_hash:access_hash]; - - if(self.access_hash == 0) { self.flags&= ~ (1 << 0) ;} else { self.flags|= (1 << 0); } -} + super.access_hash = access_hash; + + if(super.access_hash == 0) { super.flags&= ~ (1 << 0) ;} else { super.flags|= (1 << 0); } +} -(void)setFirst_name:(NSString*)first_name { - [super setFirst_name:first_name]; - - if(self.first_name == nil) { self.flags&= ~ (1 << 1) ;} else { self.flags|= (1 << 1); } -} + super.first_name = first_name; + + if(super.first_name == nil) { super.flags&= ~ (1 << 1) ;} else { super.flags|= (1 << 1); } +} -(void)setLast_name:(NSString*)last_name { - [super setLast_name:last_name]; - - if(self.last_name == nil) { self.flags&= ~ (1 << 2) ;} else { self.flags|= (1 << 2); } -} + super.last_name = last_name; + + if(super.last_name == nil) { super.flags&= ~ (1 << 2) ;} else { super.flags|= (1 << 2); } +} -(void)setUsername:(NSString*)username { - [super setUsername:username]; - - if(self.username == nil) { self.flags&= ~ (1 << 3) ;} else { self.flags|= (1 << 3); } -} + super.username = username; + + if(super.username == nil) { super.flags&= ~ (1 << 3) ;} else { super.flags|= (1 << 3); } +} -(void)setPhone:(NSString*)phone { - [super setPhone:phone]; - - if(self.phone == nil) { self.flags&= ~ (1 << 4) ;} else { self.flags|= (1 << 4); } -} + super.phone = phone; + + if(super.phone == nil) { super.flags&= ~ (1 << 4) ;} else { super.flags|= (1 << 4); } +} -(void)setPhoto:(TLUserProfilePhoto*)photo { - [super setPhoto:photo]; - - if(self.photo == nil) { self.flags&= ~ (1 << 5) ;} else { self.flags|= (1 << 5); } -} + super.photo = photo; + + if(super.photo == nil) { super.flags&= ~ (1 << 5) ;} else { super.flags|= (1 << 5); } +} -(void)setStatus:(TLUserStatus*)status { - [super setStatus:status]; - - if(self.status == nil) { self.flags&= ~ (1 << 6) ;} else { self.flags|= (1 << 6); } -} + super.status = status; + + if(super.status == nil) { super.flags&= ~ (1 << 6) ;} else { super.flags|= (1 << 6); } +} -(void)setBot_info_version:(int)bot_info_version { - [super setBot_info_version:bot_info_version]; - - if(self.bot_info_version == 0) { self.flags&= ~ (1 << 14) ;} else { self.flags|= (1 << 14); } + super.bot_info_version = bot_info_version; + + if(super.bot_info_version == 0) { super.flags&= ~ (1 << 14) ;} else { super.flags|= (1 << 14); } } @end @@ -2837,11 +3135,11 @@ -(void)serialize:(SerializedData*)stream { [ClassStore TLSerialize:self.status stream:stream]; } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readInt]; - self.first_name = [stream readString]; - self.last_name = [stream readString]; - self.username = [stream readString]; - self.phone = [stream readString]; + super.n_id = [stream readInt]; + super.first_name = [stream readString]; + super.last_name = [stream readString]; + super.username = [stream readString]; + super.phone = [stream readString]; self.photo = [ClassStore TLDeserialize:stream]; self.status = [ClassStore TLDeserialize:stream]; } @@ -2860,6 +3158,8 @@ -(TL_userSelf *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -2873,7 +3173,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -2903,12 +3202,12 @@ -(void)serialize:(SerializedData*)stream { [ClassStore TLSerialize:self.status stream:stream]; } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readInt]; - self.first_name = [stream readString]; - self.last_name = [stream readString]; - self.username = [stream readString]; - self.access_hash = [stream readLong]; - self.phone = [stream readString]; + super.n_id = [stream readInt]; + super.first_name = [stream readString]; + super.last_name = [stream readString]; + super.username = [stream readString]; + super.access_hash = [stream readLong]; + super.phone = [stream readString]; self.photo = [ClassStore TLDeserialize:stream]; self.status = [ClassStore TLDeserialize:stream]; } @@ -2928,6 +3227,8 @@ -(TL_userContact *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -2941,7 +3242,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -2971,12 +3271,12 @@ -(void)serialize:(SerializedData*)stream { [ClassStore TLSerialize:self.status stream:stream]; } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readInt]; - self.first_name = [stream readString]; - self.last_name = [stream readString]; - self.username = [stream readString]; - self.access_hash = [stream readLong]; - self.phone = [stream readString]; + super.n_id = [stream readInt]; + super.first_name = [stream readString]; + super.last_name = [stream readString]; + super.username = [stream readString]; + super.access_hash = [stream readLong]; + super.phone = [stream readString]; self.photo = [ClassStore TLDeserialize:stream]; self.status = [ClassStore TLDeserialize:stream]; } @@ -2996,6 +3296,8 @@ -(TL_userRequest *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -3009,7 +3311,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -3037,11 +3338,11 @@ -(void)serialize:(SerializedData*)stream { [ClassStore TLSerialize:self.status stream:stream]; } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readInt]; - self.first_name = [stream readString]; - self.last_name = [stream readString]; - self.username = [stream readString]; - self.access_hash = [stream readLong]; + super.n_id = [stream readInt]; + super.first_name = [stream readString]; + super.last_name = [stream readString]; + super.username = [stream readString]; + super.access_hash = [stream readLong]; self.photo = [ClassStore TLDeserialize:stream]; self.status = [ClassStore TLDeserialize:stream]; } @@ -3060,6 +3361,8 @@ -(TL_userForeign *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -3073,7 +3376,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -3095,10 +3397,10 @@ -(void)serialize:(SerializedData*)stream { [stream writeString:self.username]; } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readInt]; - self.first_name = [stream readString]; - self.last_name = [stream readString]; - self.username = [stream readString]; + super.n_id = [stream readInt]; + super.first_name = [stream readString]; + super.last_name = [stream readString]; + super.username = [stream readString]; } -(TL_userDeleted *)copy { @@ -3112,6 +3414,8 @@ -(TL_userDeleted *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -3125,16 +3429,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLUserProfilePhoto -@end +@end + @implementation TL_userProfilePhotoEmpty +(TL_userProfilePhotoEmpty*)create { TL_userProfilePhotoEmpty* obj = [[TL_userProfilePhotoEmpty alloc] init]; @@ -3156,6 +3459,8 @@ -(TL_userProfilePhotoEmpty *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -3169,7 +3474,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -3189,7 +3493,7 @@ -(void)serialize:(SerializedData*)stream { [ClassStore TLSerialize:self.photo_big stream:stream]; } -(void)unserialize:(SerializedData*)stream { - self.photo_id = [stream readLong]; + super.photo_id = [stream readLong]; self.photo_small = [ClassStore TLDeserialize:stream]; self.photo_big = [ClassStore TLDeserialize:stream]; } @@ -3204,6 +3508,8 @@ -(TL_userProfilePhoto *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -3217,16 +3523,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLUserStatus -@end +@end + @implementation TL_userStatusEmpty +(TL_userStatusEmpty*)create { TL_userStatusEmpty* obj = [[TL_userStatusEmpty alloc] init]; @@ -3248,6 +3553,8 @@ -(TL_userStatusEmpty *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -3261,7 +3568,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -3277,7 +3583,7 @@ -(void)serialize:(SerializedData*)stream { [stream writeInt:self.expires]; } -(void)unserialize:(SerializedData*)stream { - self.expires = [stream readInt]; + super.expires = [stream readInt]; } -(TL_userStatusOnline *)copy { @@ -3288,6 +3594,8 @@ -(TL_userStatusOnline *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -3301,7 +3609,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -3317,7 +3624,7 @@ -(void)serialize:(SerializedData*)stream { [stream writeInt:self.was_online]; } -(void)unserialize:(SerializedData*)stream { - self.was_online = [stream readInt]; + super.was_online = [stream readInt]; } -(TL_userStatusOffline *)copy { @@ -3328,6 +3635,8 @@ -(TL_userStatusOffline *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -3341,7 +3650,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -3368,6 +3676,8 @@ -(TL_userStatusRecently *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -3381,7 +3691,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -3408,6 +3717,8 @@ -(TL_userStatusLastWeek *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -3421,7 +3732,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -3448,6 +3758,8 @@ -(TL_userStatusLastMonth *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -3461,16 +3773,37 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLChat + +-(BOOL)isCreator {return NO;} + +-(BOOL)isKicked {return NO;} + +-(BOOL)isLeft {return NO;} + +-(BOOL)isAdmins_enabled {return NO;} + +-(BOOL)isAdmin {return NO;} + +-(BOOL)isDeactivated {return NO;} + +-(BOOL)isEditor {return NO;} + +-(BOOL)isModerator {return NO;} + +-(BOOL)isBroadcast {return NO;} + +-(BOOL)isVerified {return NO;} + +-(BOOL)isMegagroup {return NO;} + @end - + @implementation TL_chatEmpty +(TL_chatEmpty*)createWithN_id:(int)n_id { TL_chatEmpty* obj = [[TL_chatEmpty alloc] init]; @@ -3481,7 +3814,7 @@ -(void)serialize:(SerializedData*)stream { [stream writeInt:self.n_id]; } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readInt]; + super.n_id = [stream readInt]; } -(TL_chatEmpty *)copy { @@ -3492,6 +3825,8 @@ -(TL_chatEmpty *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -3505,57 +3840,86 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end @implementation TL_chat -+(TL_chat*)createWithN_id:(int)n_id title:(NSString*)title photo:(TLChatPhoto*)photo participants_count:(int)participants_count date:(int)date left:(Boolean)left version:(int)version { ++(TL_chat*)createWithFlags:(int)flags n_id:(int)n_id title:(NSString*)title photo:(TLChatPhoto*)photo participants_count:(int)participants_count date:(int)date version:(int)version migrated_to:(TLInputChannel*)migrated_to { TL_chat* obj = [[TL_chat alloc] init]; + obj.flags = flags; + + + + + + obj.n_id = n_id; obj.title = title; obj.photo = photo; obj.participants_count = participants_count; obj.date = date; - obj.left = left; obj.version = version; + obj.migrated_to = migrated_to; return obj; } -(void)serialize:(SerializedData*)stream { + [stream writeInt:self.flags]; + + + + + + [stream writeInt:self.n_id]; [stream writeString:self.title]; [ClassStore TLSerialize:self.photo stream:stream]; [stream writeInt:self.participants_count]; [stream writeInt:self.date]; - [stream writeBool:self.left]; [stream writeInt:self.version]; + if(self.flags & (1 << 6)) {[ClassStore TLSerialize:self.migrated_to stream:stream];} } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readInt]; - self.title = [stream readString]; + super.flags = [stream readInt]; + + + + + + + super.n_id = [stream readInt]; + super.title = [stream readString]; self.photo = [ClassStore TLDeserialize:stream]; - self.participants_count = [stream readInt]; - self.date = [stream readInt]; - self.left = [stream readBool]; - self.version = [stream readInt]; + super.participants_count = [stream readInt]; + super.date = [stream readInt]; + super.version = [stream readInt]; + if(self.flags & (1 << 6)) {self.migrated_to = [ClassStore TLDeserialize:stream];} } -(TL_chat *)copy { TL_chat *objc = [[TL_chat alloc] init]; + objc.flags = self.flags; + + + + + + objc.n_id = self.n_id; objc.title = self.title; objc.photo = [self.photo copy]; objc.participants_count = self.participants_count; objc.date = self.date; - objc.left = self.left; objc.version = self.version; + objc.migrated_to = [self.migrated_to copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -3569,29 +3933,43 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - - + +-(BOOL)isCreator {return (self.flags & (1 << 0)) > 0;} + +-(BOOL)isKicked {return (self.flags & (1 << 1)) > 0;} + +-(BOOL)isLeft {return (self.flags & (1 << 2)) > 0;} + +-(BOOL)isAdmins_enabled {return (self.flags & (1 << 3)) > 0;} + +-(BOOL)isAdmin {return (self.flags & (1 << 4)) > 0;} + +-(BOOL)isDeactivated {return (self.flags & (1 << 5)) > 0;} + +-(void)setMigrated_to:(TLInputChannel*)migrated_to +{ + super.migrated_to = migrated_to; + + if(super.migrated_to == nil) { super.flags&= ~ (1 << 6) ;} else { super.flags|= (1 << 6); } +} @end @implementation TL_chatForbidden -+(TL_chatForbidden*)createWithN_id:(int)n_id title:(NSString*)title date:(int)date { ++(TL_chatForbidden*)createWithN_id:(int)n_id title:(NSString*)title { TL_chatForbidden* obj = [[TL_chatForbidden alloc] init]; obj.n_id = n_id; obj.title = title; - obj.date = date; return obj; } -(void)serialize:(SerializedData*)stream { [stream writeInt:self.n_id]; [stream writeString:self.title]; - [stream writeInt:self.date]; } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readInt]; - self.title = [stream readString]; - self.date = [stream readInt]; + super.n_id = [stream readInt]; + super.title = [stream readString]; } -(TL_chatForbidden *)copy { @@ -3600,10 +3978,11 @@ -(TL_chatForbidden *)copy { objc.n_id = self.n_id; objc.title = self.title; - objc.date = self.date; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -3617,73 +3996,94 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_geoChat -+(TL_geoChat*)createWithN_id:(int)n_id access_hash:(long)access_hash title:(NSString*)title address:(NSString*)address venue:(NSString*)venue geo:(TLGeoPoint*)geo photo:(TLChatPhoto*)photo participants_count:(int)participants_count date:(int)date checked_in:(Boolean)checked_in version:(int)version { - TL_geoChat* obj = [[TL_geoChat alloc] init]; +@implementation TL_channel ++(TL_channel*)createWithFlags:(int)flags n_id:(int)n_id access_hash:(long)access_hash title:(NSString*)title username:(NSString*)username photo:(TLChatPhoto*)photo date:(int)date version:(int)version { + TL_channel* obj = [[TL_channel alloc] init]; + obj.flags = flags; + + + + + + + + obj.n_id = n_id; obj.access_hash = access_hash; obj.title = title; - obj.address = address; - obj.venue = venue; - obj.geo = geo; + obj.username = username; obj.photo = photo; - obj.participants_count = participants_count; obj.date = date; - obj.checked_in = checked_in; obj.version = version; return obj; } -(void)serialize:(SerializedData*)stream { + [stream writeInt:self.flags]; + + + + + + + + [stream writeInt:self.n_id]; [stream writeLong:self.access_hash]; [stream writeString:self.title]; - [stream writeString:self.address]; - [stream writeString:self.venue]; - [ClassStore TLSerialize:self.geo stream:stream]; + if(self.flags & (1 << 6)) {[stream writeString:self.username];} [ClassStore TLSerialize:self.photo stream:stream]; - [stream writeInt:self.participants_count]; [stream writeInt:self.date]; - [stream writeBool:self.checked_in]; [stream writeInt:self.version]; } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readInt]; - self.access_hash = [stream readLong]; - self.title = [stream readString]; - self.address = [stream readString]; - self.venue = [stream readString]; - self.geo = [ClassStore TLDeserialize:stream]; + super.flags = [stream readInt]; + + + + + + + + + super.n_id = [stream readInt]; + super.access_hash = [stream readLong]; + super.title = [stream readString]; + if(self.flags & (1 << 6)) {super.username = [stream readString];} self.photo = [ClassStore TLDeserialize:stream]; - self.participants_count = [stream readInt]; - self.date = [stream readInt]; - self.checked_in = [stream readBool]; - self.version = [stream readInt]; + super.date = [stream readInt]; + super.version = [stream readInt]; } --(TL_geoChat *)copy { +-(TL_channel *)copy { + + TL_channel *objc = [[TL_channel alloc] init]; + + objc.flags = self.flags; + + + + + + - TL_geoChat *objc = [[TL_geoChat alloc] init]; objc.n_id = self.n_id; objc.access_hash = self.access_hash; objc.title = self.title; - objc.address = self.address; - objc.venue = self.venue; - objc.geo = [self.geo copy]; + objc.username = self.username; objc.photo = [self.photo copy]; - objc.participants_count = self.participants_count; objc.date = self.date; - objc.checked_in = self.checked_in; objc.version = self.version; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -3697,79 +4097,64 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - - + +-(BOOL)isCreator {return (self.flags & (1 << 0)) > 0;} + +-(BOOL)isKicked {return (self.flags & (1 << 1)) > 0;} + +-(BOOL)isLeft {return (self.flags & (1 << 2)) > 0;} + +-(BOOL)isEditor {return (self.flags & (1 << 3)) > 0;} + +-(BOOL)isModerator {return (self.flags & (1 << 4)) > 0;} + +-(BOOL)isBroadcast {return (self.flags & (1 << 5)) > 0;} + +-(BOOL)isVerified {return (self.flags & (1 << 7)) > 0;} + +-(BOOL)isMegagroup {return (self.flags & (1 << 8)) > 0;} + +-(void)setUsername:(NSString*)username +{ + super.username = username; + + if(super.username == nil) { super.flags&= ~ (1 << 6) ;} else { super.flags|= (1 << 6); } +} @end - -@implementation TLChatFull -@end - -@implementation TL_chatFull -+(TL_chatFull*)createWithN_id:(int)n_id participants:(TLChatParticipants*)participants chat_photo:(TLPhoto*)chat_photo notify_settings:(TLPeerNotifySettings*)notify_settings exported_invite:(TLExportedChatInvite*)exported_invite bot_info:(NSMutableArray*)bot_info { - TL_chatFull* obj = [[TL_chatFull alloc] init]; +@implementation TL_channelForbidden ++(TL_channelForbidden*)createWithN_id:(int)n_id access_hash:(long)access_hash title:(NSString*)title { + TL_channelForbidden* obj = [[TL_channelForbidden alloc] init]; obj.n_id = n_id; - obj.participants = participants; - obj.chat_photo = chat_photo; - obj.notify_settings = notify_settings; - obj.exported_invite = exported_invite; - obj.bot_info = bot_info; + obj.access_hash = access_hash; + obj.title = title; return obj; } -(void)serialize:(SerializedData*)stream { [stream writeInt:self.n_id]; - [ClassStore TLSerialize:self.participants stream:stream]; - [ClassStore TLSerialize:self.chat_photo stream:stream]; - [ClassStore TLSerialize:self.notify_settings stream:stream]; - [ClassStore TLSerialize:self.exported_invite stream:stream]; - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.bot_info count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLBotInfo* obj = [self.bot_info objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } + [stream writeLong:self.access_hash]; + [stream writeString:self.title]; } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readInt]; - self.participants = [ClassStore TLDeserialize:stream]; - self.chat_photo = [ClassStore TLDeserialize:stream]; - self.notify_settings = [ClassStore TLDeserialize:stream]; - self.exported_invite = [ClassStore TLDeserialize:stream]; - //UNS FullVector - [stream readInt]; - { - if(!self.bot_info) - self.bot_info = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLBotInfo* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLBotInfo class]]) - [self.bot_info addObject:obj]; - else - break; - } - } + super.n_id = [stream readInt]; + super.access_hash = [stream readLong]; + super.title = [stream readString]; } --(TL_chatFull *)copy { +-(TL_channelForbidden *)copy { - TL_chatFull *objc = [[TL_chatFull alloc] init]; + TL_channelForbidden *objc = [[TL_channelForbidden alloc] init]; objc.n_id = self.n_id; - objc.participants = [self.participants copy]; - objc.chat_photo = [self.chat_photo copy]; - objc.notify_settings = [self.notify_settings copy]; - objc.exported_invite = [self.exported_invite copy]; - objc.bot_info = [self.bot_info copy]; + objc.access_hash = self.access_hash; + objc.title = self.title; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -3783,49 +4168,58 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_chatFull_old29 -+(TL_chatFull_old29*)createWithN_id:(int)n_id participants:(TLChatParticipants*)participants chat_photo:(TLPhoto*)chat_photo notify_settings:(TLPeerNotifySettings*)notify_settings exported_invite:(TLExportedChatInvite*)exported_invite { - TL_chatFull_old29* obj = [[TL_chatFull_old29 alloc] init]; +@implementation TL_chat_old34 ++(TL_chat_old34*)createWithN_id:(int)n_id title:(NSString*)title photo:(TLChatPhoto*)photo participants_count:(int)participants_count date:(int)date left:(Boolean)left version:(int)version { + TL_chat_old34* obj = [[TL_chat_old34 alloc] init]; obj.n_id = n_id; - obj.participants = participants; - obj.chat_photo = chat_photo; - obj.notify_settings = notify_settings; - obj.exported_invite = exported_invite; + obj.title = title; + obj.photo = photo; + obj.participants_count = participants_count; + obj.date = date; + obj.left = left; + obj.version = version; return obj; } -(void)serialize:(SerializedData*)stream { [stream writeInt:self.n_id]; - [ClassStore TLSerialize:self.participants stream:stream]; - [ClassStore TLSerialize:self.chat_photo stream:stream]; - [ClassStore TLSerialize:self.notify_settings stream:stream]; - [ClassStore TLSerialize:self.exported_invite stream:stream]; + [stream writeString:self.title]; + [ClassStore TLSerialize:self.photo stream:stream]; + [stream writeInt:self.participants_count]; + [stream writeInt:self.date]; + [stream writeBool:self.left]; + [stream writeInt:self.version]; } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readInt]; - self.participants = [ClassStore TLDeserialize:stream]; - self.chat_photo = [ClassStore TLDeserialize:stream]; - self.notify_settings = [ClassStore TLDeserialize:stream]; - self.exported_invite = [ClassStore TLDeserialize:stream]; + super.n_id = [stream readInt]; + super.title = [stream readString]; + self.photo = [ClassStore TLDeserialize:stream]; + super.participants_count = [stream readInt]; + super.date = [stream readInt]; + super.left = [stream readBool]; + super.version = [stream readInt]; } --(TL_chatFull_old29 *)copy { +-(TL_chat_old34 *)copy { - TL_chatFull_old29 *objc = [[TL_chatFull_old29 alloc] init]; + TL_chat_old34 *objc = [[TL_chat_old34 alloc] init]; objc.n_id = self.n_id; - objc.participants = [self.participants copy]; - objc.chat_photo = [self.chat_photo copy]; - objc.notify_settings = [self.notify_settings copy]; - objc.exported_invite = [self.exported_invite copy]; + objc.title = self.title; + objc.photo = [self.photo copy]; + objc.participants_count = self.participants_count; + objc.date = self.date; + objc.left = self.left; + objc.version = self.version; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -3839,45 +4233,42 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLChatParticipant -@end - -@implementation TL_chatParticipant -+(TL_chatParticipant*)createWithUser_id:(int)user_id inviter_id:(int)inviter_id date:(int)date { - TL_chatParticipant* obj = [[TL_chatParticipant alloc] init]; - obj.user_id = user_id; - obj.inviter_id = inviter_id; +@implementation TL_chatForbidden_old34 ++(TL_chatForbidden_old34*)createWithN_id:(int)n_id title:(NSString*)title date:(int)date { + TL_chatForbidden_old34* obj = [[TL_chatForbidden_old34 alloc] init]; + obj.n_id = n_id; + obj.title = title; obj.date = date; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.user_id]; - [stream writeInt:self.inviter_id]; + [stream writeInt:self.n_id]; + [stream writeString:self.title]; [stream writeInt:self.date]; } -(void)unserialize:(SerializedData*)stream { - self.user_id = [stream readInt]; - self.inviter_id = [stream readInt]; - self.date = [stream readInt]; + super.n_id = [stream readInt]; + super.title = [stream readString]; + super.date = [stream readInt]; } --(TL_chatParticipant *)copy { +-(TL_chatForbidden_old34 *)copy { - TL_chatParticipant *objc = [[TL_chatParticipant alloc] init]; + TL_chatForbidden_old34 *objc = [[TL_chatForbidden_old34 alloc] init]; - objc.user_id = self.user_id; - objc.inviter_id = self.inviter_id; + objc.n_id = self.n_id; + objc.title = self.title; objc.date = self.date; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -3891,37 +4282,58 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLChatParticipants -@end - -@implementation TL_chatParticipantsForbidden -+(TL_chatParticipantsForbidden*)createWithChat_id:(int)chat_id { - TL_chatParticipantsForbidden* obj = [[TL_chatParticipantsForbidden alloc] init]; - obj.chat_id = chat_id; +@implementation TL_chat_old38 ++(TL_chat_old38*)createWithFlags:(int)flags n_id:(int)n_id title:(NSString*)title photo:(TLChatPhoto*)photo participants_count:(int)participants_count date:(int)date version:(int)version { + TL_chat_old38* obj = [[TL_chat_old38 alloc] init]; + obj.flags = flags; + obj.n_id = n_id; + obj.title = title; + obj.photo = photo; + obj.participants_count = participants_count; + obj.date = date; + obj.version = version; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.chat_id]; + [stream writeInt:self.flags]; + [stream writeInt:self.n_id]; + [stream writeString:self.title]; + [ClassStore TLSerialize:self.photo stream:stream]; + [stream writeInt:self.participants_count]; + [stream writeInt:self.date]; + [stream writeInt:self.version]; } -(void)unserialize:(SerializedData*)stream { - self.chat_id = [stream readInt]; + super.flags = [stream readInt]; + super.n_id = [stream readInt]; + super.title = [stream readString]; + self.photo = [ClassStore TLDeserialize:stream]; + super.participants_count = [stream readInt]; + super.date = [stream readInt]; + super.version = [stream readInt]; } --(TL_chatParticipantsForbidden *)copy { +-(TL_chat_old38 *)copy { - TL_chatParticipantsForbidden *objc = [[TL_chatParticipantsForbidden alloc] init]; + TL_chat_old38 *objc = [[TL_chat_old38 alloc] init]; - objc.chat_id = self.chat_id; + objc.flags = self.flags; + objc.n_id = self.n_id; + objc.title = self.title; + objc.photo = [self.photo copy]; + objc.participants_count = self.participants_count; + objc.date = self.date; + objc.version = self.version; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -3935,67 +4347,82 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_chatParticipants -+(TL_chatParticipants*)createWithChat_id:(int)chat_id admin_id:(int)admin_id participants:(NSMutableArray*)participants version:(int)version { - TL_chatParticipants* obj = [[TL_chatParticipants alloc] init]; - obj.chat_id = chat_id; - obj.admin_id = admin_id; +@implementation TLChatFull + +-(BOOL)isCan_view_participants {return NO;} + +@end + +@implementation TL_chatFull ++(TL_chatFull*)createWithN_id:(int)n_id participants:(TLChatParticipants*)participants chat_photo:(TLPhoto*)chat_photo notify_settings:(TLPeerNotifySettings*)notify_settings exported_invite:(TLExportedChatInvite*)exported_invite bot_info:(NSMutableArray*)bot_info { + TL_chatFull* obj = [[TL_chatFull alloc] init]; + obj.n_id = n_id; obj.participants = participants; - obj.version = version; + obj.chat_photo = chat_photo; + obj.notify_settings = notify_settings; + obj.exported_invite = exported_invite; + obj.bot_info = bot_info; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.chat_id]; - [stream writeInt:self.admin_id]; + [stream writeInt:self.n_id]; + [ClassStore TLSerialize:self.participants stream:stream]; + [ClassStore TLSerialize:self.chat_photo stream:stream]; + [ClassStore TLSerialize:self.notify_settings stream:stream]; + [ClassStore TLSerialize:self.exported_invite stream:stream]; //Serialize FullVector [stream writeInt:0x1cb5c415]; { - NSInteger tl_count = [self.participants count]; + NSInteger tl_count = [self.bot_info count]; [stream writeInt:(int)tl_count]; for(int i = 0; i < (int)tl_count; i++) { - TLChatParticipant* obj = [self.participants objectAtIndex:i]; + TLBotInfo* obj = [self.bot_info objectAtIndex:i]; [ClassStore TLSerialize:obj stream:stream]; } } - [stream writeInt:self.version]; } -(void)unserialize:(SerializedData*)stream { - self.chat_id = [stream readInt]; - self.admin_id = [stream readInt]; + super.n_id = [stream readInt]; + self.participants = [ClassStore TLDeserialize:stream]; + self.chat_photo = [ClassStore TLDeserialize:stream]; + self.notify_settings = [ClassStore TLDeserialize:stream]; + self.exported_invite = [ClassStore TLDeserialize:stream]; //UNS FullVector [stream readInt]; { - if(!self.participants) - self.participants = [[NSMutableArray alloc] init]; + if(!self.bot_info) + self.bot_info = [[NSMutableArray alloc] init]; int count = [stream readInt]; for(int i = 0; i < count; i++) { - TLChatParticipant* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLChatParticipant class]]) - [self.participants addObject:obj]; + TLBotInfo* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLBotInfo class]]) + [self.bot_info addObject:obj]; else break; } } - self.version = [stream readInt]; } --(TL_chatParticipants *)copy { +-(TL_chatFull *)copy { - TL_chatParticipants *objc = [[TL_chatParticipants alloc] init]; + TL_chatFull *objc = [[TL_chatFull alloc] init]; - objc.chat_id = self.chat_id; - objc.admin_id = self.admin_id; + objc.n_id = self.n_id; objc.participants = [self.participants copy]; - objc.version = self.version; + objc.chat_photo = [self.chat_photo copy]; + objc.notify_settings = [self.notify_settings copy]; + objc.exported_invite = [self.exported_invite copy]; + objc.bot_info = [self.bot_info copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -4009,37 +4436,116 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLChatPhoto -@end - -@implementation TL_chatPhotoEmpty -+(TL_chatPhotoEmpty*)create { - TL_chatPhotoEmpty* obj = [[TL_chatPhotoEmpty alloc] init]; +@implementation TL_channelFull ++(TL_channelFull*)createWithFlags:(int)flags n_id:(int)n_id about:(NSString*)about participants_count:(int)participants_count admins_count:(int)admins_count kicked_count:(int)kicked_count read_inbox_max_id:(int)read_inbox_max_id unread_count:(int)unread_count unread_important_count:(int)unread_important_count chat_photo:(TLPhoto*)chat_photo notify_settings:(TLPeerNotifySettings*)notify_settings exported_invite:(TLExportedChatInvite*)exported_invite bot_info:(NSMutableArray*)bot_info migrated_from_chat_id:(int)migrated_from_chat_id migrated_from_max_id:(int)migrated_from_max_id { + TL_channelFull* obj = [[TL_channelFull alloc] init]; + obj.flags = flags; + obj.n_id = n_id; + obj.about = about; + obj.participants_count = participants_count; + obj.admins_count = admins_count; + obj.kicked_count = kicked_count; + obj.read_inbox_max_id = read_inbox_max_id; + obj.unread_count = unread_count; + obj.unread_important_count = unread_important_count; + obj.chat_photo = chat_photo; + obj.notify_settings = notify_settings; + obj.exported_invite = exported_invite; + obj.bot_info = bot_info; + obj.migrated_from_chat_id = migrated_from_chat_id; + obj.migrated_from_max_id = migrated_from_max_id; return obj; } -(void)serialize:(SerializedData*)stream { + [stream writeInt:self.flags]; + [stream writeInt:self.n_id]; + [stream writeString:self.about]; + if(self.flags & (1 << 0)) {[stream writeInt:self.participants_count];} + if(self.flags & (1 << 1)) {[stream writeInt:self.admins_count];} + if(self.flags & (1 << 2)) {[stream writeInt:self.kicked_count];} + [stream writeInt:self.read_inbox_max_id]; + [stream writeInt:self.unread_count]; + [stream writeInt:self.unread_important_count]; + [ClassStore TLSerialize:self.chat_photo stream:stream]; + [ClassStore TLSerialize:self.notify_settings stream:stream]; + [ClassStore TLSerialize:self.exported_invite stream:stream]; + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.bot_info count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLBotInfo* obj = [self.bot_info objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + if(self.flags & (1 << 4)) {[stream writeInt:self.migrated_from_chat_id];} + if(self.flags & (1 << 4)) {[stream writeInt:self.migrated_from_max_id];} } -(void)unserialize:(SerializedData*)stream { + super.flags = [stream readInt]; + super.n_id = [stream readInt]; + super.about = [stream readString]; + if(self.flags & (1 << 0)) {super.participants_count = [stream readInt];} + if(self.flags & (1 << 1)) {super.admins_count = [stream readInt];} + if(self.flags & (1 << 2)) {super.kicked_count = [stream readInt];} + super.read_inbox_max_id = [stream readInt]; + super.unread_count = [stream readInt]; + super.unread_important_count = [stream readInt]; + self.chat_photo = [ClassStore TLDeserialize:stream]; + self.notify_settings = [ClassStore TLDeserialize:stream]; + self.exported_invite = [ClassStore TLDeserialize:stream]; + //UNS FullVector + [stream readInt]; + { + if(!self.bot_info) + self.bot_info = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLBotInfo* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLBotInfo class]]) + [self.bot_info addObject:obj]; + else + break; + } + } + if(self.flags & (1 << 4)) {super.migrated_from_chat_id = [stream readInt];} + if(self.flags & (1 << 4)) {super.migrated_from_max_id = [stream readInt];} } --(TL_chatPhotoEmpty *)copy { +-(TL_channelFull *)copy { - TL_chatPhotoEmpty *objc = [[TL_chatPhotoEmpty alloc] init]; + TL_channelFull *objc = [[TL_channelFull alloc] init]; + objc.flags = self.flags; + objc.n_id = self.n_id; + objc.about = self.about; + objc.participants_count = self.participants_count; + objc.admins_count = self.admins_count; + objc.kicked_count = self.kicked_count; + objc.read_inbox_max_id = self.read_inbox_max_id; + objc.unread_count = self.unread_count; + objc.unread_important_count = self.unread_important_count; + objc.chat_photo = [self.chat_photo copy]; + objc.notify_settings = [self.notify_settings copy]; + objc.exported_invite = [self.exported_invite copy]; + objc.bot_info = [self.bot_info copy]; + objc.migrated_from_chat_id = self.migrated_from_chat_id; + objc.migrated_from_max_id = self.migrated_from_max_id; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -4053,81 +4559,82 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - - + +-(BOOL)isCan_view_participants {return (self.flags & (1 << 3)) > 0;} + +-(void)setParticipants_count:(int)participants_count +{ + super.participants_count = participants_count; + + if(super.participants_count == 0) { super.flags&= ~ (1 << 0) ;} else { super.flags|= (1 << 0); } +} +-(void)setAdmins_count:(int)admins_count +{ + super.admins_count = admins_count; + + if(super.admins_count == 0) { super.flags&= ~ (1 << 1) ;} else { super.flags|= (1 << 1); } +} +-(void)setKicked_count:(int)kicked_count +{ + super.kicked_count = kicked_count; + + if(super.kicked_count == 0) { super.flags&= ~ (1 << 2) ;} else { super.flags|= (1 << 2); } +} +-(void)setMigrated_from_chat_id:(int)migrated_from_chat_id +{ + super.migrated_from_chat_id = migrated_from_chat_id; + + if(super.migrated_from_chat_id == 0) { super.flags&= ~ (1 << 4) ;} else { super.flags|= (1 << 4); } +} +-(void)setMigrated_from_max_id:(int)migrated_from_max_id +{ + super.migrated_from_max_id = migrated_from_max_id; + + if(super.migrated_from_max_id == 0) { super.flags&= ~ (1 << 4) ;} else { super.flags|= (1 << 4); } +} @end -@implementation TL_chatPhoto -+(TL_chatPhoto*)createWithPhoto_small:(TLFileLocation*)photo_small photo_big:(TLFileLocation*)photo_big { - TL_chatPhoto* obj = [[TL_chatPhoto alloc] init]; - obj.photo_small = photo_small; - obj.photo_big = photo_big; - return obj; -} --(void)serialize:(SerializedData*)stream { - [ClassStore TLSerialize:self.photo_small stream:stream]; - [ClassStore TLSerialize:self.photo_big stream:stream]; -} --(void)unserialize:(SerializedData*)stream { - self.photo_small = [ClassStore TLDeserialize:stream]; - self.photo_big = [ClassStore TLDeserialize:stream]; -} - --(TL_chatPhoto *)copy { - - TL_chatPhoto *objc = [[TL_chatPhoto alloc] init]; - - objc.photo_small = [self.photo_small copy]; - objc.photo_big = [self.photo_big copy]; - - return objc; -} - --(id)initWithCoder:(NSCoder *)aDecoder { - - if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { - - } - - return self; -} - --(void)encodeWithCoder:(NSCoder *)aCoder { - [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; -} - - - - -@end - - -@implementation TLMessage -@end - -@implementation TL_messageEmpty -+(TL_messageEmpty*)createWithN_id:(int)n_id { - TL_messageEmpty* obj = [[TL_messageEmpty alloc] init]; - obj.n_id = n_id; +@implementation TL_chatFull_old29 ++(TL_chatFull_old29*)createWithN_id:(int)n_id participants:(TLChatParticipants*)participants chat_photo:(TLPhoto*)chat_photo notify_settings:(TLPeerNotifySettings*)notify_settings exported_invite:(TLExportedChatInvite*)exported_invite { + TL_chatFull_old29* obj = [[TL_chatFull_old29 alloc] init]; + obj.n_id = n_id; + obj.participants = participants; + obj.chat_photo = chat_photo; + obj.notify_settings = notify_settings; + obj.exported_invite = exported_invite; return obj; } -(void)serialize:(SerializedData*)stream { [stream writeInt:self.n_id]; + [ClassStore TLSerialize:self.participants stream:stream]; + [ClassStore TLSerialize:self.chat_photo stream:stream]; + [ClassStore TLSerialize:self.notify_settings stream:stream]; + [ClassStore TLSerialize:self.exported_invite stream:stream]; } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readInt]; + super.n_id = [stream readInt]; + self.participants = [ClassStore TLDeserialize:stream]; + self.chat_photo = [ClassStore TLDeserialize:stream]; + self.notify_settings = [ClassStore TLDeserialize:stream]; + self.exported_invite = [ClassStore TLDeserialize:stream]; } --(TL_messageEmpty *)copy { +-(TL_chatFull_old29 *)copy { - TL_messageEmpty *objc = [[TL_messageEmpty alloc] init]; + TL_chatFull_old29 *objc = [[TL_chatFull_old29 alloc] init]; objc.n_id = self.n_id; + objc.participants = [self.participants copy]; + objc.chat_photo = [self.chat_photo copy]; + objc.notify_settings = [self.notify_settings copy]; + objc.exported_invite = [self.exported_invite copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -4141,73 +4648,82 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_message -+(TL_message*)createWithFlags:(int)flags n_id:(int)n_id from_id:(int)from_id to_id:(TLPeer*)to_id fwd_from_id:(int)fwd_from_id fwd_date:(int)fwd_date reply_to_msg_id:(int)reply_to_msg_id date:(int)date message:(NSString*)message media:(TLMessageMedia*)media reply_markup:(TLReplyMarkup*)reply_markup { - TL_message* obj = [[TL_message alloc] init]; +@implementation TL_channelFull_old39 ++(TL_channelFull_old39*)createWithFlags:(int)flags n_id:(int)n_id about:(NSString*)about participants_count:(int)participants_count admins_count:(int)admins_count kicked_count:(int)kicked_count read_inbox_max_id:(int)read_inbox_max_id unread_count:(int)unread_count unread_important_count:(int)unread_important_count chat_photo:(TLPhoto*)chat_photo notify_settings:(TLPeerNotifySettings*)notify_settings exported_invite:(TLExportedChatInvite*)exported_invite { + TL_channelFull_old39* obj = [[TL_channelFull_old39 alloc] init]; obj.flags = flags; + obj.n_id = n_id; - obj.from_id = from_id; - obj.to_id = to_id; - obj.fwd_from_id = fwd_from_id; - obj.fwd_date = fwd_date; - obj.reply_to_msg_id = reply_to_msg_id; - obj.date = date; - obj.message = message; - obj.media = media; - obj.reply_markup = reply_markup; + obj.about = about; + obj.participants_count = participants_count; + obj.admins_count = admins_count; + obj.kicked_count = kicked_count; + obj.read_inbox_max_id = read_inbox_max_id; + obj.unread_count = unread_count; + obj.unread_important_count = unread_important_count; + obj.chat_photo = chat_photo; + obj.notify_settings = notify_settings; + obj.exported_invite = exported_invite; return obj; } -(void)serialize:(SerializedData*)stream { [stream writeInt:self.flags]; + [stream writeInt:self.n_id]; - [stream writeInt:self.from_id]; - [ClassStore TLSerialize:self.to_id stream:stream]; - if(self.flags & (1 << 2)) [stream writeInt:self.fwd_from_id]; - if(self.flags & (1 << 2)) [stream writeInt:self.fwd_date]; - if(self.flags & (1 << 3)) [stream writeInt:self.reply_to_msg_id]; - [stream writeInt:self.date]; - [stream writeString:self.message]; - [ClassStore TLSerialize:self.media stream:stream]; - if(self.flags & (1 << 6)) [ClassStore TLSerialize:self.reply_markup stream:stream]; + [stream writeString:self.about]; + if(self.flags & (1 << 0)) {[stream writeInt:self.participants_count];} + if(self.flags & (1 << 1)) {[stream writeInt:self.admins_count];} + if(self.flags & (1 << 2)) {[stream writeInt:self.kicked_count];} + [stream writeInt:self.read_inbox_max_id]; + [stream writeInt:self.unread_count]; + [stream writeInt:self.unread_important_count]; + [ClassStore TLSerialize:self.chat_photo stream:stream]; + [ClassStore TLSerialize:self.notify_settings stream:stream]; + [ClassStore TLSerialize:self.exported_invite stream:stream]; } -(void)unserialize:(SerializedData*)stream { - self.flags = [stream readInt]; - self.n_id = [stream readInt]; - self.from_id = [stream readInt]; - self.to_id = [ClassStore TLDeserialize:stream]; - if(self.flags & (1 << 2)) self.fwd_from_id = [stream readInt]; - if(self.flags & (1 << 2)) self.fwd_date = [stream readInt]; - if(self.flags & (1 << 3)) self.reply_to_msg_id = [stream readInt]; - self.date = [stream readInt]; - self.message = [stream readString]; - self.media = [ClassStore TLDeserialize:stream]; - if(self.flags & (1 << 6)) self.reply_markup = [ClassStore TLDeserialize:stream]; + super.flags = [stream readInt]; + + super.n_id = [stream readInt]; + super.about = [stream readString]; + if(self.flags & (1 << 0)) {super.participants_count = [stream readInt];} + if(self.flags & (1 << 1)) {super.admins_count = [stream readInt];} + if(self.flags & (1 << 2)) {super.kicked_count = [stream readInt];} + super.read_inbox_max_id = [stream readInt]; + super.unread_count = [stream readInt]; + super.unread_important_count = [stream readInt]; + self.chat_photo = [ClassStore TLDeserialize:stream]; + self.notify_settings = [ClassStore TLDeserialize:stream]; + self.exported_invite = [ClassStore TLDeserialize:stream]; } --(TL_message *)copy { +-(TL_channelFull_old39 *)copy { - TL_message *objc = [[TL_message alloc] init]; + TL_channelFull_old39 *objc = [[TL_channelFull_old39 alloc] init]; objc.flags = self.flags; + objc.n_id = self.n_id; - objc.from_id = self.from_id; - objc.to_id = [self.to_id copy]; - objc.fwd_from_id = self.fwd_from_id; - objc.fwd_date = self.fwd_date; - objc.reply_to_msg_id = self.reply_to_msg_id; - objc.date = self.date; - objc.message = self.message; - objc.media = [self.media copy]; - objc.reply_markup = [self.reply_markup copy]; + objc.about = self.about; + objc.participants_count = self.participants_count; + objc.admins_count = self.admins_count; + objc.kicked_count = self.kicked_count; + objc.read_inbox_max_id = self.read_inbox_max_id; + objc.unread_count = self.unread_count; + objc.unread_important_count = self.unread_important_count; + objc.chat_photo = [self.chat_photo copy]; + objc.notify_settings = [self.notify_settings copy]; + objc.exported_invite = [self.exported_invite copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -4221,77 +4737,66 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - - --(void)setFwd_from_id:(int)fwd_from_id -{ - [super setFwd_from_id:fwd_from_id]; - if(self.fwd_from_id == 0) { self.flags&= ~ (1 << 2) ;} else { self.flags|= (1 << 2); } -} --(void)setFwd_date:(int)fwd_date +-(BOOL)isCan_view_participants {return (self.flags & (1 << 3)) > 0;} + +-(void)setParticipants_count:(int)participants_count { - [super setFwd_date:fwd_date]; - - if(self.fwd_date == 0) { self.flags&= ~ (1 << 2) ;} else { self.flags|= (1 << 2); } -} --(void)setReply_to_msg_id:(int)reply_to_msg_id + super.participants_count = participants_count; + + if(super.participants_count == 0) { super.flags&= ~ (1 << 0) ;} else { super.flags|= (1 << 0); } +} +-(void)setAdmins_count:(int)admins_count { - [super setReply_to_msg_id:reply_to_msg_id]; - - if(self.reply_to_msg_id == 0) { self.flags&= ~ (1 << 3) ;} else { self.flags|= (1 << 3); } -} --(void)setReply_markup:(TLReplyMarkup*)reply_markup + super.admins_count = admins_count; + + if(super.admins_count == 0) { super.flags&= ~ (1 << 1) ;} else { super.flags|= (1 << 1); } +} +-(void)setKicked_count:(int)kicked_count { - [super setReply_markup:reply_markup]; - - if(self.reply_markup == nil) { self.flags&= ~ (1 << 6) ;} else { self.flags|= (1 << 6); } + super.kicked_count = kicked_count; + + if(super.kicked_count == 0) { super.flags&= ~ (1 << 2) ;} else { super.flags|= (1 << 2); } } @end -@implementation TL_messageService -+(TL_messageService*)createWithFlags:(int)flags n_id:(int)n_id from_id:(int)from_id to_id:(TLPeer*)to_id date:(int)date action:(TLMessageAction*)action { - TL_messageService* obj = [[TL_messageService alloc] init]; - obj.flags = flags; - obj.n_id = n_id; - obj.from_id = from_id; - obj.to_id = to_id; +@implementation TLChatParticipant + +@end + +@implementation TL_chatParticipant ++(TL_chatParticipant*)createWithUser_id:(int)user_id inviter_id:(int)inviter_id date:(int)date { + TL_chatParticipant* obj = [[TL_chatParticipant alloc] init]; + obj.user_id = user_id; + obj.inviter_id = inviter_id; obj.date = date; - obj.action = action; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.flags]; - [stream writeInt:self.n_id]; - [stream writeInt:self.from_id]; - [ClassStore TLSerialize:self.to_id stream:stream]; + [stream writeInt:self.user_id]; + [stream writeInt:self.inviter_id]; [stream writeInt:self.date]; - [ClassStore TLSerialize:self.action stream:stream]; } -(void)unserialize:(SerializedData*)stream { - self.flags = [stream readInt]; - self.n_id = [stream readInt]; - self.from_id = [stream readInt]; - self.to_id = [ClassStore TLDeserialize:stream]; - self.date = [stream readInt]; - self.action = [ClassStore TLDeserialize:stream]; + super.user_id = [stream readInt]; + super.inviter_id = [stream readInt]; + super.date = [stream readInt]; } --(TL_messageService *)copy { +-(TL_chatParticipant *)copy { - TL_messageService *objc = [[TL_messageService alloc] init]; + TL_chatParticipant *objc = [[TL_chatParticipant alloc] init]; - objc.flags = self.flags; - objc.n_id = self.n_id; - objc.from_id = self.from_id; - objc.to_id = [self.to_id copy]; + objc.user_id = self.user_id; + objc.inviter_id = self.inviter_id; objc.date = self.date; - objc.action = [self.action copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -4305,37 +4810,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLMessageMedia -@end - -@implementation TL_messageMediaEmpty -+(TL_messageMediaEmpty*)create { - TL_messageMediaEmpty* obj = [[TL_messageMediaEmpty alloc] init]; - +@implementation TL_chatParticipantCreator ++(TL_chatParticipantCreator*)createWithUser_id:(int)user_id { + TL_chatParticipantCreator* obj = [[TL_chatParticipantCreator alloc] init]; + obj.user_id = user_id; return obj; } -(void)serialize:(SerializedData*)stream { - + [stream writeInt:self.user_id]; } -(void)unserialize:(SerializedData*)stream { - + super.user_id = [stream readInt]; } --(TL_messageMediaEmpty *)copy { - - TL_messageMediaEmpty *objc = [[TL_messageMediaEmpty alloc] init]; +-(TL_chatParticipantCreator *)copy { + TL_chatParticipantCreator *objc = [[TL_chatParticipantCreator alloc] init]; + objc.user_id = self.user_id; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -4349,37 +4851,42 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_messageMediaPhoto -+(TL_messageMediaPhoto*)createWithPhoto:(TLPhoto*)photo caption:(NSString*)caption { - TL_messageMediaPhoto* obj = [[TL_messageMediaPhoto alloc] init]; - obj.photo = photo; - obj.caption = caption; +@implementation TL_chatParticipantAdmin ++(TL_chatParticipantAdmin*)createWithUser_id:(int)user_id inviter_id:(int)inviter_id date:(int)date { + TL_chatParticipantAdmin* obj = [[TL_chatParticipantAdmin alloc] init]; + obj.user_id = user_id; + obj.inviter_id = inviter_id; + obj.date = date; return obj; } -(void)serialize:(SerializedData*)stream { - [ClassStore TLSerialize:self.photo stream:stream]; - [stream writeString:self.caption]; + [stream writeInt:self.user_id]; + [stream writeInt:self.inviter_id]; + [stream writeInt:self.date]; } -(void)unserialize:(SerializedData*)stream { - self.photo = [ClassStore TLDeserialize:stream]; - self.caption = [stream readString]; + super.user_id = [stream readInt]; + super.inviter_id = [stream readInt]; + super.date = [stream readInt]; } --(TL_messageMediaPhoto *)copy { +-(TL_chatParticipantAdmin *)copy { - TL_messageMediaPhoto *objc = [[TL_messageMediaPhoto alloc] init]; + TL_chatParticipantAdmin *objc = [[TL_chatParticipantAdmin alloc] init]; - objc.photo = [self.photo copy]; - objc.caption = self.caption; + objc.user_id = self.user_id; + objc.inviter_id = self.inviter_id; + objc.date = self.date; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -4393,37 +4900,46 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_messageMediaVideo -+(TL_messageMediaVideo*)createWithVideo:(TLVideo*)video caption:(NSString*)caption { - TL_messageMediaVideo* obj = [[TL_messageMediaVideo alloc] init]; - obj.video = video; - obj.caption = caption; +@implementation TLChatParticipants + +@end + +@implementation TL_chatParticipantsForbidden ++(TL_chatParticipantsForbidden*)createWithFlags:(int)flags chat_id:(int)chat_id self_participant:(TLChatParticipant*)self_participant { + TL_chatParticipantsForbidden* obj = [[TL_chatParticipantsForbidden alloc] init]; + obj.flags = flags; + obj.chat_id = chat_id; + obj.self_participant = self_participant; return obj; } -(void)serialize:(SerializedData*)stream { - [ClassStore TLSerialize:self.video stream:stream]; - [stream writeString:self.caption]; + [stream writeInt:self.flags]; + [stream writeInt:self.chat_id]; + if(self.flags & (1 << 0)) {[ClassStore TLSerialize:self.self_participant stream:stream];} } -(void)unserialize:(SerializedData*)stream { - self.video = [ClassStore TLDeserialize:stream]; - self.caption = [stream readString]; + super.flags = [stream readInt]; + super.chat_id = [stream readInt]; + if(self.flags & (1 << 0)) {self.self_participant = [ClassStore TLDeserialize:stream];} } --(TL_messageMediaVideo *)copy { +-(TL_chatParticipantsForbidden *)copy { - TL_messageMediaVideo *objc = [[TL_messageMediaVideo alloc] init]; + TL_chatParticipantsForbidden *objc = [[TL_chatParticipantsForbidden alloc] init]; - objc.video = [self.video copy]; - objc.caption = self.caption; + objc.flags = self.flags; + objc.chat_id = self.chat_id; + objc.self_participant = [self.self_participant copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -4437,33 +4953,70 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - - + +-(void)setSelf_participant:(TLChatParticipant*)self_participant +{ + super.self_participant = self_participant; + + if(super.self_participant == nil) { super.flags&= ~ (1 << 0) ;} else { super.flags|= (1 << 0); } +} @end -@implementation TL_messageMediaGeo -+(TL_messageMediaGeo*)createWithGeo:(TLGeoPoint*)geo { - TL_messageMediaGeo* obj = [[TL_messageMediaGeo alloc] init]; - obj.geo = geo; +@implementation TL_chatParticipants ++(TL_chatParticipants*)createWithChat_id:(int)chat_id participants:(NSMutableArray*)participants version:(int)version { + TL_chatParticipants* obj = [[TL_chatParticipants alloc] init]; + obj.chat_id = chat_id; + obj.participants = participants; + obj.version = version; return obj; } -(void)serialize:(SerializedData*)stream { - [ClassStore TLSerialize:self.geo stream:stream]; -} --(void)unserialize:(SerializedData*)stream { - self.geo = [ClassStore TLDeserialize:stream]; -} - --(TL_messageMediaGeo *)copy { + [stream writeInt:self.chat_id]; + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.participants count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLChatParticipant* obj = [self.participants objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + [stream writeInt:self.version]; +} +-(void)unserialize:(SerializedData*)stream { + super.chat_id = [stream readInt]; + //UNS FullVector + [stream readInt]; + { + if(!self.participants) + self.participants = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLChatParticipant* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLChatParticipant class]]) + [self.participants addObject:obj]; + else + break; + } + } + super.version = [stream readInt]; +} + +-(TL_chatParticipants *)copy { - TL_messageMediaGeo *objc = [[TL_messageMediaGeo alloc] init]; + TL_chatParticipants *objc = [[TL_chatParticipants alloc] init]; - objc.geo = [self.geo copy]; + objc.chat_id = self.chat_id; + objc.participants = [self.participants copy]; + objc.version = self.version; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -4477,45 +5030,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_messageMediaContact -+(TL_messageMediaContact*)createWithPhone_number:(NSString*)phone_number first_name:(NSString*)first_name last_name:(NSString*)last_name user_id:(int)user_id { - TL_messageMediaContact* obj = [[TL_messageMediaContact alloc] init]; - obj.phone_number = phone_number; - obj.first_name = first_name; - obj.last_name = last_name; - obj.user_id = user_id; +@implementation TL_chatParticipantsForbidden_old34 ++(TL_chatParticipantsForbidden_old34*)createWithChat_id:(int)chat_id { + TL_chatParticipantsForbidden_old34* obj = [[TL_chatParticipantsForbidden_old34 alloc] init]; + obj.chat_id = chat_id; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeString:self.phone_number]; - [stream writeString:self.first_name]; - [stream writeString:self.last_name]; - [stream writeInt:self.user_id]; + [stream writeInt:self.chat_id]; } -(void)unserialize:(SerializedData*)stream { - self.phone_number = [stream readString]; - self.first_name = [stream readString]; - self.last_name = [stream readString]; - self.user_id = [stream readInt]; + super.chat_id = [stream readInt]; } --(TL_messageMediaContact *)copy { +-(TL_chatParticipantsForbidden_old34 *)copy { - TL_messageMediaContact *objc = [[TL_messageMediaContact alloc] init]; + TL_chatParticipantsForbidden_old34 *objc = [[TL_chatParticipantsForbidden_old34 alloc] init]; - objc.phone_number = self.phone_number; - objc.first_name = self.first_name; - objc.last_name = self.last_name; - objc.user_id = self.user_id; + objc.chat_id = self.chat_id; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -4529,33 +5071,68 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_messageMediaUnsupported -+(TL_messageMediaUnsupported*)create { - TL_messageMediaUnsupported* obj = [[TL_messageMediaUnsupported alloc] init]; - +@implementation TL_chatParticipants_old38 ++(TL_chatParticipants_old38*)createWithChat_id:(int)chat_id admin_id:(int)admin_id participants:(NSMutableArray*)participants version:(int)version { + TL_chatParticipants_old38* obj = [[TL_chatParticipants_old38 alloc] init]; + obj.chat_id = chat_id; + obj.admin_id = admin_id; + obj.participants = participants; + obj.version = version; return obj; } -(void)serialize:(SerializedData*)stream { - + [stream writeInt:self.chat_id]; + [stream writeInt:self.admin_id]; + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.participants count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLChatParticipant* obj = [self.participants objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + [stream writeInt:self.version]; } -(void)unserialize:(SerializedData*)stream { - + super.chat_id = [stream readInt]; + super.admin_id = [stream readInt]; + //UNS FullVector + [stream readInt]; + { + if(!self.participants) + self.participants = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLChatParticipant* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLChatParticipant class]]) + [self.participants addObject:obj]; + else + break; + } + } + super.version = [stream readInt]; } --(TL_messageMediaUnsupported *)copy { - - TL_messageMediaUnsupported *objc = [[TL_messageMediaUnsupported alloc] init]; +-(TL_chatParticipants_old38 *)copy { + TL_chatParticipants_old38 *objc = [[TL_chatParticipants_old38 alloc] init]; + objc.chat_id = self.chat_id; + objc.admin_id = self.admin_id; + objc.participants = [self.participants copy]; + objc.version = self.version; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -4569,33 +5146,68 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_messageMediaDocument -+(TL_messageMediaDocument*)createWithDocument:(TLDocument*)document { - TL_messageMediaDocument* obj = [[TL_messageMediaDocument alloc] init]; - obj.document = document; +@implementation TL_chatParticipants_old39 ++(TL_chatParticipants_old39*)createWithChat_id:(int)chat_id admin_id:(int)admin_id participants:(NSMutableArray*)participants version:(int)version { + TL_chatParticipants_old39* obj = [[TL_chatParticipants_old39 alloc] init]; + obj.chat_id = chat_id; + obj.admin_id = admin_id; + obj.participants = participants; + obj.version = version; return obj; } -(void)serialize:(SerializedData*)stream { - [ClassStore TLSerialize:self.document stream:stream]; + [stream writeInt:self.chat_id]; + [stream writeInt:self.admin_id]; + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.participants count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLChatParticipant* obj = [self.participants objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + [stream writeInt:self.version]; } -(void)unserialize:(SerializedData*)stream { - self.document = [ClassStore TLDeserialize:stream]; + super.chat_id = [stream readInt]; + super.admin_id = [stream readInt]; + //UNS FullVector + [stream readInt]; + { + if(!self.participants) + self.participants = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLChatParticipant* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLChatParticipant class]]) + [self.participants addObject:obj]; + else + break; + } + } + super.version = [stream readInt]; } --(TL_messageMediaDocument *)copy { +-(TL_chatParticipants_old39 *)copy { - TL_messageMediaDocument *objc = [[TL_messageMediaDocument alloc] init]; + TL_chatParticipants_old39 *objc = [[TL_chatParticipants_old39 alloc] init]; - objc.document = [self.document copy]; + objc.chat_id = self.chat_id; + objc.admin_id = self.admin_id; + objc.participants = [self.participants copy]; + objc.version = self.version; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -4609,33 +5221,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_messageMediaAudio -+(TL_messageMediaAudio*)createWithAudio:(TLAudio*)audio { - TL_messageMediaAudio* obj = [[TL_messageMediaAudio alloc] init]; - obj.audio = audio; +@implementation TLChatPhoto + +@end + +@implementation TL_chatPhotoEmpty ++(TL_chatPhotoEmpty*)create { + TL_chatPhotoEmpty* obj = [[TL_chatPhotoEmpty alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [ClassStore TLSerialize:self.audio stream:stream]; + } -(void)unserialize:(SerializedData*)stream { - self.audio = [ClassStore TLDeserialize:stream]; + } --(TL_messageMediaAudio *)copy { +-(TL_chatPhotoEmpty *)copy { + + TL_chatPhotoEmpty *objc = [[TL_chatPhotoEmpty alloc] init]; - TL_messageMediaAudio *objc = [[TL_messageMediaAudio alloc] init]; - objc.audio = [self.audio copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -4649,33 +5266,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_messageMediaWebPage -+(TL_messageMediaWebPage*)createWithWebpage:(TLWebPage*)webpage { - TL_messageMediaWebPage* obj = [[TL_messageMediaWebPage alloc] init]; - obj.webpage = webpage; +@implementation TL_chatPhoto ++(TL_chatPhoto*)createWithPhoto_small:(TLFileLocation*)photo_small photo_big:(TLFileLocation*)photo_big { + TL_chatPhoto* obj = [[TL_chatPhoto alloc] init]; + obj.photo_small = photo_small; + obj.photo_big = photo_big; return obj; } -(void)serialize:(SerializedData*)stream { - [ClassStore TLSerialize:self.webpage stream:stream]; + [ClassStore TLSerialize:self.photo_small stream:stream]; + [ClassStore TLSerialize:self.photo_big stream:stream]; } -(void)unserialize:(SerializedData*)stream { - self.webpage = [ClassStore TLDeserialize:stream]; + self.photo_small = [ClassStore TLDeserialize:stream]; + self.photo_big = [ClassStore TLDeserialize:stream]; } --(TL_messageMediaWebPage *)copy { +-(TL_chatPhoto *)copy { - TL_messageMediaWebPage *objc = [[TL_messageMediaWebPage alloc] init]; + TL_chatPhoto *objc = [[TL_chatPhoto alloc] init]; - objc.webpage = [self.webpage copy]; + objc.photo_small = [self.photo_small copy]; + objc.photo_big = [self.photo_big copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -4689,49 +5311,46 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_messageMediaVenue -+(TL_messageMediaVenue*)createWithGeo:(TLGeoPoint*)geo title:(NSString*)title address:(NSString*)address provider:(NSString*)provider venue_id:(NSString*)venue_id { - TL_messageMediaVenue* obj = [[TL_messageMediaVenue alloc] init]; - obj.geo = geo; - obj.title = title; - obj.address = address; - obj.provider = provider; - obj.venue_id = venue_id; +@implementation TLMessage + +-(BOOL)isUnread {return NO;} + +-(BOOL)isN_out {return NO;} + +-(BOOL)isMentioned {return NO;} + +-(BOOL)isMedia_unread {return NO;} + +@end + +@implementation TL_messageEmpty ++(TL_messageEmpty*)createWithN_id:(int)n_id { + TL_messageEmpty* obj = [[TL_messageEmpty alloc] init]; + obj.n_id = n_id; return obj; } -(void)serialize:(SerializedData*)stream { - [ClassStore TLSerialize:self.geo stream:stream]; - [stream writeString:self.title]; - [stream writeString:self.address]; - [stream writeString:self.provider]; - [stream writeString:self.venue_id]; + [stream writeInt:self.n_id]; } -(void)unserialize:(SerializedData*)stream { - self.geo = [ClassStore TLDeserialize:stream]; - self.title = [stream readString]; - self.address = [stream readString]; - self.provider = [stream readString]; - self.venue_id = [stream readString]; + super.n_id = [stream readInt]; } --(TL_messageMediaVenue *)copy { +-(TL_messageEmpty *)copy { - TL_messageMediaVenue *objc = [[TL_messageMediaVenue alloc] init]; + TL_messageEmpty *objc = [[TL_messageEmpty alloc] init]; - objc.geo = [self.geo copy]; - objc.title = self.title; - objc.address = self.address; - objc.provider = self.provider; - objc.venue_id = self.venue_id; + objc.n_id = self.n_id; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -4745,37 +5364,120 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLMessageAction -@end - -@implementation TL_messageActionEmpty -+(TL_messageActionEmpty*)create { - TL_messageActionEmpty* obj = [[TL_messageActionEmpty alloc] init]; +@implementation TL_message ++(TL_message*)createWithFlags:(int)flags n_id:(int)n_id from_id:(int)from_id to_id:(TLPeer*)to_id fwd_from_id:(TLPeer*)fwd_from_id fwd_date:(int)fwd_date reply_to_msg_id:(int)reply_to_msg_id date:(int)date message:(NSString*)message media:(TLMessageMedia*)media reply_markup:(TLReplyMarkup*)reply_markup entities:(NSMutableArray*)entities views:(int)views { + TL_message* obj = [[TL_message alloc] init]; + obj.flags = flags; - return obj; -} + + + + obj.n_id = n_id; + obj.from_id = from_id; + obj.to_id = to_id; + obj.fwd_from_id = fwd_from_id; + obj.fwd_date = fwd_date; + obj.reply_to_msg_id = reply_to_msg_id; + obj.date = date; + obj.message = message; + obj.media = media; + obj.reply_markup = reply_markup; + obj.entities = entities; + obj.views = views; + return obj; +} -(void)serialize:(SerializedData*)stream { + [stream writeInt:self.flags]; + + + + [stream writeInt:self.n_id]; + if(self.flags & (1 << 8)) {[stream writeInt:self.from_id];} + [ClassStore TLSerialize:self.to_id stream:stream]; + if(self.flags & (1 << 2)) {[ClassStore TLSerialize:self.fwd_from_id stream:stream];} + if(self.flags & (1 << 2)) {[stream writeInt:self.fwd_date];} + if(self.flags & (1 << 3)) {[stream writeInt:self.reply_to_msg_id];} + [stream writeInt:self.date]; + [stream writeString:self.message]; + if(self.flags & (1 << 9)) {[ClassStore TLSerialize:self.media stream:stream];} + if(self.flags & (1 << 6)) {[ClassStore TLSerialize:self.reply_markup stream:stream];} + if(self.flags & (1 << 7)) {//Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.entities count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLMessageEntity* obj = [self.entities objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + }} + if(self.flags & (1 << 10)) {[stream writeInt:self.views];} } -(void)unserialize:(SerializedData*)stream { + super.flags = [stream readInt]; + + + + super.n_id = [stream readInt]; + if(self.flags & (1 << 8)) {super.from_id = [stream readInt];} + self.to_id = [ClassStore TLDeserialize:stream]; + if(self.flags & (1 << 2)) {self.fwd_from_id = [ClassStore TLDeserialize:stream];} + if(self.flags & (1 << 2)) {super.fwd_date = [stream readInt];} + if(self.flags & (1 << 3)) {super.reply_to_msg_id = [stream readInt];} + super.date = [stream readInt]; + super.message = [stream readString]; + if(self.flags & (1 << 9)) {self.media = [ClassStore TLDeserialize:stream];} + if(self.flags & (1 << 6)) {self.reply_markup = [ClassStore TLDeserialize:stream];} + if(self.flags & (1 << 7)) {//UNS FullVector + [stream readInt]; + { + if(!self.entities) + self.entities = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLMessageEntity* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLMessageEntity class]]) + [self.entities addObject:obj]; + else + break; + } + }} + if(self.flags & (1 << 10)) {super.views = [stream readInt];} } --(TL_messageActionEmpty *)copy { +-(TL_message *)copy { + + TL_message *objc = [[TL_message alloc] init]; + + objc.flags = self.flags; + - TL_messageActionEmpty *objc = [[TL_messageActionEmpty alloc] init]; + objc.n_id = self.n_id; + objc.from_id = self.from_id; + objc.to_id = [self.to_id copy]; + objc.fwd_from_id = [self.fwd_from_id copy]; + objc.fwd_date = self.fwd_date; + objc.reply_to_msg_id = self.reply_to_msg_id; + objc.date = self.date; + objc.message = self.message; + objc.media = [self.media copy]; + objc.reply_markup = [self.reply_markup copy]; + objc.entities = [self.entities copy]; + objc.views = self.views; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -4789,59 +5491,126 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - - + +-(BOOL)isUnread {return (self.flags & (1 << 0)) > 0;} + +-(BOOL)isN_out {return (self.flags & (1 << 1)) > 0;} + +-(BOOL)isMentioned {return (self.flags & (1 << 4)) > 0;} + +-(BOOL)isMedia_unread {return (self.flags & (1 << 5)) > 0;} + +-(void)setFrom_id:(int)from_id +{ + super.from_id = from_id; + + if(super.from_id == 0) { super.flags&= ~ (1 << 8) ;} else { super.flags|= (1 << 8); } +} +-(void)setFwd_from_id:(TLPeer*)fwd_from_id +{ + super.fwd_from_id = fwd_from_id; + + if(super.fwd_from_id == nil) { super.flags&= ~ (1 << 2) ;} else { super.flags|= (1 << 2); } +} +-(void)setFwd_date:(int)fwd_date +{ + super.fwd_date = fwd_date; + + if(super.fwd_date == 0) { super.flags&= ~ (1 << 2) ;} else { super.flags|= (1 << 2); } +} +-(void)setReply_to_msg_id:(int)reply_to_msg_id +{ + super.reply_to_msg_id = reply_to_msg_id; + + if(super.reply_to_msg_id == 0) { super.flags&= ~ (1 << 3) ;} else { super.flags|= (1 << 3); } +} +-(void)setMedia:(TLMessageMedia*)media +{ + super.media = media; + + if(super.media == nil) { super.flags&= ~ (1 << 9) ;} else { super.flags|= (1 << 9); } +} +-(void)setReply_markup:(TLReplyMarkup*)reply_markup +{ + super.reply_markup = reply_markup; + + if(super.reply_markup == nil) { super.flags&= ~ (1 << 6) ;} else { super.flags|= (1 << 6); } +} +-(void)setEntities:(NSMutableArray*)entities +{ + super.entities = entities; + + if(super.entities == nil) { super.flags&= ~ (1 << 7) ;} else { super.flags|= (1 << 7); } +} +-(void)setViews:(int)views +{ + super.views = views; + + if(super.views == 0) { super.flags&= ~ (1 << 10) ;} else { super.flags|= (1 << 10); } +} @end -@implementation TL_messageActionChatCreate -+(TL_messageActionChatCreate*)createWithTitle:(NSString*)title users:(NSMutableArray*)users { - TL_messageActionChatCreate* obj = [[TL_messageActionChatCreate alloc] init]; - obj.title = title; - obj.users = users; +@implementation TL_messageService ++(TL_messageService*)createWithFlags:(int)flags n_id:(int)n_id from_id:(int)from_id to_id:(TLPeer*)to_id date:(int)date action:(TLMessageAction*)action { + TL_messageService* obj = [[TL_messageService alloc] init]; + obj.flags = flags; + + + + + obj.n_id = n_id; + obj.from_id = from_id; + obj.to_id = to_id; + obj.date = date; + obj.action = action; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeString:self.title]; - //Serialize ShortVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.users count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - if([self.users count] > i) { - NSNumber* obj = [self.users objectAtIndex:i]; - [stream writeInt:[obj intValue]]; - } else - break; - } - } + [stream writeInt:self.flags]; + + + + + [stream writeInt:self.n_id]; + if(self.flags & (1 << 8)) {[stream writeInt:self.from_id];} + [ClassStore TLSerialize:self.to_id stream:stream]; + [stream writeInt:self.date]; + [ClassStore TLSerialize:self.action stream:stream]; } -(void)unserialize:(SerializedData*)stream { - self.title = [stream readString]; - //UNS ShortVector - [stream readInt]; - { - if(!self.users) - self.users = [[NSMutableArray alloc] init]; - int tl_count = [stream readInt]; - for(int i = 0; i < tl_count; i++) { - int obj = [stream readInt]; - [self.users addObject:@(obj)]; - } - } + super.flags = [stream readInt]; + + + + + super.n_id = [stream readInt]; + if(self.flags & (1 << 8)) {super.from_id = [stream readInt];} + self.to_id = [ClassStore TLDeserialize:stream]; + super.date = [stream readInt]; + self.action = [ClassStore TLDeserialize:stream]; } --(TL_messageActionChatCreate *)copy { +-(TL_messageService *)copy { - TL_messageActionChatCreate *objc = [[TL_messageActionChatCreate alloc] init]; + TL_messageService *objc = [[TL_messageService alloc] init]; - objc.title = self.title; - objc.users = [self.users copy]; + objc.flags = self.flags; + + + + + objc.n_id = self.n_id; + objc.from_id = self.from_id; + objc.to_id = [self.to_id copy]; + objc.date = self.date; + objc.action = [self.action copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -4855,33 +5624,52 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - - + +-(BOOL)isUnread {return (self.flags & (1 << 0)) > 0;} + +-(BOOL)isN_out {return (self.flags & (1 << 1)) > 0;} + +-(BOOL)isMentioned {return (self.flags & (1 << 4)) > 0;} + +-(BOOL)isMedia_unread {return (self.flags & (1 << 5)) > 0;} + +-(void)setFrom_id:(int)from_id +{ + super.from_id = from_id; + + if(super.from_id == 0) { super.flags&= ~ (1 << 8) ;} else { super.flags|= (1 << 8); } +} @end -@implementation TL_messageActionChatEditTitle -+(TL_messageActionChatEditTitle*)createWithTitle:(NSString*)title { - TL_messageActionChatEditTitle* obj = [[TL_messageActionChatEditTitle alloc] init]; - obj.title = title; +@implementation TLMessageMedia + +@end + +@implementation TL_messageMediaEmpty ++(TL_messageMediaEmpty*)create { + TL_messageMediaEmpty* obj = [[TL_messageMediaEmpty alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeString:self.title]; + } -(void)unserialize:(SerializedData*)stream { - self.title = [stream readString]; + } --(TL_messageActionChatEditTitle *)copy { +-(TL_messageMediaEmpty *)copy { + + TL_messageMediaEmpty *objc = [[TL_messageMediaEmpty alloc] init]; - TL_messageActionChatEditTitle *objc = [[TL_messageActionChatEditTitle alloc] init]; - objc.title = self.title; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -4895,33 +5683,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_messageActionChatEditPhoto -+(TL_messageActionChatEditPhoto*)createWithPhoto:(TLPhoto*)photo { - TL_messageActionChatEditPhoto* obj = [[TL_messageActionChatEditPhoto alloc] init]; +@implementation TL_messageMediaPhoto ++(TL_messageMediaPhoto*)createWithPhoto:(TLPhoto*)photo caption:(NSString*)caption { + TL_messageMediaPhoto* obj = [[TL_messageMediaPhoto alloc] init]; obj.photo = photo; + obj.caption = caption; return obj; } -(void)serialize:(SerializedData*)stream { [ClassStore TLSerialize:self.photo stream:stream]; + [stream writeString:self.caption]; } -(void)unserialize:(SerializedData*)stream { self.photo = [ClassStore TLDeserialize:stream]; + super.caption = [stream readString]; } --(TL_messageActionChatEditPhoto *)copy { +-(TL_messageMediaPhoto *)copy { - TL_messageActionChatEditPhoto *objc = [[TL_messageActionChatEditPhoto alloc] init]; + TL_messageMediaPhoto *objc = [[TL_messageMediaPhoto alloc] init]; objc.photo = [self.photo copy]; + objc.caption = self.caption; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -4935,33 +5728,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_messageActionChatDeletePhoto -+(TL_messageActionChatDeletePhoto*)create { - TL_messageActionChatDeletePhoto* obj = [[TL_messageActionChatDeletePhoto alloc] init]; - +@implementation TL_messageMediaVideo ++(TL_messageMediaVideo*)createWithVideo:(TLVideo*)video caption:(NSString*)caption { + TL_messageMediaVideo* obj = [[TL_messageMediaVideo alloc] init]; + obj.video = video; + obj.caption = caption; return obj; } -(void)serialize:(SerializedData*)stream { - + [ClassStore TLSerialize:self.video stream:stream]; + [stream writeString:self.caption]; } -(void)unserialize:(SerializedData*)stream { - + self.video = [ClassStore TLDeserialize:stream]; + super.caption = [stream readString]; } --(TL_messageActionChatDeletePhoto *)copy { - - TL_messageActionChatDeletePhoto *objc = [[TL_messageActionChatDeletePhoto alloc] init]; +-(TL_messageMediaVideo *)copy { + TL_messageMediaVideo *objc = [[TL_messageMediaVideo alloc] init]; + objc.video = [self.video copy]; + objc.caption = self.caption; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -4975,33 +5773,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_messageActionChatAddUser -+(TL_messageActionChatAddUser*)createWithUser_id:(int)user_id { - TL_messageActionChatAddUser* obj = [[TL_messageActionChatAddUser alloc] init]; - obj.user_id = user_id; +@implementation TL_messageMediaGeo ++(TL_messageMediaGeo*)createWithGeo:(TLGeoPoint*)geo { + TL_messageMediaGeo* obj = [[TL_messageMediaGeo alloc] init]; + obj.geo = geo; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.user_id]; + [ClassStore TLSerialize:self.geo stream:stream]; } -(void)unserialize:(SerializedData*)stream { - self.user_id = [stream readInt]; + self.geo = [ClassStore TLDeserialize:stream]; } --(TL_messageActionChatAddUser *)copy { +-(TL_messageMediaGeo *)copy { - TL_messageActionChatAddUser *objc = [[TL_messageActionChatAddUser alloc] init]; + TL_messageMediaGeo *objc = [[TL_messageMediaGeo alloc] init]; - objc.user_id = self.user_id; + objc.geo = [self.geo copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -5015,33 +5814,46 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_messageActionChatDeleteUser -+(TL_messageActionChatDeleteUser*)createWithUser_id:(int)user_id { - TL_messageActionChatDeleteUser* obj = [[TL_messageActionChatDeleteUser alloc] init]; +@implementation TL_messageMediaContact ++(TL_messageMediaContact*)createWithPhone_number:(NSString*)phone_number first_name:(NSString*)first_name last_name:(NSString*)last_name user_id:(int)user_id { + TL_messageMediaContact* obj = [[TL_messageMediaContact alloc] init]; + obj.phone_number = phone_number; + obj.first_name = first_name; + obj.last_name = last_name; obj.user_id = user_id; return obj; } -(void)serialize:(SerializedData*)stream { + [stream writeString:self.phone_number]; + [stream writeString:self.first_name]; + [stream writeString:self.last_name]; [stream writeInt:self.user_id]; } -(void)unserialize:(SerializedData*)stream { - self.user_id = [stream readInt]; + super.phone_number = [stream readString]; + super.first_name = [stream readString]; + super.last_name = [stream readString]; + super.user_id = [stream readInt]; } --(TL_messageActionChatDeleteUser *)copy { +-(TL_messageMediaContact *)copy { - TL_messageActionChatDeleteUser *objc = [[TL_messageActionChatDeleteUser alloc] init]; + TL_messageMediaContact *objc = [[TL_messageMediaContact alloc] init]; + objc.phone_number = self.phone_number; + objc.first_name = self.first_name; + objc.last_name = self.last_name; objc.user_id = self.user_id; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -5055,37 +5867,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_messageActionGeoChatCreate -+(TL_messageActionGeoChatCreate*)createWithTitle:(NSString*)title address:(NSString*)address { - TL_messageActionGeoChatCreate* obj = [[TL_messageActionGeoChatCreate alloc] init]; - obj.title = title; - obj.address = address; +@implementation TL_messageMediaUnsupported ++(TL_messageMediaUnsupported*)create { + TL_messageMediaUnsupported* obj = [[TL_messageMediaUnsupported alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeString:self.title]; - [stream writeString:self.address]; + } -(void)unserialize:(SerializedData*)stream { - self.title = [stream readString]; - self.address = [stream readString]; + } --(TL_messageActionGeoChatCreate *)copy { +-(TL_messageMediaUnsupported *)copy { + + TL_messageMediaUnsupported *objc = [[TL_messageMediaUnsupported alloc] init]; - TL_messageActionGeoChatCreate *objc = [[TL_messageActionGeoChatCreate alloc] init]; - objc.title = self.title; - objc.address = self.address; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -5099,33 +5908,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_messageActionGeoChatCheckin -+(TL_messageActionGeoChatCheckin*)create { - TL_messageActionGeoChatCheckin* obj = [[TL_messageActionGeoChatCheckin alloc] init]; - +@implementation TL_messageMediaDocument ++(TL_messageMediaDocument*)createWithDocument:(TLDocument*)document { + TL_messageMediaDocument* obj = [[TL_messageMediaDocument alloc] init]; + obj.document = document; return obj; } -(void)serialize:(SerializedData*)stream { - + [ClassStore TLSerialize:self.document stream:stream]; } -(void)unserialize:(SerializedData*)stream { - + self.document = [ClassStore TLDeserialize:stream]; } --(TL_messageActionGeoChatCheckin *)copy { - - TL_messageActionGeoChatCheckin *objc = [[TL_messageActionGeoChatCheckin alloc] init]; +-(TL_messageMediaDocument *)copy { + TL_messageMediaDocument *objc = [[TL_messageMediaDocument alloc] init]; + objc.document = [self.document copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -5139,33 +5949,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_messageActionChatJoinedByLink -+(TL_messageActionChatJoinedByLink*)createWithInviter_id:(int)inviter_id { - TL_messageActionChatJoinedByLink* obj = [[TL_messageActionChatJoinedByLink alloc] init]; - obj.inviter_id = inviter_id; +@implementation TL_messageMediaAudio ++(TL_messageMediaAudio*)createWithAudio:(TLAudio*)audio { + TL_messageMediaAudio* obj = [[TL_messageMediaAudio alloc] init]; + obj.audio = audio; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.inviter_id]; + [ClassStore TLSerialize:self.audio stream:stream]; } -(void)unserialize:(SerializedData*)stream { - self.inviter_id = [stream readInt]; + self.audio = [ClassStore TLDeserialize:stream]; } --(TL_messageActionChatJoinedByLink *)copy { +-(TL_messageMediaAudio *)copy { - TL_messageActionChatJoinedByLink *objc = [[TL_messageActionChatJoinedByLink alloc] init]; + TL_messageMediaAudio *objc = [[TL_messageMediaAudio alloc] init]; - objc.inviter_id = self.inviter_id; + objc.audio = [self.audio copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -5179,53 +5990,91 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TL_messageMediaWebPage ++(TL_messageMediaWebPage*)createWithWebpage:(TLWebPage*)webpage { + TL_messageMediaWebPage* obj = [[TL_messageMediaWebPage alloc] init]; + obj.webpage = webpage; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [ClassStore TLSerialize:self.webpage stream:stream]; +} +-(void)unserialize:(SerializedData*)stream { + self.webpage = [ClassStore TLDeserialize:stream]; +} + +-(TL_messageMediaWebPage *)copy { + + TL_messageMediaWebPage *objc = [[TL_messageMediaWebPage alloc] init]; + + objc.webpage = [self.webpage copy]; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { -@implementation TLDialog + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + @end -@implementation TL_dialog -+(TL_dialog*)createWithPeer:(TLPeer*)peer top_message:(int)top_message read_inbox_max_id:(int)read_inbox_max_id unread_count:(int)unread_count notify_settings:(TLPeerNotifySettings*)notify_settings { - TL_dialog* obj = [[TL_dialog alloc] init]; - obj.peer = peer; - obj.top_message = top_message; - obj.read_inbox_max_id = read_inbox_max_id; - obj.unread_count = unread_count; - obj.notify_settings = notify_settings; +@implementation TL_messageMediaVenue ++(TL_messageMediaVenue*)createWithGeo:(TLGeoPoint*)geo title:(NSString*)title address:(NSString*)address provider:(NSString*)provider venue_id:(NSString*)venue_id { + TL_messageMediaVenue* obj = [[TL_messageMediaVenue alloc] init]; + obj.geo = geo; + obj.title = title; + obj.address = address; + obj.provider = provider; + obj.venue_id = venue_id; return obj; } -(void)serialize:(SerializedData*)stream { - [ClassStore TLSerialize:self.peer stream:stream]; - [stream writeInt:self.top_message]; - [stream writeInt:self.read_inbox_max_id]; - [stream writeInt:self.unread_count]; - [ClassStore TLSerialize:self.notify_settings stream:stream]; + [ClassStore TLSerialize:self.geo stream:stream]; + [stream writeString:self.title]; + [stream writeString:self.address]; + [stream writeString:self.provider]; + [stream writeString:self.venue_id]; } -(void)unserialize:(SerializedData*)stream { - self.peer = [ClassStore TLDeserialize:stream]; - self.top_message = [stream readInt]; - self.read_inbox_max_id = [stream readInt]; - self.unread_count = [stream readInt]; - self.notify_settings = [ClassStore TLDeserialize:stream]; + self.geo = [ClassStore TLDeserialize:stream]; + super.title = [stream readString]; + super.address = [stream readString]; + super.provider = [stream readString]; + super.venue_id = [stream readString]; } --(TL_dialog *)copy { +-(TL_messageMediaVenue *)copy { - TL_dialog *objc = [[TL_dialog alloc] init]; + TL_messageMediaVenue *objc = [[TL_messageMediaVenue alloc] init]; - objc.peer = [self.peer copy]; - objc.top_message = self.top_message; - objc.read_inbox_max_id = self.read_inbox_max_id; - objc.unread_count = self.unread_count; - objc.notify_settings = [self.notify_settings copy]; + objc.geo = [self.geo copy]; + objc.title = self.title; + objc.address = self.address; + objc.provider = self.provider; + objc.venue_id = self.venue_id; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -5239,37 +6088,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TLMessageAction -@implementation TLPhoto @end - -@implementation TL_photoEmpty -+(TL_photoEmpty*)createWithN_id:(long)n_id { - TL_photoEmpty* obj = [[TL_photoEmpty alloc] init]; - obj.n_id = n_id; + +@implementation TL_messageActionEmpty ++(TL_messageActionEmpty*)create { + TL_messageActionEmpty* obj = [[TL_messageActionEmpty alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeLong:self.n_id]; + } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readLong]; + } --(TL_photoEmpty *)copy { +-(TL_messageActionEmpty *)copy { + + TL_messageActionEmpty *objc = [[TL_messageActionEmpty alloc] init]; - TL_photoEmpty *objc = [[TL_photoEmpty alloc] init]; - objc.n_id = self.n_id; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -5283,75 +6133,60 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_photo -+(TL_photo*)createWithN_id:(long)n_id access_hash:(long)access_hash user_id:(int)user_id date:(int)date geo:(TLGeoPoint*)geo sizes:(NSMutableArray*)sizes { - TL_photo* obj = [[TL_photo alloc] init]; - obj.n_id = n_id; - obj.access_hash = access_hash; - obj.user_id = user_id; - obj.date = date; - obj.geo = geo; - obj.sizes = sizes; +@implementation TL_messageActionChatCreate ++(TL_messageActionChatCreate*)createWithTitle:(NSString*)title users:(NSMutableArray*)users { + TL_messageActionChatCreate* obj = [[TL_messageActionChatCreate alloc] init]; + obj.title = title; + obj.users = users; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeLong:self.n_id]; - [stream writeLong:self.access_hash]; - [stream writeInt:self.user_id]; - [stream writeInt:self.date]; - [ClassStore TLSerialize:self.geo stream:stream]; - //Serialize FullVector + [stream writeString:self.title]; + //Serialize ShortVector [stream writeInt:0x1cb5c415]; { - NSInteger tl_count = [self.sizes count]; + NSInteger tl_count = [self.users count]; [stream writeInt:(int)tl_count]; for(int i = 0; i < (int)tl_count; i++) { - TLPhotoSize* obj = [self.sizes objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; + if([self.users count] > i) { + NSNumber* obj = [self.users objectAtIndex:i]; + [stream writeInt:[obj intValue]]; + } else + break; } } } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readLong]; - self.access_hash = [stream readLong]; - self.user_id = [stream readInt]; - self.date = [stream readInt]; - self.geo = [ClassStore TLDeserialize:stream]; - //UNS FullVector + super.title = [stream readString]; + //UNS ShortVector [stream readInt]; { - if(!self.sizes) - self.sizes = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLPhotoSize* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLPhotoSize class]]) - [self.sizes addObject:obj]; - else - break; + if(!self.users) + self.users = [[NSMutableArray alloc] init]; + int tl_count = [stream readInt]; + for(int i = 0; i < tl_count; i++) { + int obj = [stream readInt]; + [self.users addObject:@(obj)]; } } } --(TL_photo *)copy { +-(TL_messageActionChatCreate *)copy { - TL_photo *objc = [[TL_photo alloc] init]; + TL_messageActionChatCreate *objc = [[TL_messageActionChatCreate alloc] init]; - objc.n_id = self.n_id; - objc.access_hash = self.access_hash; - objc.user_id = self.user_id; - objc.date = self.date; - objc.geo = [self.geo copy]; - objc.sizes = [self.sizes copy]; + objc.title = self.title; + objc.users = [self.users copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -5365,37 +6200,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLPhotoSize -@end - -@implementation TL_photoSizeEmpty -+(TL_photoSizeEmpty*)createWithType:(NSString*)type { - TL_photoSizeEmpty* obj = [[TL_photoSizeEmpty alloc] init]; - obj.type = type; +@implementation TL_messageActionChatEditTitle ++(TL_messageActionChatEditTitle*)createWithTitle:(NSString*)title { + TL_messageActionChatEditTitle* obj = [[TL_messageActionChatEditTitle alloc] init]; + obj.title = title; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeString:self.type]; + [stream writeString:self.title]; } -(void)unserialize:(SerializedData*)stream { - self.type = [stream readString]; + super.title = [stream readString]; } --(TL_photoSizeEmpty *)copy { +-(TL_messageActionChatEditTitle *)copy { - TL_photoSizeEmpty *objc = [[TL_photoSizeEmpty alloc] init]; + TL_messageActionChatEditTitle *objc = [[TL_messageActionChatEditTitle alloc] init]; - objc.type = self.type; + objc.title = self.title; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -5409,49 +6241,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_photoSize -+(TL_photoSize*)createWithType:(NSString*)type location:(TLFileLocation*)location w:(int)w h:(int)h size:(int)size { - TL_photoSize* obj = [[TL_photoSize alloc] init]; - obj.type = type; - obj.location = location; - obj.w = w; - obj.h = h; - obj.size = size; +@implementation TL_messageActionChatEditPhoto ++(TL_messageActionChatEditPhoto*)createWithPhoto:(TLPhoto*)photo { + TL_messageActionChatEditPhoto* obj = [[TL_messageActionChatEditPhoto alloc] init]; + obj.photo = photo; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeString:self.type]; - [ClassStore TLSerialize:self.location stream:stream]; - [stream writeInt:self.w]; - [stream writeInt:self.h]; - [stream writeInt:self.size]; + [ClassStore TLSerialize:self.photo stream:stream]; } -(void)unserialize:(SerializedData*)stream { - self.type = [stream readString]; - self.location = [ClassStore TLDeserialize:stream]; - self.w = [stream readInt]; - self.h = [stream readInt]; - self.size = [stream readInt]; + self.photo = [ClassStore TLDeserialize:stream]; } --(TL_photoSize *)copy { +-(TL_messageActionChatEditPhoto *)copy { - TL_photoSize *objc = [[TL_photoSize alloc] init]; + TL_messageActionChatEditPhoto *objc = [[TL_messageActionChatEditPhoto alloc] init]; - objc.type = self.type; - objc.location = [self.location copy]; - objc.w = self.w; - objc.h = self.h; - objc.size = self.size; + objc.photo = [self.photo copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -5465,49 +6282,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_photoCachedSize -+(TL_photoCachedSize*)createWithType:(NSString*)type location:(TLFileLocation*)location w:(int)w h:(int)h bytes:(NSData*)bytes { - TL_photoCachedSize* obj = [[TL_photoCachedSize alloc] init]; - obj.type = type; - obj.location = location; - obj.w = w; - obj.h = h; - obj.bytes = bytes; +@implementation TL_messageActionChatDeletePhoto ++(TL_messageActionChatDeletePhoto*)create { + TL_messageActionChatDeletePhoto* obj = [[TL_messageActionChatDeletePhoto alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeString:self.type]; - [ClassStore TLSerialize:self.location stream:stream]; - [stream writeInt:self.w]; - [stream writeInt:self.h]; - [stream writeByteArray:self.bytes]; + } -(void)unserialize:(SerializedData*)stream { - self.type = [stream readString]; - self.location = [ClassStore TLDeserialize:stream]; - self.w = [stream readInt]; - self.h = [stream readInt]; - self.bytes = [stream readByteArray]; + } --(TL_photoCachedSize *)copy { +-(TL_messageActionChatDeletePhoto *)copy { + + TL_messageActionChatDeletePhoto *objc = [[TL_messageActionChatDeletePhoto alloc] init]; - TL_photoCachedSize *objc = [[TL_photoCachedSize alloc] init]; - objc.type = self.type; - objc.location = [self.location copy]; - objc.w = self.w; - objc.h = self.h; - objc.bytes = [self.bytes copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -5521,37 +6323,56 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLVideo -@end - -@implementation TL_videoEmpty -+(TL_videoEmpty*)createWithN_id:(long)n_id { - TL_videoEmpty* obj = [[TL_videoEmpty alloc] init]; - obj.n_id = n_id; +@implementation TL_messageActionChatAddUser ++(TL_messageActionChatAddUser*)createWithUsers:(NSMutableArray*)users { + TL_messageActionChatAddUser* obj = [[TL_messageActionChatAddUser alloc] init]; + obj.users = users; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeLong:self.n_id]; + //Serialize ShortVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.users count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + if([self.users count] > i) { + NSNumber* obj = [self.users objectAtIndex:i]; + [stream writeInt:[obj intValue]]; + } else + break; + } + } } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readLong]; + //UNS ShortVector + [stream readInt]; + { + if(!self.users) + self.users = [[NSMutableArray alloc] init]; + int tl_count = [stream readInt]; + for(int i = 0; i < tl_count; i++) { + int obj = [stream readInt]; + [self.users addObject:@(obj)]; + } + } } --(TL_videoEmpty *)copy { +-(TL_messageActionChatAddUser *)copy { - TL_videoEmpty *objc = [[TL_videoEmpty alloc] init]; + TL_messageActionChatAddUser *objc = [[TL_messageActionChatAddUser alloc] init]; - objc.n_id = self.n_id; + objc.users = [self.users copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -5565,69 +6386,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_video -+(TL_video*)createWithN_id:(long)n_id access_hash:(long)access_hash user_id:(int)user_id date:(int)date duration:(int)duration size:(int)size thumb:(TLPhotoSize*)thumb dc_id:(int)dc_id w:(int)w h:(int)h { - TL_video* obj = [[TL_video alloc] init]; - obj.n_id = n_id; - obj.access_hash = access_hash; +@implementation TL_messageActionChatDeleteUser ++(TL_messageActionChatDeleteUser*)createWithUser_id:(int)user_id { + TL_messageActionChatDeleteUser* obj = [[TL_messageActionChatDeleteUser alloc] init]; obj.user_id = user_id; - obj.date = date; - obj.duration = duration; - obj.size = size; - obj.thumb = thumb; - obj.dc_id = dc_id; - obj.w = w; - obj.h = h; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeLong:self.n_id]; - [stream writeLong:self.access_hash]; [stream writeInt:self.user_id]; - [stream writeInt:self.date]; - [stream writeInt:self.duration]; - [stream writeInt:self.size]; - [ClassStore TLSerialize:self.thumb stream:stream]; - [stream writeInt:self.dc_id]; - [stream writeInt:self.w]; - [stream writeInt:self.h]; } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readLong]; - self.access_hash = [stream readLong]; - self.user_id = [stream readInt]; - self.date = [stream readInt]; - self.duration = [stream readInt]; - self.size = [stream readInt]; - self.thumb = [ClassStore TLDeserialize:stream]; - self.dc_id = [stream readInt]; - self.w = [stream readInt]; - self.h = [stream readInt]; + super.user_id = [stream readInt]; } --(TL_video *)copy { +-(TL_messageActionChatDeleteUser *)copy { - TL_video *objc = [[TL_video alloc] init]; + TL_messageActionChatDeleteUser *objc = [[TL_messageActionChatDeleteUser alloc] init]; - objc.n_id = self.n_id; - objc.access_hash = self.access_hash; objc.user_id = self.user_id; - objc.date = self.date; - objc.duration = self.duration; - objc.size = self.size; - objc.thumb = [self.thumb copy]; - objc.dc_id = self.dc_id; - objc.w = self.w; - objc.h = self.h; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -5641,37 +6427,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLGeoPoint -@end - -@implementation TL_geoPointEmpty -+(TL_geoPointEmpty*)create { - TL_geoPointEmpty* obj = [[TL_geoPointEmpty alloc] init]; - +@implementation TL_messageActionChatJoinedByLink ++(TL_messageActionChatJoinedByLink*)createWithInviter_id:(int)inviter_id { + TL_messageActionChatJoinedByLink* obj = [[TL_messageActionChatJoinedByLink alloc] init]; + obj.inviter_id = inviter_id; return obj; } -(void)serialize:(SerializedData*)stream { - + [stream writeInt:self.inviter_id]; } -(void)unserialize:(SerializedData*)stream { - + super.inviter_id = [stream readInt]; } --(TL_geoPointEmpty *)copy { - - TL_geoPointEmpty *objc = [[TL_geoPointEmpty alloc] init]; +-(TL_messageActionChatJoinedByLink *)copy { + TL_messageActionChatJoinedByLink *objc = [[TL_messageActionChatJoinedByLink alloc] init]; + objc.inviter_id = self.inviter_id; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -5685,37 +6468,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_geoPoint -+(TL_geoPoint*)createWithN_long:(double)n_long lat:(double)lat { - TL_geoPoint* obj = [[TL_geoPoint alloc] init]; - obj.n_long = n_long; - obj.lat = lat; +@implementation TL_messageActionChannelCreate ++(TL_messageActionChannelCreate*)createWithTitle:(NSString*)title { + TL_messageActionChannelCreate* obj = [[TL_messageActionChannelCreate alloc] init]; + obj.title = title; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeDouble:self.n_long]; - [stream writeDouble:self.lat]; + [stream writeString:self.title]; } -(void)unserialize:(SerializedData*)stream { - self.n_long = [stream readDouble]; - self.lat = [stream readDouble]; + super.title = [stream readString]; } --(TL_geoPoint *)copy { +-(TL_messageActionChannelCreate *)copy { - TL_geoPoint *objc = [[TL_geoPoint alloc] init]; + TL_messageActionChannelCreate *objc = [[TL_messageActionChannelCreate alloc] init]; - objc.n_long = self.n_long; - objc.lat = self.lat; + objc.title = self.title; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -5729,37 +6509,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLauth_CheckedPhone -@end - -@implementation TL_auth_checkedPhone -+(TL_auth_checkedPhone*)createWithPhone_registered:(Boolean)phone_registered { - TL_auth_checkedPhone* obj = [[TL_auth_checkedPhone alloc] init]; - obj.phone_registered = phone_registered; +@implementation TL_messageActionChatMigrateTo ++(TL_messageActionChatMigrateTo*)createWithChannel_id:(int)channel_id { + TL_messageActionChatMigrateTo* obj = [[TL_messageActionChatMigrateTo alloc] init]; + obj.channel_id = channel_id; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeBool:self.phone_registered]; + [stream writeInt:self.channel_id]; } -(void)unserialize:(SerializedData*)stream { - self.phone_registered = [stream readBool]; + super.channel_id = [stream readInt]; } --(TL_auth_checkedPhone *)copy { +-(TL_messageActionChatMigrateTo *)copy { - TL_auth_checkedPhone *objc = [[TL_auth_checkedPhone alloc] init]; + TL_messageActionChatMigrateTo *objc = [[TL_messageActionChatMigrateTo alloc] init]; - objc.phone_registered = self.phone_registered; + objc.channel_id = self.channel_id; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -5773,49 +6550,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLauth_SentCode -@end - -@implementation TL_auth_sentCode -+(TL_auth_sentCode*)createWithPhone_registered:(Boolean)phone_registered phone_code_hash:(NSString*)phone_code_hash send_call_timeout:(int)send_call_timeout is_password:(Boolean)is_password { - TL_auth_sentCode* obj = [[TL_auth_sentCode alloc] init]; - obj.phone_registered = phone_registered; - obj.phone_code_hash = phone_code_hash; - obj.send_call_timeout = send_call_timeout; - obj.is_password = is_password; +@implementation TL_messageActionChannelMigrateFrom ++(TL_messageActionChannelMigrateFrom*)createWithTitle:(NSString*)title chat_id:(int)chat_id { + TL_messageActionChannelMigrateFrom* obj = [[TL_messageActionChannelMigrateFrom alloc] init]; + obj.title = title; + obj.chat_id = chat_id; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeBool:self.phone_registered]; - [stream writeString:self.phone_code_hash]; - [stream writeInt:self.send_call_timeout]; - [stream writeBool:self.is_password]; + [stream writeString:self.title]; + [stream writeInt:self.chat_id]; } -(void)unserialize:(SerializedData*)stream { - self.phone_registered = [stream readBool]; - self.phone_code_hash = [stream readString]; - self.send_call_timeout = [stream readInt]; - self.is_password = [stream readBool]; + super.title = [stream readString]; + super.chat_id = [stream readInt]; } --(TL_auth_sentCode *)copy { +-(TL_messageActionChannelMigrateFrom *)copy { - TL_auth_sentCode *objc = [[TL_auth_sentCode alloc] init]; + TL_messageActionChannelMigrateFrom *objc = [[TL_messageActionChannelMigrateFrom alloc] init]; - objc.phone_registered = self.phone_registered; - objc.phone_code_hash = self.phone_code_hash; - objc.send_call_timeout = self.send_call_timeout; - objc.is_password = self.is_password; + objc.title = self.title; + objc.chat_id = self.chat_id; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -5829,45 +6595,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_auth_sentAppCode -+(TL_auth_sentAppCode*)createWithPhone_registered:(Boolean)phone_registered phone_code_hash:(NSString*)phone_code_hash send_call_timeout:(int)send_call_timeout is_password:(Boolean)is_password { - TL_auth_sentAppCode* obj = [[TL_auth_sentAppCode alloc] init]; - obj.phone_registered = phone_registered; - obj.phone_code_hash = phone_code_hash; - obj.send_call_timeout = send_call_timeout; - obj.is_password = is_password; +@implementation TL_messageActionChatAddUser_old40 ++(TL_messageActionChatAddUser_old40*)createWithUser_id:(int)user_id { + TL_messageActionChatAddUser_old40* obj = [[TL_messageActionChatAddUser_old40 alloc] init]; + obj.user_id = user_id; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeBool:self.phone_registered]; - [stream writeString:self.phone_code_hash]; - [stream writeInt:self.send_call_timeout]; - [stream writeBool:self.is_password]; + [stream writeInt:self.user_id]; } -(void)unserialize:(SerializedData*)stream { - self.phone_registered = [stream readBool]; - self.phone_code_hash = [stream readString]; - self.send_call_timeout = [stream readInt]; - self.is_password = [stream readBool]; + super.user_id = [stream readInt]; } --(TL_auth_sentAppCode *)copy { +-(TL_messageActionChatAddUser_old40 *)copy { - TL_auth_sentAppCode *objc = [[TL_auth_sentAppCode alloc] init]; + TL_messageActionChatAddUser_old40 *objc = [[TL_messageActionChatAddUser_old40 alloc] init]; - objc.phone_registered = self.phone_registered; - objc.phone_code_hash = self.phone_code_hash; - objc.send_call_timeout = self.send_call_timeout; - objc.is_password = self.is_password; + objc.user_id = self.user_id; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -5881,37 +6636,54 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TLDialog -@implementation TLauth_Authorization @end - -@implementation TL_auth_authorization -+(TL_auth_authorization*)createWithUser:(TLUser*)user { - TL_auth_authorization* obj = [[TL_auth_authorization alloc] init]; - obj.user = user; + +@implementation TL_dialog ++(TL_dialog*)createWithPeer:(TLPeer*)peer top_message:(int)top_message read_inbox_max_id:(int)read_inbox_max_id unread_count:(int)unread_count notify_settings:(TLPeerNotifySettings*)notify_settings { + TL_dialog* obj = [[TL_dialog alloc] init]; + obj.peer = peer; + obj.top_message = top_message; + obj.read_inbox_max_id = read_inbox_max_id; + obj.unread_count = unread_count; + obj.notify_settings = notify_settings; return obj; } -(void)serialize:(SerializedData*)stream { - [ClassStore TLSerialize:self.user stream:stream]; + [ClassStore TLSerialize:self.peer stream:stream]; + [stream writeInt:self.top_message]; + [stream writeInt:self.read_inbox_max_id]; + [stream writeInt:self.unread_count]; + [ClassStore TLSerialize:self.notify_settings stream:stream]; } -(void)unserialize:(SerializedData*)stream { - self.user = [ClassStore TLDeserialize:stream]; + self.peer = [ClassStore TLDeserialize:stream]; + super.top_message = [stream readInt]; + super.read_inbox_max_id = [stream readInt]; + super.unread_count = [stream readInt]; + self.notify_settings = [ClassStore TLDeserialize:stream]; } --(TL_auth_authorization *)copy { +-(TL_dialog *)copy { - TL_auth_authorization *objc = [[TL_auth_authorization alloc] init]; + TL_dialog *objc = [[TL_dialog alloc] init]; - objc.user = [self.user copy]; + objc.peer = [self.peer copy]; + objc.top_message = self.top_message; + objc.read_inbox_max_id = self.read_inbox_max_id; + objc.unread_count = self.unread_count; + objc.notify_settings = [self.notify_settings copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -5925,41 +6697,62 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLauth_ExportedAuthorization -@end - -@implementation TL_auth_exportedAuthorization -+(TL_auth_exportedAuthorization*)createWithN_id:(int)n_id bytes:(NSData*)bytes { - TL_auth_exportedAuthorization* obj = [[TL_auth_exportedAuthorization alloc] init]; - obj.n_id = n_id; - obj.bytes = bytes; +@implementation TL_dialogChannel ++(TL_dialogChannel*)createWithPeer:(TLPeer*)peer top_message:(int)top_message top_important_message:(int)top_important_message read_inbox_max_id:(int)read_inbox_max_id unread_count:(int)unread_count unread_important_count:(int)unread_important_count notify_settings:(TLPeerNotifySettings*)notify_settings pts:(int)pts { + TL_dialogChannel* obj = [[TL_dialogChannel alloc] init]; + obj.peer = peer; + obj.top_message = top_message; + obj.top_important_message = top_important_message; + obj.read_inbox_max_id = read_inbox_max_id; + obj.unread_count = unread_count; + obj.unread_important_count = unread_important_count; + obj.notify_settings = notify_settings; + obj.pts = pts; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.n_id]; - [stream writeByteArray:self.bytes]; + [ClassStore TLSerialize:self.peer stream:stream]; + [stream writeInt:self.top_message]; + [stream writeInt:self.top_important_message]; + [stream writeInt:self.read_inbox_max_id]; + [stream writeInt:self.unread_count]; + [stream writeInt:self.unread_important_count]; + [ClassStore TLSerialize:self.notify_settings stream:stream]; + [stream writeInt:self.pts]; } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readInt]; - self.bytes = [stream readByteArray]; + self.peer = [ClassStore TLDeserialize:stream]; + super.top_message = [stream readInt]; + super.top_important_message = [stream readInt]; + super.read_inbox_max_id = [stream readInt]; + super.unread_count = [stream readInt]; + super.unread_important_count = [stream readInt]; + self.notify_settings = [ClassStore TLDeserialize:stream]; + super.pts = [stream readInt]; } --(TL_auth_exportedAuthorization *)copy { +-(TL_dialogChannel *)copy { - TL_auth_exportedAuthorization *objc = [[TL_auth_exportedAuthorization alloc] init]; + TL_dialogChannel *objc = [[TL_dialogChannel alloc] init]; - objc.n_id = self.n_id; - objc.bytes = [self.bytes copy]; + objc.peer = [self.peer copy]; + objc.top_message = self.top_message; + objc.top_important_message = self.top_important_message; + objc.read_inbox_max_id = self.read_inbox_max_id; + objc.unread_count = self.unread_count; + objc.unread_important_count = self.unread_important_count; + objc.notify_settings = [self.notify_settings copy]; + objc.pts = self.pts; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -5973,37 +6766,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TLPhoto -@implementation TLInputNotifyPeer @end - -@implementation TL_inputNotifyPeer -+(TL_inputNotifyPeer*)createWithPeer:(TLInputPeer*)peer { - TL_inputNotifyPeer* obj = [[TL_inputNotifyPeer alloc] init]; - obj.peer = peer; + +@implementation TL_photoEmpty ++(TL_photoEmpty*)createWithN_id:(long)n_id { + TL_photoEmpty* obj = [[TL_photoEmpty alloc] init]; + obj.n_id = n_id; return obj; } -(void)serialize:(SerializedData*)stream { - [ClassStore TLSerialize:self.peer stream:stream]; + [stream writeLong:self.n_id]; } -(void)unserialize:(SerializedData*)stream { - self.peer = [ClassStore TLDeserialize:stream]; + super.n_id = [stream readLong]; } --(TL_inputNotifyPeer *)copy { +-(TL_photoEmpty *)copy { - TL_inputNotifyPeer *objc = [[TL_inputNotifyPeer alloc] init]; + TL_photoEmpty *objc = [[TL_photoEmpty alloc] init]; - objc.peer = [self.peer copy]; + objc.n_id = self.n_id; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -6017,33 +6811,68 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_inputNotifyUsers -+(TL_inputNotifyUsers*)create { - TL_inputNotifyUsers* obj = [[TL_inputNotifyUsers alloc] init]; - +@implementation TL_photo ++(TL_photo*)createWithN_id:(long)n_id access_hash:(long)access_hash date:(int)date sizes:(NSMutableArray*)sizes { + TL_photo* obj = [[TL_photo alloc] init]; + obj.n_id = n_id; + obj.access_hash = access_hash; + obj.date = date; + obj.sizes = sizes; return obj; } -(void)serialize:(SerializedData*)stream { - + [stream writeLong:self.n_id]; + [stream writeLong:self.access_hash]; + [stream writeInt:self.date]; + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.sizes count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLPhotoSize* obj = [self.sizes objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } } -(void)unserialize:(SerializedData*)stream { - + super.n_id = [stream readLong]; + super.access_hash = [stream readLong]; + super.date = [stream readInt]; + //UNS FullVector + [stream readInt]; + { + if(!self.sizes) + self.sizes = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLPhotoSize* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLPhotoSize class]]) + [self.sizes addObject:obj]; + else + break; + } + } } --(TL_inputNotifyUsers *)copy { - - TL_inputNotifyUsers *objc = [[TL_inputNotifyUsers alloc] init]; +-(TL_photo *)copy { + TL_photo *objc = [[TL_photo alloc] init]; + objc.n_id = self.n_id; + objc.access_hash = self.access_hash; + objc.date = self.date; + objc.sizes = [self.sizes copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -6057,33 +6886,76 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_inputNotifyChats -+(TL_inputNotifyChats*)create { - TL_inputNotifyChats* obj = [[TL_inputNotifyChats alloc] init]; - +@implementation TL_photo_old31 ++(TL_photo_old31*)createWithN_id:(long)n_id access_hash:(long)access_hash user_id:(int)user_id date:(int)date geo:(TLGeoPoint*)geo sizes:(NSMutableArray*)sizes { + TL_photo_old31* obj = [[TL_photo_old31 alloc] init]; + obj.n_id = n_id; + obj.access_hash = access_hash; + obj.user_id = user_id; + obj.date = date; + obj.geo = geo; + obj.sizes = sizes; return obj; } -(void)serialize:(SerializedData*)stream { - + [stream writeLong:self.n_id]; + [stream writeLong:self.access_hash]; + [stream writeInt:self.user_id]; + [stream writeInt:self.date]; + [ClassStore TLSerialize:self.geo stream:stream]; + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.sizes count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLPhotoSize* obj = [self.sizes objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } } -(void)unserialize:(SerializedData*)stream { - + super.n_id = [stream readLong]; + super.access_hash = [stream readLong]; + super.user_id = [stream readInt]; + super.date = [stream readInt]; + self.geo = [ClassStore TLDeserialize:stream]; + //UNS FullVector + [stream readInt]; + { + if(!self.sizes) + self.sizes = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLPhotoSize* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLPhotoSize class]]) + [self.sizes addObject:obj]; + else + break; + } + } } --(TL_inputNotifyChats *)copy { - - TL_inputNotifyChats *objc = [[TL_inputNotifyChats alloc] init]; +-(TL_photo_old31 *)copy { + TL_photo_old31 *objc = [[TL_photo_old31 alloc] init]; + objc.n_id = self.n_id; + objc.access_hash = self.access_hash; + objc.user_id = self.user_id; + objc.date = self.date; + objc.geo = [self.geo copy]; + objc.sizes = [self.sizes copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -6097,33 +6969,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_inputNotifyAll -+(TL_inputNotifyAll*)create { - TL_inputNotifyAll* obj = [[TL_inputNotifyAll alloc] init]; - +@implementation TLPhotoSize + +@end + +@implementation TL_photoSizeEmpty ++(TL_photoSizeEmpty*)createWithType:(NSString*)type { + TL_photoSizeEmpty* obj = [[TL_photoSizeEmpty alloc] init]; + obj.type = type; return obj; } -(void)serialize:(SerializedData*)stream { - + [stream writeString:self.type]; } -(void)unserialize:(SerializedData*)stream { - + super.type = [stream readString]; } --(TL_inputNotifyAll *)copy { - - TL_inputNotifyAll *objc = [[TL_inputNotifyAll alloc] init]; +-(TL_photoSizeEmpty *)copy { + TL_photoSizeEmpty *objc = [[TL_photoSizeEmpty alloc] init]; + objc.type = self.type; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -6137,33 +7014,50 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_inputNotifyGeoChatPeer -+(TL_inputNotifyGeoChatPeer*)createWithPeer:(TLInputGeoChat*)peer { - TL_inputNotifyGeoChatPeer* obj = [[TL_inputNotifyGeoChatPeer alloc] init]; - obj.peer = peer; +@implementation TL_photoSize ++(TL_photoSize*)createWithType:(NSString*)type location:(TLFileLocation*)location w:(int)w h:(int)h size:(int)size { + TL_photoSize* obj = [[TL_photoSize alloc] init]; + obj.type = type; + obj.location = location; + obj.w = w; + obj.h = h; + obj.size = size; return obj; } -(void)serialize:(SerializedData*)stream { - [ClassStore TLSerialize:self.peer stream:stream]; + [stream writeString:self.type]; + [ClassStore TLSerialize:self.location stream:stream]; + [stream writeInt:self.w]; + [stream writeInt:self.h]; + [stream writeInt:self.size]; } -(void)unserialize:(SerializedData*)stream { - self.peer = [ClassStore TLDeserialize:stream]; + super.type = [stream readString]; + self.location = [ClassStore TLDeserialize:stream]; + super.w = [stream readInt]; + super.h = [stream readInt]; + super.size = [stream readInt]; } --(TL_inputNotifyGeoChatPeer *)copy { +-(TL_photoSize *)copy { - TL_inputNotifyGeoChatPeer *objc = [[TL_inputNotifyGeoChatPeer alloc] init]; + TL_photoSize *objc = [[TL_photoSize alloc] init]; - objc.peer = [self.peer copy]; + objc.type = self.type; + objc.location = [self.location copy]; + objc.w = self.w; + objc.h = self.h; + objc.size = self.size; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -6177,37 +7071,50 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLInputPeerNotifyEvents -@end - -@implementation TL_inputPeerNotifyEventsEmpty -+(TL_inputPeerNotifyEventsEmpty*)create { - TL_inputPeerNotifyEventsEmpty* obj = [[TL_inputPeerNotifyEventsEmpty alloc] init]; - +@implementation TL_photoCachedSize ++(TL_photoCachedSize*)createWithType:(NSString*)type location:(TLFileLocation*)location w:(int)w h:(int)h bytes:(NSData*)bytes { + TL_photoCachedSize* obj = [[TL_photoCachedSize alloc] init]; + obj.type = type; + obj.location = location; + obj.w = w; + obj.h = h; + obj.bytes = bytes; return obj; } -(void)serialize:(SerializedData*)stream { - + [stream writeString:self.type]; + [ClassStore TLSerialize:self.location stream:stream]; + [stream writeInt:self.w]; + [stream writeInt:self.h]; + [stream writeByteArray:self.bytes]; } -(void)unserialize:(SerializedData*)stream { - + super.type = [stream readString]; + self.location = [ClassStore TLDeserialize:stream]; + super.w = [stream readInt]; + super.h = [stream readInt]; + super.bytes = [stream readByteArray]; } --(TL_inputPeerNotifyEventsEmpty *)copy { - - TL_inputPeerNotifyEventsEmpty *objc = [[TL_inputPeerNotifyEventsEmpty alloc] init]; +-(TL_photoCachedSize *)copy { + TL_photoCachedSize *objc = [[TL_photoCachedSize alloc] init]; + objc.type = self.type; + objc.location = [self.location copy]; + objc.w = self.w; + objc.h = self.h; + objc.bytes = [self.bytes copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -6221,33 +7128,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_inputPeerNotifyEventsAll -+(TL_inputPeerNotifyEventsAll*)create { - TL_inputPeerNotifyEventsAll* obj = [[TL_inputPeerNotifyEventsAll alloc] init]; - +@implementation TLVideo + +@end + +@implementation TL_videoEmpty ++(TL_videoEmpty*)createWithN_id:(long)n_id { + TL_videoEmpty* obj = [[TL_videoEmpty alloc] init]; + obj.n_id = n_id; return obj; } -(void)serialize:(SerializedData*)stream { - + [stream writeLong:self.n_id]; } -(void)unserialize:(SerializedData*)stream { - + super.n_id = [stream readLong]; } --(TL_inputPeerNotifyEventsAll *)copy { - - TL_inputPeerNotifyEventsAll *objc = [[TL_inputPeerNotifyEventsAll alloc] init]; +-(TL_videoEmpty *)copy { + TL_videoEmpty *objc = [[TL_videoEmpty alloc] init]; + objc.n_id = self.n_id; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -6261,49 +7173,70 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLInputPeerNotifySettings -@end - -@implementation TL_inputPeerNotifySettings -+(TL_inputPeerNotifySettings*)createWithMute_until:(int)mute_until sound:(NSString*)sound show_previews:(Boolean)show_previews events_mask:(int)events_mask { - TL_inputPeerNotifySettings* obj = [[TL_inputPeerNotifySettings alloc] init]; - obj.mute_until = mute_until; - obj.sound = sound; - obj.show_previews = show_previews; - obj.events_mask = events_mask; +@implementation TL_video ++(TL_video*)createWithN_id:(long)n_id access_hash:(long)access_hash date:(int)date duration:(int)duration mime_type:(NSString*)mime_type size:(int)size thumb:(TLPhotoSize*)thumb dc_id:(int)dc_id w:(int)w h:(int)h { + TL_video* obj = [[TL_video alloc] init]; + obj.n_id = n_id; + obj.access_hash = access_hash; + obj.date = date; + obj.duration = duration; + obj.mime_type = mime_type; + obj.size = size; + obj.thumb = thumb; + obj.dc_id = dc_id; + obj.w = w; + obj.h = h; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.mute_until]; - [stream writeString:self.sound]; - [stream writeBool:self.show_previews]; - [stream writeInt:self.events_mask]; + [stream writeLong:self.n_id]; + [stream writeLong:self.access_hash]; + [stream writeInt:self.date]; + [stream writeInt:self.duration]; + [stream writeString:self.mime_type]; + [stream writeInt:self.size]; + [ClassStore TLSerialize:self.thumb stream:stream]; + [stream writeInt:self.dc_id]; + [stream writeInt:self.w]; + [stream writeInt:self.h]; } -(void)unserialize:(SerializedData*)stream { - self.mute_until = [stream readInt]; - self.sound = [stream readString]; - self.show_previews = [stream readBool]; - self.events_mask = [stream readInt]; + super.n_id = [stream readLong]; + super.access_hash = [stream readLong]; + super.date = [stream readInt]; + super.duration = [stream readInt]; + super.mime_type = [stream readString]; + super.size = [stream readInt]; + self.thumb = [ClassStore TLDeserialize:stream]; + super.dc_id = [stream readInt]; + super.w = [stream readInt]; + super.h = [stream readInt]; } --(TL_inputPeerNotifySettings *)copy { +-(TL_video *)copy { - TL_inputPeerNotifySettings *objc = [[TL_inputPeerNotifySettings alloc] init]; + TL_video *objc = [[TL_video alloc] init]; - objc.mute_until = self.mute_until; - objc.sound = self.sound; - objc.show_previews = self.show_previews; - objc.events_mask = self.events_mask; + objc.n_id = self.n_id; + objc.access_hash = self.access_hash; + objc.date = self.date; + objc.duration = self.duration; + objc.mime_type = self.mime_type; + objc.size = self.size; + objc.thumb = [self.thumb copy]; + objc.dc_id = self.dc_id; + objc.w = self.w; + objc.h = self.h; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -6317,37 +7250,70 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLPeerNotifyEvents -@end - -@implementation TL_peerNotifyEventsEmpty -+(TL_peerNotifyEventsEmpty*)create { - TL_peerNotifyEventsEmpty* obj = [[TL_peerNotifyEventsEmpty alloc] init]; - +@implementation TL_video_old29 ++(TL_video_old29*)createWithN_id:(long)n_id access_hash:(long)access_hash user_id:(int)user_id date:(int)date duration:(int)duration size:(int)size thumb:(TLPhotoSize*)thumb dc_id:(int)dc_id w:(int)w h:(int)h { + TL_video_old29* obj = [[TL_video_old29 alloc] init]; + obj.n_id = n_id; + obj.access_hash = access_hash; + obj.user_id = user_id; + obj.date = date; + obj.duration = duration; + obj.size = size; + obj.thumb = thumb; + obj.dc_id = dc_id; + obj.w = w; + obj.h = h; return obj; } -(void)serialize:(SerializedData*)stream { - + [stream writeLong:self.n_id]; + [stream writeLong:self.access_hash]; + [stream writeInt:self.user_id]; + [stream writeInt:self.date]; + [stream writeInt:self.duration]; + [stream writeInt:self.size]; + [ClassStore TLSerialize:self.thumb stream:stream]; + [stream writeInt:self.dc_id]; + [stream writeInt:self.w]; + [stream writeInt:self.h]; } -(void)unserialize:(SerializedData*)stream { - + super.n_id = [stream readLong]; + super.access_hash = [stream readLong]; + super.user_id = [stream readInt]; + super.date = [stream readInt]; + super.duration = [stream readInt]; + super.size = [stream readInt]; + self.thumb = [ClassStore TLDeserialize:stream]; + super.dc_id = [stream readInt]; + super.w = [stream readInt]; + super.h = [stream readInt]; } --(TL_peerNotifyEventsEmpty *)copy { - - TL_peerNotifyEventsEmpty *objc = [[TL_peerNotifyEventsEmpty alloc] init]; +-(TL_video_old29 *)copy { + TL_video_old29 *objc = [[TL_video_old29 alloc] init]; + objc.n_id = self.n_id; + objc.access_hash = self.access_hash; + objc.user_id = self.user_id; + objc.date = self.date; + objc.duration = self.duration; + objc.size = self.size; + objc.thumb = [self.thumb copy]; + objc.dc_id = self.dc_id; + objc.w = self.w; + objc.h = self.h; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -6361,15 +7327,18 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_peerNotifyEventsAll -+(TL_peerNotifyEventsAll*)create { - TL_peerNotifyEventsAll* obj = [[TL_peerNotifyEventsAll alloc] init]; +@implementation TLGeoPoint + +@end + +@implementation TL_geoPointEmpty ++(TL_geoPointEmpty*)create { + TL_geoPointEmpty* obj = [[TL_geoPointEmpty alloc] init]; return obj; } @@ -6380,14 +7349,16 @@ -(void)unserialize:(SerializedData*)stream { } --(TL_peerNotifyEventsAll *)copy { +-(TL_geoPointEmpty *)copy { - TL_peerNotifyEventsAll *objc = [[TL_peerNotifyEventsAll alloc] init]; + TL_geoPointEmpty *objc = [[TL_geoPointEmpty alloc] init]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -6401,37 +7372,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLPeerNotifySettings -@end - -@implementation TL_peerNotifySettingsEmpty -+(TL_peerNotifySettingsEmpty*)create { - TL_peerNotifySettingsEmpty* obj = [[TL_peerNotifySettingsEmpty alloc] init]; - +@implementation TL_geoPoint ++(TL_geoPoint*)createWithN_long:(double)n_long lat:(double)lat { + TL_geoPoint* obj = [[TL_geoPoint alloc] init]; + obj.n_long = n_long; + obj.lat = lat; return obj; } -(void)serialize:(SerializedData*)stream { - + [stream writeDouble:self.n_long]; + [stream writeDouble:self.lat]; } -(void)unserialize:(SerializedData*)stream { - + super.n_long = [stream readDouble]; + super.lat = [stream readDouble]; } --(TL_peerNotifySettingsEmpty *)copy { - - TL_peerNotifySettingsEmpty *objc = [[TL_peerNotifySettingsEmpty alloc] init]; +-(TL_geoPoint *)copy { + TL_geoPoint *objc = [[TL_geoPoint alloc] init]; + objc.n_long = self.n_long; + objc.lat = self.lat; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -6445,45 +7417,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_peerNotifySettings -+(TL_peerNotifySettings*)createWithMute_until:(int)mute_until sound:(NSString*)sound show_previews:(Boolean)show_previews events_mask:(int)events_mask { - TL_peerNotifySettings* obj = [[TL_peerNotifySettings alloc] init]; - obj.mute_until = mute_until; - obj.sound = sound; - obj.show_previews = show_previews; - obj.events_mask = events_mask; +@implementation TLauth_CheckedPhone + +@end + +@implementation TL_auth_checkedPhone ++(TL_auth_checkedPhone*)createWithPhone_registered:(Boolean)phone_registered { + TL_auth_checkedPhone* obj = [[TL_auth_checkedPhone alloc] init]; + obj.phone_registered = phone_registered; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.mute_until]; - [stream writeString:self.sound]; - [stream writeBool:self.show_previews]; - [stream writeInt:self.events_mask]; + [stream writeBool:self.phone_registered]; } -(void)unserialize:(SerializedData*)stream { - self.mute_until = [stream readInt]; - self.sound = [stream readString]; - self.show_previews = [stream readBool]; - self.events_mask = [stream readInt]; + super.phone_registered = [stream readBool]; } --(TL_peerNotifySettings *)copy { +-(TL_auth_checkedPhone *)copy { - TL_peerNotifySettings *objc = [[TL_peerNotifySettings alloc] init]; + TL_auth_checkedPhone *objc = [[TL_auth_checkedPhone alloc] init]; - objc.mute_until = self.mute_until; - objc.sound = self.sound; - objc.show_previews = self.show_previews; - objc.events_mask = self.events_mask; + objc.phone_registered = self.phone_registered; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -6497,71 +7462,50 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TLauth_SentCode -@implementation TLWallPaper @end - -@implementation TL_wallPaper -+(TL_wallPaper*)createWithN_id:(int)n_id title:(NSString*)title sizes:(NSMutableArray*)sizes color:(int)color { - TL_wallPaper* obj = [[TL_wallPaper alloc] init]; - obj.n_id = n_id; - obj.title = title; - obj.sizes = sizes; - obj.color = color; - return obj; -} + +@implementation TL_auth_sentCode ++(TL_auth_sentCode*)createWithPhone_registered:(Boolean)phone_registered phone_code_hash:(NSString*)phone_code_hash send_call_timeout:(int)send_call_timeout is_password:(Boolean)is_password { + TL_auth_sentCode* obj = [[TL_auth_sentCode alloc] init]; + obj.phone_registered = phone_registered; + obj.phone_code_hash = phone_code_hash; + obj.send_call_timeout = send_call_timeout; + obj.is_password = is_password; + return obj; +} -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.n_id]; - [stream writeString:self.title]; - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.sizes count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLPhotoSize* obj = [self.sizes objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - [stream writeInt:self.color]; + [stream writeBool:self.phone_registered]; + [stream writeString:self.phone_code_hash]; + [stream writeInt:self.send_call_timeout]; + [stream writeBool:self.is_password]; } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readInt]; - self.title = [stream readString]; - //UNS FullVector - [stream readInt]; - { - if(!self.sizes) - self.sizes = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLPhotoSize* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLPhotoSize class]]) - [self.sizes addObject:obj]; - else - break; - } - } - self.color = [stream readInt]; + super.phone_registered = [stream readBool]; + super.phone_code_hash = [stream readString]; + super.send_call_timeout = [stream readInt]; + super.is_password = [stream readBool]; } --(TL_wallPaper *)copy { +-(TL_auth_sentCode *)copy { - TL_wallPaper *objc = [[TL_wallPaper alloc] init]; + TL_auth_sentCode *objc = [[TL_auth_sentCode alloc] init]; - objc.n_id = self.n_id; - objc.title = self.title; - objc.sizes = [self.sizes copy]; - objc.color = self.color; + objc.phone_registered = self.phone_registered; + objc.phone_code_hash = self.phone_code_hash; + objc.send_call_timeout = self.send_call_timeout; + objc.is_password = self.is_password; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -6575,45 +7519,46 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_wallPaperSolid -+(TL_wallPaperSolid*)createWithN_id:(int)n_id title:(NSString*)title bg_color:(int)bg_color color:(int)color { - TL_wallPaperSolid* obj = [[TL_wallPaperSolid alloc] init]; - obj.n_id = n_id; - obj.title = title; - obj.bg_color = bg_color; - obj.color = color; +@implementation TL_auth_sentAppCode ++(TL_auth_sentAppCode*)createWithPhone_registered:(Boolean)phone_registered phone_code_hash:(NSString*)phone_code_hash send_call_timeout:(int)send_call_timeout is_password:(Boolean)is_password { + TL_auth_sentAppCode* obj = [[TL_auth_sentAppCode alloc] init]; + obj.phone_registered = phone_registered; + obj.phone_code_hash = phone_code_hash; + obj.send_call_timeout = send_call_timeout; + obj.is_password = is_password; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.n_id]; - [stream writeString:self.title]; - [stream writeInt:self.bg_color]; - [stream writeInt:self.color]; + [stream writeBool:self.phone_registered]; + [stream writeString:self.phone_code_hash]; + [stream writeInt:self.send_call_timeout]; + [stream writeBool:self.is_password]; } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readInt]; - self.title = [stream readString]; - self.bg_color = [stream readInt]; - self.color = [stream readInt]; + super.phone_registered = [stream readBool]; + super.phone_code_hash = [stream readString]; + super.send_call_timeout = [stream readInt]; + super.is_password = [stream readBool]; } --(TL_wallPaperSolid *)copy { +-(TL_auth_sentAppCode *)copy { - TL_wallPaperSolid *objc = [[TL_wallPaperSolid alloc] init]; + TL_auth_sentAppCode *objc = [[TL_auth_sentAppCode alloc] init]; - objc.n_id = self.n_id; - objc.title = self.title; - objc.bg_color = self.bg_color; - objc.color = self.color; + objc.phone_registered = self.phone_registered; + objc.phone_code_hash = self.phone_code_hash; + objc.send_call_timeout = self.send_call_timeout; + objc.is_password = self.is_password; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -6627,57 +7572,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TLauth_Authorization -@implementation TLUserFull @end - -@implementation TL_userFull -+(TL_userFull*)createWithUser:(TLUser*)user link:(TLcontacts_Link*)link profile_photo:(TLPhoto*)profile_photo notify_settings:(TLPeerNotifySettings*)notify_settings blocked:(Boolean)blocked bot_info:(TLBotInfo*)bot_info { - TL_userFull* obj = [[TL_userFull alloc] init]; + +@implementation TL_auth_authorization ++(TL_auth_authorization*)createWithUser:(TLUser*)user { + TL_auth_authorization* obj = [[TL_auth_authorization alloc] init]; obj.user = user; - obj.link = link; - obj.profile_photo = profile_photo; - obj.notify_settings = notify_settings; - obj.blocked = blocked; - obj.bot_info = bot_info; return obj; } -(void)serialize:(SerializedData*)stream { [ClassStore TLSerialize:self.user stream:stream]; - [ClassStore TLSerialize:self.link stream:stream]; - [ClassStore TLSerialize:self.profile_photo stream:stream]; - [ClassStore TLSerialize:self.notify_settings stream:stream]; - [stream writeBool:self.blocked]; - [ClassStore TLSerialize:self.bot_info stream:stream]; } -(void)unserialize:(SerializedData*)stream { self.user = [ClassStore TLDeserialize:stream]; - self.link = [ClassStore TLDeserialize:stream]; - self.profile_photo = [ClassStore TLDeserialize:stream]; - self.notify_settings = [ClassStore TLDeserialize:stream]; - self.blocked = [stream readBool]; - self.bot_info = [ClassStore TLDeserialize:stream]; } --(TL_userFull *)copy { +-(TL_auth_authorization *)copy { - TL_userFull *objc = [[TL_userFull alloc] init]; + TL_auth_authorization *objc = [[TL_auth_authorization alloc] init]; objc.user = [self.user copy]; - objc.link = [self.link copy]; - objc.profile_photo = [self.profile_photo copy]; - objc.notify_settings = [self.notify_settings copy]; - objc.blocked = self.blocked; - objc.bot_info = [self.bot_info copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -6691,41 +7617,42 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TLauth_ExportedAuthorization -@implementation TLContact @end - -@implementation TL_contact -+(TL_contact*)createWithUser_id:(int)user_id mutual:(Boolean)mutual { - TL_contact* obj = [[TL_contact alloc] init]; - obj.user_id = user_id; - obj.mutual = mutual; + +@implementation TL_auth_exportedAuthorization ++(TL_auth_exportedAuthorization*)createWithN_id:(int)n_id bytes:(NSData*)bytes { + TL_auth_exportedAuthorization* obj = [[TL_auth_exportedAuthorization alloc] init]; + obj.n_id = n_id; + obj.bytes = bytes; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.user_id]; - [stream writeBool:self.mutual]; + [stream writeInt:self.n_id]; + [stream writeByteArray:self.bytes]; } -(void)unserialize:(SerializedData*)stream { - self.user_id = [stream readInt]; - self.mutual = [stream readBool]; + super.n_id = [stream readInt]; + super.bytes = [stream readByteArray]; } --(TL_contact *)copy { +-(TL_auth_exportedAuthorization *)copy { - TL_contact *objc = [[TL_contact alloc] init]; + TL_auth_exportedAuthorization *objc = [[TL_auth_exportedAuthorization alloc] init]; - objc.user_id = self.user_id; - objc.mutual = self.mutual; + objc.n_id = self.n_id; + objc.bytes = [self.bytes copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -6739,41 +7666,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TLInputNotifyPeer -@implementation TLImportedContact @end - -@implementation TL_importedContact -+(TL_importedContact*)createWithUser_id:(int)user_id client_id:(long)client_id { - TL_importedContact* obj = [[TL_importedContact alloc] init]; - obj.user_id = user_id; - obj.client_id = client_id; + +@implementation TL_inputNotifyPeer ++(TL_inputNotifyPeer*)createWithPeer:(TLInputPeer*)peer { + TL_inputNotifyPeer* obj = [[TL_inputNotifyPeer alloc] init]; + obj.peer = peer; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.user_id]; - [stream writeLong:self.client_id]; + [ClassStore TLSerialize:self.peer stream:stream]; } -(void)unserialize:(SerializedData*)stream { - self.user_id = [stream readInt]; - self.client_id = [stream readLong]; + self.peer = [ClassStore TLDeserialize:stream]; } --(TL_importedContact *)copy { +-(TL_inputNotifyPeer *)copy { - TL_importedContact *objc = [[TL_importedContact alloc] init]; + TL_inputNotifyPeer *objc = [[TL_inputNotifyPeer alloc] init]; - objc.user_id = self.user_id; - objc.client_id = self.client_id; + objc.peer = [self.peer copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -6787,41 +7711,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLContactBlocked -@end - -@implementation TL_contactBlocked -+(TL_contactBlocked*)createWithUser_id:(int)user_id date:(int)date { - TL_contactBlocked* obj = [[TL_contactBlocked alloc] init]; - obj.user_id = user_id; - obj.date = date; +@implementation TL_inputNotifyUsers ++(TL_inputNotifyUsers*)create { + TL_inputNotifyUsers* obj = [[TL_inputNotifyUsers alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.user_id]; - [stream writeInt:self.date]; + } -(void)unserialize:(SerializedData*)stream { - self.user_id = [stream readInt]; - self.date = [stream readInt]; + } --(TL_contactBlocked *)copy { +-(TL_inputNotifyUsers *)copy { + + TL_inputNotifyUsers *objc = [[TL_inputNotifyUsers alloc] init]; - TL_contactBlocked *objc = [[TL_contactBlocked alloc] init]; - objc.user_id = self.user_id; - objc.date = self.date; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -6835,41 +7752,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLContactSuggested -@end - -@implementation TL_contactSuggested -+(TL_contactSuggested*)createWithUser_id:(int)user_id mutual_contacts:(int)mutual_contacts { - TL_contactSuggested* obj = [[TL_contactSuggested alloc] init]; - obj.user_id = user_id; - obj.mutual_contacts = mutual_contacts; +@implementation TL_inputNotifyChats ++(TL_inputNotifyChats*)create { + TL_inputNotifyChats* obj = [[TL_inputNotifyChats alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.user_id]; - [stream writeInt:self.mutual_contacts]; + } -(void)unserialize:(SerializedData*)stream { - self.user_id = [stream readInt]; - self.mutual_contacts = [stream readInt]; + } --(TL_contactSuggested *)copy { +-(TL_inputNotifyChats *)copy { + + TL_inputNotifyChats *objc = [[TL_inputNotifyChats alloc] init]; - TL_contactSuggested *objc = [[TL_contactSuggested alloc] init]; - objc.user_id = self.user_id; - objc.mutual_contacts = self.mutual_contacts; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -6883,41 +7793,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLContactStatus -@end - -@implementation TL_contactStatus -+(TL_contactStatus*)createWithUser_id:(int)user_id status:(TLUserStatus*)status { - TL_contactStatus* obj = [[TL_contactStatus alloc] init]; - obj.user_id = user_id; - obj.status = status; +@implementation TL_inputNotifyAll ++(TL_inputNotifyAll*)create { + TL_inputNotifyAll* obj = [[TL_inputNotifyAll alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.user_id]; - [ClassStore TLSerialize:self.status stream:stream]; + } -(void)unserialize:(SerializedData*)stream { - self.user_id = [stream readInt]; - self.status = [ClassStore TLDeserialize:stream]; + } --(TL_contactStatus *)copy { +-(TL_inputNotifyAll *)copy { + + TL_inputNotifyAll *objc = [[TL_inputNotifyAll alloc] init]; - TL_contactStatus *objc = [[TL_contactStatus alloc] init]; - objc.user_id = self.user_id; - objc.status = [self.status copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -6931,41 +7834,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TLInputPeerNotifyEvents -@implementation TLChatLocated @end - -@implementation TL_chatLocated -+(TL_chatLocated*)createWithChat_id:(int)chat_id distance:(int)distance { - TL_chatLocated* obj = [[TL_chatLocated alloc] init]; - obj.chat_id = chat_id; - obj.distance = distance; + +@implementation TL_inputPeerNotifyEventsEmpty ++(TL_inputPeerNotifyEventsEmpty*)create { + TL_inputPeerNotifyEventsEmpty* obj = [[TL_inputPeerNotifyEventsEmpty alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.chat_id]; - [stream writeInt:self.distance]; + } -(void)unserialize:(SerializedData*)stream { - self.chat_id = [stream readInt]; - self.distance = [stream readInt]; + } --(TL_chatLocated *)copy { +-(TL_inputPeerNotifyEventsEmpty *)copy { + + TL_inputPeerNotifyEventsEmpty *objc = [[TL_inputPeerNotifyEventsEmpty alloc] init]; - TL_chatLocated *objc = [[TL_chatLocated alloc] init]; - objc.chat_id = self.chat_id; - objc.distance = self.distance; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -6979,45 +7879,91 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TL_inputPeerNotifyEventsAll ++(TL_inputPeerNotifyEventsAll*)create { + TL_inputPeerNotifyEventsAll* obj = [[TL_inputPeerNotifyEventsAll alloc] init]; + + return obj; +} +-(void)serialize:(SerializedData*)stream { + +} +-(void)unserialize:(SerializedData*)stream { + +} + +-(TL_inputPeerNotifyEventsAll *)copy { + + TL_inputPeerNotifyEventsAll *objc = [[TL_inputPeerNotifyEventsAll alloc] init]; + + + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { -@implementation TLcontacts_Link + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + @end -@implementation TL_contacts_link -+(TL_contacts_link*)createWithMy_link:(TLContactLink*)my_link foreign_link:(TLContactLink*)foreign_link user:(TLUser*)user { - TL_contacts_link* obj = [[TL_contacts_link alloc] init]; - obj.my_link = my_link; - obj.foreign_link = foreign_link; - obj.user = user; +@implementation TLInputPeerNotifySettings + +@end + +@implementation TL_inputPeerNotifySettings ++(TL_inputPeerNotifySettings*)createWithMute_until:(int)mute_until sound:(NSString*)sound show_previews:(Boolean)show_previews events_mask:(int)events_mask { + TL_inputPeerNotifySettings* obj = [[TL_inputPeerNotifySettings alloc] init]; + obj.mute_until = mute_until; + obj.sound = sound; + obj.show_previews = show_previews; + obj.events_mask = events_mask; return obj; } -(void)serialize:(SerializedData*)stream { - [ClassStore TLSerialize:self.my_link stream:stream]; - [ClassStore TLSerialize:self.foreign_link stream:stream]; - [ClassStore TLSerialize:self.user stream:stream]; + [stream writeInt:self.mute_until]; + [stream writeString:self.sound]; + [stream writeBool:self.show_previews]; + [stream writeInt:self.events_mask]; } -(void)unserialize:(SerializedData*)stream { - self.my_link = [ClassStore TLDeserialize:stream]; - self.foreign_link = [ClassStore TLDeserialize:stream]; - self.user = [ClassStore TLDeserialize:stream]; + super.mute_until = [stream readInt]; + super.sound = [stream readString]; + super.show_previews = [stream readBool]; + super.events_mask = [stream readInt]; } --(TL_contacts_link *)copy { +-(TL_inputPeerNotifySettings *)copy { - TL_contacts_link *objc = [[TL_contacts_link alloc] init]; + TL_inputPeerNotifySettings *objc = [[TL_inputPeerNotifySettings alloc] init]; - objc.my_link = [self.my_link copy]; - objc.foreign_link = [self.foreign_link copy]; - objc.user = [self.user copy]; + objc.mute_until = self.mute_until; + objc.sound = self.sound; + objc.show_previews = self.show_previews; + objc.events_mask = self.events_mask; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -7031,19 +7977,18 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TLPeerNotifyEvents -@implementation TLcontacts_Contacts @end - -@implementation TL_contacts_contactsNotModified -+(TL_contacts_contactsNotModified*)create { - TL_contacts_contactsNotModified* obj = [[TL_contacts_contactsNotModified alloc] init]; + +@implementation TL_peerNotifyEventsEmpty ++(TL_peerNotifyEventsEmpty*)create { + TL_peerNotifyEventsEmpty* obj = [[TL_peerNotifyEventsEmpty alloc] init]; return obj; } @@ -7054,14 +7999,16 @@ -(void)unserialize:(SerializedData*)stream { } --(TL_contacts_contactsNotModified *)copy { +-(TL_peerNotifyEventsEmpty *)copy { - TL_contacts_contactsNotModified *objc = [[TL_contacts_contactsNotModified alloc] init]; + TL_peerNotifyEventsEmpty *objc = [[TL_peerNotifyEventsEmpty alloc] init]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -7075,81 +8022,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_contacts_contacts -+(TL_contacts_contacts*)createWithContacts:(NSMutableArray*)contacts users:(NSMutableArray*)users { - TL_contacts_contacts* obj = [[TL_contacts_contacts alloc] init]; - obj.contacts = contacts; - obj.users = users; +@implementation TL_peerNotifyEventsAll ++(TL_peerNotifyEventsAll*)create { + TL_peerNotifyEventsAll* obj = [[TL_peerNotifyEventsAll alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.contacts count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLContact* obj = [self.contacts objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.users count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLUser* obj = [self.users objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } + } -(void)unserialize:(SerializedData*)stream { - //UNS FullVector - [stream readInt]; - { - if(!self.contacts) - self.contacts = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLContact* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLContact class]]) - [self.contacts addObject:obj]; - else - break; - } - } - //UNS FullVector - [stream readInt]; - { - if(!self.users) - self.users = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLUser* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLUser class]]) - [self.users addObject:obj]; - else - break; - } - } + } --(TL_contacts_contacts *)copy { +-(TL_peerNotifyEventsAll *)copy { + + TL_peerNotifyEventsAll *objc = [[TL_peerNotifyEventsAll alloc] init]; - TL_contacts_contacts *objc = [[TL_contacts_contacts alloc] init]; - objc.contacts = [self.contacts copy]; - objc.users = [self.users copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -7163,111 +8063,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TLPeerNotifySettings -@implementation TLcontacts_ImportedContacts @end - -@implementation TL_contacts_importedContacts -+(TL_contacts_importedContacts*)createWithImported:(NSMutableArray*)imported retry_contacts:(NSMutableArray*)retry_contacts users:(NSMutableArray*)users { - TL_contacts_importedContacts* obj = [[TL_contacts_importedContacts alloc] init]; - obj.imported = imported; - obj.retry_contacts = retry_contacts; - obj.users = users; + +@implementation TL_peerNotifySettingsEmpty ++(TL_peerNotifySettingsEmpty*)create { + TL_peerNotifySettingsEmpty* obj = [[TL_peerNotifySettingsEmpty alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.imported count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLImportedContact* obj = [self.imported objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - //Serialize ShortVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.retry_contacts count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - if([self.retry_contacts count] > i) { - NSNumber* obj = [self.retry_contacts objectAtIndex:i]; - [stream writeLong:[obj longValue]]; - } else - break; - } - } - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.users count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLUser* obj = [self.users objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } + } -(void)unserialize:(SerializedData*)stream { - //UNS FullVector - [stream readInt]; - { - if(!self.imported) - self.imported = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLImportedContact* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLImportedContact class]]) - [self.imported addObject:obj]; - else - break; - } - } - //UNS ShortVector - [stream readInt]; - { - if(!self.retry_contacts) - self.retry_contacts = [[NSMutableArray alloc] init]; - int tl_count = [stream readInt]; - for(int i = 0; i < tl_count; i++) { - long obj = [stream readLong]; - [self.retry_contacts addObject:@(obj)]; - } - } - //UNS FullVector - [stream readInt]; - { - if(!self.users) - self.users = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLUser* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLUser class]]) - [self.users addObject:obj]; - else - break; - } - } + } --(TL_contacts_importedContacts *)copy { +-(TL_peerNotifySettingsEmpty *)copy { + + TL_peerNotifySettingsEmpty *objc = [[TL_peerNotifySettingsEmpty alloc] init]; - TL_contacts_importedContacts *objc = [[TL_contacts_importedContacts alloc] init]; - objc.imported = [self.imported copy]; - objc.retry_contacts = [self.retry_contacts copy]; - objc.users = [self.users copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -7281,85 +8108,125 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TL_peerNotifySettings ++(TL_peerNotifySettings*)createWithMute_until:(int)mute_until sound:(NSString*)sound show_previews:(Boolean)show_previews events_mask:(int)events_mask { + TL_peerNotifySettings* obj = [[TL_peerNotifySettings alloc] init]; + obj.mute_until = mute_until; + obj.sound = sound; + obj.show_previews = show_previews; + obj.events_mask = events_mask; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeInt:self.mute_until]; + [stream writeString:self.sound]; + [stream writeBool:self.show_previews]; + [stream writeInt:self.events_mask]; +} +-(void)unserialize:(SerializedData*)stream { + super.mute_until = [stream readInt]; + super.sound = [stream readString]; + super.show_previews = [stream readBool]; + super.events_mask = [stream readInt]; +} + +-(TL_peerNotifySettings *)copy { + + TL_peerNotifySettings *objc = [[TL_peerNotifySettings alloc] init]; + + objc.mute_until = self.mute_until; + objc.sound = self.sound; + objc.show_previews = self.show_previews; + objc.events_mask = self.events_mask; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { -@implementation TLcontacts_Blocked + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + @end -@implementation TL_contacts_blocked -+(TL_contacts_blocked*)createWithBlocked:(NSMutableArray*)blocked users:(NSMutableArray*)users { - TL_contacts_blocked* obj = [[TL_contacts_blocked alloc] init]; - obj.blocked = blocked; - obj.users = users; +@implementation TLWallPaper + +@end + +@implementation TL_wallPaper ++(TL_wallPaper*)createWithN_id:(int)n_id title:(NSString*)title sizes:(NSMutableArray*)sizes color:(int)color { + TL_wallPaper* obj = [[TL_wallPaper alloc] init]; + obj.n_id = n_id; + obj.title = title; + obj.sizes = sizes; + obj.color = color; return obj; } -(void)serialize:(SerializedData*)stream { + [stream writeInt:self.n_id]; + [stream writeString:self.title]; //Serialize FullVector [stream writeInt:0x1cb5c415]; { - NSInteger tl_count = [self.blocked count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLContactBlocked* obj = [self.blocked objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.users count]; + NSInteger tl_count = [self.sizes count]; [stream writeInt:(int)tl_count]; for(int i = 0; i < (int)tl_count; i++) { - TLUser* obj = [self.users objectAtIndex:i]; + TLPhotoSize* obj = [self.sizes objectAtIndex:i]; [ClassStore TLSerialize:obj stream:stream]; } } + [stream writeInt:self.color]; } -(void)unserialize:(SerializedData*)stream { + super.n_id = [stream readInt]; + super.title = [stream readString]; //UNS FullVector [stream readInt]; { - if(!self.blocked) - self.blocked = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLContactBlocked* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLContactBlocked class]]) - [self.blocked addObject:obj]; - else - break; - } - } - //UNS FullVector - [stream readInt]; - { - if(!self.users) - self.users = [[NSMutableArray alloc] init]; + if(!self.sizes) + self.sizes = [[NSMutableArray alloc] init]; int count = [stream readInt]; for(int i = 0; i < count; i++) { - TLUser* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLUser class]]) - [self.users addObject:obj]; + TLPhotoSize* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLPhotoSize class]]) + [self.sizes addObject:obj]; else break; } } + super.color = [stream readInt]; } --(TL_contacts_blocked *)copy { +-(TL_wallPaper *)copy { - TL_contacts_blocked *objc = [[TL_contacts_blocked alloc] init]; + TL_wallPaper *objc = [[TL_wallPaper alloc] init]; - objc.blocked = [self.blocked copy]; - objc.users = [self.users copy]; + objc.n_id = self.n_id; + objc.title = self.title; + objc.sizes = [self.sizes copy]; + objc.color = self.color; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -7373,85 +8240,46 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_contacts_blockedSlice -+(TL_contacts_blockedSlice*)createWithN_count:(int)n_count blocked:(NSMutableArray*)blocked users:(NSMutableArray*)users { - TL_contacts_blockedSlice* obj = [[TL_contacts_blockedSlice alloc] init]; - obj.n_count = n_count; - obj.blocked = blocked; - obj.users = users; +@implementation TL_wallPaperSolid ++(TL_wallPaperSolid*)createWithN_id:(int)n_id title:(NSString*)title bg_color:(int)bg_color color:(int)color { + TL_wallPaperSolid* obj = [[TL_wallPaperSolid alloc] init]; + obj.n_id = n_id; + obj.title = title; + obj.bg_color = bg_color; + obj.color = color; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.n_count]; - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.blocked count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLContactBlocked* obj = [self.blocked objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.users count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLUser* obj = [self.users objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } + [stream writeInt:self.n_id]; + [stream writeString:self.title]; + [stream writeInt:self.bg_color]; + [stream writeInt:self.color]; } -(void)unserialize:(SerializedData*)stream { - self.n_count = [stream readInt]; - //UNS FullVector - [stream readInt]; - { - if(!self.blocked) - self.blocked = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLContactBlocked* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLContactBlocked class]]) - [self.blocked addObject:obj]; - else - break; - } - } - //UNS FullVector - [stream readInt]; - { - if(!self.users) - self.users = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLUser* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLUser class]]) - [self.users addObject:obj]; - else - break; - } - } + super.n_id = [stream readInt]; + super.title = [stream readString]; + super.bg_color = [stream readInt]; + super.color = [stream readInt]; } --(TL_contacts_blockedSlice *)copy { +-(TL_wallPaperSolid *)copy { - TL_contacts_blockedSlice *objc = [[TL_contacts_blockedSlice alloc] init]; + TL_wallPaperSolid *objc = [[TL_wallPaperSolid alloc] init]; - objc.n_count = self.n_count; - objc.blocked = [self.blocked copy]; - objc.users = [self.users copy]; + objc.n_id = self.n_id; + objc.title = self.title; + objc.bg_color = self.bg_color; + objc.color = self.color; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -7465,85 +8293,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TLReportReason -@implementation TLcontacts_Suggested @end - -@implementation TL_contacts_suggested -+(TL_contacts_suggested*)createWithResults:(NSMutableArray*)results users:(NSMutableArray*)users { - TL_contacts_suggested* obj = [[TL_contacts_suggested alloc] init]; - obj.results = results; - obj.users = users; + +@implementation TL_inputReportReasonSpam ++(TL_inputReportReasonSpam*)create { + TL_inputReportReasonSpam* obj = [[TL_inputReportReasonSpam alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.results count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLContactSuggested* obj = [self.results objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.users count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLUser* obj = [self.users objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } + } -(void)unserialize:(SerializedData*)stream { - //UNS FullVector - [stream readInt]; - { - if(!self.results) - self.results = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLContactSuggested* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLContactSuggested class]]) - [self.results addObject:obj]; - else - break; - } - } - //UNS FullVector - [stream readInt]; - { - if(!self.users) - self.users = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLUser* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLUser class]]) - [self.users addObject:obj]; - else - break; - } - } + } --(TL_contacts_suggested *)copy { +-(TL_inputReportReasonSpam *)copy { + + TL_inputReportReasonSpam *objc = [[TL_inputReportReasonSpam alloc] init]; - TL_contacts_suggested *objc = [[TL_contacts_suggested alloc] init]; - objc.results = [self.results copy]; - objc.users = [self.users copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -7557,137 +8338,75 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TL_inputReportReasonViolence ++(TL_inputReportReasonViolence*)create { + TL_inputReportReasonViolence* obj = [[TL_inputReportReasonViolence alloc] init]; + + return obj; +} +-(void)serialize:(SerializedData*)stream { + +} +-(void)unserialize:(SerializedData*)stream { + +} + +-(TL_inputReportReasonViolence *)copy { + + TL_inputReportReasonViolence *objc = [[TL_inputReportReasonViolence alloc] init]; + + + + return objc; +} + -@implementation TLmessages_Dialogs + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + @end -@implementation TL_messages_dialogs -+(TL_messages_dialogs*)createWithDialogs:(NSMutableArray*)dialogs messages:(NSMutableArray*)messages chats:(NSMutableArray*)chats users:(NSMutableArray*)users { - TL_messages_dialogs* obj = [[TL_messages_dialogs alloc] init]; - obj.dialogs = dialogs; - obj.messages = messages; - obj.chats = chats; - obj.users = users; +@implementation TL_inputReportReasonPornography ++(TL_inputReportReasonPornography*)create { + TL_inputReportReasonPornography* obj = [[TL_inputReportReasonPornography alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.dialogs count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLDialog* obj = [self.dialogs objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.messages count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLMessage* obj = [self.messages objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.chats count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLChat* obj = [self.chats objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.users count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLUser* obj = [self.users objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } + } -(void)unserialize:(SerializedData*)stream { - //UNS FullVector - [stream readInt]; - { - if(!self.dialogs) - self.dialogs = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLDialog* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLDialog class]]) - [self.dialogs addObject:obj]; - else - break; - } - } - //UNS FullVector - [stream readInt]; - { - if(!self.messages) - self.messages = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLMessage* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLMessage class]]) - [self.messages addObject:obj]; - else - break; - } - } - //UNS FullVector - [stream readInt]; - { - if(!self.chats) - self.chats = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLChat* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLChat class]]) - [self.chats addObject:obj]; - else - break; - } - } - //UNS FullVector - [stream readInt]; - { - if(!self.users) - self.users = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLUser* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLUser class]]) - [self.users addObject:obj]; - else - break; - } - } + } --(TL_messages_dialogs *)copy { +-(TL_inputReportReasonPornography *)copy { + + TL_inputReportReasonPornography *objc = [[TL_inputReportReasonPornography alloc] init]; - TL_messages_dialogs *objc = [[TL_messages_dialogs alloc] init]; - objc.dialogs = [self.dialogs copy]; - objc.messages = [self.messages copy]; - objc.chats = [self.chats copy]; - objc.users = [self.users copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -7701,137 +8420,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_messages_dialogsSlice -+(TL_messages_dialogsSlice*)createWithN_count:(int)n_count dialogs:(NSMutableArray*)dialogs messages:(NSMutableArray*)messages chats:(NSMutableArray*)chats users:(NSMutableArray*)users { - TL_messages_dialogsSlice* obj = [[TL_messages_dialogsSlice alloc] init]; - obj.n_count = n_count; - obj.dialogs = dialogs; - obj.messages = messages; - obj.chats = chats; - obj.users = users; +@implementation TL_inputReportReasonOther ++(TL_inputReportReasonOther*)createWithText:(NSString*)text { + TL_inputReportReasonOther* obj = [[TL_inputReportReasonOther alloc] init]; + obj.text = text; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.n_count]; - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.dialogs count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLDialog* obj = [self.dialogs objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.messages count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLMessage* obj = [self.messages objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.chats count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLChat* obj = [self.chats objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.users count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLUser* obj = [self.users objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } + [stream writeString:self.text]; } -(void)unserialize:(SerializedData*)stream { - self.n_count = [stream readInt]; - //UNS FullVector - [stream readInt]; - { - if(!self.dialogs) - self.dialogs = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLDialog* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLDialog class]]) - [self.dialogs addObject:obj]; - else - break; - } - } - //UNS FullVector - [stream readInt]; - { - if(!self.messages) - self.messages = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLMessage* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLMessage class]]) - [self.messages addObject:obj]; - else - break; - } - } - //UNS FullVector - [stream readInt]; - { - if(!self.chats) - self.chats = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLChat* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLChat class]]) - [self.chats addObject:obj]; - else - break; - } - } - //UNS FullVector - [stream readInt]; - { - if(!self.users) - self.users = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLUser* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLUser class]]) - [self.users addObject:obj]; - else - break; - } - } + super.text = [stream readString]; } --(TL_messages_dialogsSlice *)copy { +-(TL_inputReportReasonOther *)copy { - TL_messages_dialogsSlice *objc = [[TL_messages_dialogsSlice alloc] init]; + TL_inputReportReasonOther *objc = [[TL_inputReportReasonOther alloc] init]; - objc.n_count = self.n_count; - objc.dialogs = [self.dialogs copy]; - objc.messages = [self.messages copy]; - objc.chats = [self.chats copy]; - objc.users = [self.users copy]; + objc.text = self.text; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -7845,111 +8461,58 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TLUserFull -@implementation TLmessages_Messages @end - -@implementation TL_messages_messages -+(TL_messages_messages*)createWithMessages:(NSMutableArray*)messages chats:(NSMutableArray*)chats users:(NSMutableArray*)users { - TL_messages_messages* obj = [[TL_messages_messages alloc] init]; - obj.messages = messages; - obj.chats = chats; - obj.users = users; + +@implementation TL_userFull ++(TL_userFull*)createWithUser:(TLUser*)user link:(TLcontacts_Link*)link profile_photo:(TLPhoto*)profile_photo notify_settings:(TLPeerNotifySettings*)notify_settings blocked:(Boolean)blocked bot_info:(TLBotInfo*)bot_info { + TL_userFull* obj = [[TL_userFull alloc] init]; + obj.user = user; + obj.link = link; + obj.profile_photo = profile_photo; + obj.notify_settings = notify_settings; + obj.blocked = blocked; + obj.bot_info = bot_info; return obj; } -(void)serialize:(SerializedData*)stream { - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.messages count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLMessage* obj = [self.messages objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.chats count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLChat* obj = [self.chats objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.users count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLUser* obj = [self.users objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } + [ClassStore TLSerialize:self.user stream:stream]; + [ClassStore TLSerialize:self.link stream:stream]; + [ClassStore TLSerialize:self.profile_photo stream:stream]; + [ClassStore TLSerialize:self.notify_settings stream:stream]; + [stream writeBool:self.blocked]; + [ClassStore TLSerialize:self.bot_info stream:stream]; } -(void)unserialize:(SerializedData*)stream { - //UNS FullVector - [stream readInt]; - { - if(!self.messages) - self.messages = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLMessage* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLMessage class]]) - [self.messages addObject:obj]; - else - break; - } - } - //UNS FullVector - [stream readInt]; - { - if(!self.chats) - self.chats = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLChat* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLChat class]]) - [self.chats addObject:obj]; - else - break; - } - } - //UNS FullVector - [stream readInt]; - { - if(!self.users) - self.users = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLUser* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLUser class]]) - [self.users addObject:obj]; - else - break; - } - } + self.user = [ClassStore TLDeserialize:stream]; + self.link = [ClassStore TLDeserialize:stream]; + self.profile_photo = [ClassStore TLDeserialize:stream]; + self.notify_settings = [ClassStore TLDeserialize:stream]; + super.blocked = [stream readBool]; + self.bot_info = [ClassStore TLDeserialize:stream]; } --(TL_messages_messages *)copy { +-(TL_userFull *)copy { - TL_messages_messages *objc = [[TL_messages_messages alloc] init]; + TL_userFull *objc = [[TL_userFull alloc] init]; - objc.messages = [self.messages copy]; - objc.chats = [self.chats copy]; - objc.users = [self.users copy]; + objc.user = [self.user copy]; + objc.link = [self.link copy]; + objc.profile_photo = [self.profile_photo copy]; + objc.notify_settings = [self.notify_settings copy]; + objc.blocked = self.blocked; + objc.bot_info = [self.bot_info copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -7963,111 +8526,42 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_messages_messagesSlice -+(TL_messages_messagesSlice*)createWithN_count:(int)n_count messages:(NSMutableArray*)messages chats:(NSMutableArray*)chats users:(NSMutableArray*)users { - TL_messages_messagesSlice* obj = [[TL_messages_messagesSlice alloc] init]; - obj.n_count = n_count; - obj.messages = messages; - obj.chats = chats; - obj.users = users; +@implementation TLContact + +@end + +@implementation TL_contact ++(TL_contact*)createWithUser_id:(int)user_id mutual:(Boolean)mutual { + TL_contact* obj = [[TL_contact alloc] init]; + obj.user_id = user_id; + obj.mutual = mutual; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.n_count]; - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.messages count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLMessage* obj = [self.messages objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.chats count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLChat* obj = [self.chats objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.users count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLUser* obj = [self.users objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } + [stream writeInt:self.user_id]; + [stream writeBool:self.mutual]; } -(void)unserialize:(SerializedData*)stream { - self.n_count = [stream readInt]; - //UNS FullVector - [stream readInt]; - { - if(!self.messages) - self.messages = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLMessage* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLMessage class]]) - [self.messages addObject:obj]; - else - break; - } - } - //UNS FullVector - [stream readInt]; - { - if(!self.chats) - self.chats = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLChat* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLChat class]]) - [self.chats addObject:obj]; - else - break; - } - } - //UNS FullVector - [stream readInt]; - { - if(!self.users) - self.users = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLUser* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLUser class]]) - [self.users addObject:obj]; - else - break; - } - } + super.user_id = [stream readInt]; + super.mutual = [stream readBool]; } --(TL_messages_messagesSlice *)copy { +-(TL_contact *)copy { - TL_messages_messagesSlice *objc = [[TL_messages_messagesSlice alloc] init]; + TL_contact *objc = [[TL_contact alloc] init]; - objc.n_count = self.n_count; - objc.messages = [self.messages copy]; - objc.chats = [self.chats copy]; - objc.users = [self.users copy]; + objc.user_id = self.user_id; + objc.mutual = self.mutual; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -8081,37 +8575,42 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TLImportedContact -@implementation TLmessages_Message @end - -@implementation TL_messages_messageEmpty -+(TL_messages_messageEmpty*)create { - TL_messages_messageEmpty* obj = [[TL_messages_messageEmpty alloc] init]; - + +@implementation TL_importedContact ++(TL_importedContact*)createWithUser_id:(int)user_id client_id:(long)client_id { + TL_importedContact* obj = [[TL_importedContact alloc] init]; + obj.user_id = user_id; + obj.client_id = client_id; return obj; } -(void)serialize:(SerializedData*)stream { - + [stream writeInt:self.user_id]; + [stream writeLong:self.client_id]; } -(void)unserialize:(SerializedData*)stream { - + super.user_id = [stream readInt]; + super.client_id = [stream readLong]; } --(TL_messages_messageEmpty *)copy { - - TL_messages_messageEmpty *objc = [[TL_messages_messageEmpty alloc] init]; +-(TL_importedContact *)copy { + TL_importedContact *objc = [[TL_importedContact alloc] init]; + objc.user_id = self.user_id; + objc.client_id = self.client_id; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -8125,53 +8624,42 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TLContactBlocked -@implementation TLmessages_SentMessage @end - -@implementation TL_messages_sentMessage -+(TL_messages_sentMessage*)createWithN_id:(int)n_id date:(int)date media:(TLMessageMedia*)media pts:(int)pts pts_count:(int)pts_count { - TL_messages_sentMessage* obj = [[TL_messages_sentMessage alloc] init]; - obj.n_id = n_id; + +@implementation TL_contactBlocked ++(TL_contactBlocked*)createWithUser_id:(int)user_id date:(int)date { + TL_contactBlocked* obj = [[TL_contactBlocked alloc] init]; + obj.user_id = user_id; obj.date = date; - obj.media = media; - obj.pts = pts; - obj.pts_count = pts_count; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.n_id]; + [stream writeInt:self.user_id]; [stream writeInt:self.date]; - [ClassStore TLSerialize:self.media stream:stream]; - [stream writeInt:self.pts]; - [stream writeInt:self.pts_count]; } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readInt]; - self.date = [stream readInt]; - self.media = [ClassStore TLDeserialize:stream]; - self.pts = [stream readInt]; - self.pts_count = [stream readInt]; + super.user_id = [stream readInt]; + super.date = [stream readInt]; } --(TL_messages_sentMessage *)copy { +-(TL_contactBlocked *)copy { - TL_messages_sentMessage *objc = [[TL_messages_sentMessage alloc] init]; + TL_contactBlocked *objc = [[TL_contactBlocked alloc] init]; - objc.n_id = self.n_id; + objc.user_id = self.user_id; objc.date = self.date; - objc.media = [self.media copy]; - objc.pts = self.pts; - objc.pts_count = self.pts_count; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -8185,79 +8673,42 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_messages_sentMessageLink -+(TL_messages_sentMessageLink*)createWithN_id:(int)n_id date:(int)date media:(TLMessageMedia*)media pts:(int)pts pts_count:(int)pts_count links:(NSMutableArray*)links seq:(int)seq { - TL_messages_sentMessageLink* obj = [[TL_messages_sentMessageLink alloc] init]; - obj.n_id = n_id; - obj.date = date; - obj.media = media; - obj.pts = pts; - obj.pts_count = pts_count; - obj.links = links; - obj.seq = seq; +@implementation TLContactSuggested + +@end + +@implementation TL_contactSuggested ++(TL_contactSuggested*)createWithUser_id:(int)user_id mutual_contacts:(int)mutual_contacts { + TL_contactSuggested* obj = [[TL_contactSuggested alloc] init]; + obj.user_id = user_id; + obj.mutual_contacts = mutual_contacts; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.n_id]; - [stream writeInt:self.date]; - [ClassStore TLSerialize:self.media stream:stream]; - [stream writeInt:self.pts]; - [stream writeInt:self.pts_count]; - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.links count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLcontacts_Link* obj = [self.links objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - [stream writeInt:self.seq]; + [stream writeInt:self.user_id]; + [stream writeInt:self.mutual_contacts]; } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readInt]; - self.date = [stream readInt]; - self.media = [ClassStore TLDeserialize:stream]; - self.pts = [stream readInt]; - self.pts_count = [stream readInt]; - //UNS FullVector - [stream readInt]; - { - if(!self.links) - self.links = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLcontacts_Link* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLcontacts_Link class]]) - [self.links addObject:obj]; - else - break; - } - } - self.seq = [stream readInt]; + super.user_id = [stream readInt]; + super.mutual_contacts = [stream readInt]; } --(TL_messages_sentMessageLink *)copy { +-(TL_contactSuggested *)copy { - TL_messages_sentMessageLink *objc = [[TL_messages_sentMessageLink alloc] init]; + TL_contactSuggested *objc = [[TL_contactSuggested alloc] init]; - objc.n_id = self.n_id; - objc.date = self.date; - objc.media = [self.media copy]; - objc.pts = self.pts; - objc.pts_count = self.pts_count; - objc.links = [self.links copy]; - objc.seq = self.seq; + objc.user_id = self.user_id; + objc.mutual_contacts = self.mutual_contacts; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -8271,59 +8722,42 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TLContactStatus -@implementation TLmessages_Chats @end - -@implementation TL_messages_chats -+(TL_messages_chats*)createWithChats:(NSMutableArray*)chats { - TL_messages_chats* obj = [[TL_messages_chats alloc] init]; - obj.chats = chats; + +@implementation TL_contactStatus ++(TL_contactStatus*)createWithUser_id:(int)user_id status:(TLUserStatus*)status { + TL_contactStatus* obj = [[TL_contactStatus alloc] init]; + obj.user_id = user_id; + obj.status = status; return obj; } -(void)serialize:(SerializedData*)stream { - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.chats count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLChat* obj = [self.chats objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } + [stream writeInt:self.user_id]; + [ClassStore TLSerialize:self.status stream:stream]; } -(void)unserialize:(SerializedData*)stream { - //UNS FullVector - [stream readInt]; - { - if(!self.chats) - self.chats = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLChat* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLChat class]]) - [self.chats addObject:obj]; - else - break; - } - } + super.user_id = [stream readInt]; + self.status = [ClassStore TLDeserialize:stream]; } --(TL_messages_chats *)copy { +-(TL_contactStatus *)copy { - TL_messages_chats *objc = [[TL_messages_chats alloc] init]; + TL_contactStatus *objc = [[TL_contactStatus alloc] init]; - objc.chats = [self.chats copy]; + objc.user_id = self.user_id; + objc.status = [self.status copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -8337,141 +8771,46 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TLcontacts_Link -@implementation TLmessages_ChatFull @end - -@implementation TL_messages_chatFull -+(TL_messages_chatFull*)createWithFull_chat:(TLChatFull*)full_chat chats:(NSMutableArray*)chats users:(NSMutableArray*)users { - TL_messages_chatFull* obj = [[TL_messages_chatFull alloc] init]; - obj.full_chat = full_chat; - obj.chats = chats; - obj.users = users; + +@implementation TL_contacts_link ++(TL_contacts_link*)createWithMy_link:(TLContactLink*)my_link foreign_link:(TLContactLink*)foreign_link user:(TLUser*)user { + TL_contacts_link* obj = [[TL_contacts_link alloc] init]; + obj.my_link = my_link; + obj.foreign_link = foreign_link; + obj.user = user; return obj; } -(void)serialize:(SerializedData*)stream { - [ClassStore TLSerialize:self.full_chat stream:stream]; - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.chats count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLChat* obj = [self.chats objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.users count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLUser* obj = [self.users objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } + [ClassStore TLSerialize:self.my_link stream:stream]; + [ClassStore TLSerialize:self.foreign_link stream:stream]; + [ClassStore TLSerialize:self.user stream:stream]; } -(void)unserialize:(SerializedData*)stream { - self.full_chat = [ClassStore TLDeserialize:stream]; - //UNS FullVector - [stream readInt]; - { - if(!self.chats) - self.chats = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLChat* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLChat class]]) - [self.chats addObject:obj]; - else - break; - } - } - //UNS FullVector - [stream readInt]; - { - if(!self.users) - self.users = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLUser* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLUser class]]) - [self.users addObject:obj]; - else - break; - } - } + self.my_link = [ClassStore TLDeserialize:stream]; + self.foreign_link = [ClassStore TLDeserialize:stream]; + self.user = [ClassStore TLDeserialize:stream]; } --(TL_messages_chatFull *)copy { - - TL_messages_chatFull *objc = [[TL_messages_chatFull alloc] init]; +-(TL_contacts_link *)copy { - objc.full_chat = [self.full_chat copy]; - objc.chats = [self.chats copy]; - objc.users = [self.users copy]; + TL_contacts_link *objc = [[TL_contacts_link alloc] init]; - return objc; -} - --(id)initWithCoder:(NSCoder *)aDecoder { - - if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { - - } + objc.my_link = [self.my_link copy]; + objc.foreign_link = [self.foreign_link copy]; + objc.user = [self.user copy]; - return self; -} - --(void)encodeWithCoder:(NSCoder *)aCoder { - [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; + return objc; } - - - -@end - - -@implementation TLmessages_AffectedHistory -@end -@implementation TL_messages_affectedHistory -+(TL_messages_affectedHistory*)createWithPts:(int)pts pts_count:(int)pts_count offset:(int)offset { - TL_messages_affectedHistory* obj = [[TL_messages_affectedHistory alloc] init]; - obj.pts = pts; - obj.pts_count = pts_count; - obj.offset = offset; - return obj; -} --(void)serialize:(SerializedData*)stream { - [stream writeInt:self.pts]; - [stream writeInt:self.pts_count]; - [stream writeInt:self.offset]; -} --(void)unserialize:(SerializedData*)stream { - self.pts = [stream readInt]; - self.pts_count = [stream readInt]; - self.offset = [stream readInt]; -} - --(TL_messages_affectedHistory *)copy { - - TL_messages_affectedHistory *objc = [[TL_messages_affectedHistory alloc] init]; - - objc.pts = self.pts; - objc.pts_count = self.pts_count; - objc.offset = self.offset; - - return objc; -} -(id)initWithCoder:(NSCoder *)aDecoder { @@ -8485,19 +8824,18 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TLcontacts_Contacts -@implementation TLMessagesFilter @end - -@implementation TL_inputMessagesFilterEmpty -+(TL_inputMessagesFilterEmpty*)create { - TL_inputMessagesFilterEmpty* obj = [[TL_inputMessagesFilterEmpty alloc] init]; + +@implementation TL_contacts_contactsNotModified ++(TL_contacts_contactsNotModified*)create { + TL_contacts_contactsNotModified* obj = [[TL_contacts_contactsNotModified alloc] init]; return obj; } @@ -8508,14 +8846,16 @@ -(void)unserialize:(SerializedData*)stream { } --(TL_inputMessagesFilterEmpty *)copy { +-(TL_contacts_contactsNotModified *)copy { - TL_inputMessagesFilterEmpty *objc = [[TL_inputMessagesFilterEmpty alloc] init]; + TL_contacts_contactsNotModified *objc = [[TL_contacts_contactsNotModified alloc] init]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -8529,33 +8869,82 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_inputMessagesFilterPhotos -+(TL_inputMessagesFilterPhotos*)create { - TL_inputMessagesFilterPhotos* obj = [[TL_inputMessagesFilterPhotos alloc] init]; - +@implementation TL_contacts_contacts ++(TL_contacts_contacts*)createWithContacts:(NSMutableArray*)contacts users:(NSMutableArray*)users { + TL_contacts_contacts* obj = [[TL_contacts_contacts alloc] init]; + obj.contacts = contacts; + obj.users = users; return obj; } -(void)serialize:(SerializedData*)stream { - + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.contacts count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLContact* obj = [self.contacts objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.users count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLUser* obj = [self.users objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } } -(void)unserialize:(SerializedData*)stream { - + //UNS FullVector + [stream readInt]; + { + if(!self.contacts) + self.contacts = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLContact* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLContact class]]) + [self.contacts addObject:obj]; + else + break; + } + } + //UNS FullVector + [stream readInt]; + { + if(!self.users) + self.users = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLUser* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLUser class]]) + [self.users addObject:obj]; + else + break; + } + } } --(TL_inputMessagesFilterPhotos *)copy { - - TL_inputMessagesFilterPhotos *objc = [[TL_inputMessagesFilterPhotos alloc] init]; +-(TL_contacts_contacts *)copy { + TL_contacts_contacts *objc = [[TL_contacts_contacts alloc] init]; + objc.contacts = [self.contacts copy]; + objc.users = [self.users copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -8569,33 +8958,112 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_inputMessagesFilterVideo -+(TL_inputMessagesFilterVideo*)create { - TL_inputMessagesFilterVideo* obj = [[TL_inputMessagesFilterVideo alloc] init]; - +@implementation TLcontacts_ImportedContacts + +@end + +@implementation TL_contacts_importedContacts ++(TL_contacts_importedContacts*)createWithImported:(NSMutableArray*)imported retry_contacts:(NSMutableArray*)retry_contacts users:(NSMutableArray*)users { + TL_contacts_importedContacts* obj = [[TL_contacts_importedContacts alloc] init]; + obj.imported = imported; + obj.retry_contacts = retry_contacts; + obj.users = users; return obj; } -(void)serialize:(SerializedData*)stream { - + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.imported count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLImportedContact* obj = [self.imported objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + //Serialize ShortVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.retry_contacts count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + if([self.retry_contacts count] > i) { + NSNumber* obj = [self.retry_contacts objectAtIndex:i]; + [stream writeLong:[obj longValue]]; + } else + break; + } + } + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.users count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLUser* obj = [self.users objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } } -(void)unserialize:(SerializedData*)stream { - + //UNS FullVector + [stream readInt]; + { + if(!self.imported) + self.imported = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLImportedContact* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLImportedContact class]]) + [self.imported addObject:obj]; + else + break; + } + } + //UNS ShortVector + [stream readInt]; + { + if(!self.retry_contacts) + self.retry_contacts = [[NSMutableArray alloc] init]; + int tl_count = [stream readInt]; + for(int i = 0; i < tl_count; i++) { + long obj = [stream readLong]; + [self.retry_contacts addObject:@(obj)]; + } + } + //UNS FullVector + [stream readInt]; + { + if(!self.users) + self.users = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLUser* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLUser class]]) + [self.users addObject:obj]; + else + break; + } + } } --(TL_inputMessagesFilterVideo *)copy { - - TL_inputMessagesFilterVideo *objc = [[TL_inputMessagesFilterVideo alloc] init]; +-(TL_contacts_importedContacts *)copy { + TL_contacts_importedContacts *objc = [[TL_contacts_importedContacts alloc] init]; + objc.imported = [self.imported copy]; + objc.retry_contacts = [self.retry_contacts copy]; + objc.users = [self.users copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -8609,73 +9077,86 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_inputMessagesFilterPhotoVideo -+(TL_inputMessagesFilterPhotoVideo*)create { - TL_inputMessagesFilterPhotoVideo* obj = [[TL_inputMessagesFilterPhotoVideo alloc] init]; - +@implementation TLcontacts_Blocked + +@end + +@implementation TL_contacts_blocked ++(TL_contacts_blocked*)createWithBlocked:(NSMutableArray*)blocked users:(NSMutableArray*)users { + TL_contacts_blocked* obj = [[TL_contacts_blocked alloc] init]; + obj.blocked = blocked; + obj.users = users; return obj; } -(void)serialize:(SerializedData*)stream { - -} --(void)unserialize:(SerializedData*)stream { - -} - --(TL_inputMessagesFilterPhotoVideo *)copy { - - TL_inputMessagesFilterPhotoVideo *objc = [[TL_inputMessagesFilterPhotoVideo alloc] init]; - - - - return objc; -} - --(id)initWithCoder:(NSCoder *)aDecoder { - - if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { - - } - - return self; -} - --(void)encodeWithCoder:(NSCoder *)aCoder { - [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; -} - - - - -@end - -@implementation TL_inputMessagesFilterPhotoVideoDocuments -+(TL_inputMessagesFilterPhotoVideoDocuments*)create { - TL_inputMessagesFilterPhotoVideoDocuments* obj = [[TL_inputMessagesFilterPhotoVideoDocuments alloc] init]; - - return obj; -} --(void)serialize:(SerializedData*)stream { - + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.blocked count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLContactBlocked* obj = [self.blocked objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.users count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLUser* obj = [self.users objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } } -(void)unserialize:(SerializedData*)stream { - + //UNS FullVector + [stream readInt]; + { + if(!self.blocked) + self.blocked = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLContactBlocked* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLContactBlocked class]]) + [self.blocked addObject:obj]; + else + break; + } + } + //UNS FullVector + [stream readInt]; + { + if(!self.users) + self.users = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLUser* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLUser class]]) + [self.users addObject:obj]; + else + break; + } + } } --(TL_inputMessagesFilterPhotoVideoDocuments *)copy { - - TL_inputMessagesFilterPhotoVideoDocuments *objc = [[TL_inputMessagesFilterPhotoVideoDocuments alloc] init]; +-(TL_contacts_blocked *)copy { + TL_contacts_blocked *objc = [[TL_contacts_blocked alloc] init]; + objc.blocked = [self.blocked copy]; + objc.users = [self.users copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -8689,33 +9170,86 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_inputMessagesFilterDocument -+(TL_inputMessagesFilterDocument*)create { - TL_inputMessagesFilterDocument* obj = [[TL_inputMessagesFilterDocument alloc] init]; - +@implementation TL_contacts_blockedSlice ++(TL_contacts_blockedSlice*)createWithN_count:(int)n_count blocked:(NSMutableArray*)blocked users:(NSMutableArray*)users { + TL_contacts_blockedSlice* obj = [[TL_contacts_blockedSlice alloc] init]; + obj.n_count = n_count; + obj.blocked = blocked; + obj.users = users; return obj; } -(void)serialize:(SerializedData*)stream { - + [stream writeInt:self.n_count]; + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.blocked count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLContactBlocked* obj = [self.blocked objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.users count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLUser* obj = [self.users objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } } -(void)unserialize:(SerializedData*)stream { - + super.n_count = [stream readInt]; + //UNS FullVector + [stream readInt]; + { + if(!self.blocked) + self.blocked = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLContactBlocked* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLContactBlocked class]]) + [self.blocked addObject:obj]; + else + break; + } + } + //UNS FullVector + [stream readInt]; + { + if(!self.users) + self.users = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLUser* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLUser class]]) + [self.users addObject:obj]; + else + break; + } + } } --(TL_inputMessagesFilterDocument *)copy { - - TL_inputMessagesFilterDocument *objc = [[TL_inputMessagesFilterDocument alloc] init]; +-(TL_contacts_blockedSlice *)copy { + TL_contacts_blockedSlice *objc = [[TL_contacts_blockedSlice alloc] init]; + objc.n_count = self.n_count; + objc.blocked = [self.blocked copy]; + objc.users = [self.users copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -8729,33 +9263,86 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_inputMessagesFilterAudio -+(TL_inputMessagesFilterAudio*)create { - TL_inputMessagesFilterAudio* obj = [[TL_inputMessagesFilterAudio alloc] init]; - +@implementation TLcontacts_Suggested + +@end + +@implementation TL_contacts_suggested ++(TL_contacts_suggested*)createWithResults:(NSMutableArray*)results users:(NSMutableArray*)users { + TL_contacts_suggested* obj = [[TL_contacts_suggested alloc] init]; + obj.results = results; + obj.users = users; return obj; } -(void)serialize:(SerializedData*)stream { - + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.results count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLContactSuggested* obj = [self.results objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.users count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLUser* obj = [self.users objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } } -(void)unserialize:(SerializedData*)stream { - + //UNS FullVector + [stream readInt]; + { + if(!self.results) + self.results = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLContactSuggested* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLContactSuggested class]]) + [self.results addObject:obj]; + else + break; + } + } + //UNS FullVector + [stream readInt]; + { + if(!self.users) + self.users = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLUser* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLUser class]]) + [self.users addObject:obj]; + else + break; + } + } } --(TL_inputMessagesFilterAudio *)copy { - - TL_inputMessagesFilterAudio *objc = [[TL_inputMessagesFilterAudio alloc] init]; +-(TL_contacts_suggested *)copy { + TL_contacts_suggested *objc = [[TL_contacts_suggested alloc] init]; + objc.results = [self.results copy]; + objc.users = [self.users copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -8769,33 +9356,138 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_inputMessagesFilterAudioDocuments -+(TL_inputMessagesFilterAudioDocuments*)create { - TL_inputMessagesFilterAudioDocuments* obj = [[TL_inputMessagesFilterAudioDocuments alloc] init]; - +@implementation TLmessages_Dialogs + +@end + +@implementation TL_messages_dialogs ++(TL_messages_dialogs*)createWithDialogs:(NSMutableArray*)dialogs messages:(NSMutableArray*)messages chats:(NSMutableArray*)chats users:(NSMutableArray*)users { + TL_messages_dialogs* obj = [[TL_messages_dialogs alloc] init]; + obj.dialogs = dialogs; + obj.messages = messages; + obj.chats = chats; + obj.users = users; return obj; } -(void)serialize:(SerializedData*)stream { - -} + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.dialogs count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLDialog* obj = [self.dialogs objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.messages count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLMessage* obj = [self.messages objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.chats count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLChat* obj = [self.chats objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.users count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLUser* obj = [self.users objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } +} -(void)unserialize:(SerializedData*)stream { - + //UNS FullVector + [stream readInt]; + { + if(!self.dialogs) + self.dialogs = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLDialog* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLDialog class]]) + [self.dialogs addObject:obj]; + else + break; + } + } + //UNS FullVector + [stream readInt]; + { + if(!self.messages) + self.messages = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLMessage* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLMessage class]]) + [self.messages addObject:obj]; + else + break; + } + } + //UNS FullVector + [stream readInt]; + { + if(!self.chats) + self.chats = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLChat* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLChat class]]) + [self.chats addObject:obj]; + else + break; + } + } + //UNS FullVector + [stream readInt]; + { + if(!self.users) + self.users = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLUser* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLUser class]]) + [self.users addObject:obj]; + else + break; + } + } } --(TL_inputMessagesFilterAudioDocuments *)copy { - - TL_inputMessagesFilterAudioDocuments *objc = [[TL_inputMessagesFilterAudioDocuments alloc] init]; +-(TL_messages_dialogs *)copy { + TL_messages_dialogs *objc = [[TL_messages_dialogs alloc] init]; + objc.dialogs = [self.dialogs copy]; + objc.messages = [self.messages copy]; + objc.chats = [self.chats copy]; + objc.users = [self.users copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -8809,33 +9501,138 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_inputMessagesFilterUrl -+(TL_inputMessagesFilterUrl*)create { - TL_inputMessagesFilterUrl* obj = [[TL_inputMessagesFilterUrl alloc] init]; - +@implementation TL_messages_dialogsSlice ++(TL_messages_dialogsSlice*)createWithN_count:(int)n_count dialogs:(NSMutableArray*)dialogs messages:(NSMutableArray*)messages chats:(NSMutableArray*)chats users:(NSMutableArray*)users { + TL_messages_dialogsSlice* obj = [[TL_messages_dialogsSlice alloc] init]; + obj.n_count = n_count; + obj.dialogs = dialogs; + obj.messages = messages; + obj.chats = chats; + obj.users = users; return obj; } -(void)serialize:(SerializedData*)stream { - + [stream writeInt:self.n_count]; + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.dialogs count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLDialog* obj = [self.dialogs objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.messages count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLMessage* obj = [self.messages objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.chats count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLChat* obj = [self.chats objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.users count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLUser* obj = [self.users objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } } -(void)unserialize:(SerializedData*)stream { - + super.n_count = [stream readInt]; + //UNS FullVector + [stream readInt]; + { + if(!self.dialogs) + self.dialogs = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLDialog* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLDialog class]]) + [self.dialogs addObject:obj]; + else + break; + } + } + //UNS FullVector + [stream readInt]; + { + if(!self.messages) + self.messages = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLMessage* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLMessage class]]) + [self.messages addObject:obj]; + else + break; + } + } + //UNS FullVector + [stream readInt]; + { + if(!self.chats) + self.chats = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLChat* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLChat class]]) + [self.chats addObject:obj]; + else + break; + } + } + //UNS FullVector + [stream readInt]; + { + if(!self.users) + self.users = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLUser* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLUser class]]) + [self.users addObject:obj]; + else + break; + } + } } --(TL_inputMessagesFilterUrl *)copy { - - TL_inputMessagesFilterUrl *objc = [[TL_inputMessagesFilterUrl alloc] init]; +-(TL_messages_dialogsSlice *)copy { + TL_messages_dialogsSlice *objc = [[TL_messages_dialogsSlice alloc] init]; + objc.n_count = self.n_count; + objc.dialogs = [self.dialogs copy]; + objc.messages = [self.messages copy]; + objc.chats = [self.chats copy]; + objc.users = [self.users copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -8849,89 +9646,112 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TLmessages_Messages -@implementation TLUpdate @end - -@implementation TL_updateNewMessage -+(TL_updateNewMessage*)createWithMessage:(TLMessage*)message pts:(int)pts pts_count:(int)pts_count { - TL_updateNewMessage* obj = [[TL_updateNewMessage alloc] init]; - obj.message = message; - obj.pts = pts; - obj.pts_count = pts_count; + +@implementation TL_messages_messages ++(TL_messages_messages*)createWithMessages:(NSMutableArray*)messages chats:(NSMutableArray*)chats users:(NSMutableArray*)users { + TL_messages_messages* obj = [[TL_messages_messages alloc] init]; + obj.messages = messages; + obj.chats = chats; + obj.users = users; return obj; } -(void)serialize:(SerializedData*)stream { - [ClassStore TLSerialize:self.message stream:stream]; - [stream writeInt:self.pts]; - [stream writeInt:self.pts_count]; -} --(void)unserialize:(SerializedData*)stream { - self.message = [ClassStore TLDeserialize:stream]; - self.pts = [stream readInt]; - self.pts_count = [stream readInt]; -} - --(TL_updateNewMessage *)copy { - - TL_updateNewMessage *objc = [[TL_updateNewMessage alloc] init]; - - objc.message = [self.message copy]; - objc.pts = self.pts; - objc.pts_count = self.pts_count; - - return objc; -} - --(id)initWithCoder:(NSCoder *)aDecoder { - - if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { - - } - - return self; -} - --(void)encodeWithCoder:(NSCoder *)aCoder { - [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; -} - - - - -@end - -@implementation TL_updateMessageID -+(TL_updateMessageID*)createWithN_id:(int)n_id random_id:(long)random_id { - TL_updateMessageID* obj = [[TL_updateMessageID alloc] init]; - obj.n_id = n_id; - obj.random_id = random_id; - return obj; -} --(void)serialize:(SerializedData*)stream { - [stream writeInt:self.n_id]; - [stream writeLong:self.random_id]; + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.messages count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLMessage* obj = [self.messages objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.chats count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLChat* obj = [self.chats objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.users count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLUser* obj = [self.users objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readInt]; - self.random_id = [stream readLong]; + //UNS FullVector + [stream readInt]; + { + if(!self.messages) + self.messages = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLMessage* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLMessage class]]) + [self.messages addObject:obj]; + else + break; + } + } + //UNS FullVector + [stream readInt]; + { + if(!self.chats) + self.chats = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLChat* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLChat class]]) + [self.chats addObject:obj]; + else + break; + } + } + //UNS FullVector + [stream readInt]; + { + if(!self.users) + self.users = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLUser* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLUser class]]) + [self.users addObject:obj]; + else + break; + } + } } --(TL_updateMessageID *)copy { +-(TL_messages_messages *)copy { - TL_updateMessageID *objc = [[TL_updateMessageID alloc] init]; + TL_messages_messages *objc = [[TL_messages_messages alloc] init]; - objc.n_id = self.n_id; - objc.random_id = self.random_id; + objc.messages = [self.messages copy]; + objc.chats = [self.chats copy]; + objc.users = [self.users copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -8945,63 +9765,112 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_updateDeleteMessages -+(TL_updateDeleteMessages*)createWithMessages:(NSMutableArray*)messages pts:(int)pts pts_count:(int)pts_count { - TL_updateDeleteMessages* obj = [[TL_updateDeleteMessages alloc] init]; +@implementation TL_messages_messagesSlice ++(TL_messages_messagesSlice*)createWithN_count:(int)n_count messages:(NSMutableArray*)messages chats:(NSMutableArray*)chats users:(NSMutableArray*)users { + TL_messages_messagesSlice* obj = [[TL_messages_messagesSlice alloc] init]; + obj.n_count = n_count; obj.messages = messages; - obj.pts = pts; - obj.pts_count = pts_count; + obj.chats = chats; + obj.users = users; return obj; } -(void)serialize:(SerializedData*)stream { - //Serialize ShortVector + [stream writeInt:self.n_count]; + //Serialize FullVector [stream writeInt:0x1cb5c415]; { NSInteger tl_count = [self.messages count]; [stream writeInt:(int)tl_count]; for(int i = 0; i < (int)tl_count; i++) { - if([self.messages count] > i) { - NSNumber* obj = [self.messages objectAtIndex:i]; - [stream writeInt:[obj intValue]]; - } else - break; + TLMessage* obj = [self.messages objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.chats count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLChat* obj = [self.chats objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.users count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLUser* obj = [self.users objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; } } - [stream writeInt:self.pts]; - [stream writeInt:self.pts_count]; } -(void)unserialize:(SerializedData*)stream { - //UNS ShortVector + super.n_count = [stream readInt]; + //UNS FullVector [stream readInt]; { if(!self.messages) self.messages = [[NSMutableArray alloc] init]; - int tl_count = [stream readInt]; - for(int i = 0; i < tl_count; i++) { - int obj = [stream readInt]; - [self.messages addObject:@(obj)]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLMessage* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLMessage class]]) + [self.messages addObject:obj]; + else + break; + } + } + //UNS FullVector + [stream readInt]; + { + if(!self.chats) + self.chats = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLChat* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLChat class]]) + [self.chats addObject:obj]; + else + break; + } + } + //UNS FullVector + [stream readInt]; + { + if(!self.users) + self.users = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLUser* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLUser class]]) + [self.users addObject:obj]; + else + break; } } - self.pts = [stream readInt]; - self.pts_count = [stream readInt]; } --(TL_updateDeleteMessages *)copy { +-(TL_messages_messagesSlice *)copy { - TL_updateDeleteMessages *objc = [[TL_updateDeleteMessages alloc] init]; + TL_messages_messagesSlice *objc = [[TL_messages_messagesSlice alloc] init]; + objc.n_count = self.n_count; objc.messages = [self.messages copy]; - objc.pts = self.pts; - objc.pts_count = self.pts_count; + objc.chats = [self.chats copy]; + objc.users = [self.users copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -9015,85 +9884,146 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_updateUserTyping -+(TL_updateUserTyping*)createWithUser_id:(int)user_id action:(TLSendMessageAction*)action { - TL_updateUserTyping* obj = [[TL_updateUserTyping alloc] init]; - obj.user_id = user_id; - obj.action = action; +@implementation TL_messages_channelMessages ++(TL_messages_channelMessages*)createWithFlags:(int)flags pts:(int)pts n_count:(int)n_count messages:(NSMutableArray*)messages collapsed:(NSMutableArray*)collapsed chats:(NSMutableArray*)chats users:(NSMutableArray*)users { + TL_messages_channelMessages* obj = [[TL_messages_channelMessages alloc] init]; + obj.flags = flags; + obj.pts = pts; + obj.n_count = n_count; + obj.messages = messages; + obj.collapsed = collapsed; + obj.chats = chats; + obj.users = users; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.user_id]; - [ClassStore TLSerialize:self.action stream:stream]; -} --(void)unserialize:(SerializedData*)stream { - self.user_id = [stream readInt]; - self.action = [ClassStore TLDeserialize:stream]; -} - --(TL_updateUserTyping *)copy { - - TL_updateUserTyping *objc = [[TL_updateUserTyping alloc] init]; - - objc.user_id = self.user_id; - objc.action = [self.action copy]; - - return objc; -} - --(id)initWithCoder:(NSCoder *)aDecoder { - - if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { - - } - - return self; -} - --(void)encodeWithCoder:(NSCoder *)aCoder { - [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; -} - - - - -@end - -@implementation TL_updateChatUserTyping -+(TL_updateChatUserTyping*)createWithChat_id:(int)chat_id user_id:(int)user_id action:(TLSendMessageAction*)action { - TL_updateChatUserTyping* obj = [[TL_updateChatUserTyping alloc] init]; - obj.chat_id = chat_id; - obj.user_id = user_id; - obj.action = action; - return obj; -} --(void)serialize:(SerializedData*)stream { - [stream writeInt:self.chat_id]; - [stream writeInt:self.user_id]; - [ClassStore TLSerialize:self.action stream:stream]; + [stream writeInt:self.flags]; + [stream writeInt:self.pts]; + [stream writeInt:self.n_count]; + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.messages count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLMessage* obj = [self.messages objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + if(self.flags & (1 << 0)) {//Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.collapsed count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLMessageGroup* obj = [self.collapsed objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + }} + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.chats count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLChat* obj = [self.chats objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.users count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLUser* obj = [self.users objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } } -(void)unserialize:(SerializedData*)stream { - self.chat_id = [stream readInt]; - self.user_id = [stream readInt]; - self.action = [ClassStore TLDeserialize:stream]; + super.flags = [stream readInt]; + super.pts = [stream readInt]; + super.n_count = [stream readInt]; + //UNS FullVector + [stream readInt]; + { + if(!self.messages) + self.messages = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLMessage* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLMessage class]]) + [self.messages addObject:obj]; + else + break; + } + } + if(self.flags & (1 << 0)) {//UNS FullVector + [stream readInt]; + { + if(!self.collapsed) + self.collapsed = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLMessageGroup* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLMessageGroup class]]) + [self.collapsed addObject:obj]; + else + break; + } + }} + //UNS FullVector + [stream readInt]; + { + if(!self.chats) + self.chats = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLChat* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLChat class]]) + [self.chats addObject:obj]; + else + break; + } + } + //UNS FullVector + [stream readInt]; + { + if(!self.users) + self.users = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLUser* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLUser class]]) + [self.users addObject:obj]; + else + break; + } + } } --(TL_updateChatUserTyping *)copy { +-(TL_messages_channelMessages *)copy { - TL_updateChatUserTyping *objc = [[TL_updateChatUserTyping alloc] init]; + TL_messages_channelMessages *objc = [[TL_messages_channelMessages alloc] init]; - objc.chat_id = self.chat_id; - objc.user_id = self.user_id; - objc.action = [self.action copy]; + objc.flags = self.flags; + objc.pts = self.pts; + objc.n_count = self.n_count; + objc.messages = [self.messages copy]; + objc.collapsed = [self.collapsed copy]; + objc.chats = [self.chats copy]; + objc.users = [self.users copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -9107,33 +10037,66 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - - + +-(void)setCollapsed:(NSMutableArray*)collapsed +{ + super.collapsed = collapsed; + + if(super.collapsed == nil) { super.flags&= ~ (1 << 0) ;} else { super.flags|= (1 << 0); } +} @end -@implementation TL_updateChatParticipants -+(TL_updateChatParticipants*)createWithParticipants:(TLChatParticipants*)participants { - TL_updateChatParticipants* obj = [[TL_updateChatParticipants alloc] init]; - obj.participants = participants; +@implementation TLmessages_Chats + +@end + +@implementation TL_messages_chats ++(TL_messages_chats*)createWithChats:(NSMutableArray*)chats { + TL_messages_chats* obj = [[TL_messages_chats alloc] init]; + obj.chats = chats; return obj; } -(void)serialize:(SerializedData*)stream { - [ClassStore TLSerialize:self.participants stream:stream]; + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.chats count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLChat* obj = [self.chats objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } } -(void)unserialize:(SerializedData*)stream { - self.participants = [ClassStore TLDeserialize:stream]; + //UNS FullVector + [stream readInt]; + { + if(!self.chats) + self.chats = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLChat* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLChat class]]) + [self.chats addObject:obj]; + else + break; + } + } } --(TL_updateChatParticipants *)copy { +-(TL_messages_chats *)copy { - TL_updateChatParticipants *objc = [[TL_updateChatParticipants alloc] init]; + TL_messages_chats *objc = [[TL_messages_chats alloc] init]; - objc.participants = [self.participants copy]; + objc.chats = [self.chats copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -9147,37 +10110,90 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_updateUserStatus -+(TL_updateUserStatus*)createWithUser_id:(int)user_id status:(TLUserStatus*)status { - TL_updateUserStatus* obj = [[TL_updateUserStatus alloc] init]; - obj.user_id = user_id; - obj.status = status; +@implementation TLmessages_ChatFull + +@end + +@implementation TL_messages_chatFull ++(TL_messages_chatFull*)createWithFull_chat:(TLChatFull*)full_chat chats:(NSMutableArray*)chats users:(NSMutableArray*)users { + TL_messages_chatFull* obj = [[TL_messages_chatFull alloc] init]; + obj.full_chat = full_chat; + obj.chats = chats; + obj.users = users; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.user_id]; - [ClassStore TLSerialize:self.status stream:stream]; + [ClassStore TLSerialize:self.full_chat stream:stream]; + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.chats count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLChat* obj = [self.chats objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.users count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLUser* obj = [self.users objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } } -(void)unserialize:(SerializedData*)stream { - self.user_id = [stream readInt]; - self.status = [ClassStore TLDeserialize:stream]; + self.full_chat = [ClassStore TLDeserialize:stream]; + //UNS FullVector + [stream readInt]; + { + if(!self.chats) + self.chats = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLChat* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLChat class]]) + [self.chats addObject:obj]; + else + break; + } + } + //UNS FullVector + [stream readInt]; + { + if(!self.users) + self.users = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLUser* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLUser class]]) + [self.users addObject:obj]; + else + break; + } + } } --(TL_updateUserStatus *)copy { +-(TL_messages_chatFull *)copy { - TL_updateUserStatus *objc = [[TL_updateUserStatus alloc] init]; + TL_messages_chatFull *objc = [[TL_messages_chatFull alloc] init]; - objc.user_id = self.user_id; - objc.status = [self.status copy]; + objc.full_chat = [self.full_chat copy]; + objc.chats = [self.chats copy]; + objc.users = [self.users copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -9191,45 +10207,46 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_updateUserName -+(TL_updateUserName*)createWithUser_id:(int)user_id first_name:(NSString*)first_name last_name:(NSString*)last_name username:(NSString*)username { - TL_updateUserName* obj = [[TL_updateUserName alloc] init]; - obj.user_id = user_id; - obj.first_name = first_name; - obj.last_name = last_name; - obj.username = username; +@implementation TLmessages_AffectedHistory + +@end + +@implementation TL_messages_affectedHistory ++(TL_messages_affectedHistory*)createWithPts:(int)pts pts_count:(int)pts_count offset:(int)offset { + TL_messages_affectedHistory* obj = [[TL_messages_affectedHistory alloc] init]; + obj.pts = pts; + obj.pts_count = pts_count; + obj.offset = offset; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.user_id]; - [stream writeString:self.first_name]; - [stream writeString:self.last_name]; - [stream writeString:self.username]; + [stream writeInt:self.pts]; + [stream writeInt:self.pts_count]; + [stream writeInt:self.offset]; } -(void)unserialize:(SerializedData*)stream { - self.user_id = [stream readInt]; - self.first_name = [stream readString]; - self.last_name = [stream readString]; - self.username = [stream readString]; + super.pts = [stream readInt]; + super.pts_count = [stream readInt]; + super.offset = [stream readInt]; } --(TL_updateUserName *)copy { +-(TL_messages_affectedHistory *)copy { - TL_updateUserName *objc = [[TL_updateUserName alloc] init]; + TL_messages_affectedHistory *objc = [[TL_messages_affectedHistory alloc] init]; - objc.user_id = self.user_id; - objc.first_name = self.first_name; - objc.last_name = self.last_name; - objc.username = self.username; + objc.pts = self.pts; + objc.pts_count = self.pts_count; + objc.offset = self.offset; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -9243,45 +10260,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_updateUserPhoto -+(TL_updateUserPhoto*)createWithUser_id:(int)user_id date:(int)date photo:(TLUserProfilePhoto*)photo previous:(Boolean)previous { - TL_updateUserPhoto* obj = [[TL_updateUserPhoto alloc] init]; - obj.user_id = user_id; - obj.date = date; - obj.photo = photo; - obj.previous = previous; +@implementation TLMessagesFilter + +@end + +@implementation TL_inputMessagesFilterEmpty ++(TL_inputMessagesFilterEmpty*)create { + TL_inputMessagesFilterEmpty* obj = [[TL_inputMessagesFilterEmpty alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.user_id]; - [stream writeInt:self.date]; - [ClassStore TLSerialize:self.photo stream:stream]; - [stream writeBool:self.previous]; + } -(void)unserialize:(SerializedData*)stream { - self.user_id = [stream readInt]; - self.date = [stream readInt]; - self.photo = [ClassStore TLDeserialize:stream]; - self.previous = [stream readBool]; + } --(TL_updateUserPhoto *)copy { +-(TL_inputMessagesFilterEmpty *)copy { + + TL_inputMessagesFilterEmpty *objc = [[TL_inputMessagesFilterEmpty alloc] init]; - TL_updateUserPhoto *objc = [[TL_updateUserPhoto alloc] init]; - objc.user_id = self.user_id; - objc.date = self.date; - objc.photo = [self.photo copy]; - objc.previous = self.previous; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -9295,37 +10305,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_updateContactRegistered -+(TL_updateContactRegistered*)createWithUser_id:(int)user_id date:(int)date { - TL_updateContactRegistered* obj = [[TL_updateContactRegistered alloc] init]; - obj.user_id = user_id; - obj.date = date; +@implementation TL_inputMessagesFilterPhotos ++(TL_inputMessagesFilterPhotos*)create { + TL_inputMessagesFilterPhotos* obj = [[TL_inputMessagesFilterPhotos alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.user_id]; - [stream writeInt:self.date]; + } -(void)unserialize:(SerializedData*)stream { - self.user_id = [stream readInt]; - self.date = [stream readInt]; + } --(TL_updateContactRegistered *)copy { +-(TL_inputMessagesFilterPhotos *)copy { + + TL_inputMessagesFilterPhotos *objc = [[TL_inputMessagesFilterPhotos alloc] init]; - TL_updateContactRegistered *objc = [[TL_updateContactRegistered alloc] init]; - objc.user_id = self.user_id; - objc.date = self.date; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -9339,41 +10346,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_updateContactLink -+(TL_updateContactLink*)createWithUser_id:(int)user_id my_link:(TLContactLink*)my_link foreign_link:(TLContactLink*)foreign_link { - TL_updateContactLink* obj = [[TL_updateContactLink alloc] init]; - obj.user_id = user_id; - obj.my_link = my_link; - obj.foreign_link = foreign_link; +@implementation TL_inputMessagesFilterVideo ++(TL_inputMessagesFilterVideo*)create { + TL_inputMessagesFilterVideo* obj = [[TL_inputMessagesFilterVideo alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.user_id]; - [ClassStore TLSerialize:self.my_link stream:stream]; - [ClassStore TLSerialize:self.foreign_link stream:stream]; + } -(void)unserialize:(SerializedData*)stream { - self.user_id = [stream readInt]; - self.my_link = [ClassStore TLDeserialize:stream]; - self.foreign_link = [ClassStore TLDeserialize:stream]; + } --(TL_updateContactLink *)copy { +-(TL_inputMessagesFilterVideo *)copy { + + TL_inputMessagesFilterVideo *objc = [[TL_inputMessagesFilterVideo alloc] init]; - TL_updateContactLink *objc = [[TL_updateContactLink alloc] init]; - objc.user_id = self.user_id; - objc.my_link = [self.my_link copy]; - objc.foreign_link = [self.foreign_link copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -9387,45 +10387,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_updateNewAuthorization -+(TL_updateNewAuthorization*)createWithAuth_key_id:(long)auth_key_id date:(int)date device:(NSString*)device location:(NSString*)location { - TL_updateNewAuthorization* obj = [[TL_updateNewAuthorization alloc] init]; - obj.auth_key_id = auth_key_id; - obj.date = date; - obj.device = device; - obj.location = location; +@implementation TL_inputMessagesFilterPhotoVideo ++(TL_inputMessagesFilterPhotoVideo*)create { + TL_inputMessagesFilterPhotoVideo* obj = [[TL_inputMessagesFilterPhotoVideo alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeLong:self.auth_key_id]; - [stream writeInt:self.date]; - [stream writeString:self.device]; - [stream writeString:self.location]; + } -(void)unserialize:(SerializedData*)stream { - self.auth_key_id = [stream readLong]; - self.date = [stream readInt]; - self.device = [stream readString]; - self.location = [stream readString]; + } --(TL_updateNewAuthorization *)copy { +-(TL_inputMessagesFilterPhotoVideo *)copy { + + TL_inputMessagesFilterPhotoVideo *objc = [[TL_inputMessagesFilterPhotoVideo alloc] init]; - TL_updateNewAuthorization *objc = [[TL_updateNewAuthorization alloc] init]; - objc.auth_key_id = self.auth_key_id; - objc.date = self.date; - objc.device = self.device; - objc.location = self.location; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -9439,33 +10428,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_updateNewGeoChatMessage -+(TL_updateNewGeoChatMessage*)createWithMessage:(TLGeoChatMessage*)message { - TL_updateNewGeoChatMessage* obj = [[TL_updateNewGeoChatMessage alloc] init]; - obj.message = message; +@implementation TL_inputMessagesFilterPhotoVideoDocuments ++(TL_inputMessagesFilterPhotoVideoDocuments*)create { + TL_inputMessagesFilterPhotoVideoDocuments* obj = [[TL_inputMessagesFilterPhotoVideoDocuments alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [ClassStore TLSerialize:self.message stream:stream]; + } -(void)unserialize:(SerializedData*)stream { - self.message = [ClassStore TLDeserialize:stream]; + } --(TL_updateNewGeoChatMessage *)copy { +-(TL_inputMessagesFilterPhotoVideoDocuments *)copy { + + TL_inputMessagesFilterPhotoVideoDocuments *objc = [[TL_inputMessagesFilterPhotoVideoDocuments alloc] init]; - TL_updateNewGeoChatMessage *objc = [[TL_updateNewGeoChatMessage alloc] init]; - objc.message = [self.message copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -9479,37 +10469,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_updateNewEncryptedMessage -+(TL_updateNewEncryptedMessage*)createWithMessage:(TLEncryptedMessage*)message qts:(int)qts { - TL_updateNewEncryptedMessage* obj = [[TL_updateNewEncryptedMessage alloc] init]; - obj.message = message; - obj.qts = qts; +@implementation TL_inputMessagesFilterDocument ++(TL_inputMessagesFilterDocument*)create { + TL_inputMessagesFilterDocument* obj = [[TL_inputMessagesFilterDocument alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [ClassStore TLSerialize:self.message stream:stream]; - [stream writeInt:self.qts]; + } -(void)unserialize:(SerializedData*)stream { - self.message = [ClassStore TLDeserialize:stream]; - self.qts = [stream readInt]; + } --(TL_updateNewEncryptedMessage *)copy { +-(TL_inputMessagesFilterDocument *)copy { + + TL_inputMessagesFilterDocument *objc = [[TL_inputMessagesFilterDocument alloc] init]; - TL_updateNewEncryptedMessage *objc = [[TL_updateNewEncryptedMessage alloc] init]; - objc.message = [self.message copy]; - objc.qts = self.qts; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -9523,33 +10510,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_updateEncryptedChatTyping -+(TL_updateEncryptedChatTyping*)createWithChat_id:(int)chat_id { - TL_updateEncryptedChatTyping* obj = [[TL_updateEncryptedChatTyping alloc] init]; - obj.chat_id = chat_id; +@implementation TL_inputMessagesFilterAudio ++(TL_inputMessagesFilterAudio*)create { + TL_inputMessagesFilterAudio* obj = [[TL_inputMessagesFilterAudio alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.chat_id]; + } -(void)unserialize:(SerializedData*)stream { - self.chat_id = [stream readInt]; + } --(TL_updateEncryptedChatTyping *)copy { +-(TL_inputMessagesFilterAudio *)copy { + + TL_inputMessagesFilterAudio *objc = [[TL_inputMessagesFilterAudio alloc] init]; - TL_updateEncryptedChatTyping *objc = [[TL_updateEncryptedChatTyping alloc] init]; - objc.chat_id = self.chat_id; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -9563,37 +10551,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_updateEncryption -+(TL_updateEncryption*)createWithChat:(TLEncryptedChat*)chat date:(int)date { - TL_updateEncryption* obj = [[TL_updateEncryption alloc] init]; - obj.chat = chat; - obj.date = date; +@implementation TL_inputMessagesFilterAudioDocuments ++(TL_inputMessagesFilterAudioDocuments*)create { + TL_inputMessagesFilterAudioDocuments* obj = [[TL_inputMessagesFilterAudioDocuments alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [ClassStore TLSerialize:self.chat stream:stream]; - [stream writeInt:self.date]; + } -(void)unserialize:(SerializedData*)stream { - self.chat = [ClassStore TLDeserialize:stream]; - self.date = [stream readInt]; + } --(TL_updateEncryption *)copy { +-(TL_inputMessagesFilterAudioDocuments *)copy { + + TL_inputMessagesFilterAudioDocuments *objc = [[TL_inputMessagesFilterAudioDocuments alloc] init]; - TL_updateEncryption *objc = [[TL_updateEncryption alloc] init]; - objc.chat = [self.chat copy]; - objc.date = self.date; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -9607,41 +10592,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_updateEncryptedMessagesRead -+(TL_updateEncryptedMessagesRead*)createWithChat_id:(int)chat_id max_date:(int)max_date date:(int)date { - TL_updateEncryptedMessagesRead* obj = [[TL_updateEncryptedMessagesRead alloc] init]; - obj.chat_id = chat_id; - obj.max_date = max_date; - obj.date = date; +@implementation TL_inputMessagesFilterUrl ++(TL_inputMessagesFilterUrl*)create { + TL_inputMessagesFilterUrl* obj = [[TL_inputMessagesFilterUrl alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.chat_id]; - [stream writeInt:self.max_date]; - [stream writeInt:self.date]; + } -(void)unserialize:(SerializedData*)stream { - self.chat_id = [stream readInt]; - self.max_date = [stream readInt]; - self.date = [stream readInt]; + } --(TL_updateEncryptedMessagesRead *)copy { +-(TL_inputMessagesFilterUrl *)copy { + + TL_inputMessagesFilterUrl *objc = [[TL_inputMessagesFilterUrl alloc] init]; - TL_updateEncryptedMessagesRead *objc = [[TL_updateEncryptedMessagesRead alloc] init]; - objc.chat_id = self.chat_id; - objc.max_date = self.max_date; - objc.date = self.date; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -9655,45 +10633,46 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_updateChatParticipantAdd -+(TL_updateChatParticipantAdd*)createWithChat_id:(int)chat_id user_id:(int)user_id inviter_id:(int)inviter_id version:(int)version { - TL_updateChatParticipantAdd* obj = [[TL_updateChatParticipantAdd alloc] init]; - obj.chat_id = chat_id; - obj.user_id = user_id; - obj.inviter_id = inviter_id; - obj.version = version; +@implementation TLUpdate + +@end + +@implementation TL_updateNewMessage ++(TL_updateNewMessage*)createWithMessage:(TLMessage*)message pts:(int)pts pts_count:(int)pts_count { + TL_updateNewMessage* obj = [[TL_updateNewMessage alloc] init]; + obj.message = message; + obj.pts = pts; + obj.pts_count = pts_count; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.chat_id]; - [stream writeInt:self.user_id]; - [stream writeInt:self.inviter_id]; - [stream writeInt:self.version]; + [ClassStore TLSerialize:self.message stream:stream]; + [stream writeInt:self.pts]; + [stream writeInt:self.pts_count]; } -(void)unserialize:(SerializedData*)stream { - self.chat_id = [stream readInt]; - self.user_id = [stream readInt]; - self.inviter_id = [stream readInt]; - self.version = [stream readInt]; + self.message = [ClassStore TLDeserialize:stream]; + super.pts = [stream readInt]; + super.pts_count = [stream readInt]; } --(TL_updateChatParticipantAdd *)copy { +-(TL_updateNewMessage *)copy { - TL_updateChatParticipantAdd *objc = [[TL_updateChatParticipantAdd alloc] init]; + TL_updateNewMessage *objc = [[TL_updateNewMessage alloc] init]; - objc.chat_id = self.chat_id; - objc.user_id = self.user_id; - objc.inviter_id = self.inviter_id; - objc.version = self.version; + objc.message = [self.message copy]; + objc.pts = self.pts; + objc.pts_count = self.pts_count; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -9707,41 +10686,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_updateChatParticipantDelete -+(TL_updateChatParticipantDelete*)createWithChat_id:(int)chat_id user_id:(int)user_id version:(int)version { - TL_updateChatParticipantDelete* obj = [[TL_updateChatParticipantDelete alloc] init]; - obj.chat_id = chat_id; - obj.user_id = user_id; - obj.version = version; +@implementation TL_updateMessageID ++(TL_updateMessageID*)createWithN_id:(int)n_id random_id:(long)random_id { + TL_updateMessageID* obj = [[TL_updateMessageID alloc] init]; + obj.n_id = n_id; + obj.random_id = random_id; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.chat_id]; - [stream writeInt:self.user_id]; - [stream writeInt:self.version]; + [stream writeInt:self.n_id]; + [stream writeLong:self.random_id]; } -(void)unserialize:(SerializedData*)stream { - self.chat_id = [stream readInt]; - self.user_id = [stream readInt]; - self.version = [stream readInt]; + super.n_id = [stream readInt]; + super.random_id = [stream readLong]; } --(TL_updateChatParticipantDelete *)copy { +-(TL_updateMessageID *)copy { - TL_updateChatParticipantDelete *objc = [[TL_updateChatParticipantDelete alloc] init]; + TL_updateMessageID *objc = [[TL_updateMessageID alloc] init]; - objc.chat_id = self.chat_id; - objc.user_id = self.user_id; - objc.version = self.version; + objc.n_id = self.n_id; + objc.random_id = self.random_id; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -9755,55 +10731,64 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_updateDcOptions -+(TL_updateDcOptions*)createWithDc_options:(NSMutableArray*)dc_options { - TL_updateDcOptions* obj = [[TL_updateDcOptions alloc] init]; - obj.dc_options = dc_options; +@implementation TL_updateDeleteMessages ++(TL_updateDeleteMessages*)createWithMessages:(NSMutableArray*)messages pts:(int)pts pts_count:(int)pts_count { + TL_updateDeleteMessages* obj = [[TL_updateDeleteMessages alloc] init]; + obj.messages = messages; + obj.pts = pts; + obj.pts_count = pts_count; return obj; } -(void)serialize:(SerializedData*)stream { - //Serialize FullVector + //Serialize ShortVector [stream writeInt:0x1cb5c415]; { - NSInteger tl_count = [self.dc_options count]; + NSInteger tl_count = [self.messages count]; [stream writeInt:(int)tl_count]; for(int i = 0; i < (int)tl_count; i++) { - TLDcOption* obj = [self.dc_options objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; + if([self.messages count] > i) { + NSNumber* obj = [self.messages objectAtIndex:i]; + [stream writeInt:[obj intValue]]; + } else + break; } } + [stream writeInt:self.pts]; + [stream writeInt:self.pts_count]; } -(void)unserialize:(SerializedData*)stream { - //UNS FullVector + //UNS ShortVector [stream readInt]; { - if(!self.dc_options) - self.dc_options = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLDcOption* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLDcOption class]]) - [self.dc_options addObject:obj]; - else - break; + if(!self.messages) + self.messages = [[NSMutableArray alloc] init]; + int tl_count = [stream readInt]; + for(int i = 0; i < tl_count; i++) { + int obj = [stream readInt]; + [self.messages addObject:@(obj)]; } } + super.pts = [stream readInt]; + super.pts_count = [stream readInt]; } --(TL_updateDcOptions *)copy { +-(TL_updateDeleteMessages *)copy { - TL_updateDcOptions *objc = [[TL_updateDcOptions alloc] init]; + TL_updateDeleteMessages *objc = [[TL_updateDeleteMessages alloc] init]; - objc.dc_options = [self.dc_options copy]; + objc.messages = [self.messages copy]; + objc.pts = self.pts; + objc.pts_count = self.pts_count; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -9817,37 +10802,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_updateUserBlocked -+(TL_updateUserBlocked*)createWithUser_id:(int)user_id blocked:(Boolean)blocked { - TL_updateUserBlocked* obj = [[TL_updateUserBlocked alloc] init]; +@implementation TL_updateUserTyping ++(TL_updateUserTyping*)createWithUser_id:(int)user_id action:(TLSendMessageAction*)action { + TL_updateUserTyping* obj = [[TL_updateUserTyping alloc] init]; obj.user_id = user_id; - obj.blocked = blocked; + obj.action = action; return obj; } -(void)serialize:(SerializedData*)stream { [stream writeInt:self.user_id]; - [stream writeBool:self.blocked]; + [ClassStore TLSerialize:self.action stream:stream]; } -(void)unserialize:(SerializedData*)stream { - self.user_id = [stream readInt]; - self.blocked = [stream readBool]; + super.user_id = [stream readInt]; + self.action = [ClassStore TLDeserialize:stream]; } --(TL_updateUserBlocked *)copy { +-(TL_updateUserTyping *)copy { - TL_updateUserBlocked *objc = [[TL_updateUserBlocked alloc] init]; + TL_updateUserTyping *objc = [[TL_updateUserTyping alloc] init]; objc.user_id = self.user_id; - objc.blocked = self.blocked; + objc.action = [self.action copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -9861,37 +10847,42 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_updateNotifySettings -+(TL_updateNotifySettings*)createWithPeer:(TLNotifyPeer*)peer notify_settings:(TLPeerNotifySettings*)notify_settings { - TL_updateNotifySettings* obj = [[TL_updateNotifySettings alloc] init]; - obj.peer = peer; - obj.notify_settings = notify_settings; +@implementation TL_updateChatUserTyping ++(TL_updateChatUserTyping*)createWithChat_id:(int)chat_id user_id:(int)user_id action:(TLSendMessageAction*)action { + TL_updateChatUserTyping* obj = [[TL_updateChatUserTyping alloc] init]; + obj.chat_id = chat_id; + obj.user_id = user_id; + obj.action = action; return obj; } -(void)serialize:(SerializedData*)stream { - [ClassStore TLSerialize:self.peer stream:stream]; - [ClassStore TLSerialize:self.notify_settings stream:stream]; + [stream writeInt:self.chat_id]; + [stream writeInt:self.user_id]; + [ClassStore TLSerialize:self.action stream:stream]; } -(void)unserialize:(SerializedData*)stream { - self.peer = [ClassStore TLDeserialize:stream]; - self.notify_settings = [ClassStore TLDeserialize:stream]; + super.chat_id = [stream readInt]; + super.user_id = [stream readInt]; + self.action = [ClassStore TLDeserialize:stream]; } --(TL_updateNotifySettings *)copy { +-(TL_updateChatUserTyping *)copy { - TL_updateNotifySettings *objc = [[TL_updateNotifySettings alloc] init]; + TL_updateChatUserTyping *objc = [[TL_updateChatUserTyping alloc] init]; - objc.peer = [self.peer copy]; - objc.notify_settings = [self.notify_settings copy]; + objc.chat_id = self.chat_id; + objc.user_id = self.user_id; + objc.action = [self.action copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -9905,45 +10896,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_updateServiceNotification -+(TL_updateServiceNotification*)createWithType:(NSString*)type message:(NSString*)message media:(TLMessageMedia*)media popup:(Boolean)popup { - TL_updateServiceNotification* obj = [[TL_updateServiceNotification alloc] init]; - obj.type = type; - obj.message = message; - obj.media = media; - obj.popup = popup; +@implementation TL_updateChatParticipants ++(TL_updateChatParticipants*)createWithParticipants:(TLChatParticipants*)participants { + TL_updateChatParticipants* obj = [[TL_updateChatParticipants alloc] init]; + obj.participants = participants; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeString:self.type]; - [stream writeString:self.message]; - [ClassStore TLSerialize:self.media stream:stream]; - [stream writeBool:self.popup]; + [ClassStore TLSerialize:self.participants stream:stream]; } -(void)unserialize:(SerializedData*)stream { - self.type = [stream readString]; - self.message = [stream readString]; - self.media = [ClassStore TLDeserialize:stream]; - self.popup = [stream readBool]; + self.participants = [ClassStore TLDeserialize:stream]; } --(TL_updateServiceNotification *)copy { +-(TL_updateChatParticipants *)copy { - TL_updateServiceNotification *objc = [[TL_updateServiceNotification alloc] init]; + TL_updateChatParticipants *objc = [[TL_updateChatParticipants alloc] init]; - objc.type = self.type; - objc.message = self.message; - objc.media = [self.media copy]; - objc.popup = self.popup; + objc.participants = [self.participants copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -9957,59 +10937,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_updatePrivacy -+(TL_updatePrivacy*)createWithN_key:(TLPrivacyKey*)n_key rules:(NSMutableArray*)rules { - TL_updatePrivacy* obj = [[TL_updatePrivacy alloc] init]; - obj.n_key = n_key; - obj.rules = rules; +@implementation TL_updateUserStatus ++(TL_updateUserStatus*)createWithUser_id:(int)user_id status:(TLUserStatus*)status { + TL_updateUserStatus* obj = [[TL_updateUserStatus alloc] init]; + obj.user_id = user_id; + obj.status = status; return obj; } -(void)serialize:(SerializedData*)stream { - [ClassStore TLSerialize:self.n_key stream:stream]; - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.rules count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLPrivacyRule* obj = [self.rules objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } + [stream writeInt:self.user_id]; + [ClassStore TLSerialize:self.status stream:stream]; } -(void)unserialize:(SerializedData*)stream { - self.n_key = [ClassStore TLDeserialize:stream]; - //UNS FullVector - [stream readInt]; - { - if(!self.rules) - self.rules = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLPrivacyRule* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLPrivacyRule class]]) - [self.rules addObject:obj]; - else - break; - } - } + super.user_id = [stream readInt]; + self.status = [ClassStore TLDeserialize:stream]; } --(TL_updatePrivacy *)copy { +-(TL_updateUserStatus *)copy { - TL_updatePrivacy *objc = [[TL_updatePrivacy alloc] init]; + TL_updateUserStatus *objc = [[TL_updateUserStatus alloc] init]; - objc.n_key = [self.n_key copy]; - objc.rules = [self.rules copy]; + objc.user_id = self.user_id; + objc.status = [self.status copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -10023,37 +10982,46 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_updateUserPhone -+(TL_updateUserPhone*)createWithUser_id:(int)user_id phone:(NSString*)phone { - TL_updateUserPhone* obj = [[TL_updateUserPhone alloc] init]; +@implementation TL_updateUserName ++(TL_updateUserName*)createWithUser_id:(int)user_id first_name:(NSString*)first_name last_name:(NSString*)last_name username:(NSString*)username { + TL_updateUserName* obj = [[TL_updateUserName alloc] init]; obj.user_id = user_id; - obj.phone = phone; + obj.first_name = first_name; + obj.last_name = last_name; + obj.username = username; return obj; } -(void)serialize:(SerializedData*)stream { [stream writeInt:self.user_id]; - [stream writeString:self.phone]; + [stream writeString:self.first_name]; + [stream writeString:self.last_name]; + [stream writeString:self.username]; } -(void)unserialize:(SerializedData*)stream { - self.user_id = [stream readInt]; - self.phone = [stream readString]; + super.user_id = [stream readInt]; + super.first_name = [stream readString]; + super.last_name = [stream readString]; + super.username = [stream readString]; } --(TL_updateUserPhone *)copy { +-(TL_updateUserName *)copy { - TL_updateUserPhone *objc = [[TL_updateUserPhone alloc] init]; + TL_updateUserName *objc = [[TL_updateUserName alloc] init]; objc.user_id = self.user_id; - objc.phone = self.phone; + objc.first_name = self.first_name; + objc.last_name = self.last_name; + objc.username = self.username; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -10067,45 +11035,46 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_updateReadHistoryInbox -+(TL_updateReadHistoryInbox*)createWithPeer:(TLPeer*)peer max_id:(int)max_id pts:(int)pts pts_count:(int)pts_count { - TL_updateReadHistoryInbox* obj = [[TL_updateReadHistoryInbox alloc] init]; - obj.peer = peer; - obj.max_id = max_id; - obj.pts = pts; - obj.pts_count = pts_count; +@implementation TL_updateUserPhoto ++(TL_updateUserPhoto*)createWithUser_id:(int)user_id date:(int)date photo:(TLUserProfilePhoto*)photo previous:(Boolean)previous { + TL_updateUserPhoto* obj = [[TL_updateUserPhoto alloc] init]; + obj.user_id = user_id; + obj.date = date; + obj.photo = photo; + obj.previous = previous; return obj; } -(void)serialize:(SerializedData*)stream { - [ClassStore TLSerialize:self.peer stream:stream]; - [stream writeInt:self.max_id]; - [stream writeInt:self.pts]; - [stream writeInt:self.pts_count]; + [stream writeInt:self.user_id]; + [stream writeInt:self.date]; + [ClassStore TLSerialize:self.photo stream:stream]; + [stream writeBool:self.previous]; } -(void)unserialize:(SerializedData*)stream { - self.peer = [ClassStore TLDeserialize:stream]; - self.max_id = [stream readInt]; - self.pts = [stream readInt]; - self.pts_count = [stream readInt]; + super.user_id = [stream readInt]; + super.date = [stream readInt]; + self.photo = [ClassStore TLDeserialize:stream]; + super.previous = [stream readBool]; } --(TL_updateReadHistoryInbox *)copy { +-(TL_updateUserPhoto *)copy { - TL_updateReadHistoryInbox *objc = [[TL_updateReadHistoryInbox alloc] init]; + TL_updateUserPhoto *objc = [[TL_updateUserPhoto alloc] init]; - objc.peer = [self.peer copy]; - objc.max_id = self.max_id; - objc.pts = self.pts; - objc.pts_count = self.pts_count; + objc.user_id = self.user_id; + objc.date = self.date; + objc.photo = [self.photo copy]; + objc.previous = self.previous; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -10119,45 +11088,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_updateReadHistoryOutbox -+(TL_updateReadHistoryOutbox*)createWithPeer:(TLPeer*)peer max_id:(int)max_id pts:(int)pts pts_count:(int)pts_count { - TL_updateReadHistoryOutbox* obj = [[TL_updateReadHistoryOutbox alloc] init]; - obj.peer = peer; - obj.max_id = max_id; - obj.pts = pts; - obj.pts_count = pts_count; +@implementation TL_updateContactRegistered ++(TL_updateContactRegistered*)createWithUser_id:(int)user_id date:(int)date { + TL_updateContactRegistered* obj = [[TL_updateContactRegistered alloc] init]; + obj.user_id = user_id; + obj.date = date; return obj; } -(void)serialize:(SerializedData*)stream { - [ClassStore TLSerialize:self.peer stream:stream]; - [stream writeInt:self.max_id]; - [stream writeInt:self.pts]; - [stream writeInt:self.pts_count]; + [stream writeInt:self.user_id]; + [stream writeInt:self.date]; } -(void)unserialize:(SerializedData*)stream { - self.peer = [ClassStore TLDeserialize:stream]; - self.max_id = [stream readInt]; - self.pts = [stream readInt]; - self.pts_count = [stream readInt]; + super.user_id = [stream readInt]; + super.date = [stream readInt]; } --(TL_updateReadHistoryOutbox *)copy { +-(TL_updateContactRegistered *)copy { - TL_updateReadHistoryOutbox *objc = [[TL_updateReadHistoryOutbox alloc] init]; + TL_updateContactRegistered *objc = [[TL_updateContactRegistered alloc] init]; - objc.peer = [self.peer copy]; - objc.max_id = self.max_id; - objc.pts = self.pts; - objc.pts_count = self.pts_count; + objc.user_id = self.user_id; + objc.date = self.date; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -10171,33 +11133,42 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_updateWebPage -+(TL_updateWebPage*)createWithWebpage:(TLWebPage*)webpage { - TL_updateWebPage* obj = [[TL_updateWebPage alloc] init]; - obj.webpage = webpage; +@implementation TL_updateContactLink ++(TL_updateContactLink*)createWithUser_id:(int)user_id my_link:(TLContactLink*)my_link foreign_link:(TLContactLink*)foreign_link { + TL_updateContactLink* obj = [[TL_updateContactLink alloc] init]; + obj.user_id = user_id; + obj.my_link = my_link; + obj.foreign_link = foreign_link; return obj; } -(void)serialize:(SerializedData*)stream { - [ClassStore TLSerialize:self.webpage stream:stream]; + [stream writeInt:self.user_id]; + [ClassStore TLSerialize:self.my_link stream:stream]; + [ClassStore TLSerialize:self.foreign_link stream:stream]; } -(void)unserialize:(SerializedData*)stream { - self.webpage = [ClassStore TLDeserialize:stream]; + super.user_id = [stream readInt]; + self.my_link = [ClassStore TLDeserialize:stream]; + self.foreign_link = [ClassStore TLDeserialize:stream]; } --(TL_updateWebPage *)copy { +-(TL_updateContactLink *)copy { - TL_updateWebPage *objc = [[TL_updateWebPage alloc] init]; + TL_updateContactLink *objc = [[TL_updateContactLink alloc] init]; - objc.webpage = [self.webpage copy]; + objc.user_id = self.user_id; + objc.my_link = [self.my_link copy]; + objc.foreign_link = [self.foreign_link copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -10211,63 +11182,46 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_updateReadMessagesContents -+(TL_updateReadMessagesContents*)createWithMessages:(NSMutableArray*)messages pts:(int)pts pts_count:(int)pts_count { - TL_updateReadMessagesContents* obj = [[TL_updateReadMessagesContents alloc] init]; - obj.messages = messages; - obj.pts = pts; - obj.pts_count = pts_count; +@implementation TL_updateNewAuthorization ++(TL_updateNewAuthorization*)createWithAuth_key_id:(long)auth_key_id date:(int)date device:(NSString*)device location:(NSString*)location { + TL_updateNewAuthorization* obj = [[TL_updateNewAuthorization alloc] init]; + obj.auth_key_id = auth_key_id; + obj.date = date; + obj.device = device; + obj.location = location; return obj; } -(void)serialize:(SerializedData*)stream { - //Serialize ShortVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.messages count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - if([self.messages count] > i) { - NSNumber* obj = [self.messages objectAtIndex:i]; - [stream writeInt:[obj intValue]]; - } else - break; - } - } - [stream writeInt:self.pts]; - [stream writeInt:self.pts_count]; + [stream writeLong:self.auth_key_id]; + [stream writeInt:self.date]; + [stream writeString:self.device]; + [stream writeString:self.location]; } -(void)unserialize:(SerializedData*)stream { - //UNS ShortVector - [stream readInt]; - { - if(!self.messages) - self.messages = [[NSMutableArray alloc] init]; - int tl_count = [stream readInt]; - for(int i = 0; i < tl_count; i++) { - int obj = [stream readInt]; - [self.messages addObject:@(obj)]; - } - } - self.pts = [stream readInt]; - self.pts_count = [stream readInt]; + super.auth_key_id = [stream readLong]; + super.date = [stream readInt]; + super.device = [stream readString]; + super.location = [stream readString]; } --(TL_updateReadMessagesContents *)copy { +-(TL_updateNewAuthorization *)copy { - TL_updateReadMessagesContents *objc = [[TL_updateReadMessagesContents alloc] init]; + TL_updateNewAuthorization *objc = [[TL_updateNewAuthorization alloc] init]; - objc.messages = [self.messages copy]; - objc.pts = self.pts; - objc.pts_count = self.pts_count; + objc.auth_key_id = self.auth_key_id; + objc.date = self.date; + objc.device = self.device; + objc.location = self.location; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -10281,53 +11235,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLupdates_State -@end - -@implementation TL_updates_state -+(TL_updates_state*)createWithPts:(int)pts qts:(int)qts date:(int)date seq:(int)seq unread_count:(int)unread_count { - TL_updates_state* obj = [[TL_updates_state alloc] init]; - obj.pts = pts; +@implementation TL_updateNewEncryptedMessage ++(TL_updateNewEncryptedMessage*)createWithMessage:(TLEncryptedMessage*)message qts:(int)qts { + TL_updateNewEncryptedMessage* obj = [[TL_updateNewEncryptedMessage alloc] init]; + obj.message = message; obj.qts = qts; - obj.date = date; - obj.seq = seq; - obj.unread_count = unread_count; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.pts]; + [ClassStore TLSerialize:self.message stream:stream]; [stream writeInt:self.qts]; - [stream writeInt:self.date]; - [stream writeInt:self.seq]; - [stream writeInt:self.unread_count]; } -(void)unserialize:(SerializedData*)stream { - self.pts = [stream readInt]; - self.qts = [stream readInt]; - self.date = [stream readInt]; - self.seq = [stream readInt]; - self.unread_count = [stream readInt]; + self.message = [ClassStore TLDeserialize:stream]; + super.qts = [stream readInt]; } --(TL_updates_state *)copy { +-(TL_updateNewEncryptedMessage *)copy { - TL_updates_state *objc = [[TL_updates_state alloc] init]; + TL_updateNewEncryptedMessage *objc = [[TL_updateNewEncryptedMessage alloc] init]; - objc.pts = self.pts; + objc.message = [self.message copy]; objc.qts = self.qts; - objc.date = self.date; - objc.seq = self.seq; - objc.unread_count = self.unread_count; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -10341,41 +11280,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLupdates_Difference -@end - -@implementation TL_updates_differenceEmpty -+(TL_updates_differenceEmpty*)createWithDate:(int)date seq:(int)seq { - TL_updates_differenceEmpty* obj = [[TL_updates_differenceEmpty alloc] init]; - obj.date = date; - obj.seq = seq; +@implementation TL_updateEncryptedChatTyping ++(TL_updateEncryptedChatTyping*)createWithChat_id:(int)chat_id { + TL_updateEncryptedChatTyping* obj = [[TL_updateEncryptedChatTyping alloc] init]; + obj.chat_id = chat_id; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.date]; - [stream writeInt:self.seq]; + [stream writeInt:self.chat_id]; } -(void)unserialize:(SerializedData*)stream { - self.date = [stream readInt]; - self.seq = [stream readInt]; + super.chat_id = [stream readInt]; } --(TL_updates_differenceEmpty *)copy { +-(TL_updateEncryptedChatTyping *)copy { - TL_updates_differenceEmpty *objc = [[TL_updates_differenceEmpty alloc] init]; + TL_updateEncryptedChatTyping *objc = [[TL_updateEncryptedChatTyping alloc] init]; - objc.date = self.date; - objc.seq = self.seq; + objc.chat_id = self.chat_id; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -10389,163 +11321,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_updates_difference -+(TL_updates_difference*)createWithN_messages:(NSMutableArray*)n_messages n_encrypted_messages:(NSMutableArray*)n_encrypted_messages other_updates:(NSMutableArray*)other_updates chats:(NSMutableArray*)chats users:(NSMutableArray*)users state:(TLupdates_State*)state { - TL_updates_difference* obj = [[TL_updates_difference alloc] init]; - obj.n_messages = n_messages; - obj.n_encrypted_messages = n_encrypted_messages; - obj.other_updates = other_updates; - obj.chats = chats; - obj.users = users; - obj.state = state; +@implementation TL_updateEncryption ++(TL_updateEncryption*)createWithChat:(TLEncryptedChat*)chat date:(int)date { + TL_updateEncryption* obj = [[TL_updateEncryption alloc] init]; + obj.chat = chat; + obj.date = date; return obj; } -(void)serialize:(SerializedData*)stream { - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.n_messages count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLMessage* obj = [self.n_messages objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.n_encrypted_messages count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLEncryptedMessage* obj = [self.n_encrypted_messages objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.other_updates count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLUpdate* obj = [self.other_updates objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.chats count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLChat* obj = [self.chats objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.users count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLUser* obj = [self.users objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - [ClassStore TLSerialize:self.state stream:stream]; + [ClassStore TLSerialize:self.chat stream:stream]; + [stream writeInt:self.date]; } -(void)unserialize:(SerializedData*)stream { - //UNS FullVector - [stream readInt]; - { - if(!self.n_messages) - self.n_messages = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLMessage* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLMessage class]]) - [self.n_messages addObject:obj]; - else - break; - } - } - //UNS FullVector - [stream readInt]; - { - if(!self.n_encrypted_messages) - self.n_encrypted_messages = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLEncryptedMessage* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLEncryptedMessage class]]) - [self.n_encrypted_messages addObject:obj]; - else - break; - } - } - //UNS FullVector - [stream readInt]; - { - if(!self.other_updates) - self.other_updates = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLUpdate* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLUpdate class]]) - [self.other_updates addObject:obj]; - else - break; - } - } - //UNS FullVector - [stream readInt]; - { - if(!self.chats) - self.chats = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLChat* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLChat class]]) - [self.chats addObject:obj]; - else - break; - } - } - //UNS FullVector - [stream readInt]; - { - if(!self.users) - self.users = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLUser* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLUser class]]) - [self.users addObject:obj]; - else - break; - } - } - self.state = [ClassStore TLDeserialize:stream]; + self.chat = [ClassStore TLDeserialize:stream]; + super.date = [stream readInt]; } --(TL_updates_difference *)copy { +-(TL_updateEncryption *)copy { - TL_updates_difference *objc = [[TL_updates_difference alloc] init]; + TL_updateEncryption *objc = [[TL_updateEncryption alloc] init]; - objc.n_messages = [self.n_messages copy]; - objc.n_encrypted_messages = [self.n_encrypted_messages copy]; - objc.other_updates = [self.other_updates copy]; - objc.chats = [self.chats copy]; - objc.users = [self.users copy]; - objc.state = [self.state copy]; + objc.chat = [self.chat copy]; + objc.date = self.date; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -10559,163 +11366,4061 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } + + + +@end + +@implementation TL_updateEncryptedMessagesRead ++(TL_updateEncryptedMessagesRead*)createWithChat_id:(int)chat_id max_date:(int)max_date date:(int)date { + TL_updateEncryptedMessagesRead* obj = [[TL_updateEncryptedMessagesRead alloc] init]; + obj.chat_id = chat_id; + obj.max_date = max_date; + obj.date = date; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeInt:self.chat_id]; + [stream writeInt:self.max_date]; + [stream writeInt:self.date]; +} +-(void)unserialize:(SerializedData*)stream { + super.chat_id = [stream readInt]; + super.max_date = [stream readInt]; + super.date = [stream readInt]; +} + +-(TL_updateEncryptedMessagesRead *)copy { + + TL_updateEncryptedMessagesRead *objc = [[TL_updateEncryptedMessagesRead alloc] init]; + + objc.chat_id = self.chat_id; + objc.max_date = self.max_date; + objc.date = self.date; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} @end -@implementation TL_updates_differenceSlice -+(TL_updates_differenceSlice*)createWithN_messages:(NSMutableArray*)n_messages n_encrypted_messages:(NSMutableArray*)n_encrypted_messages other_updates:(NSMutableArray*)other_updates chats:(NSMutableArray*)chats users:(NSMutableArray*)users intermediate_state:(TLupdates_State*)intermediate_state { - TL_updates_differenceSlice* obj = [[TL_updates_differenceSlice alloc] init]; - obj.n_messages = n_messages; - obj.n_encrypted_messages = n_encrypted_messages; - obj.other_updates = other_updates; - obj.chats = chats; - obj.users = users; - obj.intermediate_state = intermediate_state; +@implementation TL_updateChatParticipantAdd ++(TL_updateChatParticipantAdd*)createWithChat_id:(int)chat_id user_id:(int)user_id inviter_id:(int)inviter_id date:(int)date version:(int)version { + TL_updateChatParticipantAdd* obj = [[TL_updateChatParticipantAdd alloc] init]; + obj.chat_id = chat_id; + obj.user_id = user_id; + obj.inviter_id = inviter_id; + obj.date = date; + obj.version = version; return obj; } -(void)serialize:(SerializedData*)stream { - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.n_messages count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLMessage* obj = [self.n_messages objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.n_encrypted_messages count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLEncryptedMessage* obj = [self.n_encrypted_messages objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.other_updates count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLUpdate* obj = [self.other_updates objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.chats count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLChat* obj = [self.chats objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.users count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLUser* obj = [self.users objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - [ClassStore TLSerialize:self.intermediate_state stream:stream]; + [stream writeInt:self.chat_id]; + [stream writeInt:self.user_id]; + [stream writeInt:self.inviter_id]; + [stream writeInt:self.date]; + [stream writeInt:self.version]; } -(void)unserialize:(SerializedData*)stream { - //UNS FullVector - [stream readInt]; - { - if(!self.n_messages) - self.n_messages = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLMessage* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLMessage class]]) - [self.n_messages addObject:obj]; - else - break; - } - } - //UNS FullVector - [stream readInt]; - { - if(!self.n_encrypted_messages) - self.n_encrypted_messages = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLEncryptedMessage* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLEncryptedMessage class]]) - [self.n_encrypted_messages addObject:obj]; - else - break; - } - } - //UNS FullVector - [stream readInt]; - { - if(!self.other_updates) - self.other_updates = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLUpdate* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLUpdate class]]) - [self.other_updates addObject:obj]; - else - break; - } - } - //UNS FullVector - [stream readInt]; + super.chat_id = [stream readInt]; + super.user_id = [stream readInt]; + super.inviter_id = [stream readInt]; + super.date = [stream readInt]; + super.version = [stream readInt]; +} + +-(TL_updateChatParticipantAdd *)copy { + + TL_updateChatParticipantAdd *objc = [[TL_updateChatParticipantAdd alloc] init]; + + objc.chat_id = self.chat_id; + objc.user_id = self.user_id; + objc.inviter_id = self.inviter_id; + objc.date = self.date; + objc.version = self.version; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_updateChatParticipantDelete ++(TL_updateChatParticipantDelete*)createWithChat_id:(int)chat_id user_id:(int)user_id version:(int)version { + TL_updateChatParticipantDelete* obj = [[TL_updateChatParticipantDelete alloc] init]; + obj.chat_id = chat_id; + obj.user_id = user_id; + obj.version = version; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeInt:self.chat_id]; + [stream writeInt:self.user_id]; + [stream writeInt:self.version]; +} +-(void)unserialize:(SerializedData*)stream { + super.chat_id = [stream readInt]; + super.user_id = [stream readInt]; + super.version = [stream readInt]; +} + +-(TL_updateChatParticipantDelete *)copy { + + TL_updateChatParticipantDelete *objc = [[TL_updateChatParticipantDelete alloc] init]; + + objc.chat_id = self.chat_id; + objc.user_id = self.user_id; + objc.version = self.version; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_updateDcOptions ++(TL_updateDcOptions*)createWithDc_options:(NSMutableArray*)dc_options { + TL_updateDcOptions* obj = [[TL_updateDcOptions alloc] init]; + obj.dc_options = dc_options; + return obj; +} +-(void)serialize:(SerializedData*)stream { + //Serialize FullVector + [stream writeInt:0x1cb5c415]; { - if(!self.chats) - self.chats = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLChat* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLChat class]]) - [self.chats addObject:obj]; - else - break; + NSInteger tl_count = [self.dc_options count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLDcOption* obj = [self.dc_options objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; } } +} +-(void)unserialize:(SerializedData*)stream { //UNS FullVector [stream readInt]; { - if(!self.users) - self.users = [[NSMutableArray alloc] init]; + if(!self.dc_options) + self.dc_options = [[NSMutableArray alloc] init]; int count = [stream readInt]; for(int i = 0; i < count; i++) { - TLUser* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLUser class]]) - [self.users addObject:obj]; + TLDcOption* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLDcOption class]]) + [self.dc_options addObject:obj]; else break; } } - self.intermediate_state = [ClassStore TLDeserialize:stream]; } --(TL_updates_differenceSlice *)copy { +-(TL_updateDcOptions *)copy { + + TL_updateDcOptions *objc = [[TL_updateDcOptions alloc] init]; + + objc.dc_options = [self.dc_options copy]; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_updateUserBlocked ++(TL_updateUserBlocked*)createWithUser_id:(int)user_id blocked:(Boolean)blocked { + TL_updateUserBlocked* obj = [[TL_updateUserBlocked alloc] init]; + obj.user_id = user_id; + obj.blocked = blocked; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeInt:self.user_id]; + [stream writeBool:self.blocked]; +} +-(void)unserialize:(SerializedData*)stream { + super.user_id = [stream readInt]; + super.blocked = [stream readBool]; +} + +-(TL_updateUserBlocked *)copy { + + TL_updateUserBlocked *objc = [[TL_updateUserBlocked alloc] init]; + + objc.user_id = self.user_id; + objc.blocked = self.blocked; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_updateNotifySettings ++(TL_updateNotifySettings*)createWithPeer:(TLNotifyPeer*)peer notify_settings:(TLPeerNotifySettings*)notify_settings { + TL_updateNotifySettings* obj = [[TL_updateNotifySettings alloc] init]; + obj.peer = peer; + obj.notify_settings = notify_settings; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [ClassStore TLSerialize:self.peer stream:stream]; + [ClassStore TLSerialize:self.notify_settings stream:stream]; +} +-(void)unserialize:(SerializedData*)stream { + self.peer = [ClassStore TLDeserialize:stream]; + self.notify_settings = [ClassStore TLDeserialize:stream]; +} + +-(TL_updateNotifySettings *)copy { + + TL_updateNotifySettings *objc = [[TL_updateNotifySettings alloc] init]; + + objc.peer = [self.peer copy]; + objc.notify_settings = [self.notify_settings copy]; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_updateServiceNotification ++(TL_updateServiceNotification*)createWithType:(NSString*)type message:(NSString*)message media:(TLMessageMedia*)media popup:(Boolean)popup { + TL_updateServiceNotification* obj = [[TL_updateServiceNotification alloc] init]; + obj.type = type; + obj.message = message; + obj.media = media; + obj.popup = popup; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeString:self.type]; + [stream writeString:self.message]; + [ClassStore TLSerialize:self.media stream:stream]; + [stream writeBool:self.popup]; +} +-(void)unserialize:(SerializedData*)stream { + super.type = [stream readString]; + super.message = [stream readString]; + self.media = [ClassStore TLDeserialize:stream]; + super.popup = [stream readBool]; +} + +-(TL_updateServiceNotification *)copy { + + TL_updateServiceNotification *objc = [[TL_updateServiceNotification alloc] init]; + + objc.type = self.type; + objc.message = self.message; + objc.media = [self.media copy]; + objc.popup = self.popup; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_updatePrivacy ++(TL_updatePrivacy*)createWithN_key:(TLPrivacyKey*)n_key rules:(NSMutableArray*)rules { + TL_updatePrivacy* obj = [[TL_updatePrivacy alloc] init]; + obj.n_key = n_key; + obj.rules = rules; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [ClassStore TLSerialize:self.n_key stream:stream]; + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.rules count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLPrivacyRule* obj = [self.rules objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } +} +-(void)unserialize:(SerializedData*)stream { + self.n_key = [ClassStore TLDeserialize:stream]; + //UNS FullVector + [stream readInt]; + { + if(!self.rules) + self.rules = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLPrivacyRule* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLPrivacyRule class]]) + [self.rules addObject:obj]; + else + break; + } + } +} + +-(TL_updatePrivacy *)copy { + + TL_updatePrivacy *objc = [[TL_updatePrivacy alloc] init]; + + objc.n_key = [self.n_key copy]; + objc.rules = [self.rules copy]; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_updateUserPhone ++(TL_updateUserPhone*)createWithUser_id:(int)user_id phone:(NSString*)phone { + TL_updateUserPhone* obj = [[TL_updateUserPhone alloc] init]; + obj.user_id = user_id; + obj.phone = phone; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeInt:self.user_id]; + [stream writeString:self.phone]; +} +-(void)unserialize:(SerializedData*)stream { + super.user_id = [stream readInt]; + super.phone = [stream readString]; +} + +-(TL_updateUserPhone *)copy { + + TL_updateUserPhone *objc = [[TL_updateUserPhone alloc] init]; + + objc.user_id = self.user_id; + objc.phone = self.phone; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_updateReadHistoryInbox ++(TL_updateReadHistoryInbox*)createWithPeer:(TLPeer*)peer max_id:(int)max_id pts:(int)pts pts_count:(int)pts_count { + TL_updateReadHistoryInbox* obj = [[TL_updateReadHistoryInbox alloc] init]; + obj.peer = peer; + obj.max_id = max_id; + obj.pts = pts; + obj.pts_count = pts_count; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [ClassStore TLSerialize:self.peer stream:stream]; + [stream writeInt:self.max_id]; + [stream writeInt:self.pts]; + [stream writeInt:self.pts_count]; +} +-(void)unserialize:(SerializedData*)stream { + self.peer = [ClassStore TLDeserialize:stream]; + super.max_id = [stream readInt]; + super.pts = [stream readInt]; + super.pts_count = [stream readInt]; +} + +-(TL_updateReadHistoryInbox *)copy { + + TL_updateReadHistoryInbox *objc = [[TL_updateReadHistoryInbox alloc] init]; + + objc.peer = [self.peer copy]; + objc.max_id = self.max_id; + objc.pts = self.pts; + objc.pts_count = self.pts_count; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_updateReadHistoryOutbox ++(TL_updateReadHistoryOutbox*)createWithPeer:(TLPeer*)peer max_id:(int)max_id pts:(int)pts pts_count:(int)pts_count { + TL_updateReadHistoryOutbox* obj = [[TL_updateReadHistoryOutbox alloc] init]; + obj.peer = peer; + obj.max_id = max_id; + obj.pts = pts; + obj.pts_count = pts_count; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [ClassStore TLSerialize:self.peer stream:stream]; + [stream writeInt:self.max_id]; + [stream writeInt:self.pts]; + [stream writeInt:self.pts_count]; +} +-(void)unserialize:(SerializedData*)stream { + self.peer = [ClassStore TLDeserialize:stream]; + super.max_id = [stream readInt]; + super.pts = [stream readInt]; + super.pts_count = [stream readInt]; +} + +-(TL_updateReadHistoryOutbox *)copy { + + TL_updateReadHistoryOutbox *objc = [[TL_updateReadHistoryOutbox alloc] init]; + + objc.peer = [self.peer copy]; + objc.max_id = self.max_id; + objc.pts = self.pts; + objc.pts_count = self.pts_count; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_updateWebPage ++(TL_updateWebPage*)createWithWebpage:(TLWebPage*)webpage pts:(int)pts pts_count:(int)pts_count { + TL_updateWebPage* obj = [[TL_updateWebPage alloc] init]; + obj.webpage = webpage; + obj.pts = pts; + obj.pts_count = pts_count; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [ClassStore TLSerialize:self.webpage stream:stream]; + [stream writeInt:self.pts]; + [stream writeInt:self.pts_count]; +} +-(void)unserialize:(SerializedData*)stream { + self.webpage = [ClassStore TLDeserialize:stream]; + super.pts = [stream readInt]; + super.pts_count = [stream readInt]; +} + +-(TL_updateWebPage *)copy { + + TL_updateWebPage *objc = [[TL_updateWebPage alloc] init]; + + objc.webpage = [self.webpage copy]; + objc.pts = self.pts; + objc.pts_count = self.pts_count; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_updateReadMessagesContents ++(TL_updateReadMessagesContents*)createWithMessages:(NSMutableArray*)messages pts:(int)pts pts_count:(int)pts_count { + TL_updateReadMessagesContents* obj = [[TL_updateReadMessagesContents alloc] init]; + obj.messages = messages; + obj.pts = pts; + obj.pts_count = pts_count; + return obj; +} +-(void)serialize:(SerializedData*)stream { + //Serialize ShortVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.messages count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + if([self.messages count] > i) { + NSNumber* obj = [self.messages objectAtIndex:i]; + [stream writeInt:[obj intValue]]; + } else + break; + } + } + [stream writeInt:self.pts]; + [stream writeInt:self.pts_count]; +} +-(void)unserialize:(SerializedData*)stream { + //UNS ShortVector + [stream readInt]; + { + if(!self.messages) + self.messages = [[NSMutableArray alloc] init]; + int tl_count = [stream readInt]; + for(int i = 0; i < tl_count; i++) { + int obj = [stream readInt]; + [self.messages addObject:@(obj)]; + } + } + super.pts = [stream readInt]; + super.pts_count = [stream readInt]; +} + +-(TL_updateReadMessagesContents *)copy { + + TL_updateReadMessagesContents *objc = [[TL_updateReadMessagesContents alloc] init]; + + objc.messages = [self.messages copy]; + objc.pts = self.pts; + objc.pts_count = self.pts_count; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_updateChannelTooLong ++(TL_updateChannelTooLong*)createWithChannel_id:(int)channel_id { + TL_updateChannelTooLong* obj = [[TL_updateChannelTooLong alloc] init]; + obj.channel_id = channel_id; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeInt:self.channel_id]; +} +-(void)unserialize:(SerializedData*)stream { + super.channel_id = [stream readInt]; +} + +-(TL_updateChannelTooLong *)copy { + + TL_updateChannelTooLong *objc = [[TL_updateChannelTooLong alloc] init]; + + objc.channel_id = self.channel_id; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_updateChannel ++(TL_updateChannel*)createWithChannel_id:(int)channel_id { + TL_updateChannel* obj = [[TL_updateChannel alloc] init]; + obj.channel_id = channel_id; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeInt:self.channel_id]; +} +-(void)unserialize:(SerializedData*)stream { + super.channel_id = [stream readInt]; +} + +-(TL_updateChannel *)copy { + + TL_updateChannel *objc = [[TL_updateChannel alloc] init]; + + objc.channel_id = self.channel_id; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_updateChannelGroup ++(TL_updateChannelGroup*)createWithChannel_id:(int)channel_id group:(TLMessageGroup*)group { + TL_updateChannelGroup* obj = [[TL_updateChannelGroup alloc] init]; + obj.channel_id = channel_id; + obj.group = group; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeInt:self.channel_id]; + [ClassStore TLSerialize:self.group stream:stream]; +} +-(void)unserialize:(SerializedData*)stream { + super.channel_id = [stream readInt]; + self.group = [ClassStore TLDeserialize:stream]; +} + +-(TL_updateChannelGroup *)copy { + + TL_updateChannelGroup *objc = [[TL_updateChannelGroup alloc] init]; + + objc.channel_id = self.channel_id; + objc.group = [self.group copy]; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_updateNewChannelMessage ++(TL_updateNewChannelMessage*)createWithMessage:(TLMessage*)message pts:(int)pts pts_count:(int)pts_count { + TL_updateNewChannelMessage* obj = [[TL_updateNewChannelMessage alloc] init]; + obj.message = message; + obj.pts = pts; + obj.pts_count = pts_count; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [ClassStore TLSerialize:self.message stream:stream]; + [stream writeInt:self.pts]; + [stream writeInt:self.pts_count]; +} +-(void)unserialize:(SerializedData*)stream { + self.message = [ClassStore TLDeserialize:stream]; + super.pts = [stream readInt]; + super.pts_count = [stream readInt]; +} + +-(TL_updateNewChannelMessage *)copy { + + TL_updateNewChannelMessage *objc = [[TL_updateNewChannelMessage alloc] init]; + + objc.message = [self.message copy]; + objc.pts = self.pts; + objc.pts_count = self.pts_count; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_updateReadChannelInbox ++(TL_updateReadChannelInbox*)createWithChannel_id:(int)channel_id max_id:(int)max_id { + TL_updateReadChannelInbox* obj = [[TL_updateReadChannelInbox alloc] init]; + obj.channel_id = channel_id; + obj.max_id = max_id; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeInt:self.channel_id]; + [stream writeInt:self.max_id]; +} +-(void)unserialize:(SerializedData*)stream { + super.channel_id = [stream readInt]; + super.max_id = [stream readInt]; +} + +-(TL_updateReadChannelInbox *)copy { + + TL_updateReadChannelInbox *objc = [[TL_updateReadChannelInbox alloc] init]; + + objc.channel_id = self.channel_id; + objc.max_id = self.max_id; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_updateDeleteChannelMessages ++(TL_updateDeleteChannelMessages*)createWithChannel_id:(int)channel_id messages:(NSMutableArray*)messages pts:(int)pts pts_count:(int)pts_count { + TL_updateDeleteChannelMessages* obj = [[TL_updateDeleteChannelMessages alloc] init]; + obj.channel_id = channel_id; + obj.messages = messages; + obj.pts = pts; + obj.pts_count = pts_count; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeInt:self.channel_id]; + //Serialize ShortVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.messages count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + if([self.messages count] > i) { + NSNumber* obj = [self.messages objectAtIndex:i]; + [stream writeInt:[obj intValue]]; + } else + break; + } + } + [stream writeInt:self.pts]; + [stream writeInt:self.pts_count]; +} +-(void)unserialize:(SerializedData*)stream { + super.channel_id = [stream readInt]; + //UNS ShortVector + [stream readInt]; + { + if(!self.messages) + self.messages = [[NSMutableArray alloc] init]; + int tl_count = [stream readInt]; + for(int i = 0; i < tl_count; i++) { + int obj = [stream readInt]; + [self.messages addObject:@(obj)]; + } + } + super.pts = [stream readInt]; + super.pts_count = [stream readInt]; +} + +-(TL_updateDeleteChannelMessages *)copy { + + TL_updateDeleteChannelMessages *objc = [[TL_updateDeleteChannelMessages alloc] init]; + + objc.channel_id = self.channel_id; + objc.messages = [self.messages copy]; + objc.pts = self.pts; + objc.pts_count = self.pts_count; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_updateChannelMessageViews ++(TL_updateChannelMessageViews*)createWithChannel_id:(int)channel_id n_id:(int)n_id views:(int)views { + TL_updateChannelMessageViews* obj = [[TL_updateChannelMessageViews alloc] init]; + obj.channel_id = channel_id; + obj.n_id = n_id; + obj.views = views; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeInt:self.channel_id]; + [stream writeInt:self.n_id]; + [stream writeInt:self.views]; +} +-(void)unserialize:(SerializedData*)stream { + super.channel_id = [stream readInt]; + super.n_id = [stream readInt]; + super.views = [stream readInt]; +} + +-(TL_updateChannelMessageViews *)copy { + + TL_updateChannelMessageViews *objc = [[TL_updateChannelMessageViews alloc] init]; + + objc.channel_id = self.channel_id; + objc.n_id = self.n_id; + objc.views = self.views; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_updateChatAdmins ++(TL_updateChatAdmins*)createWithChat_id:(int)chat_id enabled:(Boolean)enabled version:(int)version { + TL_updateChatAdmins* obj = [[TL_updateChatAdmins alloc] init]; + obj.chat_id = chat_id; + obj.enabled = enabled; + obj.version = version; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeInt:self.chat_id]; + [stream writeBool:self.enabled]; + [stream writeInt:self.version]; +} +-(void)unserialize:(SerializedData*)stream { + super.chat_id = [stream readInt]; + super.enabled = [stream readBool]; + super.version = [stream readInt]; +} + +-(TL_updateChatAdmins *)copy { + + TL_updateChatAdmins *objc = [[TL_updateChatAdmins alloc] init]; + + objc.chat_id = self.chat_id; + objc.enabled = self.enabled; + objc.version = self.version; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_updateChatParticipantAdmin ++(TL_updateChatParticipantAdmin*)createWithChat_id:(int)chat_id user_id:(int)user_id is_admin:(Boolean)is_admin version:(int)version { + TL_updateChatParticipantAdmin* obj = [[TL_updateChatParticipantAdmin alloc] init]; + obj.chat_id = chat_id; + obj.user_id = user_id; + obj.is_admin = is_admin; + obj.version = version; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeInt:self.chat_id]; + [stream writeInt:self.user_id]; + [stream writeBool:self.is_admin]; + [stream writeInt:self.version]; +} +-(void)unserialize:(SerializedData*)stream { + super.chat_id = [stream readInt]; + super.user_id = [stream readInt]; + super.is_admin = [stream readBool]; + super.version = [stream readInt]; +} + +-(TL_updateChatParticipantAdmin *)copy { + + TL_updateChatParticipantAdmin *objc = [[TL_updateChatParticipantAdmin alloc] init]; + + objc.chat_id = self.chat_id; + objc.user_id = self.user_id; + objc.is_admin = self.is_admin; + objc.version = self.version; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_updateNewStickerSet ++(TL_updateNewStickerSet*)createWithStickerset:(TLmessages_StickerSet*)stickerset { + TL_updateNewStickerSet* obj = [[TL_updateNewStickerSet alloc] init]; + obj.stickerset = stickerset; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [ClassStore TLSerialize:self.stickerset stream:stream]; +} +-(void)unserialize:(SerializedData*)stream { + self.stickerset = [ClassStore TLDeserialize:stream]; +} + +-(TL_updateNewStickerSet *)copy { + + TL_updateNewStickerSet *objc = [[TL_updateNewStickerSet alloc] init]; + + objc.stickerset = [self.stickerset copy]; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_updateStickerSetsOrder ++(TL_updateStickerSetsOrder*)createWithOrder:(NSMutableArray*)order { + TL_updateStickerSetsOrder* obj = [[TL_updateStickerSetsOrder alloc] init]; + obj.order = order; + return obj; +} +-(void)serialize:(SerializedData*)stream { + //Serialize ShortVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.order count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + if([self.order count] > i) { + NSNumber* obj = [self.order objectAtIndex:i]; + [stream writeLong:[obj longValue]]; + } else + break; + } + } +} +-(void)unserialize:(SerializedData*)stream { + //UNS ShortVector + [stream readInt]; + { + if(!self.order) + self.order = [[NSMutableArray alloc] init]; + int tl_count = [stream readInt]; + for(int i = 0; i < tl_count; i++) { + long obj = [stream readLong]; + [self.order addObject:@(obj)]; + } + } +} + +-(TL_updateStickerSetsOrder *)copy { + + TL_updateStickerSetsOrder *objc = [[TL_updateStickerSetsOrder alloc] init]; + + objc.order = [self.order copy]; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_updateStickerSets ++(TL_updateStickerSets*)create { + TL_updateStickerSets* obj = [[TL_updateStickerSets alloc] init]; + + return obj; +} +-(void)serialize:(SerializedData*)stream { + +} +-(void)unserialize:(SerializedData*)stream { + +} + +-(TL_updateStickerSets *)copy { + + TL_updateStickerSets *objc = [[TL_updateStickerSets alloc] init]; + + + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TLupdates_State + +@end + +@implementation TL_updates_state ++(TL_updates_state*)createWithPts:(int)pts qts:(int)qts date:(int)date seq:(int)seq unread_count:(int)unread_count { + TL_updates_state* obj = [[TL_updates_state alloc] init]; + obj.pts = pts; + obj.qts = qts; + obj.date = date; + obj.seq = seq; + obj.unread_count = unread_count; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeInt:self.pts]; + [stream writeInt:self.qts]; + [stream writeInt:self.date]; + [stream writeInt:self.seq]; + [stream writeInt:self.unread_count]; +} +-(void)unserialize:(SerializedData*)stream { + super.pts = [stream readInt]; + super.qts = [stream readInt]; + super.date = [stream readInt]; + super.seq = [stream readInt]; + super.unread_count = [stream readInt]; +} + +-(TL_updates_state *)copy { + + TL_updates_state *objc = [[TL_updates_state alloc] init]; + + objc.pts = self.pts; + objc.qts = self.qts; + objc.date = self.date; + objc.seq = self.seq; + objc.unread_count = self.unread_count; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TLupdates_Difference + +@end + +@implementation TL_updates_differenceEmpty ++(TL_updates_differenceEmpty*)createWithDate:(int)date seq:(int)seq { + TL_updates_differenceEmpty* obj = [[TL_updates_differenceEmpty alloc] init]; + obj.date = date; + obj.seq = seq; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeInt:self.date]; + [stream writeInt:self.seq]; +} +-(void)unserialize:(SerializedData*)stream { + super.date = [stream readInt]; + super.seq = [stream readInt]; +} + +-(TL_updates_differenceEmpty *)copy { + + TL_updates_differenceEmpty *objc = [[TL_updates_differenceEmpty alloc] init]; + + objc.date = self.date; + objc.seq = self.seq; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_updates_difference ++(TL_updates_difference*)createWithN_messages:(NSMutableArray*)n_messages n_encrypted_messages:(NSMutableArray*)n_encrypted_messages other_updates:(NSMutableArray*)other_updates chats:(NSMutableArray*)chats users:(NSMutableArray*)users state:(TLupdates_State*)state { + TL_updates_difference* obj = [[TL_updates_difference alloc] init]; + obj.n_messages = n_messages; + obj.n_encrypted_messages = n_encrypted_messages; + obj.other_updates = other_updates; + obj.chats = chats; + obj.users = users; + obj.state = state; + return obj; +} +-(void)serialize:(SerializedData*)stream { + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.n_messages count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLMessage* obj = [self.n_messages objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.n_encrypted_messages count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLEncryptedMessage* obj = [self.n_encrypted_messages objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.other_updates count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLUpdate* obj = [self.other_updates objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.chats count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLChat* obj = [self.chats objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.users count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLUser* obj = [self.users objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + [ClassStore TLSerialize:self.state stream:stream]; +} +-(void)unserialize:(SerializedData*)stream { + //UNS FullVector + [stream readInt]; + { + if(!self.n_messages) + self.n_messages = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLMessage* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLMessage class]]) + [self.n_messages addObject:obj]; + else + break; + } + } + //UNS FullVector + [stream readInt]; + { + if(!self.n_encrypted_messages) + self.n_encrypted_messages = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLEncryptedMessage* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLEncryptedMessage class]]) + [self.n_encrypted_messages addObject:obj]; + else + break; + } + } + //UNS FullVector + [stream readInt]; + { + if(!self.other_updates) + self.other_updates = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLUpdate* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLUpdate class]]) + [self.other_updates addObject:obj]; + else + break; + } + } + //UNS FullVector + [stream readInt]; + { + if(!self.chats) + self.chats = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLChat* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLChat class]]) + [self.chats addObject:obj]; + else + break; + } + } + //UNS FullVector + [stream readInt]; + { + if(!self.users) + self.users = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLUser* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLUser class]]) + [self.users addObject:obj]; + else + break; + } + } + self.state = [ClassStore TLDeserialize:stream]; +} + +-(TL_updates_difference *)copy { + + TL_updates_difference *objc = [[TL_updates_difference alloc] init]; + + objc.n_messages = [self.n_messages copy]; + objc.n_encrypted_messages = [self.n_encrypted_messages copy]; + objc.other_updates = [self.other_updates copy]; + objc.chats = [self.chats copy]; + objc.users = [self.users copy]; + objc.state = [self.state copy]; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_updates_differenceSlice ++(TL_updates_differenceSlice*)createWithN_messages:(NSMutableArray*)n_messages n_encrypted_messages:(NSMutableArray*)n_encrypted_messages other_updates:(NSMutableArray*)other_updates chats:(NSMutableArray*)chats users:(NSMutableArray*)users intermediate_state:(TLupdates_State*)intermediate_state { + TL_updates_differenceSlice* obj = [[TL_updates_differenceSlice alloc] init]; + obj.n_messages = n_messages; + obj.n_encrypted_messages = n_encrypted_messages; + obj.other_updates = other_updates; + obj.chats = chats; + obj.users = users; + obj.intermediate_state = intermediate_state; + return obj; +} +-(void)serialize:(SerializedData*)stream { + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.n_messages count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLMessage* obj = [self.n_messages objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.n_encrypted_messages count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLEncryptedMessage* obj = [self.n_encrypted_messages objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.other_updates count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLUpdate* obj = [self.other_updates objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.chats count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLChat* obj = [self.chats objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.users count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLUser* obj = [self.users objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + [ClassStore TLSerialize:self.intermediate_state stream:stream]; +} +-(void)unserialize:(SerializedData*)stream { + //UNS FullVector + [stream readInt]; + { + if(!self.n_messages) + self.n_messages = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLMessage* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLMessage class]]) + [self.n_messages addObject:obj]; + else + break; + } + } + //UNS FullVector + [stream readInt]; + { + if(!self.n_encrypted_messages) + self.n_encrypted_messages = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLEncryptedMessage* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLEncryptedMessage class]]) + [self.n_encrypted_messages addObject:obj]; + else + break; + } + } + //UNS FullVector + [stream readInt]; + { + if(!self.other_updates) + self.other_updates = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLUpdate* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLUpdate class]]) + [self.other_updates addObject:obj]; + else + break; + } + } + //UNS FullVector + [stream readInt]; + { + if(!self.chats) + self.chats = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLChat* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLChat class]]) + [self.chats addObject:obj]; + else + break; + } + } + //UNS FullVector + [stream readInt]; + { + if(!self.users) + self.users = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLUser* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLUser class]]) + [self.users addObject:obj]; + else + break; + } + } + self.intermediate_state = [ClassStore TLDeserialize:stream]; +} + +-(TL_updates_differenceSlice *)copy { + + TL_updates_differenceSlice *objc = [[TL_updates_differenceSlice alloc] init]; + + objc.n_messages = [self.n_messages copy]; + objc.n_encrypted_messages = [self.n_encrypted_messages copy]; + objc.other_updates = [self.other_updates copy]; + objc.chats = [self.chats copy]; + objc.users = [self.users copy]; + objc.intermediate_state = [self.intermediate_state copy]; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TLUpdates + +-(BOOL)isUnread {return NO;} + +-(BOOL)isN_out {return NO;} + +-(BOOL)isMentioned {return NO;} + +-(BOOL)isMedia_unread {return NO;} + +@end + +@implementation TL_updatesTooLong ++(TL_updatesTooLong*)create { + TL_updatesTooLong* obj = [[TL_updatesTooLong alloc] init]; + + return obj; +} +-(void)serialize:(SerializedData*)stream { + +} +-(void)unserialize:(SerializedData*)stream { + +} + +-(TL_updatesTooLong *)copy { + + TL_updatesTooLong *objc = [[TL_updatesTooLong alloc] init]; + + + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_updateShortMessage ++(TL_updateShortMessage*)createWithFlags:(int)flags n_id:(int)n_id user_id:(int)user_id message:(NSString*)message pts:(int)pts pts_count:(int)pts_count date:(int)date fwd_from_id:(TLPeer*)fwd_from_id fwd_date:(int)fwd_date reply_to_msg_id:(int)reply_to_msg_id entities:(NSMutableArray*)entities { + TL_updateShortMessage* obj = [[TL_updateShortMessage alloc] init]; + obj.flags = flags; + + + + + obj.n_id = n_id; + obj.user_id = user_id; + obj.message = message; + obj.pts = pts; + obj.pts_count = pts_count; + obj.date = date; + obj.fwd_from_id = fwd_from_id; + obj.fwd_date = fwd_date; + obj.reply_to_msg_id = reply_to_msg_id; + obj.entities = entities; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeInt:self.flags]; + + + + + [stream writeInt:self.n_id]; + [stream writeInt:self.user_id]; + [stream writeString:self.message]; + [stream writeInt:self.pts]; + [stream writeInt:self.pts_count]; + [stream writeInt:self.date]; + if(self.flags & (1 << 2)) {[ClassStore TLSerialize:self.fwd_from_id stream:stream];} + if(self.flags & (1 << 2)) {[stream writeInt:self.fwd_date];} + if(self.flags & (1 << 3)) {[stream writeInt:self.reply_to_msg_id];} + if(self.flags & (1 << 7)) {//Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.entities count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLMessageEntity* obj = [self.entities objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + }} +} +-(void)unserialize:(SerializedData*)stream { + super.flags = [stream readInt]; + + + + + super.n_id = [stream readInt]; + super.user_id = [stream readInt]; + super.message = [stream readString]; + super.pts = [stream readInt]; + super.pts_count = [stream readInt]; + super.date = [stream readInt]; + if(self.flags & (1 << 2)) {self.fwd_from_id = [ClassStore TLDeserialize:stream];} + if(self.flags & (1 << 2)) {super.fwd_date = [stream readInt];} + if(self.flags & (1 << 3)) {super.reply_to_msg_id = [stream readInt];} + if(self.flags & (1 << 7)) {//UNS FullVector + [stream readInt]; + { + if(!self.entities) + self.entities = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLMessageEntity* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLMessageEntity class]]) + [self.entities addObject:obj]; + else + break; + } + }} +} + +-(TL_updateShortMessage *)copy { + + TL_updateShortMessage *objc = [[TL_updateShortMessage alloc] init]; + + objc.flags = self.flags; + + + + + objc.n_id = self.n_id; + objc.user_id = self.user_id; + objc.message = self.message; + objc.pts = self.pts; + objc.pts_count = self.pts_count; + objc.date = self.date; + objc.fwd_from_id = [self.fwd_from_id copy]; + objc.fwd_date = self.fwd_date; + objc.reply_to_msg_id = self.reply_to_msg_id; + objc.entities = [self.entities copy]; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + +-(BOOL)isUnread {return (self.flags & (1 << 0)) > 0;} + +-(BOOL)isN_out {return (self.flags & (1 << 1)) > 0;} + +-(BOOL)isMentioned {return (self.flags & (1 << 4)) > 0;} + +-(BOOL)isMedia_unread {return (self.flags & (1 << 5)) > 0;} + +-(void)setFwd_from_id:(TLPeer*)fwd_from_id +{ + super.fwd_from_id = fwd_from_id; + + if(super.fwd_from_id == nil) { super.flags&= ~ (1 << 2) ;} else { super.flags|= (1 << 2); } +} +-(void)setFwd_date:(int)fwd_date +{ + super.fwd_date = fwd_date; + + if(super.fwd_date == 0) { super.flags&= ~ (1 << 2) ;} else { super.flags|= (1 << 2); } +} +-(void)setReply_to_msg_id:(int)reply_to_msg_id +{ + super.reply_to_msg_id = reply_to_msg_id; + + if(super.reply_to_msg_id == 0) { super.flags&= ~ (1 << 3) ;} else { super.flags|= (1 << 3); } +} +-(void)setEntities:(NSMutableArray*)entities +{ + super.entities = entities; + + if(super.entities == nil) { super.flags&= ~ (1 << 7) ;} else { super.flags|= (1 << 7); } +} + +@end + +@implementation TL_updateShortChatMessage ++(TL_updateShortChatMessage*)createWithFlags:(int)flags n_id:(int)n_id from_id:(int)from_id chat_id:(int)chat_id message:(NSString*)message pts:(int)pts pts_count:(int)pts_count date:(int)date fwd_from_id:(TLPeer*)fwd_from_id fwd_date:(int)fwd_date reply_to_msg_id:(int)reply_to_msg_id entities:(NSMutableArray*)entities { + TL_updateShortChatMessage* obj = [[TL_updateShortChatMessage alloc] init]; + obj.flags = flags; + + + + + obj.n_id = n_id; + obj.from_id = from_id; + obj.chat_id = chat_id; + obj.message = message; + obj.pts = pts; + obj.pts_count = pts_count; + obj.date = date; + obj.fwd_from_id = fwd_from_id; + obj.fwd_date = fwd_date; + obj.reply_to_msg_id = reply_to_msg_id; + obj.entities = entities; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeInt:self.flags]; + + + + + [stream writeInt:self.n_id]; + [stream writeInt:self.from_id]; + [stream writeInt:self.chat_id]; + [stream writeString:self.message]; + [stream writeInt:self.pts]; + [stream writeInt:self.pts_count]; + [stream writeInt:self.date]; + if(self.flags & (1 << 2)) {[ClassStore TLSerialize:self.fwd_from_id stream:stream];} + if(self.flags & (1 << 2)) {[stream writeInt:self.fwd_date];} + if(self.flags & (1 << 3)) {[stream writeInt:self.reply_to_msg_id];} + if(self.flags & (1 << 7)) {//Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.entities count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLMessageEntity* obj = [self.entities objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + }} +} +-(void)unserialize:(SerializedData*)stream { + super.flags = [stream readInt]; + + + + + super.n_id = [stream readInt]; + super.from_id = [stream readInt]; + super.chat_id = [stream readInt]; + super.message = [stream readString]; + super.pts = [stream readInt]; + super.pts_count = [stream readInt]; + super.date = [stream readInt]; + if(self.flags & (1 << 2)) {self.fwd_from_id = [ClassStore TLDeserialize:stream];} + if(self.flags & (1 << 2)) {super.fwd_date = [stream readInt];} + if(self.flags & (1 << 3)) {super.reply_to_msg_id = [stream readInt];} + if(self.flags & (1 << 7)) {//UNS FullVector + [stream readInt]; + { + if(!self.entities) + self.entities = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLMessageEntity* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLMessageEntity class]]) + [self.entities addObject:obj]; + else + break; + } + }} +} + +-(TL_updateShortChatMessage *)copy { + + TL_updateShortChatMessage *objc = [[TL_updateShortChatMessage alloc] init]; + + objc.flags = self.flags; + + + + + objc.n_id = self.n_id; + objc.from_id = self.from_id; + objc.chat_id = self.chat_id; + objc.message = self.message; + objc.pts = self.pts; + objc.pts_count = self.pts_count; + objc.date = self.date; + objc.fwd_from_id = [self.fwd_from_id copy]; + objc.fwd_date = self.fwd_date; + objc.reply_to_msg_id = self.reply_to_msg_id; + objc.entities = [self.entities copy]; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + +-(BOOL)isUnread {return (self.flags & (1 << 0)) > 0;} + +-(BOOL)isN_out {return (self.flags & (1 << 1)) > 0;} + +-(BOOL)isMentioned {return (self.flags & (1 << 4)) > 0;} + +-(BOOL)isMedia_unread {return (self.flags & (1 << 5)) > 0;} + +-(void)setFwd_from_id:(TLPeer*)fwd_from_id +{ + super.fwd_from_id = fwd_from_id; + + if(super.fwd_from_id == nil) { super.flags&= ~ (1 << 2) ;} else { super.flags|= (1 << 2); } +} +-(void)setFwd_date:(int)fwd_date +{ + super.fwd_date = fwd_date; + + if(super.fwd_date == 0) { super.flags&= ~ (1 << 2) ;} else { super.flags|= (1 << 2); } +} +-(void)setReply_to_msg_id:(int)reply_to_msg_id +{ + super.reply_to_msg_id = reply_to_msg_id; + + if(super.reply_to_msg_id == 0) { super.flags&= ~ (1 << 3) ;} else { super.flags|= (1 << 3); } +} +-(void)setEntities:(NSMutableArray*)entities +{ + super.entities = entities; + + if(super.entities == nil) { super.flags&= ~ (1 << 7) ;} else { super.flags|= (1 << 7); } +} + +@end + +@implementation TL_updateShort ++(TL_updateShort*)createWithUpdate:(TLUpdate*)update date:(int)date { + TL_updateShort* obj = [[TL_updateShort alloc] init]; + obj.update = update; + obj.date = date; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [ClassStore TLSerialize:self.update stream:stream]; + [stream writeInt:self.date]; +} +-(void)unserialize:(SerializedData*)stream { + self.update = [ClassStore TLDeserialize:stream]; + super.date = [stream readInt]; +} + +-(TL_updateShort *)copy { + + TL_updateShort *objc = [[TL_updateShort alloc] init]; + + objc.update = [self.update copy]; + objc.date = self.date; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_updatesCombined ++(TL_updatesCombined*)createWithUpdates:(NSMutableArray*)updates users:(NSMutableArray*)users chats:(NSMutableArray*)chats date:(int)date seq_start:(int)seq_start seq:(int)seq { + TL_updatesCombined* obj = [[TL_updatesCombined alloc] init]; + obj.updates = updates; + obj.users = users; + obj.chats = chats; + obj.date = date; + obj.seq_start = seq_start; + obj.seq = seq; + return obj; +} +-(void)serialize:(SerializedData*)stream { + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.updates count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLUpdate* obj = [self.updates objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.users count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLUser* obj = [self.users objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.chats count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLChat* obj = [self.chats objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + [stream writeInt:self.date]; + [stream writeInt:self.seq_start]; + [stream writeInt:self.seq]; +} +-(void)unserialize:(SerializedData*)stream { + //UNS FullVector + [stream readInt]; + { + if(!self.updates) + self.updates = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLUpdate* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLUpdate class]]) + [self.updates addObject:obj]; + else + break; + } + } + //UNS FullVector + [stream readInt]; + { + if(!self.users) + self.users = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLUser* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLUser class]]) + [self.users addObject:obj]; + else + break; + } + } + //UNS FullVector + [stream readInt]; + { + if(!self.chats) + self.chats = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLChat* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLChat class]]) + [self.chats addObject:obj]; + else + break; + } + } + super.date = [stream readInt]; + super.seq_start = [stream readInt]; + super.seq = [stream readInt]; +} + +-(TL_updatesCombined *)copy { + + TL_updatesCombined *objc = [[TL_updatesCombined alloc] init]; + + objc.updates = [self.updates copy]; + objc.users = [self.users copy]; + objc.chats = [self.chats copy]; + objc.date = self.date; + objc.seq_start = self.seq_start; + objc.seq = self.seq; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_updates ++(TL_updates*)createWithUpdates:(NSMutableArray*)updates users:(NSMutableArray*)users chats:(NSMutableArray*)chats date:(int)date seq:(int)seq { + TL_updates* obj = [[TL_updates alloc] init]; + obj.updates = updates; + obj.users = users; + obj.chats = chats; + obj.date = date; + obj.seq = seq; + return obj; +} +-(void)serialize:(SerializedData*)stream { + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.updates count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLUpdate* obj = [self.updates objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.users count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLUser* obj = [self.users objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.chats count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLChat* obj = [self.chats objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + [stream writeInt:self.date]; + [stream writeInt:self.seq]; +} +-(void)unserialize:(SerializedData*)stream { + //UNS FullVector + [stream readInt]; + { + if(!self.updates) + self.updates = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLUpdate* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLUpdate class]]) + [self.updates addObject:obj]; + else + break; + } + } + //UNS FullVector + [stream readInt]; + { + if(!self.users) + self.users = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLUser* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLUser class]]) + [self.users addObject:obj]; + else + break; + } + } + //UNS FullVector + [stream readInt]; + { + if(!self.chats) + self.chats = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLChat* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLChat class]]) + [self.chats addObject:obj]; + else + break; + } + } + super.date = [stream readInt]; + super.seq = [stream readInt]; +} + +-(TL_updates *)copy { + + TL_updates *objc = [[TL_updates alloc] init]; + + objc.updates = [self.updates copy]; + objc.users = [self.users copy]; + objc.chats = [self.chats copy]; + objc.date = self.date; + objc.seq = self.seq; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_updateShortSentMessage ++(TL_updateShortSentMessage*)createWithFlags:(int)flags n_id:(int)n_id pts:(int)pts pts_count:(int)pts_count date:(int)date media:(TLMessageMedia*)media entities:(NSMutableArray*)entities { + TL_updateShortSentMessage* obj = [[TL_updateShortSentMessage alloc] init]; + obj.flags = flags; + + + obj.n_id = n_id; + obj.pts = pts; + obj.pts_count = pts_count; + obj.date = date; + obj.media = media; + obj.entities = entities; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeInt:self.flags]; + + + [stream writeInt:self.n_id]; + [stream writeInt:self.pts]; + [stream writeInt:self.pts_count]; + [stream writeInt:self.date]; + if(self.flags & (1 << 9)) {[ClassStore TLSerialize:self.media stream:stream];} + if(self.flags & (1 << 7)) {//Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.entities count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLMessageEntity* obj = [self.entities objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + }} +} +-(void)unserialize:(SerializedData*)stream { + super.flags = [stream readInt]; + + + super.n_id = [stream readInt]; + super.pts = [stream readInt]; + super.pts_count = [stream readInt]; + super.date = [stream readInt]; + if(self.flags & (1 << 9)) {self.media = [ClassStore TLDeserialize:stream];} + if(self.flags & (1 << 7)) {//UNS FullVector + [stream readInt]; + { + if(!self.entities) + self.entities = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLMessageEntity* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLMessageEntity class]]) + [self.entities addObject:obj]; + else + break; + } + }} +} + +-(TL_updateShortSentMessage *)copy { + + TL_updateShortSentMessage *objc = [[TL_updateShortSentMessage alloc] init]; + + objc.flags = self.flags; + + + objc.n_id = self.n_id; + objc.pts = self.pts; + objc.pts_count = self.pts_count; + objc.date = self.date; + objc.media = [self.media copy]; + objc.entities = [self.entities copy]; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + +-(BOOL)isUnread {return (self.flags & (1 << 0)) > 0;} + +-(BOOL)isN_out {return (self.flags & (1 << 1)) > 0;} + +-(void)setMedia:(TLMessageMedia*)media +{ + super.media = media; + + if(super.media == nil) { super.flags&= ~ (1 << 9) ;} else { super.flags|= (1 << 9); } +} +-(void)setEntities:(NSMutableArray*)entities +{ + super.entities = entities; + + if(super.entities == nil) { super.flags&= ~ (1 << 7) ;} else { super.flags|= (1 << 7); } +} + +@end + +@implementation TLphotos_Photos + +@end + +@implementation TL_photos_photos ++(TL_photos_photos*)createWithPhotos:(NSMutableArray*)photos users:(NSMutableArray*)users { + TL_photos_photos* obj = [[TL_photos_photos alloc] init]; + obj.photos = photos; + obj.users = users; + return obj; +} +-(void)serialize:(SerializedData*)stream { + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.photos count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLPhoto* obj = [self.photos objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.users count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLUser* obj = [self.users objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } +} +-(void)unserialize:(SerializedData*)stream { + //UNS FullVector + [stream readInt]; + { + if(!self.photos) + self.photos = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLPhoto* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLPhoto class]]) + [self.photos addObject:obj]; + else + break; + } + } + //UNS FullVector + [stream readInt]; + { + if(!self.users) + self.users = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLUser* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLUser class]]) + [self.users addObject:obj]; + else + break; + } + } +} + +-(TL_photos_photos *)copy { + + TL_photos_photos *objc = [[TL_photos_photos alloc] init]; + + objc.photos = [self.photos copy]; + objc.users = [self.users copy]; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_photos_photosSlice ++(TL_photos_photosSlice*)createWithN_count:(int)n_count photos:(NSMutableArray*)photos users:(NSMutableArray*)users { + TL_photos_photosSlice* obj = [[TL_photos_photosSlice alloc] init]; + obj.n_count = n_count; + obj.photos = photos; + obj.users = users; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeInt:self.n_count]; + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.photos count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLPhoto* obj = [self.photos objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.users count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLUser* obj = [self.users objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } +} +-(void)unserialize:(SerializedData*)stream { + super.n_count = [stream readInt]; + //UNS FullVector + [stream readInt]; + { + if(!self.photos) + self.photos = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLPhoto* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLPhoto class]]) + [self.photos addObject:obj]; + else + break; + } + } + //UNS FullVector + [stream readInt]; + { + if(!self.users) + self.users = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLUser* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLUser class]]) + [self.users addObject:obj]; + else + break; + } + } +} + +-(TL_photos_photosSlice *)copy { + + TL_photos_photosSlice *objc = [[TL_photos_photosSlice alloc] init]; + + objc.n_count = self.n_count; + objc.photos = [self.photos copy]; + objc.users = [self.users copy]; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TLphotos_Photo + +@end + +@implementation TL_photos_photo ++(TL_photos_photo*)createWithPhoto:(TLPhoto*)photo users:(NSMutableArray*)users { + TL_photos_photo* obj = [[TL_photos_photo alloc] init]; + obj.photo = photo; + obj.users = users; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [ClassStore TLSerialize:self.photo stream:stream]; + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.users count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLUser* obj = [self.users objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } +} +-(void)unserialize:(SerializedData*)stream { + self.photo = [ClassStore TLDeserialize:stream]; + //UNS FullVector + [stream readInt]; + { + if(!self.users) + self.users = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLUser* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLUser class]]) + [self.users addObject:obj]; + else + break; + } + } +} + +-(TL_photos_photo *)copy { + + TL_photos_photo *objc = [[TL_photos_photo alloc] init]; + + objc.photo = [self.photo copy]; + objc.users = [self.users copy]; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TLupload_File + +@end + +@implementation TL_upload_file ++(TL_upload_file*)createWithType:(TLstorage_FileType*)type mtime:(int)mtime bytes:(NSData*)bytes { + TL_upload_file* obj = [[TL_upload_file alloc] init]; + obj.type = type; + obj.mtime = mtime; + obj.bytes = bytes; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [ClassStore TLSerialize:self.type stream:stream]; + [stream writeInt:self.mtime]; + [stream writeByteArray:self.bytes]; +} +-(void)unserialize:(SerializedData*)stream { + self.type = [ClassStore TLDeserialize:stream]; + super.mtime = [stream readInt]; + super.bytes = [stream readByteArray]; +} + +-(TL_upload_file *)copy { + + TL_upload_file *objc = [[TL_upload_file alloc] init]; + + objc.type = [self.type copy]; + objc.mtime = self.mtime; + objc.bytes = [self.bytes copy]; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TLDcOption + +-(BOOL)isIpv6 {return NO;} + +-(BOOL)isMedia_only {return NO;} + +@end + +@implementation TL_dcOption ++(TL_dcOption*)createWithFlags:(int)flags n_id:(int)n_id ip_address:(NSString*)ip_address port:(int)port { + TL_dcOption* obj = [[TL_dcOption alloc] init]; + obj.flags = flags; + + + obj.n_id = n_id; + obj.ip_address = ip_address; + obj.port = port; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeInt:self.flags]; + + + [stream writeInt:self.n_id]; + [stream writeString:self.ip_address]; + [stream writeInt:self.port]; +} +-(void)unserialize:(SerializedData*)stream { + super.flags = [stream readInt]; + + + super.n_id = [stream readInt]; + super.ip_address = [stream readString]; + super.port = [stream readInt]; +} + +-(TL_dcOption *)copy { + + TL_dcOption *objc = [[TL_dcOption alloc] init]; + + objc.flags = self.flags; + + + objc.n_id = self.n_id; + objc.ip_address = self.ip_address; + objc.port = self.port; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + +-(BOOL)isIpv6 {return (self.flags & (1 << 0)) > 0;} + +-(BOOL)isMedia_only {return (self.flags & (1 << 1)) > 0;} + + +@end + +@implementation TLConfig + +@end + +@implementation TL_config ++(TL_config*)createWithDate:(int)date expires:(int)expires test_mode:(Boolean)test_mode this_dc:(int)this_dc dc_options:(NSMutableArray*)dc_options chat_size_max:(int)chat_size_max megagroup_size_max:(int)megagroup_size_max forwarded_count_max:(int)forwarded_count_max online_update_period_ms:(int)online_update_period_ms offline_blur_timeout_ms:(int)offline_blur_timeout_ms offline_idle_timeout_ms:(int)offline_idle_timeout_ms online_cloud_timeout_ms:(int)online_cloud_timeout_ms notify_cloud_delay_ms:(int)notify_cloud_delay_ms notify_default_delay_ms:(int)notify_default_delay_ms chat_big_size:(int)chat_big_size push_chat_period_ms:(int)push_chat_period_ms push_chat_limit:(int)push_chat_limit disabled_features:(NSMutableArray*)disabled_features { + TL_config* obj = [[TL_config alloc] init]; + obj.date = date; + obj.expires = expires; + obj.test_mode = test_mode; + obj.this_dc = this_dc; + obj.dc_options = dc_options; + obj.chat_size_max = chat_size_max; + obj.megagroup_size_max = megagroup_size_max; + obj.forwarded_count_max = forwarded_count_max; + obj.online_update_period_ms = online_update_period_ms; + obj.offline_blur_timeout_ms = offline_blur_timeout_ms; + obj.offline_idle_timeout_ms = offline_idle_timeout_ms; + obj.online_cloud_timeout_ms = online_cloud_timeout_ms; + obj.notify_cloud_delay_ms = notify_cloud_delay_ms; + obj.notify_default_delay_ms = notify_default_delay_ms; + obj.chat_big_size = chat_big_size; + obj.push_chat_period_ms = push_chat_period_ms; + obj.push_chat_limit = push_chat_limit; + obj.disabled_features = disabled_features; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeInt:self.date]; + [stream writeInt:self.expires]; + [stream writeBool:self.test_mode]; + [stream writeInt:self.this_dc]; + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.dc_options count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLDcOption* obj = [self.dc_options objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + [stream writeInt:self.chat_size_max]; + [stream writeInt:self.megagroup_size_max]; + [stream writeInt:self.forwarded_count_max]; + [stream writeInt:self.online_update_period_ms]; + [stream writeInt:self.offline_blur_timeout_ms]; + [stream writeInt:self.offline_idle_timeout_ms]; + [stream writeInt:self.online_cloud_timeout_ms]; + [stream writeInt:self.notify_cloud_delay_ms]; + [stream writeInt:self.notify_default_delay_ms]; + [stream writeInt:self.chat_big_size]; + [stream writeInt:self.push_chat_period_ms]; + [stream writeInt:self.push_chat_limit]; + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.disabled_features count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLDisabledFeature* obj = [self.disabled_features objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } +} +-(void)unserialize:(SerializedData*)stream { + super.date = [stream readInt]; + super.expires = [stream readInt]; + super.test_mode = [stream readBool]; + super.this_dc = [stream readInt]; + //UNS FullVector + [stream readInt]; + { + if(!self.dc_options) + self.dc_options = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLDcOption* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLDcOption class]]) + [self.dc_options addObject:obj]; + else + break; + } + } + super.chat_size_max = [stream readInt]; + super.megagroup_size_max = [stream readInt]; + super.forwarded_count_max = [stream readInt]; + super.online_update_period_ms = [stream readInt]; + super.offline_blur_timeout_ms = [stream readInt]; + super.offline_idle_timeout_ms = [stream readInt]; + super.online_cloud_timeout_ms = [stream readInt]; + super.notify_cloud_delay_ms = [stream readInt]; + super.notify_default_delay_ms = [stream readInt]; + super.chat_big_size = [stream readInt]; + super.push_chat_period_ms = [stream readInt]; + super.push_chat_limit = [stream readInt]; + //UNS FullVector + [stream readInt]; + { + if(!self.disabled_features) + self.disabled_features = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLDisabledFeature* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLDisabledFeature class]]) + [self.disabled_features addObject:obj]; + else + break; + } + } +} + +-(TL_config *)copy { + + TL_config *objc = [[TL_config alloc] init]; + + objc.date = self.date; + objc.expires = self.expires; + objc.test_mode = self.test_mode; + objc.this_dc = self.this_dc; + objc.dc_options = [self.dc_options copy]; + objc.chat_size_max = self.chat_size_max; + objc.megagroup_size_max = self.megagroup_size_max; + objc.forwarded_count_max = self.forwarded_count_max; + objc.online_update_period_ms = self.online_update_period_ms; + objc.offline_blur_timeout_ms = self.offline_blur_timeout_ms; + objc.offline_idle_timeout_ms = self.offline_idle_timeout_ms; + objc.online_cloud_timeout_ms = self.online_cloud_timeout_ms; + objc.notify_cloud_delay_ms = self.notify_cloud_delay_ms; + objc.notify_default_delay_ms = self.notify_default_delay_ms; + objc.chat_big_size = self.chat_big_size; + objc.push_chat_period_ms = self.push_chat_period_ms; + objc.push_chat_limit = self.push_chat_limit; + objc.disabled_features = [self.disabled_features copy]; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TLNearestDc + +@end + +@implementation TL_nearestDc ++(TL_nearestDc*)createWithCountry:(NSString*)country this_dc:(int)this_dc nearest_dc:(int)nearest_dc { + TL_nearestDc* obj = [[TL_nearestDc alloc] init]; + obj.country = country; + obj.this_dc = this_dc; + obj.nearest_dc = nearest_dc; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeString:self.country]; + [stream writeInt:self.this_dc]; + [stream writeInt:self.nearest_dc]; +} +-(void)unserialize:(SerializedData*)stream { + super.country = [stream readString]; + super.this_dc = [stream readInt]; + super.nearest_dc = [stream readInt]; +} + +-(TL_nearestDc *)copy { + + TL_nearestDc *objc = [[TL_nearestDc alloc] init]; + + objc.country = self.country; + objc.this_dc = self.this_dc; + objc.nearest_dc = self.nearest_dc; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TLhelp_AppUpdate + +@end + +@implementation TL_help_appUpdate ++(TL_help_appUpdate*)createWithN_id:(int)n_id critical:(Boolean)critical url:(NSString*)url text:(NSString*)text { + TL_help_appUpdate* obj = [[TL_help_appUpdate alloc] init]; + obj.n_id = n_id; + obj.critical = critical; + obj.url = url; + obj.text = text; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeInt:self.n_id]; + [stream writeBool:self.critical]; + [stream writeString:self.url]; + [stream writeString:self.text]; +} +-(void)unserialize:(SerializedData*)stream { + super.n_id = [stream readInt]; + super.critical = [stream readBool]; + super.url = [stream readString]; + super.text = [stream readString]; +} + +-(TL_help_appUpdate *)copy { + + TL_help_appUpdate *objc = [[TL_help_appUpdate alloc] init]; + + objc.n_id = self.n_id; + objc.critical = self.critical; + objc.url = self.url; + objc.text = self.text; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_help_noAppUpdate ++(TL_help_noAppUpdate*)create { + TL_help_noAppUpdate* obj = [[TL_help_noAppUpdate alloc] init]; + + return obj; +} +-(void)serialize:(SerializedData*)stream { + +} +-(void)unserialize:(SerializedData*)stream { + +} + +-(TL_help_noAppUpdate *)copy { + + TL_help_noAppUpdate *objc = [[TL_help_noAppUpdate alloc] init]; + + + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TLhelp_InviteText + +@end + +@implementation TL_help_inviteText ++(TL_help_inviteText*)createWithMessage:(NSString*)message { + TL_help_inviteText* obj = [[TL_help_inviteText alloc] init]; + obj.message = message; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeString:self.message]; +} +-(void)unserialize:(SerializedData*)stream { + super.message = [stream readString]; +} + +-(TL_help_inviteText *)copy { + + TL_help_inviteText *objc = [[TL_help_inviteText alloc] init]; + + objc.message = self.message; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TLEncryptedChat + +@end + +@implementation TL_encryptedChatEmpty ++(TL_encryptedChatEmpty*)createWithN_id:(int)n_id { + TL_encryptedChatEmpty* obj = [[TL_encryptedChatEmpty alloc] init]; + obj.n_id = n_id; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeInt:self.n_id]; +} +-(void)unserialize:(SerializedData*)stream { + super.n_id = [stream readInt]; +} + +-(TL_encryptedChatEmpty *)copy { + + TL_encryptedChatEmpty *objc = [[TL_encryptedChatEmpty alloc] init]; + + objc.n_id = self.n_id; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_encryptedChatWaiting ++(TL_encryptedChatWaiting*)createWithN_id:(int)n_id access_hash:(long)access_hash date:(int)date admin_id:(int)admin_id participant_id:(int)participant_id { + TL_encryptedChatWaiting* obj = [[TL_encryptedChatWaiting alloc] init]; + obj.n_id = n_id; + obj.access_hash = access_hash; + obj.date = date; + obj.admin_id = admin_id; + obj.participant_id = participant_id; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeInt:self.n_id]; + [stream writeLong:self.access_hash]; + [stream writeInt:self.date]; + [stream writeInt:self.admin_id]; + [stream writeInt:self.participant_id]; +} +-(void)unserialize:(SerializedData*)stream { + super.n_id = [stream readInt]; + super.access_hash = [stream readLong]; + super.date = [stream readInt]; + super.admin_id = [stream readInt]; + super.participant_id = [stream readInt]; +} + +-(TL_encryptedChatWaiting *)copy { + + TL_encryptedChatWaiting *objc = [[TL_encryptedChatWaiting alloc] init]; + + objc.n_id = self.n_id; + objc.access_hash = self.access_hash; + objc.date = self.date; + objc.admin_id = self.admin_id; + objc.participant_id = self.participant_id; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_encryptedChatRequested ++(TL_encryptedChatRequested*)createWithN_id:(int)n_id access_hash:(long)access_hash date:(int)date admin_id:(int)admin_id participant_id:(int)participant_id g_a:(NSData*)g_a { + TL_encryptedChatRequested* obj = [[TL_encryptedChatRequested alloc] init]; + obj.n_id = n_id; + obj.access_hash = access_hash; + obj.date = date; + obj.admin_id = admin_id; + obj.participant_id = participant_id; + obj.g_a = g_a; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeInt:self.n_id]; + [stream writeLong:self.access_hash]; + [stream writeInt:self.date]; + [stream writeInt:self.admin_id]; + [stream writeInt:self.participant_id]; + [stream writeByteArray:self.g_a]; +} +-(void)unserialize:(SerializedData*)stream { + super.n_id = [stream readInt]; + super.access_hash = [stream readLong]; + super.date = [stream readInt]; + super.admin_id = [stream readInt]; + super.participant_id = [stream readInt]; + super.g_a = [stream readByteArray]; +} + +-(TL_encryptedChatRequested *)copy { + + TL_encryptedChatRequested *objc = [[TL_encryptedChatRequested alloc] init]; + + objc.n_id = self.n_id; + objc.access_hash = self.access_hash; + objc.date = self.date; + objc.admin_id = self.admin_id; + objc.participant_id = self.participant_id; + objc.g_a = [self.g_a copy]; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_encryptedChat ++(TL_encryptedChat*)createWithN_id:(int)n_id access_hash:(long)access_hash date:(int)date admin_id:(int)admin_id participant_id:(int)participant_id g_a_or_b:(NSData*)g_a_or_b key_fingerprint:(long)key_fingerprint { + TL_encryptedChat* obj = [[TL_encryptedChat alloc] init]; + obj.n_id = n_id; + obj.access_hash = access_hash; + obj.date = date; + obj.admin_id = admin_id; + obj.participant_id = participant_id; + obj.g_a_or_b = g_a_or_b; + obj.key_fingerprint = key_fingerprint; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeInt:self.n_id]; + [stream writeLong:self.access_hash]; + [stream writeInt:self.date]; + [stream writeInt:self.admin_id]; + [stream writeInt:self.participant_id]; + [stream writeByteArray:self.g_a_or_b]; + [stream writeLong:self.key_fingerprint]; +} +-(void)unserialize:(SerializedData*)stream { + super.n_id = [stream readInt]; + super.access_hash = [stream readLong]; + super.date = [stream readInt]; + super.admin_id = [stream readInt]; + super.participant_id = [stream readInt]; + super.g_a_or_b = [stream readByteArray]; + super.key_fingerprint = [stream readLong]; +} + +-(TL_encryptedChat *)copy { + + TL_encryptedChat *objc = [[TL_encryptedChat alloc] init]; + + objc.n_id = self.n_id; + objc.access_hash = self.access_hash; + objc.date = self.date; + objc.admin_id = self.admin_id; + objc.participant_id = self.participant_id; + objc.g_a_or_b = [self.g_a_or_b copy]; + objc.key_fingerprint = self.key_fingerprint; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_encryptedChatDiscarded ++(TL_encryptedChatDiscarded*)createWithN_id:(int)n_id { + TL_encryptedChatDiscarded* obj = [[TL_encryptedChatDiscarded alloc] init]; + obj.n_id = n_id; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeInt:self.n_id]; +} +-(void)unserialize:(SerializedData*)stream { + super.n_id = [stream readInt]; +} + +-(TL_encryptedChatDiscarded *)copy { + + TL_encryptedChatDiscarded *objc = [[TL_encryptedChatDiscarded alloc] init]; + + objc.n_id = self.n_id; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TLInputEncryptedChat + +@end + +@implementation TL_inputEncryptedChat ++(TL_inputEncryptedChat*)createWithChat_id:(int)chat_id access_hash:(long)access_hash { + TL_inputEncryptedChat* obj = [[TL_inputEncryptedChat alloc] init]; + obj.chat_id = chat_id; + obj.access_hash = access_hash; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeInt:self.chat_id]; + [stream writeLong:self.access_hash]; +} +-(void)unserialize:(SerializedData*)stream { + super.chat_id = [stream readInt]; + super.access_hash = [stream readLong]; +} + +-(TL_inputEncryptedChat *)copy { + + TL_inputEncryptedChat *objc = [[TL_inputEncryptedChat alloc] init]; + + objc.chat_id = self.chat_id; + objc.access_hash = self.access_hash; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TLEncryptedFile + +@end + +@implementation TL_encryptedFileEmpty ++(TL_encryptedFileEmpty*)create { + TL_encryptedFileEmpty* obj = [[TL_encryptedFileEmpty alloc] init]; + + return obj; +} +-(void)serialize:(SerializedData*)stream { + +} +-(void)unserialize:(SerializedData*)stream { + +} + +-(TL_encryptedFileEmpty *)copy { + + TL_encryptedFileEmpty *objc = [[TL_encryptedFileEmpty alloc] init]; + + + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_encryptedFile ++(TL_encryptedFile*)createWithN_id:(long)n_id access_hash:(long)access_hash size:(int)size dc_id:(int)dc_id key_fingerprint:(int)key_fingerprint { + TL_encryptedFile* obj = [[TL_encryptedFile alloc] init]; + obj.n_id = n_id; + obj.access_hash = access_hash; + obj.size = size; + obj.dc_id = dc_id; + obj.key_fingerprint = key_fingerprint; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeLong:self.n_id]; + [stream writeLong:self.access_hash]; + [stream writeInt:self.size]; + [stream writeInt:self.dc_id]; + [stream writeInt:self.key_fingerprint]; +} +-(void)unserialize:(SerializedData*)stream { + super.n_id = [stream readLong]; + super.access_hash = [stream readLong]; + super.size = [stream readInt]; + super.dc_id = [stream readInt]; + super.key_fingerprint = [stream readInt]; +} + +-(TL_encryptedFile *)copy { + + TL_encryptedFile *objc = [[TL_encryptedFile alloc] init]; + + objc.n_id = self.n_id; + objc.access_hash = self.access_hash; + objc.size = self.size; + objc.dc_id = self.dc_id; + objc.key_fingerprint = self.key_fingerprint; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TLInputEncryptedFile + +@end + +@implementation TL_inputEncryptedFileEmpty ++(TL_inputEncryptedFileEmpty*)create { + TL_inputEncryptedFileEmpty* obj = [[TL_inputEncryptedFileEmpty alloc] init]; + + return obj; +} +-(void)serialize:(SerializedData*)stream { + +} +-(void)unserialize:(SerializedData*)stream { + +} + +-(TL_inputEncryptedFileEmpty *)copy { + + TL_inputEncryptedFileEmpty *objc = [[TL_inputEncryptedFileEmpty alloc] init]; + + + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_inputEncryptedFileUploaded ++(TL_inputEncryptedFileUploaded*)createWithN_id:(long)n_id parts:(int)parts md5_checksum:(NSString*)md5_checksum key_fingerprint:(int)key_fingerprint { + TL_inputEncryptedFileUploaded* obj = [[TL_inputEncryptedFileUploaded alloc] init]; + obj.n_id = n_id; + obj.parts = parts; + obj.md5_checksum = md5_checksum; + obj.key_fingerprint = key_fingerprint; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeLong:self.n_id]; + [stream writeInt:self.parts]; + [stream writeString:self.md5_checksum]; + [stream writeInt:self.key_fingerprint]; +} +-(void)unserialize:(SerializedData*)stream { + super.n_id = [stream readLong]; + super.parts = [stream readInt]; + super.md5_checksum = [stream readString]; + super.key_fingerprint = [stream readInt]; +} + +-(TL_inputEncryptedFileUploaded *)copy { + + TL_inputEncryptedFileUploaded *objc = [[TL_inputEncryptedFileUploaded alloc] init]; + + objc.n_id = self.n_id; + objc.parts = self.parts; + objc.md5_checksum = self.md5_checksum; + objc.key_fingerprint = self.key_fingerprint; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_inputEncryptedFile ++(TL_inputEncryptedFile*)createWithN_id:(long)n_id access_hash:(long)access_hash { + TL_inputEncryptedFile* obj = [[TL_inputEncryptedFile alloc] init]; + obj.n_id = n_id; + obj.access_hash = access_hash; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeLong:self.n_id]; + [stream writeLong:self.access_hash]; +} +-(void)unserialize:(SerializedData*)stream { + super.n_id = [stream readLong]; + super.access_hash = [stream readLong]; +} + +-(TL_inputEncryptedFile *)copy { + + TL_inputEncryptedFile *objc = [[TL_inputEncryptedFile alloc] init]; + + objc.n_id = self.n_id; + objc.access_hash = self.access_hash; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_inputEncryptedFileBigUploaded ++(TL_inputEncryptedFileBigUploaded*)createWithN_id:(long)n_id parts:(int)parts key_fingerprint:(int)key_fingerprint { + TL_inputEncryptedFileBigUploaded* obj = [[TL_inputEncryptedFileBigUploaded alloc] init]; + obj.n_id = n_id; + obj.parts = parts; + obj.key_fingerprint = key_fingerprint; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeLong:self.n_id]; + [stream writeInt:self.parts]; + [stream writeInt:self.key_fingerprint]; +} +-(void)unserialize:(SerializedData*)stream { + super.n_id = [stream readLong]; + super.parts = [stream readInt]; + super.key_fingerprint = [stream readInt]; +} + +-(TL_inputEncryptedFileBigUploaded *)copy { + + TL_inputEncryptedFileBigUploaded *objc = [[TL_inputEncryptedFileBigUploaded alloc] init]; + + objc.n_id = self.n_id; + objc.parts = self.parts; + objc.key_fingerprint = self.key_fingerprint; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TLEncryptedMessage + +@end + +@implementation TL_encryptedMessage ++(TL_encryptedMessage*)createWithRandom_id:(long)random_id chat_id:(int)chat_id date:(int)date bytes:(NSData*)bytes file:(TLEncryptedFile*)file { + TL_encryptedMessage* obj = [[TL_encryptedMessage alloc] init]; + obj.random_id = random_id; + obj.chat_id = chat_id; + obj.date = date; + obj.bytes = bytes; + obj.file = file; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeLong:self.random_id]; + [stream writeInt:self.chat_id]; + [stream writeInt:self.date]; + [stream writeByteArray:self.bytes]; + [ClassStore TLSerialize:self.file stream:stream]; +} +-(void)unserialize:(SerializedData*)stream { + super.random_id = [stream readLong]; + super.chat_id = [stream readInt]; + super.date = [stream readInt]; + super.bytes = [stream readByteArray]; + self.file = [ClassStore TLDeserialize:stream]; +} + +-(TL_encryptedMessage *)copy { + + TL_encryptedMessage *objc = [[TL_encryptedMessage alloc] init]; + + objc.random_id = self.random_id; + objc.chat_id = self.chat_id; + objc.date = self.date; + objc.bytes = [self.bytes copy]; + objc.file = [self.file copy]; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_encryptedMessageService ++(TL_encryptedMessageService*)createWithRandom_id:(long)random_id chat_id:(int)chat_id date:(int)date bytes:(NSData*)bytes { + TL_encryptedMessageService* obj = [[TL_encryptedMessageService alloc] init]; + obj.random_id = random_id; + obj.chat_id = chat_id; + obj.date = date; + obj.bytes = bytes; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeLong:self.random_id]; + [stream writeInt:self.chat_id]; + [stream writeInt:self.date]; + [stream writeByteArray:self.bytes]; +} +-(void)unserialize:(SerializedData*)stream { + super.random_id = [stream readLong]; + super.chat_id = [stream readInt]; + super.date = [stream readInt]; + super.bytes = [stream readByteArray]; +} + +-(TL_encryptedMessageService *)copy { + + TL_encryptedMessageService *objc = [[TL_encryptedMessageService alloc] init]; + + objc.random_id = self.random_id; + objc.chat_id = self.chat_id; + objc.date = self.date; + objc.bytes = [self.bytes copy]; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TLmessages_DhConfig + +@end + +@implementation TL_messages_dhConfigNotModified ++(TL_messages_dhConfigNotModified*)createWithRandom:(NSData*)random { + TL_messages_dhConfigNotModified* obj = [[TL_messages_dhConfigNotModified alloc] init]; + obj.random = random; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeByteArray:self.random]; +} +-(void)unserialize:(SerializedData*)stream { + super.random = [stream readByteArray]; +} + +-(TL_messages_dhConfigNotModified *)copy { + + TL_messages_dhConfigNotModified *objc = [[TL_messages_dhConfigNotModified alloc] init]; + + objc.random = [self.random copy]; + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + +@end + +@implementation TL_messages_dhConfig ++(TL_messages_dhConfig*)createWithG:(int)g p:(NSData*)p version:(int)version random:(NSData*)random { + TL_messages_dhConfig* obj = [[TL_messages_dhConfig alloc] init]; + obj.g = g; + obj.p = p; + obj.version = version; + obj.random = random; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeInt:self.g]; + [stream writeByteArray:self.p]; + [stream writeInt:self.version]; + [stream writeByteArray:self.random]; +} +-(void)unserialize:(SerializedData*)stream { + super.g = [stream readInt]; + super.p = [stream readByteArray]; + super.version = [stream readInt]; + super.random = [stream readByteArray]; +} + +-(TL_messages_dhConfig *)copy { - TL_updates_differenceSlice *objc = [[TL_updates_differenceSlice alloc] init]; + TL_messages_dhConfig *objc = [[TL_messages_dhConfig alloc] init]; - objc.n_messages = [self.n_messages copy]; - objc.n_encrypted_messages = [self.n_encrypted_messages copy]; - objc.other_updates = [self.other_updates copy]; - objc.chats = [self.chats copy]; - objc.users = [self.users copy]; - objc.intermediate_state = [self.intermediate_state copy]; + objc.g = self.g; + objc.p = [self.p copy]; + objc.version = self.version; + objc.random = [self.random copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -10729,37 +15434,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TLmessages_SentEncryptedMessage -@implementation TLUpdates @end - -@implementation TL_updatesTooLong -+(TL_updatesTooLong*)create { - TL_updatesTooLong* obj = [[TL_updatesTooLong alloc] init]; - + +@implementation TL_messages_sentEncryptedMessage ++(TL_messages_sentEncryptedMessage*)createWithDate:(int)date { + TL_messages_sentEncryptedMessage* obj = [[TL_messages_sentEncryptedMessage alloc] init]; + obj.date = date; return obj; } -(void)serialize:(SerializedData*)stream { - + [stream writeInt:self.date]; } -(void)unserialize:(SerializedData*)stream { - + super.date = [stream readInt]; } --(TL_updatesTooLong *)copy { - - TL_updatesTooLong *objc = [[TL_updatesTooLong alloc] init]; +-(TL_messages_sentEncryptedMessage *)copy { + TL_messages_sentEncryptedMessage *objc = [[TL_messages_sentEncryptedMessage alloc] init]; + objc.date = self.date; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -10773,69 +15479,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_updateShortMessage -+(TL_updateShortMessage*)createWithFlags:(int)flags n_id:(int)n_id user_id:(int)user_id message:(NSString*)message pts:(int)pts pts_count:(int)pts_count date:(int)date fwd_from_id:(int)fwd_from_id fwd_date:(int)fwd_date reply_to_msg_id:(int)reply_to_msg_id { - TL_updateShortMessage* obj = [[TL_updateShortMessage alloc] init]; - obj.flags = flags; - obj.n_id = n_id; - obj.user_id = user_id; - obj.message = message; - obj.pts = pts; - obj.pts_count = pts_count; +@implementation TL_messages_sentEncryptedFile ++(TL_messages_sentEncryptedFile*)createWithDate:(int)date file:(TLEncryptedFile*)file { + TL_messages_sentEncryptedFile* obj = [[TL_messages_sentEncryptedFile alloc] init]; obj.date = date; - obj.fwd_from_id = fwd_from_id; - obj.fwd_date = fwd_date; - obj.reply_to_msg_id = reply_to_msg_id; + obj.file = file; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.flags]; - [stream writeInt:self.n_id]; - [stream writeInt:self.user_id]; - [stream writeString:self.message]; - [stream writeInt:self.pts]; - [stream writeInt:self.pts_count]; [stream writeInt:self.date]; - if(self.flags & (1 << 2)) [stream writeInt:self.fwd_from_id]; - if(self.flags & (1 << 2)) [stream writeInt:self.fwd_date]; - if(self.flags & (1 << 3)) [stream writeInt:self.reply_to_msg_id]; + [ClassStore TLSerialize:self.file stream:stream]; } -(void)unserialize:(SerializedData*)stream { - self.flags = [stream readInt]; - self.n_id = [stream readInt]; - self.user_id = [stream readInt]; - self.message = [stream readString]; - self.pts = [stream readInt]; - self.pts_count = [stream readInt]; - self.date = [stream readInt]; - if(self.flags & (1 << 2)) self.fwd_from_id = [stream readInt]; - if(self.flags & (1 << 2)) self.fwd_date = [stream readInt]; - if(self.flags & (1 << 3)) self.reply_to_msg_id = [stream readInt]; + super.date = [stream readInt]; + self.file = [ClassStore TLDeserialize:stream]; } --(TL_updateShortMessage *)copy { +-(TL_messages_sentEncryptedFile *)copy { - TL_updateShortMessage *objc = [[TL_updateShortMessage alloc] init]; + TL_messages_sentEncryptedFile *objc = [[TL_messages_sentEncryptedFile alloc] init]; - objc.flags = self.flags; - objc.n_id = self.n_id; - objc.user_id = self.user_id; - objc.message = self.message; - objc.pts = self.pts; - objc.pts_count = self.pts_count; objc.date = self.date; - objc.fwd_from_id = self.fwd_from_id; - objc.fwd_date = self.fwd_date; - objc.reply_to_msg_id = self.reply_to_msg_id; + objc.file = [self.file copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -10849,91 +15524,83 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } + +@end + +@implementation TLInputAudio + +@end --(void)setFwd_from_id:(int)fwd_from_id -{ - [super setFwd_from_id:fwd_from_id]; - - if(self.fwd_from_id == 0) { self.flags&= ~ (1 << 2) ;} else { self.flags|= (1 << 2); } -} --(void)setFwd_date:(int)fwd_date -{ - [super setFwd_date:fwd_date]; - - if(self.fwd_date == 0) { self.flags&= ~ (1 << 2) ;} else { self.flags|= (1 << 2); } -} --(void)setReply_to_msg_id:(int)reply_to_msg_id -{ - [super setReply_to_msg_id:reply_to_msg_id]; - - if(self.reply_to_msg_id == 0) { self.flags&= ~ (1 << 3) ;} else { self.flags|= (1 << 3); } +@implementation TL_inputAudioEmpty ++(TL_inputAudioEmpty*)create { + TL_inputAudioEmpty* obj = [[TL_inputAudioEmpty alloc] init]; + + return obj; +} +-(void)serialize:(SerializedData*)stream { + +} +-(void)unserialize:(SerializedData*)stream { + +} + +-(TL_inputAudioEmpty *)copy { + + TL_inputAudioEmpty *objc = [[TL_inputAudioEmpty alloc] init]; + + + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } + + @end -@implementation TL_updateShortChatMessage -+(TL_updateShortChatMessage*)createWithFlags:(int)flags n_id:(int)n_id from_id:(int)from_id chat_id:(int)chat_id message:(NSString*)message pts:(int)pts pts_count:(int)pts_count date:(int)date fwd_from_id:(int)fwd_from_id fwd_date:(int)fwd_date reply_to_msg_id:(int)reply_to_msg_id { - TL_updateShortChatMessage* obj = [[TL_updateShortChatMessage alloc] init]; - obj.flags = flags; +@implementation TL_inputAudio ++(TL_inputAudio*)createWithN_id:(long)n_id access_hash:(long)access_hash { + TL_inputAudio* obj = [[TL_inputAudio alloc] init]; obj.n_id = n_id; - obj.from_id = from_id; - obj.chat_id = chat_id; - obj.message = message; - obj.pts = pts; - obj.pts_count = pts_count; - obj.date = date; - obj.fwd_from_id = fwd_from_id; - obj.fwd_date = fwd_date; - obj.reply_to_msg_id = reply_to_msg_id; + obj.access_hash = access_hash; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.flags]; - [stream writeInt:self.n_id]; - [stream writeInt:self.from_id]; - [stream writeInt:self.chat_id]; - [stream writeString:self.message]; - [stream writeInt:self.pts]; - [stream writeInt:self.pts_count]; - [stream writeInt:self.date]; - if(self.flags & (1 << 2)) [stream writeInt:self.fwd_from_id]; - if(self.flags & (1 << 2)) [stream writeInt:self.fwd_date]; - if(self.flags & (1 << 3)) [stream writeInt:self.reply_to_msg_id]; + [stream writeLong:self.n_id]; + [stream writeLong:self.access_hash]; } -(void)unserialize:(SerializedData*)stream { - self.flags = [stream readInt]; - self.n_id = [stream readInt]; - self.from_id = [stream readInt]; - self.chat_id = [stream readInt]; - self.message = [stream readString]; - self.pts = [stream readInt]; - self.pts_count = [stream readInt]; - self.date = [stream readInt]; - if(self.flags & (1 << 2)) self.fwd_from_id = [stream readInt]; - if(self.flags & (1 << 2)) self.fwd_date = [stream readInt]; - if(self.flags & (1 << 3)) self.reply_to_msg_id = [stream readInt]; + super.n_id = [stream readLong]; + super.access_hash = [stream readLong]; } --(TL_updateShortChatMessage *)copy { +-(TL_inputAudio *)copy { - TL_updateShortChatMessage *objc = [[TL_updateShortChatMessage alloc] init]; + TL_inputAudio *objc = [[TL_inputAudio alloc] init]; - objc.flags = self.flags; objc.n_id = self.n_id; - objc.from_id = self.from_id; - objc.chat_id = self.chat_id; - objc.message = self.message; - objc.pts = self.pts; - objc.pts_count = self.pts_count; - objc.date = self.date; - objc.fwd_from_id = self.fwd_from_id; - objc.fwd_date = self.fwd_date; - objc.reply_to_msg_id = self.reply_to_msg_id; + objc.access_hash = self.access_hash; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -10947,55 +15614,83 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } + +@end + +@implementation TLInputDocument + +@end --(void)setFwd_from_id:(int)fwd_from_id -{ - [super setFwd_from_id:fwd_from_id]; - - if(self.fwd_from_id == 0) { self.flags&= ~ (1 << 2) ;} else { self.flags|= (1 << 2); } -} --(void)setFwd_date:(int)fwd_date -{ - [super setFwd_date:fwd_date]; - - if(self.fwd_date == 0) { self.flags&= ~ (1 << 2) ;} else { self.flags|= (1 << 2); } -} --(void)setReply_to_msg_id:(int)reply_to_msg_id -{ - [super setReply_to_msg_id:reply_to_msg_id]; - - if(self.reply_to_msg_id == 0) { self.flags&= ~ (1 << 3) ;} else { self.flags|= (1 << 3); } +@implementation TL_inputDocumentEmpty ++(TL_inputDocumentEmpty*)create { + TL_inputDocumentEmpty* obj = [[TL_inputDocumentEmpty alloc] init]; + + return obj; +} +-(void)serialize:(SerializedData*)stream { + +} +-(void)unserialize:(SerializedData*)stream { + +} + +-(TL_inputDocumentEmpty *)copy { + + TL_inputDocumentEmpty *objc = [[TL_inputDocumentEmpty alloc] init]; + + + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } + + @end -@implementation TL_updateShort -+(TL_updateShort*)createWithUpdate:(TLUpdate*)update date:(int)date { - TL_updateShort* obj = [[TL_updateShort alloc] init]; - obj.update = update; - obj.date = date; +@implementation TL_inputDocument ++(TL_inputDocument*)createWithN_id:(long)n_id access_hash:(long)access_hash { + TL_inputDocument* obj = [[TL_inputDocument alloc] init]; + obj.n_id = n_id; + obj.access_hash = access_hash; return obj; } -(void)serialize:(SerializedData*)stream { - [ClassStore TLSerialize:self.update stream:stream]; - [stream writeInt:self.date]; + [stream writeLong:self.n_id]; + [stream writeLong:self.access_hash]; } -(void)unserialize:(SerializedData*)stream { - self.update = [ClassStore TLDeserialize:stream]; - self.date = [stream readInt]; + super.n_id = [stream readLong]; + super.access_hash = [stream readLong]; } --(TL_updateShort *)copy { +-(TL_inputDocument *)copy { - TL_updateShort *objc = [[TL_updateShort alloc] init]; + TL_inputDocument *objc = [[TL_inputDocument alloc] init]; - objc.update = [self.update copy]; - objc.date = self.date; + objc.n_id = self.n_id; + objc.access_hash = self.access_hash; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -11009,119 +15704,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_updatesCombined -+(TL_updatesCombined*)createWithUpdates:(NSMutableArray*)updates users:(NSMutableArray*)users chats:(NSMutableArray*)chats date:(int)date seq_start:(int)seq_start seq:(int)seq { - TL_updatesCombined* obj = [[TL_updatesCombined alloc] init]; - obj.updates = updates; - obj.users = users; - obj.chats = chats; - obj.date = date; - obj.seq_start = seq_start; - obj.seq = seq; +@implementation TLAudio + +@end + +@implementation TL_audioEmpty ++(TL_audioEmpty*)createWithN_id:(long)n_id { + TL_audioEmpty* obj = [[TL_audioEmpty alloc] init]; + obj.n_id = n_id; return obj; } -(void)serialize:(SerializedData*)stream { - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.updates count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLUpdate* obj = [self.updates objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.users count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLUser* obj = [self.users objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.chats count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLChat* obj = [self.chats objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - [stream writeInt:self.date]; - [stream writeInt:self.seq_start]; - [stream writeInt:self.seq]; + [stream writeLong:self.n_id]; } -(void)unserialize:(SerializedData*)stream { - //UNS FullVector - [stream readInt]; - { - if(!self.updates) - self.updates = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLUpdate* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLUpdate class]]) - [self.updates addObject:obj]; - else - break; - } - } - //UNS FullVector - [stream readInt]; - { - if(!self.users) - self.users = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLUser* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLUser class]]) - [self.users addObject:obj]; - else - break; - } - } - //UNS FullVector - [stream readInt]; - { - if(!self.chats) - self.chats = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLChat* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLChat class]]) - [self.chats addObject:obj]; - else - break; - } - } - self.date = [stream readInt]; - self.seq_start = [stream readInt]; - self.seq = [stream readInt]; + super.n_id = [stream readLong]; } --(TL_updatesCombined *)copy { +-(TL_audioEmpty *)copy { - TL_updatesCombined *objc = [[TL_updatesCombined alloc] init]; + TL_audioEmpty *objc = [[TL_audioEmpty alloc] init]; - objc.updates = [self.updates copy]; - objc.users = [self.users copy]; - objc.chats = [self.chats copy]; - objc.date = self.date; - objc.seq_start = self.seq_start; - objc.seq = self.seq; + objc.n_id = self.n_id; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -11135,115 +15749,58 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_updates -+(TL_updates*)createWithUpdates:(NSMutableArray*)updates users:(NSMutableArray*)users chats:(NSMutableArray*)chats date:(int)date seq:(int)seq { - TL_updates* obj = [[TL_updates alloc] init]; - obj.updates = updates; - obj.users = users; - obj.chats = chats; +@implementation TL_audio ++(TL_audio*)createWithN_id:(long)n_id access_hash:(long)access_hash date:(int)date duration:(int)duration mime_type:(NSString*)mime_type size:(int)size dc_id:(int)dc_id { + TL_audio* obj = [[TL_audio alloc] init]; + obj.n_id = n_id; + obj.access_hash = access_hash; obj.date = date; - obj.seq = seq; + obj.duration = duration; + obj.mime_type = mime_type; + obj.size = size; + obj.dc_id = dc_id; return obj; } -(void)serialize:(SerializedData*)stream { - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.updates count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLUpdate* obj = [self.updates objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.users count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLUser* obj = [self.users objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.chats count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLChat* obj = [self.chats objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } + [stream writeLong:self.n_id]; + [stream writeLong:self.access_hash]; [stream writeInt:self.date]; - [stream writeInt:self.seq]; + [stream writeInt:self.duration]; + [stream writeString:self.mime_type]; + [stream writeInt:self.size]; + [stream writeInt:self.dc_id]; } -(void)unserialize:(SerializedData*)stream { - //UNS FullVector - [stream readInt]; - { - if(!self.updates) - self.updates = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLUpdate* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLUpdate class]]) - [self.updates addObject:obj]; - else - break; - } - } - //UNS FullVector - [stream readInt]; - { - if(!self.users) - self.users = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLUser* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLUser class]]) - [self.users addObject:obj]; - else - break; - } - } - //UNS FullVector - [stream readInt]; - { - if(!self.chats) - self.chats = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLChat* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLChat class]]) - [self.chats addObject:obj]; - else - break; - } - } - self.date = [stream readInt]; - self.seq = [stream readInt]; + super.n_id = [stream readLong]; + super.access_hash = [stream readLong]; + super.date = [stream readInt]; + super.duration = [stream readInt]; + super.mime_type = [stream readString]; + super.size = [stream readInt]; + super.dc_id = [stream readInt]; } --(TL_updates *)copy { +-(TL_audio *)copy { - TL_updates *objc = [[TL_updates alloc] init]; + TL_audio *objc = [[TL_audio alloc] init]; - objc.updates = [self.updates copy]; - objc.users = [self.users copy]; - objc.chats = [self.chats copy]; + objc.n_id = self.n_id; + objc.access_hash = self.access_hash; objc.date = self.date; - objc.seq = self.seq; + objc.duration = self.duration; + objc.mime_type = self.mime_type; + objc.size = self.size; + objc.dc_id = self.dc_id; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -11257,85 +15814,62 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - - - -@end - -@implementation TLphotos_Photos -@end - -@implementation TL_photos_photos -+(TL_photos_photos*)createWithPhotos:(NSMutableArray*)photos users:(NSMutableArray*)users { - TL_photos_photos* obj = [[TL_photos_photos alloc] init]; - obj.photos = photos; - obj.users = users; - return obj; -} --(void)serialize:(SerializedData*)stream { - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.photos count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLPhoto* obj = [self.photos objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.users count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLUser* obj = [self.users objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } + +@end + +@implementation TL_audio_old29 ++(TL_audio_old29*)createWithN_id:(long)n_id access_hash:(long)access_hash user_id:(int)user_id date:(int)date duration:(int)duration mime_type:(NSString*)mime_type size:(int)size dc_id:(int)dc_id { + TL_audio_old29* obj = [[TL_audio_old29 alloc] init]; + obj.n_id = n_id; + obj.access_hash = access_hash; + obj.user_id = user_id; + obj.date = date; + obj.duration = duration; + obj.mime_type = mime_type; + obj.size = size; + obj.dc_id = dc_id; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeLong:self.n_id]; + [stream writeLong:self.access_hash]; + [stream writeInt:self.user_id]; + [stream writeInt:self.date]; + [stream writeInt:self.duration]; + [stream writeString:self.mime_type]; + [stream writeInt:self.size]; + [stream writeInt:self.dc_id]; } -(void)unserialize:(SerializedData*)stream { - //UNS FullVector - [stream readInt]; - { - if(!self.photos) - self.photos = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLPhoto* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLPhoto class]]) - [self.photos addObject:obj]; - else - break; - } - } - //UNS FullVector - [stream readInt]; - { - if(!self.users) - self.users = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLUser* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLUser class]]) - [self.users addObject:obj]; - else - break; - } - } + super.n_id = [stream readLong]; + super.access_hash = [stream readLong]; + super.user_id = [stream readInt]; + super.date = [stream readInt]; + super.duration = [stream readInt]; + super.mime_type = [stream readString]; + super.size = [stream readInt]; + super.dc_id = [stream readInt]; } --(TL_photos_photos *)copy { +-(TL_audio_old29 *)copy { - TL_photos_photos *objc = [[TL_photos_photos alloc] init]; + TL_audio_old29 *objc = [[TL_audio_old29 alloc] init]; - objc.photos = [self.photos copy]; - objc.users = [self.users copy]; + objc.n_id = self.n_id; + objc.access_hash = self.access_hash; + objc.user_id = self.user_id; + objc.date = self.date; + objc.duration = self.duration; + objc.mime_type = self.mime_type; + objc.size = self.size; + objc.dc_id = self.dc_id; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -11349,85 +15883,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_photos_photosSlice -+(TL_photos_photosSlice*)createWithN_count:(int)n_count photos:(NSMutableArray*)photos users:(NSMutableArray*)users { - TL_photos_photosSlice* obj = [[TL_photos_photosSlice alloc] init]; - obj.n_count = n_count; - obj.photos = photos; - obj.users = users; +@implementation TLDocument + +@end + +@implementation TL_documentEmpty ++(TL_documentEmpty*)createWithN_id:(long)n_id { + TL_documentEmpty* obj = [[TL_documentEmpty alloc] init]; + obj.n_id = n_id; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.n_count]; - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.photos count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLPhoto* obj = [self.photos objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.users count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLUser* obj = [self.users objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } + [stream writeLong:self.n_id]; } -(void)unserialize:(SerializedData*)stream { - self.n_count = [stream readInt]; - //UNS FullVector - [stream readInt]; - { - if(!self.photos) - self.photos = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLPhoto* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLPhoto class]]) - [self.photos addObject:obj]; - else - break; - } - } - //UNS FullVector - [stream readInt]; - { - if(!self.users) - self.users = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLUser* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLUser class]]) - [self.users addObject:obj]; - else - break; - } - } + super.n_id = [stream readLong]; } --(TL_photos_photosSlice *)copy { +-(TL_documentEmpty *)copy { - TL_photos_photosSlice *objc = [[TL_photos_photosSlice alloc] init]; + TL_documentEmpty *objc = [[TL_documentEmpty alloc] init]; - objc.n_count = self.n_count; - objc.photos = [self.photos copy]; - objc.users = [self.users copy]; + objc.n_id = self.n_id; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -11441,63 +15928,84 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLphotos_Photo -@end - -@implementation TL_photos_photo -+(TL_photos_photo*)createWithPhoto:(TLPhoto*)photo users:(NSMutableArray*)users { - TL_photos_photo* obj = [[TL_photos_photo alloc] init]; - obj.photo = photo; - obj.users = users; +@implementation TL_document ++(TL_document*)createWithN_id:(long)n_id access_hash:(long)access_hash date:(int)date mime_type:(NSString*)mime_type size:(int)size thumb:(TLPhotoSize*)thumb dc_id:(int)dc_id attributes:(NSMutableArray*)attributes { + TL_document* obj = [[TL_document alloc] init]; + obj.n_id = n_id; + obj.access_hash = access_hash; + obj.date = date; + obj.mime_type = mime_type; + obj.size = size; + obj.thumb = thumb; + obj.dc_id = dc_id; + obj.attributes = attributes; return obj; } -(void)serialize:(SerializedData*)stream { - [ClassStore TLSerialize:self.photo stream:stream]; + [stream writeLong:self.n_id]; + [stream writeLong:self.access_hash]; + [stream writeInt:self.date]; + [stream writeString:self.mime_type]; + [stream writeInt:self.size]; + [ClassStore TLSerialize:self.thumb stream:stream]; + [stream writeInt:self.dc_id]; //Serialize FullVector [stream writeInt:0x1cb5c415]; { - NSInteger tl_count = [self.users count]; + NSInteger tl_count = [self.attributes count]; [stream writeInt:(int)tl_count]; for(int i = 0; i < (int)tl_count; i++) { - TLUser* obj = [self.users objectAtIndex:i]; + TLDocumentAttribute* obj = [self.attributes objectAtIndex:i]; [ClassStore TLSerialize:obj stream:stream]; } } } -(void)unserialize:(SerializedData*)stream { - self.photo = [ClassStore TLDeserialize:stream]; + super.n_id = [stream readLong]; + super.access_hash = [stream readLong]; + super.date = [stream readInt]; + super.mime_type = [stream readString]; + super.size = [stream readInt]; + self.thumb = [ClassStore TLDeserialize:stream]; + super.dc_id = [stream readInt]; //UNS FullVector [stream readInt]; { - if(!self.users) - self.users = [[NSMutableArray alloc] init]; + if(!self.attributes) + self.attributes = [[NSMutableArray alloc] init]; int count = [stream readInt]; for(int i = 0; i < count; i++) { - TLUser* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLUser class]]) - [self.users addObject:obj]; + TLDocumentAttribute* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLDocumentAttribute class]]) + [self.attributes addObject:obj]; else break; } } } --(TL_photos_photo *)copy { +-(TL_document *)copy { - TL_photos_photo *objc = [[TL_photos_photo alloc] init]; + TL_document *objc = [[TL_document alloc] init]; - objc.photo = [self.photo copy]; - objc.users = [self.users copy]; + objc.n_id = self.n_id; + objc.access_hash = self.access_hash; + objc.date = self.date; + objc.mime_type = self.mime_type; + objc.size = self.size; + objc.thumb = [self.thumb copy]; + objc.dc_id = self.dc_id; + objc.attributes = [self.attributes copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -11511,45 +16019,42 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TLhelp_Support -@implementation TLupload_File @end - -@implementation TL_upload_file -+(TL_upload_file*)createWithType:(TLstorage_FileType*)type mtime:(int)mtime bytes:(NSData*)bytes { - TL_upload_file* obj = [[TL_upload_file alloc] init]; - obj.type = type; - obj.mtime = mtime; - obj.bytes = bytes; + +@implementation TL_help_support ++(TL_help_support*)createWithPhone_number:(NSString*)phone_number user:(TLUser*)user { + TL_help_support* obj = [[TL_help_support alloc] init]; + obj.phone_number = phone_number; + obj.user = user; return obj; } -(void)serialize:(SerializedData*)stream { - [ClassStore TLSerialize:self.type stream:stream]; - [stream writeInt:self.mtime]; - [stream writeByteArray:self.bytes]; + [stream writeString:self.phone_number]; + [ClassStore TLSerialize:self.user stream:stream]; } -(void)unserialize:(SerializedData*)stream { - self.type = [ClassStore TLDeserialize:stream]; - self.mtime = [stream readInt]; - self.bytes = [stream readByteArray]; + super.phone_number = [stream readString]; + self.user = [ClassStore TLDeserialize:stream]; } --(TL_upload_file *)copy { +-(TL_help_support *)copy { - TL_upload_file *objc = [[TL_upload_file alloc] init]; + TL_help_support *objc = [[TL_help_support alloc] init]; - objc.type = [self.type copy]; - objc.mtime = self.mtime; - objc.bytes = [self.bytes copy]; + objc.phone_number = self.phone_number; + objc.user = [self.user copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -11563,49 +16068,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TLNotifyPeer -@implementation TLDcOption @end - -@implementation TL_dcOption -+(TL_dcOption*)createWithFlags:(int)flags n_id:(int)n_id ip_address:(NSString*)ip_address port:(int)port { - TL_dcOption* obj = [[TL_dcOption alloc] init]; - obj.flags = flags; - obj.n_id = n_id; - obj.ip_address = ip_address; - obj.port = port; - return obj; -} --(void)serialize:(SerializedData*)stream { - [stream writeInt:self.flags]; - [stream writeInt:self.n_id]; - [stream writeString:self.ip_address]; - [stream writeInt:self.port]; + +@implementation TL_notifyPeer ++(TL_notifyPeer*)createWithPeer:(TLPeer*)peer { + TL_notifyPeer* obj = [[TL_notifyPeer alloc] init]; + obj.peer = peer; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [ClassStore TLSerialize:self.peer stream:stream]; } -(void)unserialize:(SerializedData*)stream { - self.flags = [stream readInt]; - self.n_id = [stream readInt]; - self.ip_address = [stream readString]; - self.port = [stream readInt]; + self.peer = [ClassStore TLDeserialize:stream]; } --(TL_dcOption *)copy { +-(TL_notifyPeer *)copy { - TL_dcOption *objc = [[TL_dcOption alloc] init]; + TL_notifyPeer *objc = [[TL_notifyPeer alloc] init]; - objc.flags = self.flags; - objc.n_id = self.n_id; - objc.ip_address = self.ip_address; - objc.port = self.port; + objc.peer = [self.peer copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -11619,149 +16113,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLConfig -@end - -@implementation TL_config -+(TL_config*)createWithDate:(int)date expires:(int)expires test_mode:(Boolean)test_mode this_dc:(int)this_dc dc_options:(NSMutableArray*)dc_options chat_size_max:(int)chat_size_max broadcast_size_max:(int)broadcast_size_max forwarded_count_max:(int)forwarded_count_max online_update_period_ms:(int)online_update_period_ms offline_blur_timeout_ms:(int)offline_blur_timeout_ms offline_idle_timeout_ms:(int)offline_idle_timeout_ms online_cloud_timeout_ms:(int)online_cloud_timeout_ms notify_cloud_delay_ms:(int)notify_cloud_delay_ms notify_default_delay_ms:(int)notify_default_delay_ms chat_big_size:(int)chat_big_size push_chat_period_ms:(int)push_chat_period_ms push_chat_limit:(int)push_chat_limit disabled_features:(NSMutableArray*)disabled_features { - TL_config* obj = [[TL_config alloc] init]; - obj.date = date; - obj.expires = expires; - obj.test_mode = test_mode; - obj.this_dc = this_dc; - obj.dc_options = dc_options; - obj.chat_size_max = chat_size_max; - obj.broadcast_size_max = broadcast_size_max; - obj.forwarded_count_max = forwarded_count_max; - obj.online_update_period_ms = online_update_period_ms; - obj.offline_blur_timeout_ms = offline_blur_timeout_ms; - obj.offline_idle_timeout_ms = offline_idle_timeout_ms; - obj.online_cloud_timeout_ms = online_cloud_timeout_ms; - obj.notify_cloud_delay_ms = notify_cloud_delay_ms; - obj.notify_default_delay_ms = notify_default_delay_ms; - obj.chat_big_size = chat_big_size; - obj.push_chat_period_ms = push_chat_period_ms; - obj.push_chat_limit = push_chat_limit; - obj.disabled_features = disabled_features; +@implementation TL_notifyUsers ++(TL_notifyUsers*)create { + TL_notifyUsers* obj = [[TL_notifyUsers alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.date]; - [stream writeInt:self.expires]; - [stream writeBool:self.test_mode]; - [stream writeInt:self.this_dc]; - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.dc_options count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLDcOption* obj = [self.dc_options objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - [stream writeInt:self.chat_size_max]; - [stream writeInt:self.broadcast_size_max]; - [stream writeInt:self.forwarded_count_max]; - [stream writeInt:self.online_update_period_ms]; - [stream writeInt:self.offline_blur_timeout_ms]; - [stream writeInt:self.offline_idle_timeout_ms]; - [stream writeInt:self.online_cloud_timeout_ms]; - [stream writeInt:self.notify_cloud_delay_ms]; - [stream writeInt:self.notify_default_delay_ms]; - [stream writeInt:self.chat_big_size]; - [stream writeInt:self.push_chat_period_ms]; - [stream writeInt:self.push_chat_limit]; - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.disabled_features count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLDisabledFeature* obj = [self.disabled_features objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } + } -(void)unserialize:(SerializedData*)stream { - self.date = [stream readInt]; - self.expires = [stream readInt]; - self.test_mode = [stream readBool]; - self.this_dc = [stream readInt]; - //UNS FullVector - [stream readInt]; - { - if(!self.dc_options) - self.dc_options = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLDcOption* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLDcOption class]]) - [self.dc_options addObject:obj]; - else - break; - } - } - self.chat_size_max = [stream readInt]; - self.broadcast_size_max = [stream readInt]; - self.forwarded_count_max = [stream readInt]; - self.online_update_period_ms = [stream readInt]; - self.offline_blur_timeout_ms = [stream readInt]; - self.offline_idle_timeout_ms = [stream readInt]; - self.online_cloud_timeout_ms = [stream readInt]; - self.notify_cloud_delay_ms = [stream readInt]; - self.notify_default_delay_ms = [stream readInt]; - self.chat_big_size = [stream readInt]; - self.push_chat_period_ms = [stream readInt]; - self.push_chat_limit = [stream readInt]; - //UNS FullVector - [stream readInt]; - { - if(!self.disabled_features) - self.disabled_features = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLDisabledFeature* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLDisabledFeature class]]) - [self.disabled_features addObject:obj]; - else - break; - } - } + } --(TL_config *)copy { +-(TL_notifyUsers *)copy { + + TL_notifyUsers *objc = [[TL_notifyUsers alloc] init]; - TL_config *objc = [[TL_config alloc] init]; - objc.date = self.date; - objc.expires = self.expires; - objc.test_mode = self.test_mode; - objc.this_dc = self.this_dc; - objc.dc_options = [self.dc_options copy]; - objc.chat_size_max = self.chat_size_max; - objc.broadcast_size_max = self.broadcast_size_max; - objc.forwarded_count_max = self.forwarded_count_max; - objc.online_update_period_ms = self.online_update_period_ms; - objc.offline_blur_timeout_ms = self.offline_blur_timeout_ms; - objc.offline_idle_timeout_ms = self.offline_idle_timeout_ms; - objc.online_cloud_timeout_ms = self.online_cloud_timeout_ms; - objc.notify_cloud_delay_ms = self.notify_cloud_delay_ms; - objc.notify_default_delay_ms = self.notify_default_delay_ms; - objc.chat_big_size = self.chat_big_size; - objc.push_chat_period_ms = self.push_chat_period_ms; - objc.push_chat_limit = self.push_chat_limit; - objc.disabled_features = [self.disabled_features copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -11775,45 +16154,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLNearestDc -@end - -@implementation TL_nearestDc -+(TL_nearestDc*)createWithCountry:(NSString*)country this_dc:(int)this_dc nearest_dc:(int)nearest_dc { - TL_nearestDc* obj = [[TL_nearestDc alloc] init]; - obj.country = country; - obj.this_dc = this_dc; - obj.nearest_dc = nearest_dc; +@implementation TL_notifyChats ++(TL_notifyChats*)create { + TL_notifyChats* obj = [[TL_notifyChats alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeString:self.country]; - [stream writeInt:self.this_dc]; - [stream writeInt:self.nearest_dc]; + } -(void)unserialize:(SerializedData*)stream { - self.country = [stream readString]; - self.this_dc = [stream readInt]; - self.nearest_dc = [stream readInt]; + } --(TL_nearestDc *)copy { +-(TL_notifyChats *)copy { + + TL_notifyChats *objc = [[TL_notifyChats alloc] init]; - TL_nearestDc *objc = [[TL_nearestDc alloc] init]; - objc.country = self.country; - objc.this_dc = self.this_dc; - objc.nearest_dc = self.nearest_dc; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -11827,49 +16195,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLhelp_AppUpdate -@end - -@implementation TL_help_appUpdate -+(TL_help_appUpdate*)createWithN_id:(int)n_id critical:(Boolean)critical url:(NSString*)url text:(NSString*)text { - TL_help_appUpdate* obj = [[TL_help_appUpdate alloc] init]; - obj.n_id = n_id; - obj.critical = critical; - obj.url = url; - obj.text = text; +@implementation TL_notifyAll ++(TL_notifyAll*)create { + TL_notifyAll* obj = [[TL_notifyAll alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.n_id]; - [stream writeBool:self.critical]; - [stream writeString:self.url]; - [stream writeString:self.text]; + } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readInt]; - self.critical = [stream readBool]; - self.url = [stream readString]; - self.text = [stream readString]; + } --(TL_help_appUpdate *)copy { +-(TL_notifyAll *)copy { + + TL_notifyAll *objc = [[TL_notifyAll alloc] init]; - TL_help_appUpdate *objc = [[TL_help_appUpdate alloc] init]; - objc.n_id = self.n_id; - objc.critical = self.critical; - objc.url = self.url; - objc.text = self.text; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -11883,15 +16236,18 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_help_noAppUpdate -+(TL_help_noAppUpdate*)create { - TL_help_noAppUpdate* obj = [[TL_help_noAppUpdate alloc] init]; +@implementation TLSendMessageAction + +@end + +@implementation TL_sendMessageTypingAction ++(TL_sendMessageTypingAction*)create { + TL_sendMessageTypingAction* obj = [[TL_sendMessageTypingAction alloc] init]; return obj; } @@ -11902,14 +16258,16 @@ -(void)unserialize:(SerializedData*)stream { } --(TL_help_noAppUpdate *)copy { +-(TL_sendMessageTypingAction *)copy { - TL_help_noAppUpdate *objc = [[TL_help_noAppUpdate alloc] init]; + TL_sendMessageTypingAction *objc = [[TL_sendMessageTypingAction alloc] init]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -11923,37 +16281,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLhelp_InviteText -@end - -@implementation TL_help_inviteText -+(TL_help_inviteText*)createWithMessage:(NSString*)message { - TL_help_inviteText* obj = [[TL_help_inviteText alloc] init]; - obj.message = message; +@implementation TL_sendMessageCancelAction ++(TL_sendMessageCancelAction*)create { + TL_sendMessageCancelAction* obj = [[TL_sendMessageCancelAction alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeString:self.message]; + } -(void)unserialize:(SerializedData*)stream { - self.message = [stream readString]; + } --(TL_help_inviteText *)copy { +-(TL_sendMessageCancelAction *)copy { + + TL_sendMessageCancelAction *objc = [[TL_sendMessageCancelAction alloc] init]; - TL_help_inviteText *objc = [[TL_help_inviteText alloc] init]; - objc.message = self.message; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -11967,41 +16322,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLInputGeoChat -@end - -@implementation TL_inputGeoChat -+(TL_inputGeoChat*)createWithChat_id:(int)chat_id access_hash:(long)access_hash { - TL_inputGeoChat* obj = [[TL_inputGeoChat alloc] init]; - obj.chat_id = chat_id; - obj.access_hash = access_hash; +@implementation TL_sendMessageRecordVideoAction ++(TL_sendMessageRecordVideoAction*)create { + TL_sendMessageRecordVideoAction* obj = [[TL_sendMessageRecordVideoAction alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.chat_id]; - [stream writeLong:self.access_hash]; + } -(void)unserialize:(SerializedData*)stream { - self.chat_id = [stream readInt]; - self.access_hash = [stream readLong]; + } --(TL_inputGeoChat *)copy { +-(TL_sendMessageRecordVideoAction *)copy { + + TL_sendMessageRecordVideoAction *objc = [[TL_sendMessageRecordVideoAction alloc] init]; - TL_inputGeoChat *objc = [[TL_inputGeoChat alloc] init]; - objc.chat_id = self.chat_id; - objc.access_hash = self.access_hash; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -12015,41 +16363,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLGeoChatMessage -@end - -@implementation TL_geoChatMessageEmpty -+(TL_geoChatMessageEmpty*)createWithChat_id:(int)chat_id n_id:(int)n_id { - TL_geoChatMessageEmpty* obj = [[TL_geoChatMessageEmpty alloc] init]; - obj.chat_id = chat_id; - obj.n_id = n_id; +@implementation TL_sendMessageUploadVideoAction ++(TL_sendMessageUploadVideoAction*)createWithProgress:(int)progress { + TL_sendMessageUploadVideoAction* obj = [[TL_sendMessageUploadVideoAction alloc] init]; + obj.progress = progress; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.chat_id]; - [stream writeInt:self.n_id]; + [stream writeInt:self.progress]; } -(void)unserialize:(SerializedData*)stream { - self.chat_id = [stream readInt]; - self.n_id = [stream readInt]; + super.progress = [stream readInt]; } --(TL_geoChatMessageEmpty *)copy { +-(TL_sendMessageUploadVideoAction *)copy { - TL_geoChatMessageEmpty *objc = [[TL_geoChatMessageEmpty alloc] init]; + TL_sendMessageUploadVideoAction *objc = [[TL_sendMessageUploadVideoAction alloc] init]; - objc.chat_id = self.chat_id; - objc.n_id = self.n_id; + objc.progress = self.progress; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -12063,53 +16404,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_geoChatMessage -+(TL_geoChatMessage*)createWithChat_id:(int)chat_id n_id:(int)n_id from_id:(int)from_id date:(int)date message:(NSString*)message media:(TLMessageMedia*)media { - TL_geoChatMessage* obj = [[TL_geoChatMessage alloc] init]; - obj.chat_id = chat_id; - obj.n_id = n_id; - obj.from_id = from_id; - obj.date = date; - obj.message = message; - obj.media = media; +@implementation TL_sendMessageRecordAudioAction ++(TL_sendMessageRecordAudioAction*)create { + TL_sendMessageRecordAudioAction* obj = [[TL_sendMessageRecordAudioAction alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.chat_id]; - [stream writeInt:self.n_id]; - [stream writeInt:self.from_id]; - [stream writeInt:self.date]; - [stream writeString:self.message]; - [ClassStore TLSerialize:self.media stream:stream]; + } -(void)unserialize:(SerializedData*)stream { - self.chat_id = [stream readInt]; - self.n_id = [stream readInt]; - self.from_id = [stream readInt]; - self.date = [stream readInt]; - self.message = [stream readString]; - self.media = [ClassStore TLDeserialize:stream]; + } --(TL_geoChatMessage *)copy { +-(TL_sendMessageRecordAudioAction *)copy { + + TL_sendMessageRecordAudioAction *objc = [[TL_sendMessageRecordAudioAction alloc] init]; - TL_geoChatMessage *objc = [[TL_geoChatMessage alloc] init]; - objc.chat_id = self.chat_id; - objc.n_id = self.n_id; - objc.from_id = self.from_id; - objc.date = self.date; - objc.message = self.message; - objc.media = [self.media copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -12123,49 +16445,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_geoChatMessageService -+(TL_geoChatMessageService*)createWithChat_id:(int)chat_id n_id:(int)n_id from_id:(int)from_id date:(int)date action:(TLMessageAction*)action { - TL_geoChatMessageService* obj = [[TL_geoChatMessageService alloc] init]; - obj.chat_id = chat_id; - obj.n_id = n_id; - obj.from_id = from_id; - obj.date = date; - obj.action = action; +@implementation TL_sendMessageUploadAudioAction ++(TL_sendMessageUploadAudioAction*)createWithProgress:(int)progress { + TL_sendMessageUploadAudioAction* obj = [[TL_sendMessageUploadAudioAction alloc] init]; + obj.progress = progress; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.chat_id]; - [stream writeInt:self.n_id]; - [stream writeInt:self.from_id]; - [stream writeInt:self.date]; - [ClassStore TLSerialize:self.action stream:stream]; + [stream writeInt:self.progress]; } -(void)unserialize:(SerializedData*)stream { - self.chat_id = [stream readInt]; - self.n_id = [stream readInt]; - self.from_id = [stream readInt]; - self.date = [stream readInt]; - self.action = [ClassStore TLDeserialize:stream]; + super.progress = [stream readInt]; } --(TL_geoChatMessageService *)copy { +-(TL_sendMessageUploadAudioAction *)copy { - TL_geoChatMessageService *objc = [[TL_geoChatMessageService alloc] init]; + TL_sendMessageUploadAudioAction *objc = [[TL_sendMessageUploadAudioAction alloc] init]; - objc.chat_id = self.chat_id; - objc.n_id = self.n_id; - objc.from_id = self.from_id; - objc.date = self.date; - objc.action = [self.action copy]; + objc.progress = self.progress; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -12179,93 +16486,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLgeochats_StatedMessage -@end - -@implementation TL_geochats_statedMessage -+(TL_geochats_statedMessage*)createWithMessage:(TLGeoChatMessage*)message chats:(NSMutableArray*)chats users:(NSMutableArray*)users seq:(int)seq { - TL_geochats_statedMessage* obj = [[TL_geochats_statedMessage alloc] init]; - obj.message = message; - obj.chats = chats; - obj.users = users; - obj.seq = seq; +@implementation TL_sendMessageUploadPhotoAction ++(TL_sendMessageUploadPhotoAction*)createWithProgress:(int)progress { + TL_sendMessageUploadPhotoAction* obj = [[TL_sendMessageUploadPhotoAction alloc] init]; + obj.progress = progress; return obj; } -(void)serialize:(SerializedData*)stream { - [ClassStore TLSerialize:self.message stream:stream]; - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.chats count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLChat* obj = [self.chats objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.users count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLUser* obj = [self.users objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - [stream writeInt:self.seq]; + [stream writeInt:self.progress]; } -(void)unserialize:(SerializedData*)stream { - self.message = [ClassStore TLDeserialize:stream]; - //UNS FullVector - [stream readInt]; - { - if(!self.chats) - self.chats = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLChat* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLChat class]]) - [self.chats addObject:obj]; - else - break; - } - } - //UNS FullVector - [stream readInt]; - { - if(!self.users) - self.users = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLUser* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLUser class]]) - [self.users addObject:obj]; - else - break; - } - } - self.seq = [stream readInt]; + super.progress = [stream readInt]; } --(TL_geochats_statedMessage *)copy { +-(TL_sendMessageUploadPhotoAction *)copy { - TL_geochats_statedMessage *objc = [[TL_geochats_statedMessage alloc] init]; + TL_sendMessageUploadPhotoAction *objc = [[TL_sendMessageUploadPhotoAction alloc] init]; - objc.message = [self.message copy]; - objc.chats = [self.chats copy]; - objc.users = [self.users copy]; - objc.seq = self.seq; + objc.progress = self.progress; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -12279,137 +16527,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLgeochats_Located -@end - -@implementation TL_geochats_located -+(TL_geochats_located*)createWithResults:(NSMutableArray*)results messages:(NSMutableArray*)messages chats:(NSMutableArray*)chats users:(NSMutableArray*)users { - TL_geochats_located* obj = [[TL_geochats_located alloc] init]; - obj.results = results; - obj.messages = messages; - obj.chats = chats; - obj.users = users; - return obj; -} --(void)serialize:(SerializedData*)stream { - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.results count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLChatLocated* obj = [self.results objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.messages count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLGeoChatMessage* obj = [self.messages objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.chats count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLChat* obj = [self.chats objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.users count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLUser* obj = [self.users objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } -} --(void)unserialize:(SerializedData*)stream { - //UNS FullVector - [stream readInt]; - { - if(!self.results) - self.results = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLChatLocated* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLChatLocated class]]) - [self.results addObject:obj]; - else - break; - } - } - //UNS FullVector - [stream readInt]; - { - if(!self.messages) - self.messages = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLGeoChatMessage* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLGeoChatMessage class]]) - [self.messages addObject:obj]; - else - break; - } - } - //UNS FullVector - [stream readInt]; - { - if(!self.chats) - self.chats = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLChat* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLChat class]]) - [self.chats addObject:obj]; - else - break; - } - } - //UNS FullVector - [stream readInt]; - { - if(!self.users) - self.users = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLUser* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLUser class]]) - [self.users addObject:obj]; - else - break; - } - } +@implementation TL_sendMessageUploadDocumentAction ++(TL_sendMessageUploadDocumentAction*)createWithProgress:(int)progress { + TL_sendMessageUploadDocumentAction* obj = [[TL_sendMessageUploadDocumentAction alloc] init]; + obj.progress = progress; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeInt:self.progress]; +} +-(void)unserialize:(SerializedData*)stream { + super.progress = [stream readInt]; } --(TL_geochats_located *)copy { +-(TL_sendMessageUploadDocumentAction *)copy { - TL_geochats_located *objc = [[TL_geochats_located alloc] init]; + TL_sendMessageUploadDocumentAction *objc = [[TL_sendMessageUploadDocumentAction alloc] init]; - objc.results = [self.results copy]; - objc.messages = [self.messages copy]; - objc.chats = [self.chats copy]; - objc.users = [self.users copy]; + objc.progress = self.progress; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -12423,111 +16568,75 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TL_sendMessageGeoLocationAction ++(TL_sendMessageGeoLocationAction*)create { + TL_sendMessageGeoLocationAction* obj = [[TL_sendMessageGeoLocationAction alloc] init]; + + return obj; +} +-(void)serialize:(SerializedData*)stream { + +} +-(void)unserialize:(SerializedData*)stream { + +} + +-(TL_sendMessageGeoLocationAction *)copy { + + TL_sendMessageGeoLocationAction *objc = [[TL_sendMessageGeoLocationAction alloc] init]; + + + + return objc; +} + + + +-(id)initWithCoder:(NSCoder *)aDecoder { + + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + -@implementation TLgeochats_Messages + @end -@implementation TL_geochats_messages -+(TL_geochats_messages*)createWithMessages:(NSMutableArray*)messages chats:(NSMutableArray*)chats users:(NSMutableArray*)users { - TL_geochats_messages* obj = [[TL_geochats_messages alloc] init]; - obj.messages = messages; - obj.chats = chats; - obj.users = users; +@implementation TL_sendMessageChooseContactAction ++(TL_sendMessageChooseContactAction*)create { + TL_sendMessageChooseContactAction* obj = [[TL_sendMessageChooseContactAction alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.messages count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLGeoChatMessage* obj = [self.messages objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.chats count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLChat* obj = [self.chats objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.users count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLUser* obj = [self.users objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } + } -(void)unserialize:(SerializedData*)stream { - //UNS FullVector - [stream readInt]; - { - if(!self.messages) - self.messages = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLGeoChatMessage* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLGeoChatMessage class]]) - [self.messages addObject:obj]; - else - break; - } - } - //UNS FullVector - [stream readInt]; - { - if(!self.chats) - self.chats = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLChat* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLChat class]]) - [self.chats addObject:obj]; - else - break; - } - } - //UNS FullVector - [stream readInt]; - { - if(!self.users) - self.users = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLUser* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLUser class]]) - [self.users addObject:obj]; - else - break; - } - } + } --(TL_geochats_messages *)copy { +-(TL_sendMessageChooseContactAction *)copy { + + TL_sendMessageChooseContactAction *objc = [[TL_sendMessageChooseContactAction alloc] init]; - TL_geochats_messages *objc = [[TL_geochats_messages alloc] init]; - objc.messages = [self.messages copy]; - objc.chats = [self.chats copy]; - objc.users = [self.users copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -12541,30 +16650,31 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_geochats_messagesSlice -+(TL_geochats_messagesSlice*)createWithN_count:(int)n_count messages:(NSMutableArray*)messages chats:(NSMutableArray*)chats users:(NSMutableArray*)users { - TL_geochats_messagesSlice* obj = [[TL_geochats_messagesSlice alloc] init]; - obj.n_count = n_count; - obj.messages = messages; +@implementation TLcontacts_Found + +@end + +@implementation TL_contacts_found ++(TL_contacts_found*)createWithResults:(NSMutableArray*)results chats:(NSMutableArray*)chats users:(NSMutableArray*)users { + TL_contacts_found* obj = [[TL_contacts_found alloc] init]; + obj.results = results; obj.chats = chats; obj.users = users; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.n_count]; //Serialize FullVector [stream writeInt:0x1cb5c415]; { - NSInteger tl_count = [self.messages count]; + NSInteger tl_count = [self.results count]; [stream writeInt:(int)tl_count]; for(int i = 0; i < (int)tl_count; i++) { - TLGeoChatMessage* obj = [self.messages objectAtIndex:i]; + TLPeer* obj = [self.results objectAtIndex:i]; [ClassStore TLSerialize:obj stream:stream]; } } @@ -12590,17 +16700,16 @@ -(void)serialize:(SerializedData*)stream { } } -(void)unserialize:(SerializedData*)stream { - self.n_count = [stream readInt]; //UNS FullVector [stream readInt]; { - if(!self.messages) - self.messages = [[NSMutableArray alloc] init]; + if(!self.results) + self.results = [[NSMutableArray alloc] init]; int count = [stream readInt]; for(int i = 0; i < count; i++) { - TLGeoChatMessage* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLGeoChatMessage class]]) - [self.messages addObject:obj]; + TLPeer* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLPeer class]]) + [self.results addObject:obj]; else break; } @@ -12635,17 +16744,18 @@ -(void)unserialize:(SerializedData*)stream { } } --(TL_geochats_messagesSlice *)copy { +-(TL_contacts_found *)copy { - TL_geochats_messagesSlice *objc = [[TL_geochats_messagesSlice alloc] init]; + TL_contacts_found *objc = [[TL_contacts_found alloc] init]; - objc.n_count = self.n_count; - objc.messages = [self.messages copy]; + objc.results = [self.results copy]; objc.chats = [self.chats copy]; objc.users = [self.users copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -12659,93 +16769,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TLInputPrivacyKey -@implementation TLEncryptedChat @end - -@implementation TL_encryptedChatEmpty -+(TL_encryptedChatEmpty*)createWithN_id:(int)n_id { - TL_encryptedChatEmpty* obj = [[TL_encryptedChatEmpty alloc] init]; - obj.n_id = n_id; + +@implementation TL_inputPrivacyKeyStatusTimestamp ++(TL_inputPrivacyKeyStatusTimestamp*)create { + TL_inputPrivacyKeyStatusTimestamp* obj = [[TL_inputPrivacyKeyStatusTimestamp alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.n_id]; + } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readInt]; + } --(TL_encryptedChatEmpty *)copy { - - TL_encryptedChatEmpty *objc = [[TL_encryptedChatEmpty alloc] init]; +-(TL_inputPrivacyKeyStatusTimestamp *)copy { - objc.n_id = self.n_id; + TL_inputPrivacyKeyStatusTimestamp *objc = [[TL_inputPrivacyKeyStatusTimestamp alloc] init]; - return objc; -} --(id)initWithCoder:(NSCoder *)aDecoder { - - if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { - - } - return self; -} - --(void)encodeWithCoder:(NSCoder *)aCoder { - [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; + return objc; } - - - -@end -@implementation TL_encryptedChatWaiting -+(TL_encryptedChatWaiting*)createWithN_id:(int)n_id access_hash:(long)access_hash date:(int)date admin_id:(int)admin_id participant_id:(int)participant_id { - TL_encryptedChatWaiting* obj = [[TL_encryptedChatWaiting alloc] init]; - obj.n_id = n_id; - obj.access_hash = access_hash; - obj.date = date; - obj.admin_id = admin_id; - obj.participant_id = participant_id; - return obj; -} --(void)serialize:(SerializedData*)stream { - [stream writeInt:self.n_id]; - [stream writeLong:self.access_hash]; - [stream writeInt:self.date]; - [stream writeInt:self.admin_id]; - [stream writeInt:self.participant_id]; -} --(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readInt]; - self.access_hash = [stream readLong]; - self.date = [stream readInt]; - self.admin_id = [stream readInt]; - self.participant_id = [stream readInt]; -} - --(TL_encryptedChatWaiting *)copy { - - TL_encryptedChatWaiting *objc = [[TL_encryptedChatWaiting alloc] init]; - - objc.n_id = self.n_id; - objc.access_hash = self.access_hash; - objc.date = self.date; - objc.admin_id = self.admin_id; - objc.participant_id = self.participant_id; - - return objc; -} -(id)initWithCoder:(NSCoder *)aDecoder { @@ -12759,53 +16814,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_encryptedChatRequested -+(TL_encryptedChatRequested*)createWithN_id:(int)n_id access_hash:(long)access_hash date:(int)date admin_id:(int)admin_id participant_id:(int)participant_id g_a:(NSData*)g_a { - TL_encryptedChatRequested* obj = [[TL_encryptedChatRequested alloc] init]; - obj.n_id = n_id; - obj.access_hash = access_hash; - obj.date = date; - obj.admin_id = admin_id; - obj.participant_id = participant_id; - obj.g_a = g_a; +@implementation TLPrivacyKey + +@end + +@implementation TL_privacyKeyStatusTimestamp ++(TL_privacyKeyStatusTimestamp*)create { + TL_privacyKeyStatusTimestamp* obj = [[TL_privacyKeyStatusTimestamp alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.n_id]; - [stream writeLong:self.access_hash]; - [stream writeInt:self.date]; - [stream writeInt:self.admin_id]; - [stream writeInt:self.participant_id]; - [stream writeByteArray:self.g_a]; + } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readInt]; - self.access_hash = [stream readLong]; - self.date = [stream readInt]; - self.admin_id = [stream readInt]; - self.participant_id = [stream readInt]; - self.g_a = [stream readByteArray]; + } --(TL_encryptedChatRequested *)copy { +-(TL_privacyKeyStatusTimestamp *)copy { + + TL_privacyKeyStatusTimestamp *objc = [[TL_privacyKeyStatusTimestamp alloc] init]; - TL_encryptedChatRequested *objc = [[TL_encryptedChatRequested alloc] init]; - objc.n_id = self.n_id; - objc.access_hash = self.access_hash; - objc.date = self.date; - objc.admin_id = self.admin_id; - objc.participant_id = self.participant_id; - objc.g_a = [self.g_a copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -12819,57 +16859,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_encryptedChat -+(TL_encryptedChat*)createWithN_id:(int)n_id access_hash:(long)access_hash date:(int)date admin_id:(int)admin_id participant_id:(int)participant_id g_a_or_b:(NSData*)g_a_or_b key_fingerprint:(long)key_fingerprint { - TL_encryptedChat* obj = [[TL_encryptedChat alloc] init]; - obj.n_id = n_id; - obj.access_hash = access_hash; - obj.date = date; - obj.admin_id = admin_id; - obj.participant_id = participant_id; - obj.g_a_or_b = g_a_or_b; - obj.key_fingerprint = key_fingerprint; +@implementation TLInputPrivacyRule + +@end + +@implementation TL_inputPrivacyValueAllowContacts ++(TL_inputPrivacyValueAllowContacts*)create { + TL_inputPrivacyValueAllowContacts* obj = [[TL_inputPrivacyValueAllowContacts alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.n_id]; - [stream writeLong:self.access_hash]; - [stream writeInt:self.date]; - [stream writeInt:self.admin_id]; - [stream writeInt:self.participant_id]; - [stream writeByteArray:self.g_a_or_b]; - [stream writeLong:self.key_fingerprint]; + } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readInt]; - self.access_hash = [stream readLong]; - self.date = [stream readInt]; - self.admin_id = [stream readInt]; - self.participant_id = [stream readInt]; - self.g_a_or_b = [stream readByteArray]; - self.key_fingerprint = [stream readLong]; + } --(TL_encryptedChat *)copy { +-(TL_inputPrivacyValueAllowContacts *)copy { + + TL_inputPrivacyValueAllowContacts *objc = [[TL_inputPrivacyValueAllowContacts alloc] init]; - TL_encryptedChat *objc = [[TL_encryptedChat alloc] init]; - objc.n_id = self.n_id; - objc.access_hash = self.access_hash; - objc.date = self.date; - objc.admin_id = self.admin_id; - objc.participant_id = self.participant_id; - objc.g_a_or_b = [self.g_a_or_b copy]; - objc.key_fingerprint = self.key_fingerprint; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -12883,33 +16904,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_encryptedChatDiscarded -+(TL_encryptedChatDiscarded*)createWithN_id:(int)n_id { - TL_encryptedChatDiscarded* obj = [[TL_encryptedChatDiscarded alloc] init]; - obj.n_id = n_id; +@implementation TL_inputPrivacyValueAllowAll ++(TL_inputPrivacyValueAllowAll*)create { + TL_inputPrivacyValueAllowAll* obj = [[TL_inputPrivacyValueAllowAll alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.n_id]; + } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readInt]; + } --(TL_encryptedChatDiscarded *)copy { +-(TL_inputPrivacyValueAllowAll *)copy { + + TL_inputPrivacyValueAllowAll *objc = [[TL_inputPrivacyValueAllowAll alloc] init]; - TL_encryptedChatDiscarded *objc = [[TL_encryptedChatDiscarded alloc] init]; - objc.n_id = self.n_id; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -12923,41 +16945,56 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLInputEncryptedChat -@end - -@implementation TL_inputEncryptedChat -+(TL_inputEncryptedChat*)createWithChat_id:(int)chat_id access_hash:(long)access_hash { - TL_inputEncryptedChat* obj = [[TL_inputEncryptedChat alloc] init]; - obj.chat_id = chat_id; - obj.access_hash = access_hash; +@implementation TL_inputPrivacyValueAllowUsers ++(TL_inputPrivacyValueAllowUsers*)createWithUsers:(NSMutableArray*)users { + TL_inputPrivacyValueAllowUsers* obj = [[TL_inputPrivacyValueAllowUsers alloc] init]; + obj.users = users; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.chat_id]; - [stream writeLong:self.access_hash]; + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.users count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLInputUser* obj = [self.users objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } } -(void)unserialize:(SerializedData*)stream { - self.chat_id = [stream readInt]; - self.access_hash = [stream readLong]; + //UNS FullVector + [stream readInt]; + { + if(!self.users) + self.users = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLInputUser* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLInputUser class]]) + [self.users addObject:obj]; + else + break; + } + } } --(TL_inputEncryptedChat *)copy { +-(TL_inputPrivacyValueAllowUsers *)copy { - TL_inputEncryptedChat *objc = [[TL_inputEncryptedChat alloc] init]; + TL_inputPrivacyValueAllowUsers *objc = [[TL_inputPrivacyValueAllowUsers alloc] init]; - objc.chat_id = self.chat_id; - objc.access_hash = self.access_hash; + objc.users = [self.users copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -12971,19 +17008,14 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLEncryptedFile -@end - -@implementation TL_encryptedFileEmpty -+(TL_encryptedFileEmpty*)create { - TL_encryptedFileEmpty* obj = [[TL_encryptedFileEmpty alloc] init]; +@implementation TL_inputPrivacyValueDisallowContacts ++(TL_inputPrivacyValueDisallowContacts*)create { + TL_inputPrivacyValueDisallowContacts* obj = [[TL_inputPrivacyValueDisallowContacts alloc] init]; return obj; } @@ -12994,14 +17026,16 @@ -(void)unserialize:(SerializedData*)stream { } --(TL_encryptedFileEmpty *)copy { +-(TL_inputPrivacyValueDisallowContacts *)copy { - TL_encryptedFileEmpty *objc = [[TL_encryptedFileEmpty alloc] init]; + TL_inputPrivacyValueDisallowContacts *objc = [[TL_inputPrivacyValueDisallowContacts alloc] init]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -13015,49 +17049,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_encryptedFile -+(TL_encryptedFile*)createWithN_id:(long)n_id access_hash:(long)access_hash size:(int)size dc_id:(int)dc_id key_fingerprint:(int)key_fingerprint { - TL_encryptedFile* obj = [[TL_encryptedFile alloc] init]; - obj.n_id = n_id; - obj.access_hash = access_hash; - obj.size = size; - obj.dc_id = dc_id; - obj.key_fingerprint = key_fingerprint; +@implementation TL_inputPrivacyValueDisallowAll ++(TL_inputPrivacyValueDisallowAll*)create { + TL_inputPrivacyValueDisallowAll* obj = [[TL_inputPrivacyValueDisallowAll alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeLong:self.n_id]; - [stream writeLong:self.access_hash]; - [stream writeInt:self.size]; - [stream writeInt:self.dc_id]; - [stream writeInt:self.key_fingerprint]; + } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readLong]; - self.access_hash = [stream readLong]; - self.size = [stream readInt]; - self.dc_id = [stream readInt]; - self.key_fingerprint = [stream readInt]; + } --(TL_encryptedFile *)copy { +-(TL_inputPrivacyValueDisallowAll *)copy { + + TL_inputPrivacyValueDisallowAll *objc = [[TL_inputPrivacyValueDisallowAll alloc] init]; - TL_encryptedFile *objc = [[TL_encryptedFile alloc] init]; - objc.n_id = self.n_id; - objc.access_hash = self.access_hash; - objc.size = self.size; - objc.dc_id = self.dc_id; - objc.key_fingerprint = self.key_fingerprint; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -13071,37 +17090,56 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLInputEncryptedFile -@end - -@implementation TL_inputEncryptedFileEmpty -+(TL_inputEncryptedFileEmpty*)create { - TL_inputEncryptedFileEmpty* obj = [[TL_inputEncryptedFileEmpty alloc] init]; - +@implementation TL_inputPrivacyValueDisallowUsers ++(TL_inputPrivacyValueDisallowUsers*)createWithUsers:(NSMutableArray*)users { + TL_inputPrivacyValueDisallowUsers* obj = [[TL_inputPrivacyValueDisallowUsers alloc] init]; + obj.users = users; return obj; } -(void)serialize:(SerializedData*)stream { - + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.users count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLInputUser* obj = [self.users objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } } -(void)unserialize:(SerializedData*)stream { - + //UNS FullVector + [stream readInt]; + { + if(!self.users) + self.users = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLInputUser* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLInputUser class]]) + [self.users addObject:obj]; + else + break; + } + } } --(TL_inputEncryptedFileEmpty *)copy { - - TL_inputEncryptedFileEmpty *objc = [[TL_inputEncryptedFileEmpty alloc] init]; +-(TL_inputPrivacyValueDisallowUsers *)copy { + TL_inputPrivacyValueDisallowUsers *objc = [[TL_inputPrivacyValueDisallowUsers alloc] init]; + objc.users = [self.users copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -13115,45 +17153,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_inputEncryptedFileUploaded -+(TL_inputEncryptedFileUploaded*)createWithN_id:(long)n_id parts:(int)parts md5_checksum:(NSString*)md5_checksum key_fingerprint:(int)key_fingerprint { - TL_inputEncryptedFileUploaded* obj = [[TL_inputEncryptedFileUploaded alloc] init]; - obj.n_id = n_id; - obj.parts = parts; - obj.md5_checksum = md5_checksum; - obj.key_fingerprint = key_fingerprint; +@implementation TLPrivacyRule + +@end + +@implementation TL_privacyValueAllowContacts ++(TL_privacyValueAllowContacts*)create { + TL_privacyValueAllowContacts* obj = [[TL_privacyValueAllowContacts alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeLong:self.n_id]; - [stream writeInt:self.parts]; - [stream writeString:self.md5_checksum]; - [stream writeInt:self.key_fingerprint]; + } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readLong]; - self.parts = [stream readInt]; - self.md5_checksum = [stream readString]; - self.key_fingerprint = [stream readInt]; + } --(TL_inputEncryptedFileUploaded *)copy { +-(TL_privacyValueAllowContacts *)copy { + + TL_privacyValueAllowContacts *objc = [[TL_privacyValueAllowContacts alloc] init]; - TL_inputEncryptedFileUploaded *objc = [[TL_inputEncryptedFileUploaded alloc] init]; - objc.n_id = self.n_id; - objc.parts = self.parts; - objc.md5_checksum = self.md5_checksum; - objc.key_fingerprint = self.key_fingerprint; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -13167,37 +17198,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_inputEncryptedFile -+(TL_inputEncryptedFile*)createWithN_id:(long)n_id access_hash:(long)access_hash { - TL_inputEncryptedFile* obj = [[TL_inputEncryptedFile alloc] init]; - obj.n_id = n_id; - obj.access_hash = access_hash; +@implementation TL_privacyValueAllowAll ++(TL_privacyValueAllowAll*)create { + TL_privacyValueAllowAll* obj = [[TL_privacyValueAllowAll alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeLong:self.n_id]; - [stream writeLong:self.access_hash]; + } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readLong]; - self.access_hash = [stream readLong]; + } --(TL_inputEncryptedFile *)copy { +-(TL_privacyValueAllowAll *)copy { + + TL_privacyValueAllowAll *objc = [[TL_privacyValueAllowAll alloc] init]; - TL_inputEncryptedFile *objc = [[TL_inputEncryptedFile alloc] init]; - objc.n_id = self.n_id; - objc.access_hash = self.access_hash; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -13211,41 +17239,56 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_inputEncryptedFileBigUploaded -+(TL_inputEncryptedFileBigUploaded*)createWithN_id:(long)n_id parts:(int)parts key_fingerprint:(int)key_fingerprint { - TL_inputEncryptedFileBigUploaded* obj = [[TL_inputEncryptedFileBigUploaded alloc] init]; - obj.n_id = n_id; - obj.parts = parts; - obj.key_fingerprint = key_fingerprint; +@implementation TL_privacyValueAllowUsers ++(TL_privacyValueAllowUsers*)createWithUsers:(NSMutableArray*)users { + TL_privacyValueAllowUsers* obj = [[TL_privacyValueAllowUsers alloc] init]; + obj.users = users; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeLong:self.n_id]; - [stream writeInt:self.parts]; - [stream writeInt:self.key_fingerprint]; + //Serialize ShortVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.users count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + if([self.users count] > i) { + NSNumber* obj = [self.users objectAtIndex:i]; + [stream writeInt:[obj intValue]]; + } else + break; + } + } } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readLong]; - self.parts = [stream readInt]; - self.key_fingerprint = [stream readInt]; + //UNS ShortVector + [stream readInt]; + { + if(!self.users) + self.users = [[NSMutableArray alloc] init]; + int tl_count = [stream readInt]; + for(int i = 0; i < tl_count; i++) { + int obj = [stream readInt]; + [self.users addObject:@(obj)]; + } + } } --(TL_inputEncryptedFileBigUploaded *)copy { +-(TL_privacyValueAllowUsers *)copy { - TL_inputEncryptedFileBigUploaded *objc = [[TL_inputEncryptedFileBigUploaded alloc] init]; + TL_privacyValueAllowUsers *objc = [[TL_privacyValueAllowUsers alloc] init]; - objc.n_id = self.n_id; - objc.parts = self.parts; - objc.key_fingerprint = self.key_fingerprint; + objc.users = [self.users copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -13259,53 +17302,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLEncryptedMessage -@end - -@implementation TL_encryptedMessage -+(TL_encryptedMessage*)createWithRandom_id:(long)random_id chat_id:(int)chat_id date:(int)date bytes:(NSData*)bytes file:(TLEncryptedFile*)file { - TL_encryptedMessage* obj = [[TL_encryptedMessage alloc] init]; - obj.random_id = random_id; - obj.chat_id = chat_id; - obj.date = date; - obj.bytes = bytes; - obj.file = file; +@implementation TL_privacyValueDisallowContacts ++(TL_privacyValueDisallowContacts*)create { + TL_privacyValueDisallowContacts* obj = [[TL_privacyValueDisallowContacts alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeLong:self.random_id]; - [stream writeInt:self.chat_id]; - [stream writeInt:self.date]; - [stream writeByteArray:self.bytes]; - [ClassStore TLSerialize:self.file stream:stream]; + } -(void)unserialize:(SerializedData*)stream { - self.random_id = [stream readLong]; - self.chat_id = [stream readInt]; - self.date = [stream readInt]; - self.bytes = [stream readByteArray]; - self.file = [ClassStore TLDeserialize:stream]; + } --(TL_encryptedMessage *)copy { +-(TL_privacyValueDisallowContacts *)copy { + + TL_privacyValueDisallowContacts *objc = [[TL_privacyValueDisallowContacts alloc] init]; - TL_encryptedMessage *objc = [[TL_encryptedMessage alloc] init]; - objc.random_id = self.random_id; - objc.chat_id = self.chat_id; - objc.date = self.date; - objc.bytes = [self.bytes copy]; - objc.file = [self.file copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -13319,45 +17343,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_encryptedMessageService -+(TL_encryptedMessageService*)createWithRandom_id:(long)random_id chat_id:(int)chat_id date:(int)date bytes:(NSData*)bytes { - TL_encryptedMessageService* obj = [[TL_encryptedMessageService alloc] init]; - obj.random_id = random_id; - obj.chat_id = chat_id; - obj.date = date; - obj.bytes = bytes; +@implementation TL_privacyValueDisallowAll ++(TL_privacyValueDisallowAll*)create { + TL_privacyValueDisallowAll* obj = [[TL_privacyValueDisallowAll alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeLong:self.random_id]; - [stream writeInt:self.chat_id]; - [stream writeInt:self.date]; - [stream writeByteArray:self.bytes]; + } -(void)unserialize:(SerializedData*)stream { - self.random_id = [stream readLong]; - self.chat_id = [stream readInt]; - self.date = [stream readInt]; - self.bytes = [stream readByteArray]; + } --(TL_encryptedMessageService *)copy { +-(TL_privacyValueDisallowAll *)copy { + + TL_privacyValueDisallowAll *objc = [[TL_privacyValueDisallowAll alloc] init]; - TL_encryptedMessageService *objc = [[TL_encryptedMessageService alloc] init]; - objc.random_id = self.random_id; - objc.chat_id = self.chat_id; - objc.date = self.date; - objc.bytes = [self.bytes copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -13371,37 +17384,56 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLmessages_DhConfig -@end - -@implementation TL_messages_dhConfigNotModified -+(TL_messages_dhConfigNotModified*)createWithRandom:(NSData*)random { - TL_messages_dhConfigNotModified* obj = [[TL_messages_dhConfigNotModified alloc] init]; - obj.random = random; +@implementation TL_privacyValueDisallowUsers ++(TL_privacyValueDisallowUsers*)createWithUsers:(NSMutableArray*)users { + TL_privacyValueDisallowUsers* obj = [[TL_privacyValueDisallowUsers alloc] init]; + obj.users = users; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeByteArray:self.random]; + //Serialize ShortVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.users count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + if([self.users count] > i) { + NSNumber* obj = [self.users objectAtIndex:i]; + [stream writeInt:[obj intValue]]; + } else + break; + } + } } -(void)unserialize:(SerializedData*)stream { - self.random = [stream readByteArray]; + //UNS ShortVector + [stream readInt]; + { + if(!self.users) + self.users = [[NSMutableArray alloc] init]; + int tl_count = [stream readInt]; + for(int i = 0; i < tl_count; i++) { + int obj = [stream readInt]; + [self.users addObject:@(obj)]; + } + } } --(TL_messages_dhConfigNotModified *)copy { +-(TL_privacyValueDisallowUsers *)copy { - TL_messages_dhConfigNotModified *objc = [[TL_messages_dhConfigNotModified alloc] init]; + TL_privacyValueDisallowUsers *objc = [[TL_privacyValueDisallowUsers alloc] init]; - objc.random = [self.random copy]; + objc.users = [self.users copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -13415,45 +17447,86 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_messages_dhConfig -+(TL_messages_dhConfig*)createWithG:(int)g p:(NSData*)p version:(int)version random:(NSData*)random { - TL_messages_dhConfig* obj = [[TL_messages_dhConfig alloc] init]; - obj.g = g; - obj.p = p; - obj.version = version; - obj.random = random; +@implementation TLaccount_PrivacyRules + +@end + +@implementation TL_account_privacyRules ++(TL_account_privacyRules*)createWithRules:(NSMutableArray*)rules users:(NSMutableArray*)users { + TL_account_privacyRules* obj = [[TL_account_privacyRules alloc] init]; + obj.rules = rules; + obj.users = users; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.g]; - [stream writeByteArray:self.p]; - [stream writeInt:self.version]; - [stream writeByteArray:self.random]; + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.rules count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLPrivacyRule* obj = [self.rules objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.users count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLUser* obj = [self.users objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } } -(void)unserialize:(SerializedData*)stream { - self.g = [stream readInt]; - self.p = [stream readByteArray]; - self.version = [stream readInt]; - self.random = [stream readByteArray]; + //UNS FullVector + [stream readInt]; + { + if(!self.rules) + self.rules = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLPrivacyRule* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLPrivacyRule class]]) + [self.rules addObject:obj]; + else + break; + } + } + //UNS FullVector + [stream readInt]; + { + if(!self.users) + self.users = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLUser* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLUser class]]) + [self.users addObject:obj]; + else + break; + } + } } --(TL_messages_dhConfig *)copy { +-(TL_account_privacyRules *)copy { - TL_messages_dhConfig *objc = [[TL_messages_dhConfig alloc] init]; + TL_account_privacyRules *objc = [[TL_account_privacyRules alloc] init]; - objc.g = self.g; - objc.p = [self.p copy]; - objc.version = self.version; - objc.random = [self.random copy]; + objc.rules = [self.rules copy]; + objc.users = [self.users copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -13467,81 +17540,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TLAccountDaysTTL -@implementation TLmessages_SentEncryptedMessage @end - -@implementation TL_messages_sentEncryptedMessage -+(TL_messages_sentEncryptedMessage*)createWithDate:(int)date { - TL_messages_sentEncryptedMessage* obj = [[TL_messages_sentEncryptedMessage alloc] init]; - obj.date = date; + +@implementation TL_accountDaysTTL ++(TL_accountDaysTTL*)createWithDays:(int)days { + TL_accountDaysTTL* obj = [[TL_accountDaysTTL alloc] init]; + obj.days = days; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.date]; + [stream writeInt:self.days]; } -(void)unserialize:(SerializedData*)stream { - self.date = [stream readInt]; + super.days = [stream readInt]; } --(TL_messages_sentEncryptedMessage *)copy { +-(TL_accountDaysTTL *)copy { - TL_messages_sentEncryptedMessage *objc = [[TL_messages_sentEncryptedMessage alloc] init]; + TL_accountDaysTTL *objc = [[TL_accountDaysTTL alloc] init]; - objc.date = self.date; + objc.days = self.days; return objc; } - --(id)initWithCoder:(NSCoder *)aDecoder { - - if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { - - } - - return self; -} - --(void)encodeWithCoder:(NSCoder *)aCoder { - [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; -} - - - -@end -@implementation TL_messages_sentEncryptedFile -+(TL_messages_sentEncryptedFile*)createWithDate:(int)date file:(TLEncryptedFile*)file { - TL_messages_sentEncryptedFile* obj = [[TL_messages_sentEncryptedFile alloc] init]; - obj.date = date; - obj.file = file; - return obj; -} --(void)serialize:(SerializedData*)stream { - [stream writeInt:self.date]; - [ClassStore TLSerialize:self.file stream:stream]; -} --(void)unserialize:(SerializedData*)stream { - self.date = [stream readInt]; - self.file = [ClassStore TLDeserialize:stream]; -} - --(TL_messages_sentEncryptedFile *)copy { - - TL_messages_sentEncryptedFile *objc = [[TL_messages_sentEncryptedFile alloc] init]; - - objc.date = self.date; - objc.file = [self.file copy]; - - return objc; -} -(id)initWithCoder:(NSCoder *)aDecoder { @@ -13555,37 +17585,42 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TLaccount_SentChangePhoneCode -@implementation TLInputAudio @end - -@implementation TL_inputAudioEmpty -+(TL_inputAudioEmpty*)create { - TL_inputAudioEmpty* obj = [[TL_inputAudioEmpty alloc] init]; - + +@implementation TL_account_sentChangePhoneCode ++(TL_account_sentChangePhoneCode*)createWithPhone_code_hash:(NSString*)phone_code_hash send_call_timeout:(int)send_call_timeout { + TL_account_sentChangePhoneCode* obj = [[TL_account_sentChangePhoneCode alloc] init]; + obj.phone_code_hash = phone_code_hash; + obj.send_call_timeout = send_call_timeout; return obj; } -(void)serialize:(SerializedData*)stream { - + [stream writeString:self.phone_code_hash]; + [stream writeInt:self.send_call_timeout]; } -(void)unserialize:(SerializedData*)stream { - + super.phone_code_hash = [stream readString]; + super.send_call_timeout = [stream readInt]; } --(TL_inputAudioEmpty *)copy { - - TL_inputAudioEmpty *objc = [[TL_inputAudioEmpty alloc] init]; +-(TL_account_sentChangePhoneCode *)copy { + TL_account_sentChangePhoneCode *objc = [[TL_account_sentChangePhoneCode alloc] init]; + objc.phone_code_hash = self.phone_code_hash; + objc.send_call_timeout = self.send_call_timeout; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -13599,37 +17634,42 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_inputAudio -+(TL_inputAudio*)createWithN_id:(long)n_id access_hash:(long)access_hash { - TL_inputAudio* obj = [[TL_inputAudio alloc] init]; - obj.n_id = n_id; - obj.access_hash = access_hash; +@implementation TLDocumentAttribute + +@end + +@implementation TL_documentAttributeImageSize ++(TL_documentAttributeImageSize*)createWithW:(int)w h:(int)h { + TL_documentAttributeImageSize* obj = [[TL_documentAttributeImageSize alloc] init]; + obj.w = w; + obj.h = h; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeLong:self.n_id]; - [stream writeLong:self.access_hash]; + [stream writeInt:self.w]; + [stream writeInt:self.h]; } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readLong]; - self.access_hash = [stream readLong]; + super.w = [stream readInt]; + super.h = [stream readInt]; } --(TL_inputAudio *)copy { +-(TL_documentAttributeImageSize *)copy { - TL_inputAudio *objc = [[TL_inputAudio alloc] init]; + TL_documentAttributeImageSize *objc = [[TL_documentAttributeImageSize alloc] init]; - objc.n_id = self.n_id; - objc.access_hash = self.access_hash; + objc.w = self.w; + objc.h = self.h; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -13643,19 +17683,14 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLInputDocument -@end - -@implementation TL_inputDocumentEmpty -+(TL_inputDocumentEmpty*)create { - TL_inputDocumentEmpty* obj = [[TL_inputDocumentEmpty alloc] init]; +@implementation TL_documentAttributeAnimated ++(TL_documentAttributeAnimated*)create { + TL_documentAttributeAnimated* obj = [[TL_documentAttributeAnimated alloc] init]; return obj; } @@ -13666,14 +17701,16 @@ -(void)unserialize:(SerializedData*)stream { } --(TL_inputDocumentEmpty *)copy { +-(TL_documentAttributeAnimated *)copy { - TL_inputDocumentEmpty *objc = [[TL_inputDocumentEmpty alloc] init]; + TL_documentAttributeAnimated *objc = [[TL_documentAttributeAnimated alloc] init]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -13687,37 +17724,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_inputDocument -+(TL_inputDocument*)createWithN_id:(long)n_id access_hash:(long)access_hash { - TL_inputDocument* obj = [[TL_inputDocument alloc] init]; - obj.n_id = n_id; - obj.access_hash = access_hash; +@implementation TL_documentAttributeSticker ++(TL_documentAttributeSticker*)createWithAlt:(NSString*)alt stickerset:(TLInputStickerSet*)stickerset { + TL_documentAttributeSticker* obj = [[TL_documentAttributeSticker alloc] init]; + obj.alt = alt; + obj.stickerset = stickerset; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeLong:self.n_id]; - [stream writeLong:self.access_hash]; + [stream writeString:self.alt]; + [ClassStore TLSerialize:self.stickerset stream:stream]; } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readLong]; - self.access_hash = [stream readLong]; + super.alt = [stream readString]; + self.stickerset = [ClassStore TLDeserialize:stream]; } --(TL_inputDocument *)copy { +-(TL_documentAttributeSticker *)copy { - TL_inputDocument *objc = [[TL_inputDocument alloc] init]; + TL_documentAttributeSticker *objc = [[TL_documentAttributeSticker alloc] init]; - objc.n_id = self.n_id; - objc.access_hash = self.access_hash; + objc.alt = self.alt; + objc.stickerset = [self.stickerset copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -13731,37 +17769,42 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLAudio -@end - -@implementation TL_audioEmpty -+(TL_audioEmpty*)createWithN_id:(long)n_id { - TL_audioEmpty* obj = [[TL_audioEmpty alloc] init]; - obj.n_id = n_id; +@implementation TL_documentAttributeVideo ++(TL_documentAttributeVideo*)createWithDuration:(int)duration w:(int)w h:(int)h { + TL_documentAttributeVideo* obj = [[TL_documentAttributeVideo alloc] init]; + obj.duration = duration; + obj.w = w; + obj.h = h; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeLong:self.n_id]; + [stream writeInt:self.duration]; + [stream writeInt:self.w]; + [stream writeInt:self.h]; } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readLong]; + super.duration = [stream readInt]; + super.w = [stream readInt]; + super.h = [stream readInt]; } --(TL_audioEmpty *)copy { +-(TL_documentAttributeVideo *)copy { - TL_audioEmpty *objc = [[TL_audioEmpty alloc] init]; + TL_documentAttributeVideo *objc = [[TL_documentAttributeVideo alloc] init]; - objc.n_id = self.n_id; + objc.duration = self.duration; + objc.w = self.w; + objc.h = self.h; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -13775,61 +17818,42 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_audio -+(TL_audio*)createWithN_id:(long)n_id access_hash:(long)access_hash user_id:(int)user_id date:(int)date duration:(int)duration mime_type:(NSString*)mime_type size:(int)size dc_id:(int)dc_id { - TL_audio* obj = [[TL_audio alloc] init]; - obj.n_id = n_id; - obj.access_hash = access_hash; - obj.user_id = user_id; - obj.date = date; +@implementation TL_documentAttributeAudio ++(TL_documentAttributeAudio*)createWithDuration:(int)duration title:(NSString*)title performer:(NSString*)performer { + TL_documentAttributeAudio* obj = [[TL_documentAttributeAudio alloc] init]; obj.duration = duration; - obj.mime_type = mime_type; - obj.size = size; - obj.dc_id = dc_id; + obj.title = title; + obj.performer = performer; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeLong:self.n_id]; - [stream writeLong:self.access_hash]; - [stream writeInt:self.user_id]; - [stream writeInt:self.date]; [stream writeInt:self.duration]; - [stream writeString:self.mime_type]; - [stream writeInt:self.size]; - [stream writeInt:self.dc_id]; + [stream writeString:self.title]; + [stream writeString:self.performer]; } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readLong]; - self.access_hash = [stream readLong]; - self.user_id = [stream readInt]; - self.date = [stream readInt]; - self.duration = [stream readInt]; - self.mime_type = [stream readString]; - self.size = [stream readInt]; - self.dc_id = [stream readInt]; + super.duration = [stream readInt]; + super.title = [stream readString]; + super.performer = [stream readString]; } --(TL_audio *)copy { +-(TL_documentAttributeAudio *)copy { - TL_audio *objc = [[TL_audio alloc] init]; + TL_documentAttributeAudio *objc = [[TL_documentAttributeAudio alloc] init]; - objc.n_id = self.n_id; - objc.access_hash = self.access_hash; - objc.user_id = self.user_id; - objc.date = self.date; objc.duration = self.duration; - objc.mime_type = self.mime_type; - objc.size = self.size; - objc.dc_id = self.dc_id; + objc.title = self.title; + objc.performer = self.performer; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -13843,37 +17867,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLDocument -@end - -@implementation TL_documentEmpty -+(TL_documentEmpty*)createWithN_id:(long)n_id { - TL_documentEmpty* obj = [[TL_documentEmpty alloc] init]; - obj.n_id = n_id; +@implementation TL_documentAttributeFilename ++(TL_documentAttributeFilename*)createWithFile_name:(NSString*)file_name { + TL_documentAttributeFilename* obj = [[TL_documentAttributeFilename alloc] init]; + obj.file_name = file_name; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeLong:self.n_id]; + [stream writeString:self.file_name]; } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readLong]; + super.file_name = [stream readString]; } --(TL_documentEmpty *)copy { +-(TL_documentAttributeFilename *)copy { - TL_documentEmpty *objc = [[TL_documentEmpty alloc] init]; + TL_documentAttributeFilename *objc = [[TL_documentAttributeFilename alloc] init]; - objc.n_id = self.n_id; + objc.file_name = self.file_name; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -13887,83 +17908,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_document -+(TL_document*)createWithN_id:(long)n_id access_hash:(long)access_hash date:(int)date mime_type:(NSString*)mime_type size:(int)size thumb:(TLPhotoSize*)thumb dc_id:(int)dc_id attributes:(NSMutableArray*)attributes { - TL_document* obj = [[TL_document alloc] init]; - obj.n_id = n_id; - obj.access_hash = access_hash; - obj.date = date; - obj.mime_type = mime_type; - obj.size = size; - obj.thumb = thumb; - obj.dc_id = dc_id; - obj.attributes = attributes; +@implementation TL_documentAttributeAudio_old31 ++(TL_documentAttributeAudio_old31*)createWithDuration:(int)duration { + TL_documentAttributeAudio_old31* obj = [[TL_documentAttributeAudio_old31 alloc] init]; + obj.duration = duration; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeLong:self.n_id]; - [stream writeLong:self.access_hash]; - [stream writeInt:self.date]; - [stream writeString:self.mime_type]; - [stream writeInt:self.size]; - [ClassStore TLSerialize:self.thumb stream:stream]; - [stream writeInt:self.dc_id]; - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.attributes count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLDocumentAttribute* obj = [self.attributes objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } + [stream writeInt:self.duration]; } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readLong]; - self.access_hash = [stream readLong]; - self.date = [stream readInt]; - self.mime_type = [stream readString]; - self.size = [stream readInt]; - self.thumb = [ClassStore TLDeserialize:stream]; - self.dc_id = [stream readInt]; - //UNS FullVector - [stream readInt]; - { - if(!self.attributes) - self.attributes = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLDocumentAttribute* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLDocumentAttribute class]]) - [self.attributes addObject:obj]; - else - break; - } - } + super.duration = [stream readInt]; } --(TL_document *)copy { +-(TL_documentAttributeAudio_old31 *)copy { - TL_document *objc = [[TL_document alloc] init]; + TL_documentAttributeAudio_old31 *objc = [[TL_documentAttributeAudio_old31 alloc] init]; - objc.n_id = self.n_id; - objc.access_hash = self.access_hash; - objc.date = self.date; - objc.mime_type = self.mime_type; - objc.size = self.size; - objc.thumb = [self.thumb copy]; - objc.dc_id = self.dc_id; - objc.attributes = [self.attributes copy]; + objc.duration = self.duration; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -13977,41 +17949,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TLmessages_Stickers -@implementation TLhelp_Support @end - -@implementation TL_help_support -+(TL_help_support*)createWithPhone_number:(NSString*)phone_number user:(TLUser*)user { - TL_help_support* obj = [[TL_help_support alloc] init]; - obj.phone_number = phone_number; - obj.user = user; + +@implementation TL_messages_stickersNotModified ++(TL_messages_stickersNotModified*)create { + TL_messages_stickersNotModified* obj = [[TL_messages_stickersNotModified alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeString:self.phone_number]; - [ClassStore TLSerialize:self.user stream:stream]; + } -(void)unserialize:(SerializedData*)stream { - self.phone_number = [stream readString]; - self.user = [ClassStore TLDeserialize:stream]; + } --(TL_help_support *)copy { +-(TL_messages_stickersNotModified *)copy { + + TL_messages_stickersNotModified *objc = [[TL_messages_stickersNotModified alloc] init]; - TL_help_support *objc = [[TL_help_support alloc] init]; - objc.phone_number = self.phone_number; - objc.user = [self.user copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -14025,37 +17994,60 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLNotifyPeer -@end - -@implementation TL_notifyPeer -+(TL_notifyPeer*)createWithPeer:(TLPeer*)peer { - TL_notifyPeer* obj = [[TL_notifyPeer alloc] init]; - obj.peer = peer; +@implementation TL_messages_stickers ++(TL_messages_stickers*)createWithN_hash:(NSString*)n_hash stickers:(NSMutableArray*)stickers { + TL_messages_stickers* obj = [[TL_messages_stickers alloc] init]; + obj.n_hash = n_hash; + obj.stickers = stickers; return obj; } -(void)serialize:(SerializedData*)stream { - [ClassStore TLSerialize:self.peer stream:stream]; + [stream writeString:self.n_hash]; + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.stickers count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLDocument* obj = [self.stickers objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } } -(void)unserialize:(SerializedData*)stream { - self.peer = [ClassStore TLDeserialize:stream]; + super.n_hash = [stream readString]; + //UNS FullVector + [stream readInt]; + { + if(!self.stickers) + self.stickers = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLDocument* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLDocument class]]) + [self.stickers addObject:obj]; + else + break; + } + } } --(TL_notifyPeer *)copy { +-(TL_messages_stickers *)copy { - TL_notifyPeer *objc = [[TL_notifyPeer alloc] init]; + TL_messages_stickers *objc = [[TL_messages_stickers alloc] init]; - objc.peer = [self.peer copy]; + objc.n_hash = self.n_hash; + objc.stickers = [self.stickers copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -14069,33 +18061,64 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_notifyUsers -+(TL_notifyUsers*)create { - TL_notifyUsers* obj = [[TL_notifyUsers alloc] init]; - +@implementation TLStickerPack + +@end + +@implementation TL_stickerPack ++(TL_stickerPack*)createWithEmoticon:(NSString*)emoticon documents:(NSMutableArray*)documents { + TL_stickerPack* obj = [[TL_stickerPack alloc] init]; + obj.emoticon = emoticon; + obj.documents = documents; return obj; } -(void)serialize:(SerializedData*)stream { - + [stream writeString:self.emoticon]; + //Serialize ShortVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.documents count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + if([self.documents count] > i) { + NSNumber* obj = [self.documents objectAtIndex:i]; + [stream writeLong:[obj longValue]]; + } else + break; + } + } } -(void)unserialize:(SerializedData*)stream { - + super.emoticon = [stream readString]; + //UNS ShortVector + [stream readInt]; + { + if(!self.documents) + self.documents = [[NSMutableArray alloc] init]; + int tl_count = [stream readInt]; + for(int i = 0; i < tl_count; i++) { + long obj = [stream readLong]; + [self.documents addObject:@(obj)]; + } + } } --(TL_notifyUsers *)copy { - - TL_notifyUsers *objc = [[TL_notifyUsers alloc] init]; +-(TL_stickerPack *)copy { + TL_stickerPack *objc = [[TL_stickerPack alloc] init]; + objc.emoticon = self.emoticon; + objc.documents = [self.documents copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -14109,15 +18132,18 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_notifyChats -+(TL_notifyChats*)create { - TL_notifyChats* obj = [[TL_notifyChats alloc] init]; +@implementation TLmessages_AllStickers + +@end + +@implementation TL_messages_allStickersNotModified ++(TL_messages_allStickersNotModified*)create { + TL_messages_allStickersNotModified* obj = [[TL_messages_allStickersNotModified alloc] init]; return obj; } @@ -14128,14 +18154,16 @@ -(void)unserialize:(SerializedData*)stream { } --(TL_notifyChats *)copy { +-(TL_messages_allStickersNotModified *)copy { - TL_notifyChats *objc = [[TL_notifyChats alloc] init]; + TL_messages_allStickersNotModified *objc = [[TL_messages_allStickersNotModified alloc] init]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -14149,33 +18177,60 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_notifyAll -+(TL_notifyAll*)create { - TL_notifyAll* obj = [[TL_notifyAll alloc] init]; - +@implementation TL_messages_allStickers ++(TL_messages_allStickers*)createWithN_hash:(int)n_hash sets:(NSMutableArray*)sets { + TL_messages_allStickers* obj = [[TL_messages_allStickers alloc] init]; + obj.n_hash = n_hash; + obj.sets = sets; return obj; } -(void)serialize:(SerializedData*)stream { - + [stream writeInt:self.n_hash]; + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.sets count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLStickerSet* obj = [self.sets objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } } -(void)unserialize:(SerializedData*)stream { - + super.n_hash = [stream readInt]; + //UNS FullVector + [stream readInt]; + { + if(!self.sets) + self.sets = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLStickerSet* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLStickerSet class]]) + [self.sets addObject:obj]; + else + break; + } + } } --(TL_notifyAll *)copy { - - TL_notifyAll *objc = [[TL_notifyAll alloc] init]; +-(TL_messages_allStickers *)copy { + TL_messages_allStickers *objc = [[TL_messages_allStickers alloc] init]; + objc.n_hash = self.n_hash; + objc.sets = [self.sets copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -14189,37 +18244,42 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TLDisabledFeature -@implementation TLSendMessageAction @end - -@implementation TL_sendMessageTypingAction -+(TL_sendMessageTypingAction*)create { - TL_sendMessageTypingAction* obj = [[TL_sendMessageTypingAction alloc] init]; - + +@implementation TL_disabledFeature ++(TL_disabledFeature*)createWithFeature:(NSString*)feature n_description:(NSString*)n_description { + TL_disabledFeature* obj = [[TL_disabledFeature alloc] init]; + obj.feature = feature; + obj.n_description = n_description; return obj; } -(void)serialize:(SerializedData*)stream { - + [stream writeString:self.feature]; + [stream writeString:self.n_description]; } -(void)unserialize:(SerializedData*)stream { - + super.feature = [stream readString]; + super.n_description = [stream readString]; } --(TL_sendMessageTypingAction *)copy { - - TL_sendMessageTypingAction *objc = [[TL_sendMessageTypingAction alloc] init]; +-(TL_disabledFeature *)copy { + TL_disabledFeature *objc = [[TL_disabledFeature alloc] init]; + objc.feature = self.feature; + objc.n_description = self.n_description; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -14233,33 +18293,42 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_sendMessageCancelAction -+(TL_sendMessageCancelAction*)create { - TL_sendMessageCancelAction* obj = [[TL_sendMessageCancelAction alloc] init]; - +@implementation TLmessages_AffectedMessages + +@end + +@implementation TL_messages_affectedMessages ++(TL_messages_affectedMessages*)createWithPts:(int)pts pts_count:(int)pts_count { + TL_messages_affectedMessages* obj = [[TL_messages_affectedMessages alloc] init]; + obj.pts = pts; + obj.pts_count = pts_count; return obj; } -(void)serialize:(SerializedData*)stream { - + [stream writeInt:self.pts]; + [stream writeInt:self.pts_count]; } -(void)unserialize:(SerializedData*)stream { - + super.pts = [stream readInt]; + super.pts_count = [stream readInt]; } --(TL_sendMessageCancelAction *)copy { - - TL_sendMessageCancelAction *objc = [[TL_sendMessageCancelAction alloc] init]; +-(TL_messages_affectedMessages *)copy { + TL_messages_affectedMessages *objc = [[TL_messages_affectedMessages alloc] init]; + objc.pts = self.pts; + objc.pts_count = self.pts_count; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -14273,15 +18342,18 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_sendMessageRecordVideoAction -+(TL_sendMessageRecordVideoAction*)create { - TL_sendMessageRecordVideoAction* obj = [[TL_sendMessageRecordVideoAction alloc] init]; +@implementation TLContactLink + +@end + +@implementation TL_contactLinkUnknown ++(TL_contactLinkUnknown*)create { + TL_contactLinkUnknown* obj = [[TL_contactLinkUnknown alloc] init]; return obj; } @@ -14292,14 +18364,16 @@ -(void)unserialize:(SerializedData*)stream { } --(TL_sendMessageRecordVideoAction *)copy { +-(TL_contactLinkUnknown *)copy { - TL_sendMessageRecordVideoAction *objc = [[TL_sendMessageRecordVideoAction alloc] init]; + TL_contactLinkUnknown *objc = [[TL_contactLinkUnknown alloc] init]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -14313,33 +18387,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_sendMessageUploadVideoAction -+(TL_sendMessageUploadVideoAction*)createWithProgress:(int)progress { - TL_sendMessageUploadVideoAction* obj = [[TL_sendMessageUploadVideoAction alloc] init]; - obj.progress = progress; +@implementation TL_contactLinkNone ++(TL_contactLinkNone*)create { + TL_contactLinkNone* obj = [[TL_contactLinkNone alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.progress]; + } -(void)unserialize:(SerializedData*)stream { - self.progress = [stream readInt]; + } --(TL_sendMessageUploadVideoAction *)copy { +-(TL_contactLinkNone *)copy { + + TL_contactLinkNone *objc = [[TL_contactLinkNone alloc] init]; - TL_sendMessageUploadVideoAction *objc = [[TL_sendMessageUploadVideoAction alloc] init]; - objc.progress = self.progress; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -14353,15 +18428,14 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_sendMessageRecordAudioAction -+(TL_sendMessageRecordAudioAction*)create { - TL_sendMessageRecordAudioAction* obj = [[TL_sendMessageRecordAudioAction alloc] init]; +@implementation TL_contactLinkHasPhone ++(TL_contactLinkHasPhone*)create { + TL_contactLinkHasPhone* obj = [[TL_contactLinkHasPhone alloc] init]; return obj; } @@ -14372,14 +18446,16 @@ -(void)unserialize:(SerializedData*)stream { } --(TL_sendMessageRecordAudioAction *)copy { +-(TL_contactLinkHasPhone *)copy { - TL_sendMessageRecordAudioAction *objc = [[TL_sendMessageRecordAudioAction alloc] init]; + TL_contactLinkHasPhone *objc = [[TL_contactLinkHasPhone alloc] init]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -14393,33 +18469,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_sendMessageUploadAudioAction -+(TL_sendMessageUploadAudioAction*)createWithProgress:(int)progress { - TL_sendMessageUploadAudioAction* obj = [[TL_sendMessageUploadAudioAction alloc] init]; - obj.progress = progress; +@implementation TL_contactLinkContact ++(TL_contactLinkContact*)create { + TL_contactLinkContact* obj = [[TL_contactLinkContact alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.progress]; + } -(void)unserialize:(SerializedData*)stream { - self.progress = [stream readInt]; + } --(TL_sendMessageUploadAudioAction *)copy { +-(TL_contactLinkContact *)copy { + + TL_contactLinkContact *objc = [[TL_contactLinkContact alloc] init]; - TL_sendMessageUploadAudioAction *objc = [[TL_sendMessageUploadAudioAction alloc] init]; - objc.progress = self.progress; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -14433,33 +18510,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_sendMessageUploadPhotoAction -+(TL_sendMessageUploadPhotoAction*)createWithProgress:(int)progress { - TL_sendMessageUploadPhotoAction* obj = [[TL_sendMessageUploadPhotoAction alloc] init]; - obj.progress = progress; +@implementation TLWebPage + +@end + +@implementation TL_webPageEmpty ++(TL_webPageEmpty*)createWithN_id:(long)n_id { + TL_webPageEmpty* obj = [[TL_webPageEmpty alloc] init]; + obj.n_id = n_id; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.progress]; + [stream writeLong:self.n_id]; } -(void)unserialize:(SerializedData*)stream { - self.progress = [stream readInt]; + super.n_id = [stream readLong]; } --(TL_sendMessageUploadPhotoAction *)copy { +-(TL_webPageEmpty *)copy { - TL_sendMessageUploadPhotoAction *objc = [[TL_sendMessageUploadPhotoAction alloc] init]; + TL_webPageEmpty *objc = [[TL_webPageEmpty alloc] init]; - objc.progress = self.progress; + objc.n_id = self.n_id; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -14473,33 +18555,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_sendMessageUploadDocumentAction -+(TL_sendMessageUploadDocumentAction*)createWithProgress:(int)progress { - TL_sendMessageUploadDocumentAction* obj = [[TL_sendMessageUploadDocumentAction alloc] init]; - obj.progress = progress; +@implementation TL_webPagePending ++(TL_webPagePending*)createWithN_id:(long)n_id date:(int)date { + TL_webPagePending* obj = [[TL_webPagePending alloc] init]; + obj.n_id = n_id; + obj.date = date; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.progress]; + [stream writeLong:self.n_id]; + [stream writeInt:self.date]; } -(void)unserialize:(SerializedData*)stream { - self.progress = [stream readInt]; + super.n_id = [stream readLong]; + super.date = [stream readInt]; } --(TL_sendMessageUploadDocumentAction *)copy { +-(TL_webPagePending *)copy { - TL_sendMessageUploadDocumentAction *objc = [[TL_sendMessageUploadDocumentAction alloc] init]; + TL_webPagePending *objc = [[TL_webPagePending alloc] init]; - objc.progress = self.progress; + objc.n_id = self.n_id; + objc.date = self.date; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -14513,33 +18600,94 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_sendMessageGeoLocationAction -+(TL_sendMessageGeoLocationAction*)create { - TL_sendMessageGeoLocationAction* obj = [[TL_sendMessageGeoLocationAction alloc] init]; - +@implementation TL_webPage ++(TL_webPage*)createWithFlags:(int)flags n_id:(long)n_id url:(NSString*)url display_url:(NSString*)display_url type:(NSString*)type site_name:(NSString*)site_name title:(NSString*)title n_description:(NSString*)n_description photo:(TLPhoto*)photo embed_url:(NSString*)embed_url embed_type:(NSString*)embed_type embed_width:(int)embed_width embed_height:(int)embed_height duration:(int)duration author:(NSString*)author document:(TLDocument*)document { + TL_webPage* obj = [[TL_webPage alloc] init]; + obj.flags = flags; + obj.n_id = n_id; + obj.url = url; + obj.display_url = display_url; + obj.type = type; + obj.site_name = site_name; + obj.title = title; + obj.n_description = n_description; + obj.photo = photo; + obj.embed_url = embed_url; + obj.embed_type = embed_type; + obj.embed_width = embed_width; + obj.embed_height = embed_height; + obj.duration = duration; + obj.author = author; + obj.document = document; return obj; } -(void)serialize:(SerializedData*)stream { - -} --(void)unserialize:(SerializedData*)stream { - + [stream writeInt:self.flags]; + [stream writeLong:self.n_id]; + [stream writeString:self.url]; + [stream writeString:self.display_url]; + if(self.flags & (1 << 0)) {[stream writeString:self.type];} + if(self.flags & (1 << 1)) {[stream writeString:self.site_name];} + if(self.flags & (1 << 2)) {[stream writeString:self.title];} + if(self.flags & (1 << 3)) {[stream writeString:self.n_description];} + if(self.flags & (1 << 4)) {[ClassStore TLSerialize:self.photo stream:stream];} + if(self.flags & (1 << 5)) {[stream writeString:self.embed_url];} + if(self.flags & (1 << 5)) {[stream writeString:self.embed_type];} + if(self.flags & (1 << 6)) {[stream writeInt:self.embed_width];} + if(self.flags & (1 << 6)) {[stream writeInt:self.embed_height];} + if(self.flags & (1 << 7)) {[stream writeInt:self.duration];} + if(self.flags & (1 << 8)) {[stream writeString:self.author];} + if(self.flags & (1 << 9)) {[ClassStore TLSerialize:self.document stream:stream];} +} +-(void)unserialize:(SerializedData*)stream { + super.flags = [stream readInt]; + super.n_id = [stream readLong]; + super.url = [stream readString]; + super.display_url = [stream readString]; + if(self.flags & (1 << 0)) {super.type = [stream readString];} + if(self.flags & (1 << 1)) {super.site_name = [stream readString];} + if(self.flags & (1 << 2)) {super.title = [stream readString];} + if(self.flags & (1 << 3)) {super.n_description = [stream readString];} + if(self.flags & (1 << 4)) {self.photo = [ClassStore TLDeserialize:stream];} + if(self.flags & (1 << 5)) {super.embed_url = [stream readString];} + if(self.flags & (1 << 5)) {super.embed_type = [stream readString];} + if(self.flags & (1 << 6)) {super.embed_width = [stream readInt];} + if(self.flags & (1 << 6)) {super.embed_height = [stream readInt];} + if(self.flags & (1 << 7)) {super.duration = [stream readInt];} + if(self.flags & (1 << 8)) {super.author = [stream readString];} + if(self.flags & (1 << 9)) {self.document = [ClassStore TLDeserialize:stream];} } --(TL_sendMessageGeoLocationAction *)copy { - - TL_sendMessageGeoLocationAction *objc = [[TL_sendMessageGeoLocationAction alloc] init]; +-(TL_webPage *)copy { + TL_webPage *objc = [[TL_webPage alloc] init]; + objc.flags = self.flags; + objc.n_id = self.n_id; + objc.url = self.url; + objc.display_url = self.display_url; + objc.type = self.type; + objc.site_name = self.site_name; + objc.title = self.title; + objc.n_description = self.n_description; + objc.photo = [self.photo copy]; + objc.embed_url = self.embed_url; + objc.embed_type = self.embed_type; + objc.embed_width = self.embed_width; + objc.embed_height = self.embed_height; + objc.duration = self.duration; + objc.author = self.author; + objc.document = [self.document copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -14553,33 +18701,162 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - - - + + +-(void)setType:(NSString*)type +{ + super.type = type; + + if(super.type == nil) { super.flags&= ~ (1 << 0) ;} else { super.flags|= (1 << 0); } +} +-(void)setSite_name:(NSString*)site_name +{ + super.site_name = site_name; + + if(super.site_name == nil) { super.flags&= ~ (1 << 1) ;} else { super.flags|= (1 << 1); } +} +-(void)setTitle:(NSString*)title +{ + super.title = title; + + if(super.title == nil) { super.flags&= ~ (1 << 2) ;} else { super.flags|= (1 << 2); } +} +-(void)setN_description:(NSString*)n_description +{ + super.n_description = n_description; + + if(super.n_description == nil) { super.flags&= ~ (1 << 3) ;} else { super.flags|= (1 << 3); } +} +-(void)setPhoto:(TLPhoto*)photo +{ + super.photo = photo; + + if(super.photo == nil) { super.flags&= ~ (1 << 4) ;} else { super.flags|= (1 << 4); } +} +-(void)setEmbed_url:(NSString*)embed_url +{ + super.embed_url = embed_url; + + if(super.embed_url == nil) { super.flags&= ~ (1 << 5) ;} else { super.flags|= (1 << 5); } +} +-(void)setEmbed_type:(NSString*)embed_type +{ + super.embed_type = embed_type; + + if(super.embed_type == nil) { super.flags&= ~ (1 << 5) ;} else { super.flags|= (1 << 5); } +} +-(void)setEmbed_width:(int)embed_width +{ + super.embed_width = embed_width; + + if(super.embed_width == 0) { super.flags&= ~ (1 << 6) ;} else { super.flags|= (1 << 6); } +} +-(void)setEmbed_height:(int)embed_height +{ + super.embed_height = embed_height; + + if(super.embed_height == 0) { super.flags&= ~ (1 << 6) ;} else { super.flags|= (1 << 6); } +} +-(void)setDuration:(int)duration +{ + super.duration = duration; + + if(super.duration == 0) { super.flags&= ~ (1 << 7) ;} else { super.flags|= (1 << 7); } +} +-(void)setAuthor:(NSString*)author +{ + super.author = author; + + if(super.author == nil) { super.flags&= ~ (1 << 8) ;} else { super.flags|= (1 << 8); } +} +-(void)setDocument:(TLDocument*)document +{ + super.document = document; + + if(super.document == nil) { super.flags&= ~ (1 << 9) ;} else { super.flags|= (1 << 9); } +} @end -@implementation TL_sendMessageChooseContactAction -+(TL_sendMessageChooseContactAction*)create { - TL_sendMessageChooseContactAction* obj = [[TL_sendMessageChooseContactAction alloc] init]; - +@implementation TL_webPage_old34 ++(TL_webPage_old34*)createWithFlags:(int)flags n_id:(long)n_id url:(NSString*)url display_url:(NSString*)display_url type:(NSString*)type site_name:(NSString*)site_name title:(NSString*)title n_description:(NSString*)n_description photo:(TLPhoto*)photo embed_url:(NSString*)embed_url embed_type:(NSString*)embed_type embed_width:(int)embed_width embed_height:(int)embed_height duration:(int)duration author:(NSString*)author { + TL_webPage_old34* obj = [[TL_webPage_old34 alloc] init]; + obj.flags = flags; + obj.n_id = n_id; + obj.url = url; + obj.display_url = display_url; + obj.type = type; + obj.site_name = site_name; + obj.title = title; + obj.n_description = n_description; + obj.photo = photo; + obj.embed_url = embed_url; + obj.embed_type = embed_type; + obj.embed_width = embed_width; + obj.embed_height = embed_height; + obj.duration = duration; + obj.author = author; return obj; } -(void)serialize:(SerializedData*)stream { - -} --(void)unserialize:(SerializedData*)stream { - -} - --(TL_sendMessageChooseContactAction *)copy { - - TL_sendMessageChooseContactAction *objc = [[TL_sendMessageChooseContactAction alloc] init]; - + [stream writeInt:self.flags]; + [stream writeLong:self.n_id]; + [stream writeString:self.url]; + [stream writeString:self.display_url]; + if(self.flags & (1 << 0)) {[stream writeString:self.type];} + if(self.flags & (1 << 1)) {[stream writeString:self.site_name];} + if(self.flags & (1 << 2)) {[stream writeString:self.title];} + if(self.flags & (1 << 3)) {[stream writeString:self.n_description];} + if(self.flags & (1 << 4)) {[ClassStore TLSerialize:self.photo stream:stream];} + if(self.flags & (1 << 5)) {[stream writeString:self.embed_url];} + if(self.flags & (1 << 5)) {[stream writeString:self.embed_type];} + if(self.flags & (1 << 6)) {[stream writeInt:self.embed_width];} + if(self.flags & (1 << 6)) {[stream writeInt:self.embed_height];} + if(self.flags & (1 << 7)) {[stream writeInt:self.duration];} + if(self.flags & (1 << 8)) {[stream writeString:self.author];} +} +-(void)unserialize:(SerializedData*)stream { + super.flags = [stream readInt]; + super.n_id = [stream readLong]; + super.url = [stream readString]; + super.display_url = [stream readString]; + if(self.flags & (1 << 0)) {super.type = [stream readString];} + if(self.flags & (1 << 1)) {super.site_name = [stream readString];} + if(self.flags & (1 << 2)) {super.title = [stream readString];} + if(self.flags & (1 << 3)) {super.n_description = [stream readString];} + if(self.flags & (1 << 4)) {self.photo = [ClassStore TLDeserialize:stream];} + if(self.flags & (1 << 5)) {super.embed_url = [stream readString];} + if(self.flags & (1 << 5)) {super.embed_type = [stream readString];} + if(self.flags & (1 << 6)) {super.embed_width = [stream readInt];} + if(self.flags & (1 << 6)) {super.embed_height = [stream readInt];} + if(self.flags & (1 << 7)) {super.duration = [stream readInt];} + if(self.flags & (1 << 8)) {super.author = [stream readString];} +} + +-(TL_webPage_old34 *)copy { + + TL_webPage_old34 *objc = [[TL_webPage_old34 alloc] init]; + objc.flags = self.flags; + objc.n_id = self.n_id; + objc.url = self.url; + objc.display_url = self.display_url; + objc.type = self.type; + objc.site_name = self.site_name; + objc.title = self.title; + objc.n_description = self.n_description; + objc.photo = [self.photo copy]; + objc.embed_url = self.embed_url; + objc.embed_type = self.embed_type; + objc.embed_width = self.embed_width; + objc.embed_height = self.embed_height; + objc.duration = self.duration; + objc.author = self.author; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -14593,37 +18870,152 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - - + +-(void)setType:(NSString*)type +{ + super.type = type; + + if(super.type == nil) { super.flags&= ~ (1 << 0) ;} else { super.flags|= (1 << 0); } +} +-(void)setSite_name:(NSString*)site_name +{ + super.site_name = site_name; + + if(super.site_name == nil) { super.flags&= ~ (1 << 1) ;} else { super.flags|= (1 << 1); } +} +-(void)setTitle:(NSString*)title +{ + super.title = title; + + if(super.title == nil) { super.flags&= ~ (1 << 2) ;} else { super.flags|= (1 << 2); } +} +-(void)setN_description:(NSString*)n_description +{ + super.n_description = n_description; + + if(super.n_description == nil) { super.flags&= ~ (1 << 3) ;} else { super.flags|= (1 << 3); } +} +-(void)setPhoto:(TLPhoto*)photo +{ + super.photo = photo; + + if(super.photo == nil) { super.flags&= ~ (1 << 4) ;} else { super.flags|= (1 << 4); } +} +-(void)setEmbed_url:(NSString*)embed_url +{ + super.embed_url = embed_url; + + if(super.embed_url == nil) { super.flags&= ~ (1 << 5) ;} else { super.flags|= (1 << 5); } +} +-(void)setEmbed_type:(NSString*)embed_type +{ + super.embed_type = embed_type; + + if(super.embed_type == nil) { super.flags&= ~ (1 << 5) ;} else { super.flags|= (1 << 5); } +} +-(void)setEmbed_width:(int)embed_width +{ + super.embed_width = embed_width; + + if(super.embed_width == 0) { super.flags&= ~ (1 << 6) ;} else { super.flags|= (1 << 6); } +} +-(void)setEmbed_height:(int)embed_height +{ + super.embed_height = embed_height; + + if(super.embed_height == 0) { super.flags&= ~ (1 << 6) ;} else { super.flags|= (1 << 6); } +} +-(void)setDuration:(int)duration +{ + super.duration = duration; + + if(super.duration == 0) { super.flags&= ~ (1 << 7) ;} else { super.flags|= (1 << 7); } +} +-(void)setAuthor:(NSString*)author +{ + super.author = author; + + if(super.author == nil) { super.flags&= ~ (1 << 8) ;} else { super.flags|= (1 << 8); } +} @end +@implementation TLAuthorization -@implementation TLContactFound @end - -@implementation TL_contactFound -+(TL_contactFound*)createWithUser_id:(int)user_id { - TL_contactFound* obj = [[TL_contactFound alloc] init]; - obj.user_id = user_id; + +@implementation TL_authorization ++(TL_authorization*)createWithN_hash:(long)n_hash flags:(int)flags device_model:(NSString*)device_model platform:(NSString*)platform system_version:(NSString*)system_version api_id:(int)api_id app_name:(NSString*)app_name app_version:(NSString*)app_version date_created:(int)date_created date_active:(int)date_active ip:(NSString*)ip country:(NSString*)country region:(NSString*)region { + TL_authorization* obj = [[TL_authorization alloc] init]; + obj.n_hash = n_hash; + obj.flags = flags; + obj.device_model = device_model; + obj.platform = platform; + obj.system_version = system_version; + obj.api_id = api_id; + obj.app_name = app_name; + obj.app_version = app_version; + obj.date_created = date_created; + obj.date_active = date_active; + obj.ip = ip; + obj.country = country; + obj.region = region; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.user_id]; + [stream writeLong:self.n_hash]; + [stream writeInt:self.flags]; + [stream writeString:self.device_model]; + [stream writeString:self.platform]; + [stream writeString:self.system_version]; + [stream writeInt:self.api_id]; + [stream writeString:self.app_name]; + [stream writeString:self.app_version]; + [stream writeInt:self.date_created]; + [stream writeInt:self.date_active]; + [stream writeString:self.ip]; + [stream writeString:self.country]; + [stream writeString:self.region]; } -(void)unserialize:(SerializedData*)stream { - self.user_id = [stream readInt]; + super.n_hash = [stream readLong]; + super.flags = [stream readInt]; + super.device_model = [stream readString]; + super.platform = [stream readString]; + super.system_version = [stream readString]; + super.api_id = [stream readInt]; + super.app_name = [stream readString]; + super.app_version = [stream readString]; + super.date_created = [stream readInt]; + super.date_active = [stream readInt]; + super.ip = [stream readString]; + super.country = [stream readString]; + super.region = [stream readString]; } --(TL_contactFound *)copy { +-(TL_authorization *)copy { - TL_contactFound *objc = [[TL_contactFound alloc] init]; + TL_authorization *objc = [[TL_authorization alloc] init]; - objc.user_id = self.user_id; + objc.n_hash = self.n_hash; + objc.flags = self.flags; + objc.device_model = self.device_model; + objc.platform = self.platform; + objc.system_version = self.system_version; + objc.api_id = self.api_id; + objc.app_name = self.app_name; + objc.app_version = self.app_version; + objc.date_created = self.date_created; + objc.date_active = self.date_active; + objc.ip = self.ip; + objc.country = self.country; + objc.region = self.region; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -14637,41 +19029,29 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TLaccount_Authorizations -@implementation TLcontacts_Found @end - -@implementation TL_contacts_found -+(TL_contacts_found*)createWithResults:(NSMutableArray*)results users:(NSMutableArray*)users { - TL_contacts_found* obj = [[TL_contacts_found alloc] init]; - obj.results = results; - obj.users = users; + +@implementation TL_account_authorizations ++(TL_account_authorizations*)createWithAuthorizations:(NSMutableArray*)authorizations { + TL_account_authorizations* obj = [[TL_account_authorizations alloc] init]; + obj.authorizations = authorizations; return obj; } -(void)serialize:(SerializedData*)stream { //Serialize FullVector [stream writeInt:0x1cb5c415]; { - NSInteger tl_count = [self.results count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLContactFound* obj = [self.results objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.users count]; + NSInteger tl_count = [self.authorizations count]; [stream writeInt:(int)tl_count]; for(int i = 0; i < (int)tl_count; i++) { - TLUser* obj = [self.users objectAtIndex:i]; + TLAuthorization* obj = [self.authorizations objectAtIndex:i]; [ClassStore TLSerialize:obj stream:stream]; } } @@ -14680,42 +19060,29 @@ -(void)unserialize:(SerializedData*)stream { //UNS FullVector [stream readInt]; { - if(!self.results) - self.results = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLContactFound* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLContactFound class]]) - [self.results addObject:obj]; - else - break; - } - } - //UNS FullVector - [stream readInt]; - { - if(!self.users) - self.users = [[NSMutableArray alloc] init]; + if(!self.authorizations) + self.authorizations = [[NSMutableArray alloc] init]; int count = [stream readInt]; for(int i = 0; i < count; i++) { - TLUser* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLUser class]]) - [self.users addObject:obj]; + TLAuthorization* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLAuthorization class]]) + [self.authorizations addObject:obj]; else break; } } } --(TL_contacts_found *)copy { +-(TL_account_authorizations *)copy { - TL_contacts_found *objc = [[TL_contacts_found alloc] init]; + TL_account_authorizations *objc = [[TL_account_authorizations alloc] init]; - objc.results = [self.results copy]; - objc.users = [self.users copy]; + objc.authorizations = [self.authorizations copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -14729,37 +19096,42 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TLaccount_Password -@implementation TLInputPrivacyKey @end - -@implementation TL_inputPrivacyKeyStatusTimestamp -+(TL_inputPrivacyKeyStatusTimestamp*)create { - TL_inputPrivacyKeyStatusTimestamp* obj = [[TL_inputPrivacyKeyStatusTimestamp alloc] init]; - + +@implementation TL_account_noPassword ++(TL_account_noPassword*)createWithN_salt:(NSData*)n_salt email_unconfirmed_pattern:(NSString*)email_unconfirmed_pattern { + TL_account_noPassword* obj = [[TL_account_noPassword alloc] init]; + obj.n_salt = n_salt; + obj.email_unconfirmed_pattern = email_unconfirmed_pattern; return obj; } -(void)serialize:(SerializedData*)stream { - + [stream writeByteArray:self.n_salt]; + [stream writeString:self.email_unconfirmed_pattern]; } -(void)unserialize:(SerializedData*)stream { - + super.n_salt = [stream readByteArray]; + super.email_unconfirmed_pattern = [stream readString]; } --(TL_inputPrivacyKeyStatusTimestamp *)copy { - - TL_inputPrivacyKeyStatusTimestamp *objc = [[TL_inputPrivacyKeyStatusTimestamp alloc] init]; +-(TL_account_noPassword *)copy { + TL_account_noPassword *objc = [[TL_account_noPassword alloc] init]; + objc.n_salt = [self.n_salt copy]; + objc.email_unconfirmed_pattern = self.email_unconfirmed_pattern; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -14773,37 +19145,50 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLPrivacyKey -@end - -@implementation TL_privacyKeyStatusTimestamp -+(TL_privacyKeyStatusTimestamp*)create { - TL_privacyKeyStatusTimestamp* obj = [[TL_privacyKeyStatusTimestamp alloc] init]; - +@implementation TL_account_password ++(TL_account_password*)createWithCurrent_salt:(NSData*)current_salt n_salt:(NSData*)n_salt hint:(NSString*)hint has_recovery:(Boolean)has_recovery email_unconfirmed_pattern:(NSString*)email_unconfirmed_pattern { + TL_account_password* obj = [[TL_account_password alloc] init]; + obj.current_salt = current_salt; + obj.n_salt = n_salt; + obj.hint = hint; + obj.has_recovery = has_recovery; + obj.email_unconfirmed_pattern = email_unconfirmed_pattern; return obj; } -(void)serialize:(SerializedData*)stream { - + [stream writeByteArray:self.current_salt]; + [stream writeByteArray:self.n_salt]; + [stream writeString:self.hint]; + [stream writeBool:self.has_recovery]; + [stream writeString:self.email_unconfirmed_pattern]; } -(void)unserialize:(SerializedData*)stream { - + super.current_salt = [stream readByteArray]; + super.n_salt = [stream readByteArray]; + super.hint = [stream readString]; + super.has_recovery = [stream readBool]; + super.email_unconfirmed_pattern = [stream readString]; } --(TL_privacyKeyStatusTimestamp *)copy { - - TL_privacyKeyStatusTimestamp *objc = [[TL_privacyKeyStatusTimestamp alloc] init]; +-(TL_account_password *)copy { + TL_account_password *objc = [[TL_account_password alloc] init]; + objc.current_salt = [self.current_salt copy]; + objc.n_salt = [self.n_salt copy]; + objc.hint = self.hint; + objc.has_recovery = self.has_recovery; + objc.email_unconfirmed_pattern = self.email_unconfirmed_pattern; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -14817,37 +19202,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TLaccount_PasswordSettings -@implementation TLInputPrivacyRule @end - -@implementation TL_inputPrivacyValueAllowContacts -+(TL_inputPrivacyValueAllowContacts*)create { - TL_inputPrivacyValueAllowContacts* obj = [[TL_inputPrivacyValueAllowContacts alloc] init]; - + +@implementation TL_account_passwordSettings ++(TL_account_passwordSettings*)createWithEmail:(NSString*)email { + TL_account_passwordSettings* obj = [[TL_account_passwordSettings alloc] init]; + obj.email = email; return obj; } -(void)serialize:(SerializedData*)stream { - + [stream writeString:self.email]; } -(void)unserialize:(SerializedData*)stream { - + super.email = [stream readString]; } --(TL_inputPrivacyValueAllowContacts *)copy { - - TL_inputPrivacyValueAllowContacts *objc = [[TL_inputPrivacyValueAllowContacts alloc] init]; +-(TL_account_passwordSettings *)copy { + TL_account_passwordSettings *objc = [[TL_account_passwordSettings alloc] init]; + objc.email = self.email; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -14861,33 +19247,54 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_inputPrivacyValueAllowAll -+(TL_inputPrivacyValueAllowAll*)create { - TL_inputPrivacyValueAllowAll* obj = [[TL_inputPrivacyValueAllowAll alloc] init]; - +@implementation TLaccount_PasswordInputSettings + +@end + +@implementation TL_account_passwordInputSettings ++(TL_account_passwordInputSettings*)createWithFlags:(int)flags n_salt:(NSData*)n_salt n_password_hash:(NSData*)n_password_hash hint:(NSString*)hint email:(NSString*)email { + TL_account_passwordInputSettings* obj = [[TL_account_passwordInputSettings alloc] init]; + obj.flags = flags; + obj.n_salt = n_salt; + obj.n_password_hash = n_password_hash; + obj.hint = hint; + obj.email = email; return obj; } -(void)serialize:(SerializedData*)stream { - + [stream writeInt:self.flags]; + if(self.flags & (1 << 0)) {[stream writeByteArray:self.n_salt];} + if(self.flags & (1 << 0)) {[stream writeByteArray:self.n_password_hash];} + if(self.flags & (1 << 0)) {[stream writeString:self.hint];} + if(self.flags & (1 << 1)) {[stream writeString:self.email];} } -(void)unserialize:(SerializedData*)stream { - + super.flags = [stream readInt]; + if(self.flags & (1 << 0)) {super.n_salt = [stream readByteArray];} + if(self.flags & (1 << 0)) {super.n_password_hash = [stream readByteArray];} + if(self.flags & (1 << 0)) {super.hint = [stream readString];} + if(self.flags & (1 << 1)) {super.email = [stream readString];} } --(TL_inputPrivacyValueAllowAll *)copy { - - TL_inputPrivacyValueAllowAll *objc = [[TL_inputPrivacyValueAllowAll alloc] init]; +-(TL_account_passwordInputSettings *)copy { + TL_account_passwordInputSettings *objc = [[TL_account_passwordInputSettings alloc] init]; + objc.flags = self.flags; + objc.n_salt = [self.n_salt copy]; + objc.n_password_hash = [self.n_password_hash copy]; + objc.hint = self.hint; + objc.email = self.email; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -14901,55 +19308,62 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - - + +-(void)setN_salt:(NSData*)n_salt +{ + super.n_salt = n_salt; + + if(super.n_salt == nil) { super.flags&= ~ (1 << 0) ;} else { super.flags|= (1 << 0); } +} +-(void)setN_password_hash:(NSData*)n_password_hash +{ + super.n_password_hash = n_password_hash; + + if(super.n_password_hash == nil) { super.flags&= ~ (1 << 0) ;} else { super.flags|= (1 << 0); } +} +-(void)setHint:(NSString*)hint +{ + super.hint = hint; + + if(super.hint == nil) { super.flags&= ~ (1 << 0) ;} else { super.flags|= (1 << 0); } +} +-(void)setEmail:(NSString*)email +{ + super.email = email; + + if(super.email == nil) { super.flags&= ~ (1 << 1) ;} else { super.flags|= (1 << 1); } +} @end -@implementation TL_inputPrivacyValueAllowUsers -+(TL_inputPrivacyValueAllowUsers*)createWithUsers:(NSMutableArray*)users { - TL_inputPrivacyValueAllowUsers* obj = [[TL_inputPrivacyValueAllowUsers alloc] init]; - obj.users = users; +@implementation TLauth_PasswordRecovery + +@end + +@implementation TL_auth_passwordRecovery ++(TL_auth_passwordRecovery*)createWithEmail_pattern:(NSString*)email_pattern { + TL_auth_passwordRecovery* obj = [[TL_auth_passwordRecovery alloc] init]; + obj.email_pattern = email_pattern; return obj; } -(void)serialize:(SerializedData*)stream { - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.users count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLInputUser* obj = [self.users objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } + [stream writeString:self.email_pattern]; } -(void)unserialize:(SerializedData*)stream { - //UNS FullVector - [stream readInt]; - { - if(!self.users) - self.users = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLInputUser* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLInputUser class]]) - [self.users addObject:obj]; - else - break; - } - } + super.email_pattern = [stream readString]; } --(TL_inputPrivacyValueAllowUsers *)copy { +-(TL_auth_passwordRecovery *)copy { - TL_inputPrivacyValueAllowUsers *objc = [[TL_inputPrivacyValueAllowUsers alloc] init]; + TL_auth_passwordRecovery *objc = [[TL_auth_passwordRecovery alloc] init]; - objc.users = [self.users copy]; + objc.email_pattern = self.email_pattern; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -14963,33 +19377,42 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_inputPrivacyValueDisallowContacts -+(TL_inputPrivacyValueDisallowContacts*)create { - TL_inputPrivacyValueDisallowContacts* obj = [[TL_inputPrivacyValueDisallowContacts alloc] init]; - +@implementation TLReceivedNotifyMessage + +@end + +@implementation TL_receivedNotifyMessage ++(TL_receivedNotifyMessage*)createWithN_id:(int)n_id flags:(int)flags { + TL_receivedNotifyMessage* obj = [[TL_receivedNotifyMessage alloc] init]; + obj.n_id = n_id; + obj.flags = flags; return obj; } -(void)serialize:(SerializedData*)stream { - + [stream writeInt:self.n_id]; + [stream writeInt:self.flags]; } -(void)unserialize:(SerializedData*)stream { - + super.n_id = [stream readInt]; + super.flags = [stream readInt]; } --(TL_inputPrivacyValueDisallowContacts *)copy { - - TL_inputPrivacyValueDisallowContacts *objc = [[TL_inputPrivacyValueDisallowContacts alloc] init]; +-(TL_receivedNotifyMessage *)copy { + TL_receivedNotifyMessage *objc = [[TL_receivedNotifyMessage alloc] init]; + objc.n_id = self.n_id; + objc.flags = self.flags; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -15003,15 +19426,18 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_inputPrivacyValueDisallowAll -+(TL_inputPrivacyValueDisallowAll*)create { - TL_inputPrivacyValueDisallowAll* obj = [[TL_inputPrivacyValueDisallowAll alloc] init]; +@implementation TLExportedChatInvite + +@end + +@implementation TL_chatInviteEmpty ++(TL_chatInviteEmpty*)create { + TL_chatInviteEmpty* obj = [[TL_chatInviteEmpty alloc] init]; return obj; } @@ -15022,14 +19448,16 @@ -(void)unserialize:(SerializedData*)stream { } --(TL_inputPrivacyValueDisallowAll *)copy { +-(TL_chatInviteEmpty *)copy { - TL_inputPrivacyValueDisallowAll *objc = [[TL_inputPrivacyValueDisallowAll alloc] init]; + TL_chatInviteEmpty *objc = [[TL_chatInviteEmpty alloc] init]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -15043,55 +19471,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_inputPrivacyValueDisallowUsers -+(TL_inputPrivacyValueDisallowUsers*)createWithUsers:(NSMutableArray*)users { - TL_inputPrivacyValueDisallowUsers* obj = [[TL_inputPrivacyValueDisallowUsers alloc] init]; - obj.users = users; +@implementation TL_chatInviteExported ++(TL_chatInviteExported*)createWithLink:(NSString*)link { + TL_chatInviteExported* obj = [[TL_chatInviteExported alloc] init]; + obj.link = link; return obj; } -(void)serialize:(SerializedData*)stream { - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.users count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLInputUser* obj = [self.users objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } + [stream writeString:self.link]; } -(void)unserialize:(SerializedData*)stream { - //UNS FullVector - [stream readInt]; - { - if(!self.users) - self.users = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLInputUser* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLInputUser class]]) - [self.users addObject:obj]; - else - break; - } - } + super.link = [stream readString]; } --(TL_inputPrivacyValueDisallowUsers *)copy { +-(TL_chatInviteExported *)copy { - TL_inputPrivacyValueDisallowUsers *objc = [[TL_inputPrivacyValueDisallowUsers alloc] init]; + TL_chatInviteExported *objc = [[TL_chatInviteExported alloc] init]; - objc.users = [self.users copy]; + objc.link = self.link; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -15105,37 +19512,46 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLPrivacyRule +@implementation TLChatInvite + +-(BOOL)isChannel {return NO;} + +-(BOOL)isBroadcast {return NO;} + +-(BOOL)isPublic {return NO;} + +-(BOOL)isMegagroup {return NO;} + @end - -@implementation TL_privacyValueAllowContacts -+(TL_privacyValueAllowContacts*)create { - TL_privacyValueAllowContacts* obj = [[TL_privacyValueAllowContacts alloc] init]; - + +@implementation TL_chatInviteAlready ++(TL_chatInviteAlready*)createWithChat:(TLChat*)chat { + TL_chatInviteAlready* obj = [[TL_chatInviteAlready alloc] init]; + obj.chat = chat; return obj; } -(void)serialize:(SerializedData*)stream { - + [ClassStore TLSerialize:self.chat stream:stream]; } -(void)unserialize:(SerializedData*)stream { - + self.chat = [ClassStore TLDeserialize:stream]; } --(TL_privacyValueAllowContacts *)copy { - - TL_privacyValueAllowContacts *objc = [[TL_privacyValueAllowContacts alloc] init]; +-(TL_chatInviteAlready *)copy { + TL_chatInviteAlready *objc = [[TL_chatInviteAlready alloc] init]; + objc.chat = [self.chat copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -15149,33 +19565,54 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_privacyValueAllowAll -+(TL_privacyValueAllowAll*)create { - TL_privacyValueAllowAll* obj = [[TL_privacyValueAllowAll alloc] init]; +@implementation TL_chatInvite ++(TL_chatInvite*)createWithFlags:(int)flags title:(NSString*)title { + TL_chatInvite* obj = [[TL_chatInvite alloc] init]; + obj.flags = flags; + + + + obj.title = title; return obj; } -(void)serialize:(SerializedData*)stream { + [stream writeInt:self.flags]; + + + + [stream writeString:self.title]; } -(void)unserialize:(SerializedData*)stream { + super.flags = [stream readInt]; + + + + super.title = [stream readString]; } --(TL_privacyValueAllowAll *)copy { +-(TL_chatInvite *)copy { + + TL_chatInvite *objc = [[TL_chatInvite alloc] init]; + + objc.flags = self.flags; + - TL_privacyValueAllowAll *objc = [[TL_privacyValueAllowAll alloc] init]; + objc.title = self.title; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -15189,55 +19626,46 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - - + +-(BOOL)isChannel {return (self.flags & (1 << 0)) > 0;} + +-(BOOL)isBroadcast {return (self.flags & (1 << 1)) > 0;} + +-(BOOL)isPublic {return (self.flags & (1 << 2)) > 0;} + +-(BOOL)isMegagroup {return (self.flags & (1 << 3)) > 0;} + @end -@implementation TL_privacyValueAllowUsers -+(TL_privacyValueAllowUsers*)createWithUsers:(NSMutableArray*)users { - TL_privacyValueAllowUsers* obj = [[TL_privacyValueAllowUsers alloc] init]; - obj.users = users; +@implementation TLInputStickerSet + +@end + +@implementation TL_inputStickerSetEmpty ++(TL_inputStickerSetEmpty*)create { + TL_inputStickerSetEmpty* obj = [[TL_inputStickerSetEmpty alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - //Serialize ShortVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.users count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - if([self.users count] > i) { - NSNumber* obj = [self.users objectAtIndex:i]; - [stream writeInt:[obj intValue]]; - } else - break; - } - } + } -(void)unserialize:(SerializedData*)stream { - //UNS ShortVector - [stream readInt]; - { - if(!self.users) - self.users = [[NSMutableArray alloc] init]; - int tl_count = [stream readInt]; - for(int i = 0; i < tl_count; i++) { - int obj = [stream readInt]; - [self.users addObject:@(obj)]; - } - } + } --(TL_privacyValueAllowUsers *)copy { +-(TL_inputStickerSetEmpty *)copy { + + TL_inputStickerSetEmpty *objc = [[TL_inputStickerSetEmpty alloc] init]; - TL_privacyValueAllowUsers *objc = [[TL_privacyValueAllowUsers alloc] init]; - objc.users = [self.users copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -15251,33 +19679,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_privacyValueDisallowContacts -+(TL_privacyValueDisallowContacts*)create { - TL_privacyValueDisallowContacts* obj = [[TL_privacyValueDisallowContacts alloc] init]; - +@implementation TL_inputStickerSetID ++(TL_inputStickerSetID*)createWithN_id:(long)n_id access_hash:(long)access_hash { + TL_inputStickerSetID* obj = [[TL_inputStickerSetID alloc] init]; + obj.n_id = n_id; + obj.access_hash = access_hash; return obj; } -(void)serialize:(SerializedData*)stream { - + [stream writeLong:self.n_id]; + [stream writeLong:self.access_hash]; } -(void)unserialize:(SerializedData*)stream { - + super.n_id = [stream readLong]; + super.access_hash = [stream readLong]; } --(TL_privacyValueDisallowContacts *)copy { - - TL_privacyValueDisallowContacts *objc = [[TL_privacyValueDisallowContacts alloc] init]; +-(TL_inputStickerSetID *)copy { + TL_inputStickerSetID *objc = [[TL_inputStickerSetID alloc] init]; + objc.n_id = self.n_id; + objc.access_hash = self.access_hash; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -15291,33 +19724,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_privacyValueDisallowAll -+(TL_privacyValueDisallowAll*)create { - TL_privacyValueDisallowAll* obj = [[TL_privacyValueDisallowAll alloc] init]; - +@implementation TL_inputStickerSetShortName ++(TL_inputStickerSetShortName*)createWithShort_name:(NSString*)short_name { + TL_inputStickerSetShortName* obj = [[TL_inputStickerSetShortName alloc] init]; + obj.short_name = short_name; return obj; } -(void)serialize:(SerializedData*)stream { - + [stream writeString:self.short_name]; } -(void)unserialize:(SerializedData*)stream { - + super.short_name = [stream readString]; } --(TL_privacyValueDisallowAll *)copy { - - TL_privacyValueDisallowAll *objc = [[TL_privacyValueDisallowAll alloc] init]; +-(TL_inputStickerSetShortName *)copy { + TL_inputStickerSetShortName *objc = [[TL_inputStickerSetShortName alloc] init]; + objc.short_name = self.short_name; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -15331,55 +19765,80 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_privacyValueDisallowUsers -+(TL_privacyValueDisallowUsers*)createWithUsers:(NSMutableArray*)users { - TL_privacyValueDisallowUsers* obj = [[TL_privacyValueDisallowUsers alloc] init]; - obj.users = users; +@implementation TLStickerSet + +-(BOOL)isInstalled {return NO;} + +-(BOOL)isDisabled {return NO;} + +-(BOOL)isOfficial {return NO;} + +@end + +@implementation TL_stickerSet ++(TL_stickerSet*)createWithFlags:(int)flags n_id:(long)n_id access_hash:(long)access_hash title:(NSString*)title short_name:(NSString*)short_name n_count:(int)n_count n_hash:(int)n_hash { + TL_stickerSet* obj = [[TL_stickerSet alloc] init]; + obj.flags = flags; + + + + obj.n_id = n_id; + obj.access_hash = access_hash; + obj.title = title; + obj.short_name = short_name; + obj.n_count = n_count; + obj.n_hash = n_hash; return obj; } -(void)serialize:(SerializedData*)stream { - //Serialize ShortVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.users count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - if([self.users count] > i) { - NSNumber* obj = [self.users objectAtIndex:i]; - [stream writeInt:[obj intValue]]; - } else - break; - } - } + [stream writeInt:self.flags]; + + + + [stream writeLong:self.n_id]; + [stream writeLong:self.access_hash]; + [stream writeString:self.title]; + [stream writeString:self.short_name]; + [stream writeInt:self.n_count]; + [stream writeInt:self.n_hash]; } -(void)unserialize:(SerializedData*)stream { - //UNS ShortVector - [stream readInt]; - { - if(!self.users) - self.users = [[NSMutableArray alloc] init]; - int tl_count = [stream readInt]; - for(int i = 0; i < tl_count; i++) { - int obj = [stream readInt]; - [self.users addObject:@(obj)]; - } - } + super.flags = [stream readInt]; + + + + super.n_id = [stream readLong]; + super.access_hash = [stream readLong]; + super.title = [stream readString]; + super.short_name = [stream readString]; + super.n_count = [stream readInt]; + super.n_hash = [stream readInt]; } --(TL_privacyValueDisallowUsers *)copy { +-(TL_stickerSet *)copy { - TL_privacyValueDisallowUsers *objc = [[TL_privacyValueDisallowUsers alloc] init]; + TL_stickerSet *objc = [[TL_stickerSet alloc] init]; - objc.users = [self.users copy]; + objc.flags = self.flags; + + + + objc.n_id = self.n_id; + objc.access_hash = self.access_hash; + objc.title = self.title; + objc.short_name = self.short_name; + objc.n_count = self.n_count; + objc.n_hash = self.n_hash; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -15393,56 +19852,64 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - - + +-(BOOL)isInstalled {return (self.flags & (1 << 0)) > 0;} + +-(BOOL)isDisabled {return (self.flags & (1 << 1)) > 0;} + +-(BOOL)isOfficial {return (self.flags & (1 << 2)) > 0;} + @end +@implementation TLmessages_StickerSet -@implementation TLaccount_PrivacyRules @end - -@implementation TL_account_privacyRules -+(TL_account_privacyRules*)createWithRules:(NSMutableArray*)rules users:(NSMutableArray*)users { - TL_account_privacyRules* obj = [[TL_account_privacyRules alloc] init]; - obj.rules = rules; - obj.users = users; + +@implementation TL_messages_stickerSet ++(TL_messages_stickerSet*)createWithSet:(TLStickerSet*)set packs:(NSMutableArray*)packs documents:(NSMutableArray*)documents { + TL_messages_stickerSet* obj = [[TL_messages_stickerSet alloc] init]; + obj.set = set; + obj.packs = packs; + obj.documents = documents; return obj; } -(void)serialize:(SerializedData*)stream { + [ClassStore TLSerialize:self.set stream:stream]; //Serialize FullVector [stream writeInt:0x1cb5c415]; { - NSInteger tl_count = [self.rules count]; + NSInteger tl_count = [self.packs count]; [stream writeInt:(int)tl_count]; for(int i = 0; i < (int)tl_count; i++) { - TLPrivacyRule* obj = [self.rules objectAtIndex:i]; + TLStickerPack* obj = [self.packs objectAtIndex:i]; [ClassStore TLSerialize:obj stream:stream]; } } //Serialize FullVector [stream writeInt:0x1cb5c415]; { - NSInteger tl_count = [self.users count]; + NSInteger tl_count = [self.documents count]; [stream writeInt:(int)tl_count]; for(int i = 0; i < (int)tl_count; i++) { - TLUser* obj = [self.users objectAtIndex:i]; + TLDocument* obj = [self.documents objectAtIndex:i]; [ClassStore TLSerialize:obj stream:stream]; } } } -(void)unserialize:(SerializedData*)stream { + self.set = [ClassStore TLDeserialize:stream]; //UNS FullVector [stream readInt]; { - if(!self.rules) - self.rules = [[NSMutableArray alloc] init]; + if(!self.packs) + self.packs = [[NSMutableArray alloc] init]; int count = [stream readInt]; for(int i = 0; i < count; i++) { - TLPrivacyRule* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLPrivacyRule class]]) - [self.rules addObject:obj]; + TLStickerPack* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLStickerPack class]]) + [self.packs addObject:obj]; else break; } @@ -15450,28 +19917,31 @@ -(void)unserialize:(SerializedData*)stream { //UNS FullVector [stream readInt]; { - if(!self.users) - self.users = [[NSMutableArray alloc] init]; + if(!self.documents) + self.documents = [[NSMutableArray alloc] init]; int count = [stream readInt]; for(int i = 0; i < count; i++) { - TLUser* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLUser class]]) - [self.users addObject:obj]; + TLDocument* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLDocument class]]) + [self.documents addObject:obj]; else break; } } } --(TL_account_privacyRules *)copy { +-(TL_messages_stickerSet *)copy { - TL_account_privacyRules *objc = [[TL_account_privacyRules alloc] init]; + TL_messages_stickerSet *objc = [[TL_messages_stickerSet alloc] init]; - objc.rules = [self.rules copy]; - objc.users = [self.users copy]; + objc.set = [self.set copy]; + objc.packs = [self.packs copy]; + objc.documents = [self.documents copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -15485,37 +19955,42 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TLBotCommand -@implementation TLAccountDaysTTL @end - -@implementation TL_accountDaysTTL -+(TL_accountDaysTTL*)createWithDays:(int)days { - TL_accountDaysTTL* obj = [[TL_accountDaysTTL alloc] init]; - obj.days = days; + +@implementation TL_botCommand ++(TL_botCommand*)createWithCommand:(NSString*)command n_description:(NSString*)n_description { + TL_botCommand* obj = [[TL_botCommand alloc] init]; + obj.command = command; + obj.n_description = n_description; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.days]; + [stream writeString:self.command]; + [stream writeString:self.n_description]; } -(void)unserialize:(SerializedData*)stream { - self.days = [stream readInt]; + super.command = [stream readString]; + super.n_description = [stream readString]; } --(TL_accountDaysTTL *)copy { +-(TL_botCommand *)copy { - TL_accountDaysTTL *objc = [[TL_accountDaysTTL alloc] init]; + TL_botCommand *objc = [[TL_botCommand alloc] init]; - objc.days = self.days; + objc.command = self.command; + objc.n_description = self.n_description; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -15529,41 +20004,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TLBotInfo -@implementation TLaccount_SentChangePhoneCode @end - -@implementation TL_account_sentChangePhoneCode -+(TL_account_sentChangePhoneCode*)createWithPhone_code_hash:(NSString*)phone_code_hash send_call_timeout:(int)send_call_timeout { - TL_account_sentChangePhoneCode* obj = [[TL_account_sentChangePhoneCode alloc] init]; - obj.phone_code_hash = phone_code_hash; - obj.send_call_timeout = send_call_timeout; + +@implementation TL_botInfoEmpty ++(TL_botInfoEmpty*)create { + TL_botInfoEmpty* obj = [[TL_botInfoEmpty alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeString:self.phone_code_hash]; - [stream writeInt:self.send_call_timeout]; + } -(void)unserialize:(SerializedData*)stream { - self.phone_code_hash = [stream readString]; - self.send_call_timeout = [stream readInt]; + } --(TL_account_sentChangePhoneCode *)copy { +-(TL_botInfoEmpty *)copy { + + TL_botInfoEmpty *objc = [[TL_botInfoEmpty alloc] init]; - TL_account_sentChangePhoneCode *objc = [[TL_account_sentChangePhoneCode alloc] init]; - objc.phone_code_hash = self.phone_code_hash; - objc.send_call_timeout = self.send_call_timeout; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -15577,41 +20049,72 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLDocumentAttribute -@end - -@implementation TL_documentAttributeImageSize -+(TL_documentAttributeImageSize*)createWithW:(int)w h:(int)h { - TL_documentAttributeImageSize* obj = [[TL_documentAttributeImageSize alloc] init]; - obj.w = w; - obj.h = h; +@implementation TL_botInfo ++(TL_botInfo*)createWithUser_id:(int)user_id version:(int)version share_text:(NSString*)share_text n_description:(NSString*)n_description commands:(NSMutableArray*)commands { + TL_botInfo* obj = [[TL_botInfo alloc] init]; + obj.user_id = user_id; + obj.version = version; + obj.share_text = share_text; + obj.n_description = n_description; + obj.commands = commands; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.w]; - [stream writeInt:self.h]; + [stream writeInt:self.user_id]; + [stream writeInt:self.version]; + [stream writeString:self.share_text]; + [stream writeString:self.n_description]; + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.commands count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLBotCommand* obj = [self.commands objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } } -(void)unserialize:(SerializedData*)stream { - self.w = [stream readInt]; - self.h = [stream readInt]; + super.user_id = [stream readInt]; + super.version = [stream readInt]; + super.share_text = [stream readString]; + super.n_description = [stream readString]; + //UNS FullVector + [stream readInt]; + { + if(!self.commands) + self.commands = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLBotCommand* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLBotCommand class]]) + [self.commands addObject:obj]; + else + break; + } + } } --(TL_documentAttributeImageSize *)copy { +-(TL_botInfo *)copy { - TL_documentAttributeImageSize *objc = [[TL_documentAttributeImageSize alloc] init]; + TL_botInfo *objc = [[TL_botInfo alloc] init]; - objc.w = self.w; - objc.h = self.h; + objc.user_id = self.user_id; + objc.version = self.version; + objc.share_text = self.share_text; + objc.n_description = self.n_description; + objc.commands = [self.commands copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -15625,33 +20128,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_documentAttributeAnimated -+(TL_documentAttributeAnimated*)create { - TL_documentAttributeAnimated* obj = [[TL_documentAttributeAnimated alloc] init]; - +@implementation TLKeyboardButton + +@end + +@implementation TL_keyboardButton ++(TL_keyboardButton*)createWithText:(NSString*)text { + TL_keyboardButton* obj = [[TL_keyboardButton alloc] init]; + obj.text = text; return obj; } -(void)serialize:(SerializedData*)stream { - + [stream writeString:self.text]; } -(void)unserialize:(SerializedData*)stream { - + super.text = [stream readString]; } --(TL_documentAttributeAnimated *)copy { - - TL_documentAttributeAnimated *objc = [[TL_documentAttributeAnimated alloc] init]; +-(TL_keyboardButton *)copy { + TL_keyboardButton *objc = [[TL_keyboardButton alloc] init]; + objc.text = self.text; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -15665,37 +20173,60 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_documentAttributeSticker -+(TL_documentAttributeSticker*)createWithAlt:(NSString*)alt stickerset:(TLInputStickerSet*)stickerset { - TL_documentAttributeSticker* obj = [[TL_documentAttributeSticker alloc] init]; - obj.alt = alt; - obj.stickerset = stickerset; +@implementation TLKeyboardButtonRow + +@end + +@implementation TL_keyboardButtonRow ++(TL_keyboardButtonRow*)createWithButtons:(NSMutableArray*)buttons { + TL_keyboardButtonRow* obj = [[TL_keyboardButtonRow alloc] init]; + obj.buttons = buttons; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeString:self.alt]; - [ClassStore TLSerialize:self.stickerset stream:stream]; + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.buttons count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLKeyboardButton* obj = [self.buttons objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } } -(void)unserialize:(SerializedData*)stream { - self.alt = [stream readString]; - self.stickerset = [ClassStore TLDeserialize:stream]; + //UNS FullVector + [stream readInt]; + { + if(!self.buttons) + self.buttons = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLKeyboardButton* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLKeyboardButton class]]) + [self.buttons addObject:obj]; + else + break; + } + } } --(TL_documentAttributeSticker *)copy { +-(TL_keyboardButtonRow *)copy { - TL_documentAttributeSticker *objc = [[TL_documentAttributeSticker alloc] init]; + TL_keyboardButtonRow *objc = [[TL_keyboardButtonRow alloc] init]; - objc.alt = self.alt; - objc.stickerset = [self.stickerset copy]; + objc.buttons = [self.buttons copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -15709,41 +20240,48 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_documentAttributeVideo -+(TL_documentAttributeVideo*)createWithDuration:(int)duration w:(int)w h:(int)h { - TL_documentAttributeVideo* obj = [[TL_documentAttributeVideo alloc] init]; - obj.duration = duration; - obj.w = w; - obj.h = h; +@implementation TLReplyMarkup + +-(BOOL)isSelective {return NO;} + +-(BOOL)isSingle_use {return NO;} + +-(BOOL)isResize {return NO;} + +@end + +@implementation TL_replyKeyboardHide ++(TL_replyKeyboardHide*)createWithFlags:(int)flags { + TL_replyKeyboardHide* obj = [[TL_replyKeyboardHide alloc] init]; + obj.flags = flags; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.duration]; - [stream writeInt:self.w]; - [stream writeInt:self.h]; + [stream writeInt:self.flags]; + } -(void)unserialize:(SerializedData*)stream { - self.duration = [stream readInt]; - self.w = [stream readInt]; - self.h = [stream readInt]; + super.flags = [stream readInt]; + } --(TL_documentAttributeVideo *)copy { +-(TL_replyKeyboardHide *)copy { - TL_documentAttributeVideo *objc = [[TL_documentAttributeVideo alloc] init]; + TL_replyKeyboardHide *objc = [[TL_replyKeyboardHide alloc] init]; + + objc.flags = self.flags; - objc.duration = self.duration; - objc.w = self.w; - objc.h = self.h; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -15757,41 +20295,44 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - - + +-(BOOL)isSelective {return (self.flags & (1 << 2)) > 0;} + @end -@implementation TL_documentAttributeAudio -+(TL_documentAttributeAudio*)createWithDuration:(int)duration title:(NSString*)title performer:(NSString*)performer { - TL_documentAttributeAudio* obj = [[TL_documentAttributeAudio alloc] init]; - obj.duration = duration; - obj.title = title; - obj.performer = performer; +@implementation TL_replyKeyboardForceReply ++(TL_replyKeyboardForceReply*)createWithFlags:(int)flags { + TL_replyKeyboardForceReply* obj = [[TL_replyKeyboardForceReply alloc] init]; + obj.flags = flags; + + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.duration]; - [stream writeString:self.title]; - [stream writeString:self.performer]; + [stream writeInt:self.flags]; + + } -(void)unserialize:(SerializedData*)stream { - self.duration = [stream readInt]; - self.title = [stream readString]; - self.performer = [stream readString]; + super.flags = [stream readInt]; + + } --(TL_documentAttributeAudio *)copy { +-(TL_replyKeyboardForceReply *)copy { + + TL_replyKeyboardForceReply *objc = [[TL_replyKeyboardForceReply alloc] init]; + + objc.flags = self.flags; - TL_documentAttributeAudio *objc = [[TL_documentAttributeAudio alloc] init]; - objc.duration = self.duration; - objc.title = self.title; - objc.performer = self.performer; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -15805,33 +20346,76 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - - + +-(BOOL)isSingle_use {return (self.flags & (1 << 1)) > 0;} + +-(BOOL)isSelective {return (self.flags & (1 << 2)) > 0;} + @end -@implementation TL_documentAttributeFilename -+(TL_documentAttributeFilename*)createWithFile_name:(NSString*)file_name { - TL_documentAttributeFilename* obj = [[TL_documentAttributeFilename alloc] init]; - obj.file_name = file_name; +@implementation TL_replyKeyboardMarkup ++(TL_replyKeyboardMarkup*)createWithFlags:(int)flags rows:(NSMutableArray*)rows { + TL_replyKeyboardMarkup* obj = [[TL_replyKeyboardMarkup alloc] init]; + obj.flags = flags; + + + + obj.rows = rows; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeString:self.file_name]; + [stream writeInt:self.flags]; + + + + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.rows count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLKeyboardButtonRow* obj = [self.rows objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } } -(void)unserialize:(SerializedData*)stream { - self.file_name = [stream readString]; + super.flags = [stream readInt]; + + + + //UNS FullVector + [stream readInt]; + { + if(!self.rows) + self.rows = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLKeyboardButtonRow* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLKeyboardButtonRow class]]) + [self.rows addObject:obj]; + else + break; + } + } } --(TL_documentAttributeFilename *)copy { +-(TL_replyKeyboardMarkup *)copy { - TL_documentAttributeFilename *objc = [[TL_documentAttributeFilename alloc] init]; + TL_replyKeyboardMarkup *objc = [[TL_replyKeyboardMarkup alloc] init]; - objc.file_name = self.file_name; + objc.flags = self.flags; + + + + objc.rows = [self.rows copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -15845,33 +20429,44 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - - + +-(BOOL)isResize {return (self.flags & (1 << 0)) > 0;} + +-(BOOL)isSingle_use {return (self.flags & (1 << 1)) > 0;} + +-(BOOL)isSelective {return (self.flags & (1 << 2)) > 0;} + @end -@implementation TL_documentAttributeAudio_old31 -+(TL_documentAttributeAudio_old31*)createWithDuration:(int)duration { - TL_documentAttributeAudio_old31* obj = [[TL_documentAttributeAudio_old31 alloc] init]; - obj.duration = duration; +@implementation TLhelp_AppChangelog + +@end + +@implementation TL_help_appChangelogEmpty ++(TL_help_appChangelogEmpty*)create { + TL_help_appChangelogEmpty* obj = [[TL_help_appChangelogEmpty alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.duration]; + } -(void)unserialize:(SerializedData*)stream { - self.duration = [stream readInt]; + } --(TL_documentAttributeAudio_old31 *)copy { +-(TL_help_appChangelogEmpty *)copy { + + TL_help_appChangelogEmpty *objc = [[TL_help_appChangelogEmpty alloc] init]; - TL_documentAttributeAudio_old31 *objc = [[TL_documentAttributeAudio_old31 alloc] init]; - objc.duration = self.duration; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -15885,37 +20480,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLmessages_Stickers -@end - -@implementation TL_messages_stickersNotModified -+(TL_messages_stickersNotModified*)create { - TL_messages_stickersNotModified* obj = [[TL_messages_stickersNotModified alloc] init]; - +@implementation TL_help_appChangelog ++(TL_help_appChangelog*)createWithText:(NSString*)text { + TL_help_appChangelog* obj = [[TL_help_appChangelog alloc] init]; + obj.text = text; return obj; } -(void)serialize:(SerializedData*)stream { - + [stream writeString:self.text]; } -(void)unserialize:(SerializedData*)stream { - + super.text = [stream readString]; } --(TL_messages_stickersNotModified *)copy { - - TL_messages_stickersNotModified *objc = [[TL_messages_stickersNotModified alloc] init]; +-(TL_help_appChangelog *)copy { + TL_help_appChangelog *objc = [[TL_help_appChangelog alloc] init]; + objc.text = self.text; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -15929,59 +20521,42 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_messages_stickers -+(TL_messages_stickers*)createWithN_hash:(NSString*)n_hash stickers:(NSMutableArray*)stickers { - TL_messages_stickers* obj = [[TL_messages_stickers alloc] init]; - obj.n_hash = n_hash; - obj.stickers = stickers; +@implementation TLMessageEntity + +@end + +@implementation TL_messageEntityUnknown ++(TL_messageEntityUnknown*)createWithOffset:(int)offset length:(int)length { + TL_messageEntityUnknown* obj = [[TL_messageEntityUnknown alloc] init]; + obj.offset = offset; + obj.length = length; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeString:self.n_hash]; - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.stickers count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLDocument* obj = [self.stickers objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } + [stream writeInt:self.offset]; + [stream writeInt:self.length]; } -(void)unserialize:(SerializedData*)stream { - self.n_hash = [stream readString]; - //UNS FullVector - [stream readInt]; - { - if(!self.stickers) - self.stickers = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLDocument* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLDocument class]]) - [self.stickers addObject:obj]; - else - break; - } - } + super.offset = [stream readInt]; + super.length = [stream readInt]; } --(TL_messages_stickers *)copy { +-(TL_messageEntityUnknown *)copy { - TL_messages_stickers *objc = [[TL_messages_stickers alloc] init]; + TL_messageEntityUnknown *objc = [[TL_messageEntityUnknown alloc] init]; - objc.n_hash = self.n_hash; - objc.stickers = [self.stickers copy]; + objc.offset = self.offset; + objc.length = self.length; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -15995,63 +20570,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLStickerPack -@end - -@implementation TL_stickerPack -+(TL_stickerPack*)createWithEmoticon:(NSString*)emoticon documents:(NSMutableArray*)documents { - TL_stickerPack* obj = [[TL_stickerPack alloc] init]; - obj.emoticon = emoticon; - obj.documents = documents; +@implementation TL_messageEntityMention ++(TL_messageEntityMention*)createWithOffset:(int)offset length:(int)length { + TL_messageEntityMention* obj = [[TL_messageEntityMention alloc] init]; + obj.offset = offset; + obj.length = length; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeString:self.emoticon]; - //Serialize ShortVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.documents count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - if([self.documents count] > i) { - NSNumber* obj = [self.documents objectAtIndex:i]; - [stream writeLong:[obj longValue]]; - } else - break; - } - } + [stream writeInt:self.offset]; + [stream writeInt:self.length]; } -(void)unserialize:(SerializedData*)stream { - self.emoticon = [stream readString]; - //UNS ShortVector - [stream readInt]; - { - if(!self.documents) - self.documents = [[NSMutableArray alloc] init]; - int tl_count = [stream readInt]; - for(int i = 0; i < tl_count; i++) { - long obj = [stream readLong]; - [self.documents addObject:@(obj)]; - } - } + super.offset = [stream readInt]; + super.length = [stream readInt]; } --(TL_stickerPack *)copy { +-(TL_messageEntityMention *)copy { - TL_stickerPack *objc = [[TL_stickerPack alloc] init]; + TL_messageEntityMention *objc = [[TL_messageEntityMention alloc] init]; - objc.emoticon = self.emoticon; - objc.documents = [self.documents copy]; + objc.offset = self.offset; + objc.length = self.length; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -16065,37 +20615,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLmessages_AllStickers -@end - -@implementation TL_messages_allStickersNotModified -+(TL_messages_allStickersNotModified*)create { - TL_messages_allStickersNotModified* obj = [[TL_messages_allStickersNotModified alloc] init]; - +@implementation TL_messageEntityHashtag ++(TL_messageEntityHashtag*)createWithOffset:(int)offset length:(int)length { + TL_messageEntityHashtag* obj = [[TL_messageEntityHashtag alloc] init]; + obj.offset = offset; + obj.length = length; return obj; } -(void)serialize:(SerializedData*)stream { - + [stream writeInt:self.offset]; + [stream writeInt:self.length]; } -(void)unserialize:(SerializedData*)stream { - + super.offset = [stream readInt]; + super.length = [stream readInt]; } --(TL_messages_allStickersNotModified *)copy { - - TL_messages_allStickersNotModified *objc = [[TL_messages_allStickersNotModified alloc] init]; +-(TL_messageEntityHashtag *)copy { + TL_messageEntityHashtag *objc = [[TL_messageEntityHashtag alloc] init]; + objc.offset = self.offset; + objc.length = self.length; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -16109,59 +20660,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_messages_allStickers -+(TL_messages_allStickers*)createWithN_hash:(NSString*)n_hash sets:(NSMutableArray*)sets { - TL_messages_allStickers* obj = [[TL_messages_allStickers alloc] init]; - obj.n_hash = n_hash; - obj.sets = sets; +@implementation TL_messageEntityBotCommand ++(TL_messageEntityBotCommand*)createWithOffset:(int)offset length:(int)length { + TL_messageEntityBotCommand* obj = [[TL_messageEntityBotCommand alloc] init]; + obj.offset = offset; + obj.length = length; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeString:self.n_hash]; - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.sets count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLStickerSet* obj = [self.sets objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } + [stream writeInt:self.offset]; + [stream writeInt:self.length]; } -(void)unserialize:(SerializedData*)stream { - self.n_hash = [stream readString]; - //UNS FullVector - [stream readInt]; - { - if(!self.sets) - self.sets = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLStickerSet* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLStickerSet class]]) - [self.sets addObject:obj]; - else - break; - } - } + super.offset = [stream readInt]; + super.length = [stream readInt]; } --(TL_messages_allStickers *)copy { +-(TL_messageEntityBotCommand *)copy { - TL_messages_allStickers *objc = [[TL_messages_allStickers alloc] init]; + TL_messageEntityBotCommand *objc = [[TL_messageEntityBotCommand alloc] init]; - objc.n_hash = self.n_hash; - objc.sets = [self.sets copy]; + objc.offset = self.offset; + objc.length = self.length; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -16175,41 +20705,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLDisabledFeature -@end - -@implementation TL_disabledFeature -+(TL_disabledFeature*)createWithFeature:(NSString*)feature n_description:(NSString*)n_description { - TL_disabledFeature* obj = [[TL_disabledFeature alloc] init]; - obj.feature = feature; - obj.n_description = n_description; +@implementation TL_messageEntityUrl ++(TL_messageEntityUrl*)createWithOffset:(int)offset length:(int)length { + TL_messageEntityUrl* obj = [[TL_messageEntityUrl alloc] init]; + obj.offset = offset; + obj.length = length; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeString:self.feature]; - [stream writeString:self.n_description]; + [stream writeInt:self.offset]; + [stream writeInt:self.length]; } -(void)unserialize:(SerializedData*)stream { - self.feature = [stream readString]; - self.n_description = [stream readString]; + super.offset = [stream readInt]; + super.length = [stream readInt]; } --(TL_disabledFeature *)copy { +-(TL_messageEntityUrl *)copy { - TL_disabledFeature *objc = [[TL_disabledFeature alloc] init]; + TL_messageEntityUrl *objc = [[TL_messageEntityUrl alloc] init]; - objc.feature = self.feature; - objc.n_description = self.n_description; + objc.offset = self.offset; + objc.length = self.length; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -16223,41 +20750,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLmessages_AffectedMessages -@end - -@implementation TL_messages_affectedMessages -+(TL_messages_affectedMessages*)createWithPts:(int)pts pts_count:(int)pts_count { - TL_messages_affectedMessages* obj = [[TL_messages_affectedMessages alloc] init]; - obj.pts = pts; - obj.pts_count = pts_count; +@implementation TL_messageEntityEmail ++(TL_messageEntityEmail*)createWithOffset:(int)offset length:(int)length { + TL_messageEntityEmail* obj = [[TL_messageEntityEmail alloc] init]; + obj.offset = offset; + obj.length = length; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.pts]; - [stream writeInt:self.pts_count]; + [stream writeInt:self.offset]; + [stream writeInt:self.length]; } -(void)unserialize:(SerializedData*)stream { - self.pts = [stream readInt]; - self.pts_count = [stream readInt]; + super.offset = [stream readInt]; + super.length = [stream readInt]; } --(TL_messages_affectedMessages *)copy { +-(TL_messageEntityEmail *)copy { - TL_messages_affectedMessages *objc = [[TL_messages_affectedMessages alloc] init]; + TL_messageEntityEmail *objc = [[TL_messageEntityEmail alloc] init]; - objc.pts = self.pts; - objc.pts_count = self.pts_count; + objc.offset = self.offset; + objc.length = self.length; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -16271,37 +20795,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLContactLink -@end - -@implementation TL_contactLinkUnknown -+(TL_contactLinkUnknown*)create { - TL_contactLinkUnknown* obj = [[TL_contactLinkUnknown alloc] init]; - +@implementation TL_messageEntityBold ++(TL_messageEntityBold*)createWithOffset:(int)offset length:(int)length { + TL_messageEntityBold* obj = [[TL_messageEntityBold alloc] init]; + obj.offset = offset; + obj.length = length; return obj; } -(void)serialize:(SerializedData*)stream { - + [stream writeInt:self.offset]; + [stream writeInt:self.length]; } -(void)unserialize:(SerializedData*)stream { - + super.offset = [stream readInt]; + super.length = [stream readInt]; } --(TL_contactLinkUnknown *)copy { - - TL_contactLinkUnknown *objc = [[TL_contactLinkUnknown alloc] init]; +-(TL_messageEntityBold *)copy { + TL_messageEntityBold *objc = [[TL_messageEntityBold alloc] init]; + objc.offset = self.offset; + objc.length = self.length; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -16315,33 +20840,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_contactLinkNone -+(TL_contactLinkNone*)create { - TL_contactLinkNone* obj = [[TL_contactLinkNone alloc] init]; - +@implementation TL_messageEntityItalic ++(TL_messageEntityItalic*)createWithOffset:(int)offset length:(int)length { + TL_messageEntityItalic* obj = [[TL_messageEntityItalic alloc] init]; + obj.offset = offset; + obj.length = length; return obj; } -(void)serialize:(SerializedData*)stream { - + [stream writeInt:self.offset]; + [stream writeInt:self.length]; } -(void)unserialize:(SerializedData*)stream { - + super.offset = [stream readInt]; + super.length = [stream readInt]; } --(TL_contactLinkNone *)copy { - - TL_contactLinkNone *objc = [[TL_contactLinkNone alloc] init]; +-(TL_messageEntityItalic *)copy { + TL_messageEntityItalic *objc = [[TL_messageEntityItalic alloc] init]; + objc.offset = self.offset; + objc.length = self.length; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -16355,33 +20885,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_contactLinkHasPhone -+(TL_contactLinkHasPhone*)create { - TL_contactLinkHasPhone* obj = [[TL_contactLinkHasPhone alloc] init]; - +@implementation TL_messageEntityCode ++(TL_messageEntityCode*)createWithOffset:(int)offset length:(int)length { + TL_messageEntityCode* obj = [[TL_messageEntityCode alloc] init]; + obj.offset = offset; + obj.length = length; return obj; } -(void)serialize:(SerializedData*)stream { - + [stream writeInt:self.offset]; + [stream writeInt:self.length]; } -(void)unserialize:(SerializedData*)stream { - + super.offset = [stream readInt]; + super.length = [stream readInt]; } --(TL_contactLinkHasPhone *)copy { - - TL_contactLinkHasPhone *objc = [[TL_contactLinkHasPhone alloc] init]; +-(TL_messageEntityCode *)copy { + TL_messageEntityCode *objc = [[TL_messageEntityCode alloc] init]; + objc.offset = self.offset; + objc.length = self.length; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -16395,33 +20930,42 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_contactLinkContact -+(TL_contactLinkContact*)create { - TL_contactLinkContact* obj = [[TL_contactLinkContact alloc] init]; - +@implementation TL_messageEntityPre ++(TL_messageEntityPre*)createWithOffset:(int)offset length:(int)length language:(NSString*)language { + TL_messageEntityPre* obj = [[TL_messageEntityPre alloc] init]; + obj.offset = offset; + obj.length = length; + obj.language = language; return obj; } -(void)serialize:(SerializedData*)stream { - + [stream writeInt:self.offset]; + [stream writeInt:self.length]; + [stream writeString:self.language]; } -(void)unserialize:(SerializedData*)stream { - + super.offset = [stream readInt]; + super.length = [stream readInt]; + super.language = [stream readString]; } --(TL_contactLinkContact *)copy { - - TL_contactLinkContact *objc = [[TL_contactLinkContact alloc] init]; +-(TL_messageEntityPre *)copy { + TL_messageEntityPre *objc = [[TL_messageEntityPre alloc] init]; + objc.offset = self.offset; + objc.length = self.length; + objc.language = self.language; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -16435,37 +20979,42 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLWebPage -@end - -@implementation TL_webPageEmpty -+(TL_webPageEmpty*)createWithN_id:(long)n_id { - TL_webPageEmpty* obj = [[TL_webPageEmpty alloc] init]; - obj.n_id = n_id; +@implementation TL_messageEntityTextUrl ++(TL_messageEntityTextUrl*)createWithOffset:(int)offset length:(int)length url:(NSString*)url { + TL_messageEntityTextUrl* obj = [[TL_messageEntityTextUrl alloc] init]; + obj.offset = offset; + obj.length = length; + obj.url = url; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeLong:self.n_id]; + [stream writeInt:self.offset]; + [stream writeInt:self.length]; + [stream writeString:self.url]; } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readLong]; + super.offset = [stream readInt]; + super.length = [stream readInt]; + super.url = [stream readString]; } --(TL_webPageEmpty *)copy { +-(TL_messageEntityTextUrl *)copy { - TL_webPageEmpty *objc = [[TL_webPageEmpty alloc] init]; + TL_messageEntityTextUrl *objc = [[TL_messageEntityTextUrl alloc] init]; - objc.n_id = self.n_id; + objc.offset = self.offset; + objc.length = self.length; + objc.url = self.url; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -16479,37 +21028,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_webPagePending -+(TL_webPagePending*)createWithN_id:(long)n_id date:(int)date { - TL_webPagePending* obj = [[TL_webPagePending alloc] init]; - obj.n_id = n_id; - obj.date = date; +@implementation TLInputChannel + +@end + +@implementation TL_inputChannelEmpty ++(TL_inputChannelEmpty*)create { + TL_inputChannelEmpty* obj = [[TL_inputChannelEmpty alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeLong:self.n_id]; - [stream writeInt:self.date]; + } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readLong]; - self.date = [stream readInt]; + } --(TL_webPagePending *)copy { +-(TL_inputChannelEmpty *)copy { + + TL_inputChannelEmpty *objc = [[TL_inputChannelEmpty alloc] init]; - TL_webPagePending *objc = [[TL_webPagePending alloc] init]; - objc.n_id = self.n_id; - objc.date = self.date; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -16523,89 +21073,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_webPage -+(TL_webPage*)createWithFlags:(int)flags n_id:(long)n_id url:(NSString*)url display_url:(NSString*)display_url type:(NSString*)type site_name:(NSString*)site_name title:(NSString*)title n_description:(NSString*)n_description photo:(TLPhoto*)photo embed_url:(NSString*)embed_url embed_type:(NSString*)embed_type embed_width:(int)embed_width embed_height:(int)embed_height duration:(int)duration author:(NSString*)author { - TL_webPage* obj = [[TL_webPage alloc] init]; - obj.flags = flags; - obj.n_id = n_id; - obj.url = url; - obj.display_url = display_url; - obj.type = type; - obj.site_name = site_name; - obj.title = title; - obj.n_description = n_description; - obj.photo = photo; - obj.embed_url = embed_url; - obj.embed_type = embed_type; - obj.embed_width = embed_width; - obj.embed_height = embed_height; - obj.duration = duration; - obj.author = author; +@implementation TL_inputChannel ++(TL_inputChannel*)createWithChannel_id:(int)channel_id access_hash:(long)access_hash { + TL_inputChannel* obj = [[TL_inputChannel alloc] init]; + obj.channel_id = channel_id; + obj.access_hash = access_hash; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.flags]; - [stream writeLong:self.n_id]; - [stream writeString:self.url]; - [stream writeString:self.display_url]; - if(self.flags & (1 << 0)) [stream writeString:self.type]; - if(self.flags & (1 << 1)) [stream writeString:self.site_name]; - if(self.flags & (1 << 2)) [stream writeString:self.title]; - if(self.flags & (1 << 3)) [stream writeString:self.n_description]; - if(self.flags & (1 << 4)) [ClassStore TLSerialize:self.photo stream:stream]; - if(self.flags & (1 << 5)) [stream writeString:self.embed_url]; - if(self.flags & (1 << 5)) [stream writeString:self.embed_type]; - if(self.flags & (1 << 6)) [stream writeInt:self.embed_width]; - if(self.flags & (1 << 6)) [stream writeInt:self.embed_height]; - if(self.flags & (1 << 7)) [stream writeInt:self.duration]; - if(self.flags & (1 << 8)) [stream writeString:self.author]; -} --(void)unserialize:(SerializedData*)stream { - self.flags = [stream readInt]; - self.n_id = [stream readLong]; - self.url = [stream readString]; - self.display_url = [stream readString]; - if(self.flags & (1 << 0)) self.type = [stream readString]; - if(self.flags & (1 << 1)) self.site_name = [stream readString]; - if(self.flags & (1 << 2)) self.title = [stream readString]; - if(self.flags & (1 << 3)) self.n_description = [stream readString]; - if(self.flags & (1 << 4)) self.photo = [ClassStore TLDeserialize:stream]; - if(self.flags & (1 << 5)) self.embed_url = [stream readString]; - if(self.flags & (1 << 5)) self.embed_type = [stream readString]; - if(self.flags & (1 << 6)) self.embed_width = [stream readInt]; - if(self.flags & (1 << 6)) self.embed_height = [stream readInt]; - if(self.flags & (1 << 7)) self.duration = [stream readInt]; - if(self.flags & (1 << 8)) self.author = [stream readString]; + [stream writeInt:self.channel_id]; + [stream writeLong:self.access_hash]; +} +-(void)unserialize:(SerializedData*)stream { + super.channel_id = [stream readInt]; + super.access_hash = [stream readLong]; } --(TL_webPage *)copy { +-(TL_inputChannel *)copy { - TL_webPage *objc = [[TL_webPage alloc] init]; + TL_inputChannel *objc = [[TL_inputChannel alloc] init]; - objc.flags = self.flags; - objc.n_id = self.n_id; - objc.url = self.url; - objc.display_url = self.display_url; - objc.type = self.type; - objc.site_name = self.site_name; - objc.title = self.title; - objc.n_description = self.n_description; - objc.photo = [self.photo copy]; - objc.embed_url = self.embed_url; - objc.embed_type = self.embed_type; - objc.embed_width = self.embed_width; - objc.embed_height = self.embed_height; - objc.duration = self.duration; - objc.author = self.author; + objc.channel_id = self.channel_id; + objc.access_hash = self.access_hash; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -16619,151 +21118,139 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } + +@end + +@implementation TLcontacts_ResolvedPeer + +@end --(void)setType:(NSString*)type -{ - [super setType:type]; - - if(self.type == nil) { self.flags&= ~ (1 << 0) ;} else { self.flags|= (1 << 0); } -} --(void)setSite_name:(NSString*)site_name -{ - [super setSite_name:site_name]; - - if(self.site_name == nil) { self.flags&= ~ (1 << 1) ;} else { self.flags|= (1 << 1); } -} --(void)setTitle:(NSString*)title -{ - [super setTitle:title]; - - if(self.title == nil) { self.flags&= ~ (1 << 2) ;} else { self.flags|= (1 << 2); } -} --(void)setN_description:(NSString*)n_description -{ - [super setN_description:n_description]; - - if(self.n_description == nil) { self.flags&= ~ (1 << 3) ;} else { self.flags|= (1 << 3); } -} --(void)setPhoto:(TLPhoto*)photo -{ - [super setPhoto:photo]; - - if(self.photo == nil) { self.flags&= ~ (1 << 4) ;} else { self.flags|= (1 << 4); } -} --(void)setEmbed_url:(NSString*)embed_url -{ - [super setEmbed_url:embed_url]; - - if(self.embed_url == nil) { self.flags&= ~ (1 << 5) ;} else { self.flags|= (1 << 5); } -} --(void)setEmbed_type:(NSString*)embed_type -{ - [super setEmbed_type:embed_type]; - - if(self.embed_type == nil) { self.flags&= ~ (1 << 5) ;} else { self.flags|= (1 << 5); } -} --(void)setEmbed_width:(int)embed_width -{ - [super setEmbed_width:embed_width]; - - if(self.embed_width == 0) { self.flags&= ~ (1 << 6) ;} else { self.flags|= (1 << 6); } -} --(void)setEmbed_height:(int)embed_height -{ - [super setEmbed_height:embed_height]; - - if(self.embed_height == 0) { self.flags&= ~ (1 << 6) ;} else { self.flags|= (1 << 6); } -} --(void)setDuration:(int)duration -{ - [super setDuration:duration]; - - if(self.duration == 0) { self.flags&= ~ (1 << 7) ;} else { self.flags|= (1 << 7); } -} --(void)setAuthor:(NSString*)author -{ - [super setAuthor:author]; - - if(self.author == nil) { self.flags&= ~ (1 << 8) ;} else { self.flags|= (1 << 8); } +@implementation TL_contacts_resolvedPeer ++(TL_contacts_resolvedPeer*)createWithPeer:(TLPeer*)peer chats:(NSMutableArray*)chats users:(NSMutableArray*)users { + TL_contacts_resolvedPeer* obj = [[TL_contacts_resolvedPeer alloc] init]; + obj.peer = peer; + obj.chats = chats; + obj.users = users; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [ClassStore TLSerialize:self.peer stream:stream]; + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.chats count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLChat* obj = [self.chats objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.users count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLUser* obj = [self.users objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } +} +-(void)unserialize:(SerializedData*)stream { + self.peer = [ClassStore TLDeserialize:stream]; + //UNS FullVector + [stream readInt]; + { + if(!self.chats) + self.chats = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLChat* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLChat class]]) + [self.chats addObject:obj]; + else + break; + } + } + //UNS FullVector + [stream readInt]; + { + if(!self.users) + self.users = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLUser* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLUser class]]) + [self.users addObject:obj]; + else + break; + } + } +} + +-(TL_contacts_resolvedPeer *)copy { + + TL_contacts_resolvedPeer *objc = [[TL_contacts_resolvedPeer alloc] init]; + + objc.peer = [self.peer copy]; + objc.chats = [self.chats copy]; + objc.users = [self.users copy]; + + return objc; } -@end + +-(id)initWithCoder:(NSCoder *)aDecoder { -@implementation TLAuthorization + if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { + + } + + return self; +} + +-(void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; +} + + + @end -@implementation TL_authorization -+(TL_authorization*)createWithN_hash:(long)n_hash flags:(int)flags device_model:(NSString*)device_model platform:(NSString*)platform system_version:(NSString*)system_version api_id:(int)api_id app_name:(NSString*)app_name app_version:(NSString*)app_version date_created:(int)date_created date_active:(int)date_active ip:(NSString*)ip country:(NSString*)country region:(NSString*)region { - TL_authorization* obj = [[TL_authorization alloc] init]; - obj.n_hash = n_hash; - obj.flags = flags; - obj.device_model = device_model; - obj.platform = platform; - obj.system_version = system_version; - obj.api_id = api_id; - obj.app_name = app_name; - obj.app_version = app_version; - obj.date_created = date_created; - obj.date_active = date_active; - obj.ip = ip; - obj.country = country; - obj.region = region; +@implementation TLMessageRange + +@end + +@implementation TL_messageRange ++(TL_messageRange*)createWithMin_id:(int)min_id max_id:(int)max_id { + TL_messageRange* obj = [[TL_messageRange alloc] init]; + obj.min_id = min_id; + obj.max_id = max_id; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeLong:self.n_hash]; - [stream writeInt:self.flags]; - [stream writeString:self.device_model]; - [stream writeString:self.platform]; - [stream writeString:self.system_version]; - [stream writeInt:self.api_id]; - [stream writeString:self.app_name]; - [stream writeString:self.app_version]; - [stream writeInt:self.date_created]; - [stream writeInt:self.date_active]; - [stream writeString:self.ip]; - [stream writeString:self.country]; - [stream writeString:self.region]; + [stream writeInt:self.min_id]; + [stream writeInt:self.max_id]; } -(void)unserialize:(SerializedData*)stream { - self.n_hash = [stream readLong]; - self.flags = [stream readInt]; - self.device_model = [stream readString]; - self.platform = [stream readString]; - self.system_version = [stream readString]; - self.api_id = [stream readInt]; - self.app_name = [stream readString]; - self.app_version = [stream readString]; - self.date_created = [stream readInt]; - self.date_active = [stream readInt]; - self.ip = [stream readString]; - self.country = [stream readString]; - self.region = [stream readString]; + super.min_id = [stream readInt]; + super.max_id = [stream readInt]; } --(TL_authorization *)copy { +-(TL_messageRange *)copy { - TL_authorization *objc = [[TL_authorization alloc] init]; + TL_messageRange *objc = [[TL_messageRange alloc] init]; - objc.n_hash = self.n_hash; - objc.flags = self.flags; - objc.device_model = self.device_model; - objc.platform = self.platform; - objc.system_version = self.system_version; - objc.api_id = self.api_id; - objc.app_name = self.app_name; - objc.app_version = self.app_version; - objc.date_created = self.date_created; - objc.date_active = self.date_active; - objc.ip = self.ip; - objc.country = self.country; - objc.region = self.region; + objc.min_id = self.min_id; + objc.max_id = self.max_id; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -16777,59 +21264,50 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TLMessageGroup -@implementation TLaccount_Authorizations @end - -@implementation TL_account_authorizations -+(TL_account_authorizations*)createWithAuthorizations:(NSMutableArray*)authorizations { - TL_account_authorizations* obj = [[TL_account_authorizations alloc] init]; - obj.authorizations = authorizations; + +@implementation TL_messageGroup ++(TL_messageGroup*)createWithMin_id:(int)min_id max_id:(int)max_id n_count:(int)n_count date:(int)date { + TL_messageGroup* obj = [[TL_messageGroup alloc] init]; + obj.min_id = min_id; + obj.max_id = max_id; + obj.n_count = n_count; + obj.date = date; return obj; } -(void)serialize:(SerializedData*)stream { - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.authorizations count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLAuthorization* obj = [self.authorizations objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } + [stream writeInt:self.min_id]; + [stream writeInt:self.max_id]; + [stream writeInt:self.n_count]; + [stream writeInt:self.date]; } -(void)unserialize:(SerializedData*)stream { - //UNS FullVector - [stream readInt]; - { - if(!self.authorizations) - self.authorizations = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLAuthorization* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLAuthorization class]]) - [self.authorizations addObject:obj]; - else - break; - } - } + super.min_id = [stream readInt]; + super.max_id = [stream readInt]; + super.n_count = [stream readInt]; + super.date = [stream readInt]; } --(TL_account_authorizations *)copy { +-(TL_messageGroup *)copy { - TL_account_authorizations *objc = [[TL_account_authorizations alloc] init]; + TL_messageGroup *objc = [[TL_messageGroup alloc] init]; - objc.authorizations = [self.authorizations copy]; + objc.min_id = self.min_id; + objc.max_id = self.max_id; + objc.n_count = self.n_count; + objc.date = self.date; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -16843,41 +21321,52 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLaccount_Password +@implementation TLupdates_ChannelDifference + +-(BOOL)isFinal {return NO;} + @end - -@implementation TL_account_noPassword -+(TL_account_noPassword*)createWithN_salt:(NSData*)n_salt email_unconfirmed_pattern:(NSString*)email_unconfirmed_pattern { - TL_account_noPassword* obj = [[TL_account_noPassword alloc] init]; - obj.n_salt = n_salt; - obj.email_unconfirmed_pattern = email_unconfirmed_pattern; + +@implementation TL_updates_channelDifferenceEmpty ++(TL_updates_channelDifferenceEmpty*)createWithFlags:(int)flags pts:(int)pts timeout:(int)timeout { + TL_updates_channelDifferenceEmpty* obj = [[TL_updates_channelDifferenceEmpty alloc] init]; + obj.flags = flags; + + obj.pts = pts; + obj.timeout = timeout; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeByteArray:self.n_salt]; - [stream writeString:self.email_unconfirmed_pattern]; + [stream writeInt:self.flags]; + + [stream writeInt:self.pts]; + if(self.flags & (1 << 1)) {[stream writeInt:self.timeout];} } -(void)unserialize:(SerializedData*)stream { - self.n_salt = [stream readByteArray]; - self.email_unconfirmed_pattern = [stream readString]; + super.flags = [stream readInt]; + + super.pts = [stream readInt]; + if(self.flags & (1 << 1)) {super.timeout = [stream readInt];} } --(TL_account_noPassword *)copy { +-(TL_updates_channelDifferenceEmpty *)copy { - TL_account_noPassword *objc = [[TL_account_noPassword alloc] init]; + TL_updates_channelDifferenceEmpty *objc = [[TL_updates_channelDifferenceEmpty alloc] init]; - objc.n_salt = [self.n_salt copy]; - objc.email_unconfirmed_pattern = self.email_unconfirmed_pattern; + objc.flags = self.flags; + + objc.pts = self.pts; + objc.timeout = self.timeout; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -16891,49 +21380,152 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - - + +-(BOOL)isFinal {return (self.flags & (1 << 0)) > 0;} + +-(void)setTimeout:(int)timeout +{ + super.timeout = timeout; + + if(super.timeout == 0) { super.flags&= ~ (1 << 1) ;} else { super.flags|= (1 << 1); } +} @end -@implementation TL_account_password -+(TL_account_password*)createWithCurrent_salt:(NSData*)current_salt n_salt:(NSData*)n_salt hint:(NSString*)hint has_recovery:(Boolean)has_recovery email_unconfirmed_pattern:(NSString*)email_unconfirmed_pattern { - TL_account_password* obj = [[TL_account_password alloc] init]; - obj.current_salt = current_salt; - obj.n_salt = n_salt; - obj.hint = hint; - obj.has_recovery = has_recovery; - obj.email_unconfirmed_pattern = email_unconfirmed_pattern; +@implementation TL_updates_channelDifferenceTooLong ++(TL_updates_channelDifferenceTooLong*)createWithFlags:(int)flags pts:(int)pts timeout:(int)timeout top_message:(int)top_message top_important_message:(int)top_important_message read_inbox_max_id:(int)read_inbox_max_id unread_count:(int)unread_count unread_important_count:(int)unread_important_count messages:(NSMutableArray*)messages chats:(NSMutableArray*)chats users:(NSMutableArray*)users { + TL_updates_channelDifferenceTooLong* obj = [[TL_updates_channelDifferenceTooLong alloc] init]; + obj.flags = flags; + + obj.pts = pts; + obj.timeout = timeout; + obj.top_message = top_message; + obj.top_important_message = top_important_message; + obj.read_inbox_max_id = read_inbox_max_id; + obj.unread_count = unread_count; + obj.unread_important_count = unread_important_count; + obj.messages = messages; + obj.chats = chats; + obj.users = users; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeByteArray:self.current_salt]; - [stream writeByteArray:self.n_salt]; - [stream writeString:self.hint]; - [stream writeBool:self.has_recovery]; - [stream writeString:self.email_unconfirmed_pattern]; + [stream writeInt:self.flags]; + + [stream writeInt:self.pts]; + if(self.flags & (1 << 1)) {[stream writeInt:self.timeout];} + [stream writeInt:self.top_message]; + [stream writeInt:self.top_important_message]; + [stream writeInt:self.read_inbox_max_id]; + [stream writeInt:self.unread_count]; + [stream writeInt:self.unread_important_count]; + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.messages count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLMessage* obj = [self.messages objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.chats count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLChat* obj = [self.chats objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.users count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLUser* obj = [self.users objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } } -(void)unserialize:(SerializedData*)stream { - self.current_salt = [stream readByteArray]; - self.n_salt = [stream readByteArray]; - self.hint = [stream readString]; - self.has_recovery = [stream readBool]; - self.email_unconfirmed_pattern = [stream readString]; + super.flags = [stream readInt]; + + super.pts = [stream readInt]; + if(self.flags & (1 << 1)) {super.timeout = [stream readInt];} + super.top_message = [stream readInt]; + super.top_important_message = [stream readInt]; + super.read_inbox_max_id = [stream readInt]; + super.unread_count = [stream readInt]; + super.unread_important_count = [stream readInt]; + //UNS FullVector + [stream readInt]; + { + if(!self.messages) + self.messages = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLMessage* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLMessage class]]) + [self.messages addObject:obj]; + else + break; + } + } + //UNS FullVector + [stream readInt]; + { + if(!self.chats) + self.chats = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLChat* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLChat class]]) + [self.chats addObject:obj]; + else + break; + } + } + //UNS FullVector + [stream readInt]; + { + if(!self.users) + self.users = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLUser* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLUser class]]) + [self.users addObject:obj]; + else + break; + } + } } --(TL_account_password *)copy { +-(TL_updates_channelDifferenceTooLong *)copy { + + TL_updates_channelDifferenceTooLong *objc = [[TL_updates_channelDifferenceTooLong alloc] init]; - TL_account_password *objc = [[TL_account_password alloc] init]; + objc.flags = self.flags; - objc.current_salt = [self.current_salt copy]; - objc.n_salt = [self.n_salt copy]; - objc.hint = self.hint; - objc.has_recovery = self.has_recovery; - objc.email_unconfirmed_pattern = self.email_unconfirmed_pattern; + objc.pts = self.pts; + objc.timeout = self.timeout; + objc.top_message = self.top_message; + objc.top_important_message = self.top_important_message; + objc.read_inbox_max_id = self.read_inbox_max_id; + objc.unread_count = self.unread_count; + objc.unread_important_count = self.unread_important_count; + objc.messages = [self.messages copy]; + objc.chats = [self.chats copy]; + objc.users = [self.users copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -16947,37 +21539,158 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - - + +-(BOOL)isFinal {return (self.flags & (1 << 0)) > 0;} + +-(void)setTimeout:(int)timeout +{ + super.timeout = timeout; + + if(super.timeout == 0) { super.flags&= ~ (1 << 1) ;} else { super.flags|= (1 << 1); } +} @end - -@implementation TLaccount_PasswordSettings -@end - -@implementation TL_account_passwordSettings -+(TL_account_passwordSettings*)createWithEmail:(NSString*)email { - TL_account_passwordSettings* obj = [[TL_account_passwordSettings alloc] init]; - obj.email = email; +@implementation TL_updates_channelDifference ++(TL_updates_channelDifference*)createWithFlags:(int)flags pts:(int)pts timeout:(int)timeout n_messages:(NSMutableArray*)n_messages other_updates:(NSMutableArray*)other_updates chats:(NSMutableArray*)chats users:(NSMutableArray*)users { + TL_updates_channelDifference* obj = [[TL_updates_channelDifference alloc] init]; + obj.flags = flags; + + obj.pts = pts; + obj.timeout = timeout; + obj.n_messages = n_messages; + obj.other_updates = other_updates; + obj.chats = chats; + obj.users = users; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeString:self.email]; + [stream writeInt:self.flags]; + + [stream writeInt:self.pts]; + if(self.flags & (1 << 1)) {[stream writeInt:self.timeout];} + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.n_messages count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLMessage* obj = [self.n_messages objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.other_updates count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLUpdate* obj = [self.other_updates objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.chats count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLChat* obj = [self.chats objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.users count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLUser* obj = [self.users objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } } -(void)unserialize:(SerializedData*)stream { - self.email = [stream readString]; + super.flags = [stream readInt]; + + super.pts = [stream readInt]; + if(self.flags & (1 << 1)) {super.timeout = [stream readInt];} + //UNS FullVector + [stream readInt]; + { + if(!self.n_messages) + self.n_messages = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLMessage* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLMessage class]]) + [self.n_messages addObject:obj]; + else + break; + } + } + //UNS FullVector + [stream readInt]; + { + if(!self.other_updates) + self.other_updates = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLUpdate* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLUpdate class]]) + [self.other_updates addObject:obj]; + else + break; + } + } + //UNS FullVector + [stream readInt]; + { + if(!self.chats) + self.chats = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLChat* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLChat class]]) + [self.chats addObject:obj]; + else + break; + } + } + //UNS FullVector + [stream readInt]; + { + if(!self.users) + self.users = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLUser* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLUser class]]) + [self.users addObject:obj]; + else + break; + } + } } --(TL_account_passwordSettings *)copy { +-(TL_updates_channelDifference *)copy { - TL_account_passwordSettings *objc = [[TL_account_passwordSettings alloc] init]; + TL_updates_channelDifference *objc = [[TL_updates_channelDifference alloc] init]; - objc.email = self.email; + objc.flags = self.flags; + + objc.pts = self.pts; + objc.timeout = self.timeout; + objc.n_messages = [self.n_messages copy]; + objc.other_updates = [self.other_updates copy]; + objc.chats = [self.chats copy]; + objc.users = [self.users copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -16991,53 +21704,50 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - - + +-(BOOL)isFinal {return (self.flags & (1 << 0)) > 0;} + +-(void)setTimeout:(int)timeout +{ + super.timeout = timeout; + + if(super.timeout == 0) { super.flags&= ~ (1 << 1) ;} else { super.flags|= (1 << 1); } +} @end - -@implementation TLaccount_PasswordInputSettings +@implementation TLChannelMessagesFilter + +-(BOOL)isImportant_only {return NO;} + +-(BOOL)isExclude_new_messages {return NO;} + @end - -@implementation TL_account_passwordInputSettings -+(TL_account_passwordInputSettings*)createWithFlags:(int)flags n_salt:(NSData*)n_salt n_password_hash:(NSData*)n_password_hash hint:(NSString*)hint email:(NSString*)email { - TL_account_passwordInputSettings* obj = [[TL_account_passwordInputSettings alloc] init]; - obj.flags = flags; - obj.n_salt = n_salt; - obj.n_password_hash = n_password_hash; - obj.hint = hint; - obj.email = email; + +@implementation TL_channelMessagesFilterEmpty ++(TL_channelMessagesFilterEmpty*)create { + TL_channelMessagesFilterEmpty* obj = [[TL_channelMessagesFilterEmpty alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.flags]; - if(self.flags & (1 << 0)) [stream writeByteArray:self.n_salt]; - if(self.flags & (1 << 0)) [stream writeByteArray:self.n_password_hash]; - if(self.flags & (1 << 0)) [stream writeString:self.hint]; - if(self.flags & (1 << 1)) [stream writeString:self.email]; + } -(void)unserialize:(SerializedData*)stream { - self.flags = [stream readInt]; - if(self.flags & (1 << 0)) self.n_salt = [stream readByteArray]; - if(self.flags & (1 << 0)) self.n_password_hash = [stream readByteArray]; - if(self.flags & (1 << 0)) self.hint = [stream readString]; - if(self.flags & (1 << 1)) self.email = [stream readString]; + } --(TL_account_passwordInputSettings *)copy { +-(TL_channelMessagesFilterEmpty *)copy { + + TL_channelMessagesFilterEmpty *objc = [[TL_channelMessagesFilterEmpty alloc] init]; - TL_account_passwordInputSettings *objc = [[TL_account_passwordInputSettings alloc] init]; - objc.flags = self.flags; - objc.n_salt = [self.n_salt copy]; - objc.n_password_hash = [self.n_password_hash copy]; - objc.hint = self.hint; - objc.email = self.email; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -17051,61 +21761,68 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - - - --(void)setN_salt:(NSData*)n_salt -{ - [super setN_salt:n_salt]; - - if(self.n_salt == nil) { self.flags&= ~ (1 << 0) ;} else { self.flags|= (1 << 0); } -} --(void)setN_password_hash:(NSData*)n_password_hash -{ - [super setN_password_hash:n_password_hash]; - - if(self.n_password_hash == nil) { self.flags&= ~ (1 << 0) ;} else { self.flags|= (1 << 0); } -} --(void)setHint:(NSString*)hint -{ - [super setHint:hint]; - - if(self.hint == nil) { self.flags&= ~ (1 << 0) ;} else { self.flags|= (1 << 0); } -} --(void)setEmail:(NSString*)email -{ - [super setEmail:email]; - - if(self.email == nil) { self.flags&= ~ (1 << 1) ;} else { self.flags|= (1 << 1); } -} -@end - -@implementation TLauth_PasswordRecovery + @end -@implementation TL_auth_passwordRecovery -+(TL_auth_passwordRecovery*)createWithEmail_pattern:(NSString*)email_pattern { - TL_auth_passwordRecovery* obj = [[TL_auth_passwordRecovery alloc] init]; - obj.email_pattern = email_pattern; +@implementation TL_channelMessagesFilter ++(TL_channelMessagesFilter*)createWithFlags:(int)flags ranges:(NSMutableArray*)ranges { + TL_channelMessagesFilter* obj = [[TL_channelMessagesFilter alloc] init]; + obj.flags = flags; + + + obj.ranges = ranges; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeString:self.email_pattern]; + [stream writeInt:self.flags]; + + + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.ranges count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLMessageRange* obj = [self.ranges objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } } -(void)unserialize:(SerializedData*)stream { - self.email_pattern = [stream readString]; + super.flags = [stream readInt]; + + + //UNS FullVector + [stream readInt]; + { + if(!self.ranges) + self.ranges = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLMessageRange* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLMessageRange class]]) + [self.ranges addObject:obj]; + else + break; + } + } } --(TL_auth_passwordRecovery *)copy { +-(TL_channelMessagesFilter *)copy { - TL_auth_passwordRecovery *objc = [[TL_auth_passwordRecovery alloc] init]; + TL_channelMessagesFilter *objc = [[TL_channelMessagesFilter alloc] init]; - objc.email_pattern = self.email_pattern; + objc.flags = self.flags; + + + objc.ranges = [self.ranges copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -17119,41 +21836,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - - + +-(BOOL)isImportant_only {return (self.flags & (1 << 0)) > 0;} + +-(BOOL)isExclude_new_messages {return (self.flags & (1 << 1)) > 0;} + @end - -@implementation TLReceivedNotifyMessage -@end - -@implementation TL_receivedNotifyMessage -+(TL_receivedNotifyMessage*)createWithN_id:(int)n_id flags:(int)flags { - TL_receivedNotifyMessage* obj = [[TL_receivedNotifyMessage alloc] init]; - obj.n_id = n_id; - obj.flags = flags; +@implementation TL_channelMessagesFilterCollapsed ++(TL_channelMessagesFilterCollapsed*)create { + TL_channelMessagesFilterCollapsed* obj = [[TL_channelMessagesFilterCollapsed alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.n_id]; - [stream writeInt:self.flags]; + } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readInt]; - self.flags = [stream readInt]; + } --(TL_receivedNotifyMessage *)copy { +-(TL_channelMessagesFilterCollapsed *)copy { + + TL_channelMessagesFilterCollapsed *objc = [[TL_channelMessagesFilterCollapsed alloc] init]; - TL_receivedNotifyMessage *objc = [[TL_receivedNotifyMessage alloc] init]; - objc.n_id = self.n_id; - objc.flags = self.flags; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -17167,37 +21881,42 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TLChannelParticipant -@implementation TLExportedChatInvite @end - -@implementation TL_chatInviteEmpty -+(TL_chatInviteEmpty*)create { - TL_chatInviteEmpty* obj = [[TL_chatInviteEmpty alloc] init]; - + +@implementation TL_channelParticipant ++(TL_channelParticipant*)createWithUser_id:(int)user_id date:(int)date { + TL_channelParticipant* obj = [[TL_channelParticipant alloc] init]; + obj.user_id = user_id; + obj.date = date; return obj; } -(void)serialize:(SerializedData*)stream { - + [stream writeInt:self.user_id]; + [stream writeInt:self.date]; } -(void)unserialize:(SerializedData*)stream { - + super.user_id = [stream readInt]; + super.date = [stream readInt]; } --(TL_chatInviteEmpty *)copy { - - TL_chatInviteEmpty *objc = [[TL_chatInviteEmpty alloc] init]; +-(TL_channelParticipant *)copy { + TL_channelParticipant *objc = [[TL_channelParticipant alloc] init]; + objc.user_id = self.user_id; + objc.date = self.date; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -17211,33 +21930,42 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_chatInviteExported -+(TL_chatInviteExported*)createWithLink:(NSString*)link { - TL_chatInviteExported* obj = [[TL_chatInviteExported alloc] init]; - obj.link = link; +@implementation TL_channelParticipantSelf ++(TL_channelParticipantSelf*)createWithUser_id:(int)user_id inviter_id:(int)inviter_id date:(int)date { + TL_channelParticipantSelf* obj = [[TL_channelParticipantSelf alloc] init]; + obj.user_id = user_id; + obj.inviter_id = inviter_id; + obj.date = date; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeString:self.link]; + [stream writeInt:self.user_id]; + [stream writeInt:self.inviter_id]; + [stream writeInt:self.date]; } -(void)unserialize:(SerializedData*)stream { - self.link = [stream readString]; + super.user_id = [stream readInt]; + super.inviter_id = [stream readInt]; + super.date = [stream readInt]; } --(TL_chatInviteExported *)copy { +-(TL_channelParticipantSelf *)copy { - TL_chatInviteExported *objc = [[TL_chatInviteExported alloc] init]; + TL_channelParticipantSelf *objc = [[TL_channelParticipantSelf alloc] init]; - objc.link = self.link; + objc.user_id = self.user_id; + objc.inviter_id = self.inviter_id; + objc.date = self.date; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -17251,37 +21979,42 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLChatInvite -@end - -@implementation TL_chatInviteAlready -+(TL_chatInviteAlready*)createWithChat:(TLChat*)chat { - TL_chatInviteAlready* obj = [[TL_chatInviteAlready alloc] init]; - obj.chat = chat; +@implementation TL_channelParticipantModerator ++(TL_channelParticipantModerator*)createWithUser_id:(int)user_id inviter_id:(int)inviter_id date:(int)date { + TL_channelParticipantModerator* obj = [[TL_channelParticipantModerator alloc] init]; + obj.user_id = user_id; + obj.inviter_id = inviter_id; + obj.date = date; return obj; } -(void)serialize:(SerializedData*)stream { - [ClassStore TLSerialize:self.chat stream:stream]; + [stream writeInt:self.user_id]; + [stream writeInt:self.inviter_id]; + [stream writeInt:self.date]; } -(void)unserialize:(SerializedData*)stream { - self.chat = [ClassStore TLDeserialize:stream]; + super.user_id = [stream readInt]; + super.inviter_id = [stream readInt]; + super.date = [stream readInt]; } --(TL_chatInviteAlready *)copy { +-(TL_channelParticipantModerator *)copy { - TL_chatInviteAlready *objc = [[TL_chatInviteAlready alloc] init]; + TL_channelParticipantModerator *objc = [[TL_channelParticipantModerator alloc] init]; - objc.chat = [self.chat copy]; + objc.user_id = self.user_id; + objc.inviter_id = self.inviter_id; + objc.date = self.date; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -17295,33 +22028,42 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_chatInvite -+(TL_chatInvite*)createWithTitle:(NSString*)title { - TL_chatInvite* obj = [[TL_chatInvite alloc] init]; - obj.title = title; +@implementation TL_channelParticipantEditor ++(TL_channelParticipantEditor*)createWithUser_id:(int)user_id inviter_id:(int)inviter_id date:(int)date { + TL_channelParticipantEditor* obj = [[TL_channelParticipantEditor alloc] init]; + obj.user_id = user_id; + obj.inviter_id = inviter_id; + obj.date = date; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeString:self.title]; + [stream writeInt:self.user_id]; + [stream writeInt:self.inviter_id]; + [stream writeInt:self.date]; } -(void)unserialize:(SerializedData*)stream { - self.title = [stream readString]; + super.user_id = [stream readInt]; + super.inviter_id = [stream readInt]; + super.date = [stream readInt]; } --(TL_chatInvite *)copy { +-(TL_channelParticipantEditor *)copy { - TL_chatInvite *objc = [[TL_chatInvite alloc] init]; + TL_channelParticipantEditor *objc = [[TL_channelParticipantEditor alloc] init]; - objc.title = self.title; + objc.user_id = self.user_id; + objc.inviter_id = self.inviter_id; + objc.date = self.date; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -17335,37 +22077,42 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLInputStickerSet -@end - -@implementation TL_inputStickerSetEmpty -+(TL_inputStickerSetEmpty*)create { - TL_inputStickerSetEmpty* obj = [[TL_inputStickerSetEmpty alloc] init]; - +@implementation TL_channelParticipantKicked ++(TL_channelParticipantKicked*)createWithUser_id:(int)user_id kicked_by:(int)kicked_by date:(int)date { + TL_channelParticipantKicked* obj = [[TL_channelParticipantKicked alloc] init]; + obj.user_id = user_id; + obj.kicked_by = kicked_by; + obj.date = date; return obj; } -(void)serialize:(SerializedData*)stream { - + [stream writeInt:self.user_id]; + [stream writeInt:self.kicked_by]; + [stream writeInt:self.date]; } -(void)unserialize:(SerializedData*)stream { - + super.user_id = [stream readInt]; + super.kicked_by = [stream readInt]; + super.date = [stream readInt]; } --(TL_inputStickerSetEmpty *)copy { - - TL_inputStickerSetEmpty *objc = [[TL_inputStickerSetEmpty alloc] init]; +-(TL_channelParticipantKicked *)copy { + TL_channelParticipantKicked *objc = [[TL_channelParticipantKicked alloc] init]; + objc.user_id = self.user_id; + objc.kicked_by = self.kicked_by; + objc.date = self.date; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -17379,37 +22126,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_inputStickerSetID -+(TL_inputStickerSetID*)createWithN_id:(long)n_id access_hash:(long)access_hash { - TL_inputStickerSetID* obj = [[TL_inputStickerSetID alloc] init]; - obj.n_id = n_id; - obj.access_hash = access_hash; +@implementation TL_channelParticipantCreator ++(TL_channelParticipantCreator*)createWithUser_id:(int)user_id { + TL_channelParticipantCreator* obj = [[TL_channelParticipantCreator alloc] init]; + obj.user_id = user_id; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeLong:self.n_id]; - [stream writeLong:self.access_hash]; + [stream writeInt:self.user_id]; } -(void)unserialize:(SerializedData*)stream { - self.n_id = [stream readLong]; - self.access_hash = [stream readLong]; + super.user_id = [stream readInt]; } --(TL_inputStickerSetID *)copy { +-(TL_channelParticipantCreator *)copy { - TL_inputStickerSetID *objc = [[TL_inputStickerSetID alloc] init]; + TL_channelParticipantCreator *objc = [[TL_channelParticipantCreator alloc] init]; - objc.n_id = self.n_id; - objc.access_hash = self.access_hash; + objc.user_id = self.user_id; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -17423,33 +22167,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_inputStickerSetShortName -+(TL_inputStickerSetShortName*)createWithShort_name:(NSString*)short_name { - TL_inputStickerSetShortName* obj = [[TL_inputStickerSetShortName alloc] init]; - obj.short_name = short_name; +@implementation TLChannelParticipantsFilter + +@end + +@implementation TL_channelParticipantsRecent ++(TL_channelParticipantsRecent*)create { + TL_channelParticipantsRecent* obj = [[TL_channelParticipantsRecent alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeString:self.short_name]; + } -(void)unserialize:(SerializedData*)stream { - self.short_name = [stream readString]; + } --(TL_inputStickerSetShortName *)copy { +-(TL_channelParticipantsRecent *)copy { + + TL_channelParticipantsRecent *objc = [[TL_channelParticipantsRecent alloc] init]; - TL_inputStickerSetShortName *objc = [[TL_inputStickerSetShortName alloc] init]; - objc.short_name = self.short_name; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -17463,61 +22212,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLStickerSet -@end - -@implementation TL_stickerSet -+(TL_stickerSet*)createWithFlags:(int)flags n_id:(long)n_id access_hash:(long)access_hash title:(NSString*)title short_name:(NSString*)short_name n_count:(int)n_count n_hash:(int)n_hash { - TL_stickerSet* obj = [[TL_stickerSet alloc] init]; - obj.flags = flags; - obj.n_id = n_id; - obj.access_hash = access_hash; - obj.title = title; - obj.short_name = short_name; - obj.n_count = n_count; - obj.n_hash = n_hash; +@implementation TL_channelParticipantsAdmins ++(TL_channelParticipantsAdmins*)create { + TL_channelParticipantsAdmins* obj = [[TL_channelParticipantsAdmins alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.flags]; - [stream writeLong:self.n_id]; - [stream writeLong:self.access_hash]; - [stream writeString:self.title]; - [stream writeString:self.short_name]; - [stream writeInt:self.n_count]; - [stream writeInt:self.n_hash]; + } -(void)unserialize:(SerializedData*)stream { - self.flags = [stream readInt]; - self.n_id = [stream readLong]; - self.access_hash = [stream readLong]; - self.title = [stream readString]; - self.short_name = [stream readString]; - self.n_count = [stream readInt]; - self.n_hash = [stream readInt]; + } --(TL_stickerSet *)copy { +-(TL_channelParticipantsAdmins *)copy { + + TL_channelParticipantsAdmins *objc = [[TL_channelParticipantsAdmins alloc] init]; - TL_stickerSet *objc = [[TL_stickerSet alloc] init]; - objc.flags = self.flags; - objc.n_id = self.n_id; - objc.access_hash = self.access_hash; - objc.title = self.title; - objc.short_name = self.short_name; - objc.n_count = self.n_count; - objc.n_hash = self.n_hash; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -17531,89 +22253,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLmessages_StickerSet -@end - -@implementation TL_messages_stickerSet -+(TL_messages_stickerSet*)createWithSet:(TLStickerSet*)set packs:(NSMutableArray*)packs documents:(NSMutableArray*)documents { - TL_messages_stickerSet* obj = [[TL_messages_stickerSet alloc] init]; - obj.set = set; - obj.packs = packs; - obj.documents = documents; +@implementation TL_channelParticipantsKicked ++(TL_channelParticipantsKicked*)create { + TL_channelParticipantsKicked* obj = [[TL_channelParticipantsKicked alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [ClassStore TLSerialize:self.set stream:stream]; - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.packs count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLStickerPack* obj = [self.packs objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.documents count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLDocument* obj = [self.documents objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } + } -(void)unserialize:(SerializedData*)stream { - self.set = [ClassStore TLDeserialize:stream]; - //UNS FullVector - [stream readInt]; - { - if(!self.packs) - self.packs = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLStickerPack* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLStickerPack class]]) - [self.packs addObject:obj]; - else - break; - } - } - //UNS FullVector - [stream readInt]; - { - if(!self.documents) - self.documents = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLDocument* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLDocument class]]) - [self.documents addObject:obj]; - else - break; - } - } + } --(TL_messages_stickerSet *)copy { +-(TL_channelParticipantsKicked *)copy { + + TL_channelParticipantsKicked *objc = [[TL_channelParticipantsKicked alloc] init]; - TL_messages_stickerSet *objc = [[TL_messages_stickerSet alloc] init]; - objc.set = [self.set copy]; - objc.packs = [self.packs copy]; - objc.documents = [self.documents copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -17627,41 +22294,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLBotCommand -@end - -@implementation TL_botCommand -+(TL_botCommand*)createWithCommand:(NSString*)command n_description:(NSString*)n_description { - TL_botCommand* obj = [[TL_botCommand alloc] init]; - obj.command = command; - obj.n_description = n_description; +@implementation TL_channelParticipantsBots ++(TL_channelParticipantsBots*)create { + TL_channelParticipantsBots* obj = [[TL_channelParticipantsBots alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeString:self.command]; - [stream writeString:self.n_description]; + } -(void)unserialize:(SerializedData*)stream { - self.command = [stream readString]; - self.n_description = [stream readString]; + } --(TL_botCommand *)copy { +-(TL_channelParticipantsBots *)copy { + + TL_channelParticipantsBots *objc = [[TL_channelParticipantsBots alloc] init]; - TL_botCommand *objc = [[TL_botCommand alloc] init]; - objc.command = self.command; - objc.n_description = self.n_description; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -17675,19 +22335,18 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TLChannelParticipantRole -@implementation TLBotInfo @end - -@implementation TL_botInfoEmpty -+(TL_botInfoEmpty*)create { - TL_botInfoEmpty* obj = [[TL_botInfoEmpty alloc] init]; + +@implementation TL_channelRoleEmpty ++(TL_channelRoleEmpty*)create { + TL_channelRoleEmpty* obj = [[TL_channelRoleEmpty alloc] init]; return obj; } @@ -17698,14 +22357,16 @@ -(void)unserialize:(SerializedData*)stream { } --(TL_botInfoEmpty *)copy { +-(TL_channelRoleEmpty *)copy { - TL_botInfoEmpty *objc = [[TL_botInfoEmpty alloc] init]; + TL_channelRoleEmpty *objc = [[TL_channelRoleEmpty alloc] init]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -17719,71 +22380,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_botInfo -+(TL_botInfo*)createWithUser_id:(int)user_id version:(int)version share_text:(NSString*)share_text n_description:(NSString*)n_description commands:(NSMutableArray*)commands { - TL_botInfo* obj = [[TL_botInfo alloc] init]; - obj.user_id = user_id; - obj.version = version; - obj.share_text = share_text; - obj.n_description = n_description; - obj.commands = commands; +@implementation TL_channelRoleModerator ++(TL_channelRoleModerator*)create { + TL_channelRoleModerator* obj = [[TL_channelRoleModerator alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.user_id]; - [stream writeInt:self.version]; - [stream writeString:self.share_text]; - [stream writeString:self.n_description]; - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.commands count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLBotCommand* obj = [self.commands objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } + } -(void)unserialize:(SerializedData*)stream { - self.user_id = [stream readInt]; - self.version = [stream readInt]; - self.share_text = [stream readString]; - self.n_description = [stream readString]; - //UNS FullVector - [stream readInt]; - { - if(!self.commands) - self.commands = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLBotCommand* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLBotCommand class]]) - [self.commands addObject:obj]; - else - break; - } - } + } --(TL_botInfo *)copy { +-(TL_channelRoleModerator *)copy { + + TL_channelRoleModerator *objc = [[TL_channelRoleModerator alloc] init]; - TL_botInfo *objc = [[TL_botInfo alloc] init]; - objc.user_id = self.user_id; - objc.version = self.version; - objc.share_text = self.share_text; - objc.n_description = self.n_description; - objc.commands = [self.commands copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -17797,37 +22421,34 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - -@implementation TLKeyboardButton -@end - -@implementation TL_keyboardButton -+(TL_keyboardButton*)createWithText:(NSString*)text { - TL_keyboardButton* obj = [[TL_keyboardButton alloc] init]; - obj.text = text; +@implementation TL_channelRoleEditor ++(TL_channelRoleEditor*)create { + TL_channelRoleEditor* obj = [[TL_channelRoleEditor alloc] init]; + return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeString:self.text]; + } -(void)unserialize:(SerializedData*)stream { - self.text = [stream readString]; + } --(TL_keyboardButton *)copy { +-(TL_channelRoleEditor *)copy { + + TL_channelRoleEditor *objc = [[TL_channelRoleEditor alloc] init]; - TL_keyboardButton *objc = [[TL_keyboardButton alloc] init]; - objc.text = self.text; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -17841,59 +22462,90 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TLchannels_ChannelParticipants -@implementation TLKeyboardButtonRow @end - -@implementation TL_keyboardButtonRow -+(TL_keyboardButtonRow*)createWithButtons:(NSMutableArray*)buttons { - TL_keyboardButtonRow* obj = [[TL_keyboardButtonRow alloc] init]; - obj.buttons = buttons; + +@implementation TL_channels_channelParticipants ++(TL_channels_channelParticipants*)createWithN_count:(int)n_count participants:(NSMutableArray*)participants users:(NSMutableArray*)users { + TL_channels_channelParticipants* obj = [[TL_channels_channelParticipants alloc] init]; + obj.n_count = n_count; + obj.participants = participants; + obj.users = users; return obj; } -(void)serialize:(SerializedData*)stream { + [stream writeInt:self.n_count]; //Serialize FullVector [stream writeInt:0x1cb5c415]; { - NSInteger tl_count = [self.buttons count]; + NSInteger tl_count = [self.participants count]; [stream writeInt:(int)tl_count]; for(int i = 0; i < (int)tl_count; i++) { - TLKeyboardButton* obj = [self.buttons objectAtIndex:i]; + TLChannelParticipant* obj = [self.participants objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.users count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLUser* obj = [self.users objectAtIndex:i]; [ClassStore TLSerialize:obj stream:stream]; } } } -(void)unserialize:(SerializedData*)stream { + super.n_count = [stream readInt]; //UNS FullVector [stream readInt]; { - if(!self.buttons) - self.buttons = [[NSMutableArray alloc] init]; + if(!self.participants) + self.participants = [[NSMutableArray alloc] init]; int count = [stream readInt]; for(int i = 0; i < count; i++) { - TLKeyboardButton* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLKeyboardButton class]]) - [self.buttons addObject:obj]; + TLChannelParticipant* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLChannelParticipant class]]) + [self.participants addObject:obj]; + else + break; + } + } + //UNS FullVector + [stream readInt]; + { + if(!self.users) + self.users = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLUser* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLUser class]]) + [self.users addObject:obj]; else break; } } } --(TL_keyboardButtonRow *)copy { +-(TL_channels_channelParticipants *)copy { - TL_keyboardButtonRow *objc = [[TL_keyboardButtonRow alloc] init]; + TL_channels_channelParticipants *objc = [[TL_channels_channelParticipants alloc] init]; - objc.buttons = [self.buttons copy]; + objc.n_count = self.n_count; + objc.participants = [self.participants copy]; + objc.users = [self.users copy]; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -17907,77 +22559,64 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end +@implementation TLchannels_ChannelParticipant -@implementation TLReplyMarkup @end - -@implementation TL_replyKeyboardHide -+(TL_replyKeyboardHide*)createWithFlags:(int)flags { - TL_replyKeyboardHide* obj = [[TL_replyKeyboardHide alloc] init]; - obj.flags = flags; + +@implementation TL_channels_channelParticipant ++(TL_channels_channelParticipant*)createWithParticipant:(TLChannelParticipant*)participant users:(NSMutableArray*)users { + TL_channels_channelParticipant* obj = [[TL_channels_channelParticipant alloc] init]; + obj.participant = participant; + obj.users = users; return obj; } -(void)serialize:(SerializedData*)stream { - [stream writeInt:self.flags]; + [ClassStore TLSerialize:self.participant stream:stream]; + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.users count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLUser* obj = [self.users objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } } -(void)unserialize:(SerializedData*)stream { - self.flags = [stream readInt]; + self.participant = [ClassStore TLDeserialize:stream]; + //UNS FullVector + [stream readInt]; + { + if(!self.users) + self.users = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLUser* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLUser class]]) + [self.users addObject:obj]; + else + break; + } + } } --(TL_replyKeyboardHide *)copy { +-(TL_channels_channelParticipant *)copy { - TL_replyKeyboardHide *objc = [[TL_replyKeyboardHide alloc] init]; + TL_channels_channelParticipant *objc = [[TL_channels_channelParticipant alloc] init]; - objc.flags = self.flags; + objc.participant = [self.participant copy]; + objc.users = [self.users copy]; return objc; } - --(id)initWithCoder:(NSCoder *)aDecoder { - - if((self = [ClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { - - } - - return self; -} - --(void)encodeWithCoder:(NSCoder *)aCoder { - [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; -} - - - -@end -@implementation TL_replyKeyboardForceReply -+(TL_replyKeyboardForceReply*)createWithFlags:(int)flags { - TL_replyKeyboardForceReply* obj = [[TL_replyKeyboardForceReply alloc] init]; - obj.flags = flags; - return obj; -} --(void)serialize:(SerializedData*)stream { - [stream writeInt:self.flags]; -} --(void)unserialize:(SerializedData*)stream { - self.flags = [stream readInt]; -} - --(TL_replyKeyboardForceReply *)copy { - - TL_replyKeyboardForceReply *objc = [[TL_replyKeyboardForceReply alloc] init]; - - objc.flags = self.flags; - - return objc; -} -(id)initWithCoder:(NSCoder *)aDecoder { @@ -17991,59 +22630,38 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end -@implementation TL_replyKeyboardMarkup -+(TL_replyKeyboardMarkup*)createWithFlags:(int)flags rows:(NSMutableArray*)rows { - TL_replyKeyboardMarkup* obj = [[TL_replyKeyboardMarkup alloc] init]; - obj.flags = flags; - obj.rows = rows; - return obj; -} --(void)serialize:(SerializedData*)stream { - [stream writeInt:self.flags]; - //Serialize FullVector - [stream writeInt:0x1cb5c415]; - { - NSInteger tl_count = [self.rows count]; - [stream writeInt:(int)tl_count]; - for(int i = 0; i < (int)tl_count; i++) { - TLKeyboardButtonRow* obj = [self.rows objectAtIndex:i]; - [ClassStore TLSerialize:obj stream:stream]; - } - } +@implementation TLhelp_TermsOfService + +@end + +@implementation TL_help_termsOfService ++(TL_help_termsOfService*)createWithText:(NSString*)text { + TL_help_termsOfService* obj = [[TL_help_termsOfService alloc] init]; + obj.text = text; + return obj; +} +-(void)serialize:(SerializedData*)stream { + [stream writeString:self.text]; } -(void)unserialize:(SerializedData*)stream { - self.flags = [stream readInt]; - //UNS FullVector - [stream readInt]; - { - if(!self.rows) - self.rows = [[NSMutableArray alloc] init]; - int count = [stream readInt]; - for(int i = 0; i < count; i++) { - TLKeyboardButtonRow* obj = [ClassStore TLDeserialize:stream]; - if(obj != nil && [obj isKindOfClass:[TLKeyboardButtonRow class]]) - [self.rows addObject:obj]; - else - break; - } - } + super.text = [stream readString]; } --(TL_replyKeyboardMarkup *)copy { +-(TL_help_termsOfService *)copy { - TL_replyKeyboardMarkup *objc = [[TL_replyKeyboardMarkup alloc] init]; + TL_help_termsOfService *objc = [[TL_help_termsOfService alloc] init]; - objc.flags = self.flags; - objc.rows = [self.rows copy]; + objc.text = self.text; return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -18057,16 +22675,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLProtoMessage -@end +@end + @implementation TL_proto_message +(TL_proto_message*)createWithMsg_id:(long)msg_id seqno:(int)seqno bytes:(int)bytes body:(TLObject*)body { TL_proto_message* obj = [[TL_proto_message alloc] init]; @@ -18083,9 +22700,9 @@ -(void)serialize:(SerializedData*)stream { [ClassStore TLSerialize:self.body stream:stream]; } -(void)unserialize:(SerializedData*)stream { - self.msg_id = [stream readLong]; - self.seqno = [stream readInt]; - self.bytes = [stream readInt]; + super.msg_id = [stream readLong]; + super.seqno = [stream readInt]; + super.bytes = [stream readInt]; self.body = [ClassStore TLDeserialize:stream]; } @@ -18100,6 +22717,8 @@ -(TL_proto_message *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -18113,16 +22732,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLProtoMessageContainer -@end +@end + @implementation TL_msg_container +(TL_msg_container*)createWithMessages:(NSMutableArray*)messages { TL_msg_container* obj = [[TL_msg_container alloc] init]; @@ -18165,6 +22783,8 @@ -(TL_msg_container *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -18178,16 +22798,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLResPQ -@end +@end + @implementation TL_req_pq +(TL_req_pq*)createWithNonce:(NSData*)nonce { TL_req_pq* obj = [[TL_req_pq alloc] init]; @@ -18198,7 +22817,7 @@ -(void)serialize:(SerializedData*)stream { [stream writeData:self.nonce]; } -(void)unserialize:(SerializedData*)stream { - self.nonce = [stream readData:16]; + super.nonce = [stream readData:16]; } -(TL_req_pq *)copy { @@ -18209,6 +22828,8 @@ -(TL_req_pq *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -18222,7 +22843,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -18256,9 +22876,9 @@ -(void)serialize:(SerializedData*)stream { } } -(void)unserialize:(SerializedData*)stream { - self.nonce = [stream readData:16]; - self.server_nonce = [stream readData:16]; - self.pq = [stream readByteArray]; + super.nonce = [stream readData:16]; + super.server_nonce = [stream readData:16]; + super.pq = [stream readByteArray]; //UNS ShortVector [stream readInt]; { @@ -18283,6 +22903,8 @@ -(TL_resPQ *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -18296,16 +22918,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLServer_DH_inner_data -@end +@end + @implementation TL_server_DH_inner_data +(TL_server_DH_inner_data*)createWithNonce:(NSData*)nonce server_nonce:(NSData*)server_nonce g:(int)g dh_prime:(NSData*)dh_prime g_a:(NSData*)g_a server_time:(int)server_time { TL_server_DH_inner_data* obj = [[TL_server_DH_inner_data alloc] init]; @@ -18326,12 +22947,12 @@ -(void)serialize:(SerializedData*)stream { [stream writeInt:self.server_time]; } -(void)unserialize:(SerializedData*)stream { - self.nonce = [stream readData:16]; - self.server_nonce = [stream readData:16]; - self.g = [stream readInt]; - self.dh_prime = [stream readByteArray]; - self.g_a = [stream readByteArray]; - self.server_time = [stream readInt]; + super.nonce = [stream readData:16]; + super.server_nonce = [stream readData:16]; + super.g = [stream readInt]; + super.dh_prime = [stream readByteArray]; + super.g_a = [stream readByteArray]; + super.server_time = [stream readInt]; } -(TL_server_DH_inner_data *)copy { @@ -18347,6 +22968,8 @@ -(TL_server_DH_inner_data *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -18360,16 +22983,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLP_Q_inner_data -@end +@end + @implementation TL_p_q_inner_data +(TL_p_q_inner_data*)createWithPq:(NSData*)pq p:(NSData*)p q:(NSData*)q nonce:(NSData*)nonce server_nonce:(NSData*)server_nonce n_nonce:(NSData*)n_nonce { TL_p_q_inner_data* obj = [[TL_p_q_inner_data alloc] init]; @@ -18390,12 +23012,12 @@ -(void)serialize:(SerializedData*)stream { [stream writeData:self.n_nonce]; } -(void)unserialize:(SerializedData*)stream { - self.pq = [stream readByteArray]; - self.p = [stream readByteArray]; - self.q = [stream readByteArray]; - self.nonce = [stream readData:16]; - self.server_nonce = [stream readData:16]; - self.n_nonce = [stream readData:32]; + super.pq = [stream readByteArray]; + super.p = [stream readByteArray]; + super.q = [stream readByteArray]; + super.nonce = [stream readData:16]; + super.server_nonce = [stream readData:16]; + super.n_nonce = [stream readData:32]; } -(TL_p_q_inner_data *)copy { @@ -18411,6 +23033,8 @@ -(TL_p_q_inner_data *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -18424,16 +23048,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLServer_DH_Params -@end +@end + @implementation TL_req_DH_params +(TL_req_DH_params*)createWithNonce:(NSData*)nonce server_nonce:(NSData*)server_nonce p:(NSData*)p q:(NSData*)q public_key_fingerprint:(long)public_key_fingerprint encrypted_data:(NSData*)encrypted_data { TL_req_DH_params* obj = [[TL_req_DH_params alloc] init]; @@ -18454,12 +23077,12 @@ -(void)serialize:(SerializedData*)stream { [stream writeByteArray:self.encrypted_data]; } -(void)unserialize:(SerializedData*)stream { - self.nonce = [stream readData:16]; - self.server_nonce = [stream readData:16]; - self.p = [stream readByteArray]; - self.q = [stream readByteArray]; - self.public_key_fingerprint = [stream readLong]; - self.encrypted_data = [stream readByteArray]; + super.nonce = [stream readData:16]; + super.server_nonce = [stream readData:16]; + super.p = [stream readByteArray]; + super.q = [stream readByteArray]; + super.public_key_fingerprint = [stream readLong]; + super.encrypted_data = [stream readByteArray]; } -(TL_req_DH_params *)copy { @@ -18475,6 +23098,8 @@ -(TL_req_DH_params *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -18488,7 +23113,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -18508,9 +23132,9 @@ -(void)serialize:(SerializedData*)stream { [stream writeData:self.n_nonce_hash]; } -(void)unserialize:(SerializedData*)stream { - self.nonce = [stream readData:16]; - self.server_nonce = [stream readData:16]; - self.n_nonce_hash = [stream readData:16]; + super.nonce = [stream readData:16]; + super.server_nonce = [stream readData:16]; + super.n_nonce_hash = [stream readData:16]; } -(TL_server_DH_params_fail *)copy { @@ -18523,6 +23147,8 @@ -(TL_server_DH_params_fail *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -18536,7 +23162,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -18556,9 +23181,9 @@ -(void)serialize:(SerializedData*)stream { [stream writeByteArray:self.encrypted_answer]; } -(void)unserialize:(SerializedData*)stream { - self.nonce = [stream readData:16]; - self.server_nonce = [stream readData:16]; - self.encrypted_answer = [stream readByteArray]; + super.nonce = [stream readData:16]; + super.server_nonce = [stream readData:16]; + super.encrypted_answer = [stream readByteArray]; } -(TL_server_DH_params_ok *)copy { @@ -18571,6 +23196,8 @@ -(TL_server_DH_params_ok *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -18584,16 +23211,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLClient_DH_Inner_Data -@end +@end + @implementation TL_client_DH_inner_data +(TL_client_DH_inner_data*)createWithNonce:(NSData*)nonce server_nonce:(NSData*)server_nonce retry_id:(long)retry_id g_b:(NSData*)g_b { TL_client_DH_inner_data* obj = [[TL_client_DH_inner_data alloc] init]; @@ -18610,10 +23236,10 @@ -(void)serialize:(SerializedData*)stream { [stream writeByteArray:self.g_b]; } -(void)unserialize:(SerializedData*)stream { - self.nonce = [stream readData:16]; - self.server_nonce = [stream readData:16]; - self.retry_id = [stream readLong]; - self.g_b = [stream readByteArray]; + super.nonce = [stream readData:16]; + super.server_nonce = [stream readData:16]; + super.retry_id = [stream readLong]; + super.g_b = [stream readByteArray]; } -(TL_client_DH_inner_data *)copy { @@ -18627,6 +23253,8 @@ -(TL_client_DH_inner_data *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -18640,16 +23268,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLSet_client_DH_params_answer -@end +@end + @implementation TL_set_client_DH_params +(TL_set_client_DH_params*)createWithNonce:(NSData*)nonce server_nonce:(NSData*)server_nonce encrypted_data:(NSData*)encrypted_data { TL_set_client_DH_params* obj = [[TL_set_client_DH_params alloc] init]; @@ -18664,9 +23291,9 @@ -(void)serialize:(SerializedData*)stream { [stream writeByteArray:self.encrypted_data]; } -(void)unserialize:(SerializedData*)stream { - self.nonce = [stream readData:16]; - self.server_nonce = [stream readData:16]; - self.encrypted_data = [stream readByteArray]; + super.nonce = [stream readData:16]; + super.server_nonce = [stream readData:16]; + super.encrypted_data = [stream readByteArray]; } -(TL_set_client_DH_params *)copy { @@ -18679,6 +23306,8 @@ -(TL_set_client_DH_params *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -18692,7 +23321,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -18712,9 +23340,9 @@ -(void)serialize:(SerializedData*)stream { [stream writeData:self.n_nonce_hash1]; } -(void)unserialize:(SerializedData*)stream { - self.nonce = [stream readData:16]; - self.server_nonce = [stream readData:16]; - self.n_nonce_hash1 = [stream readData:16]; + super.nonce = [stream readData:16]; + super.server_nonce = [stream readData:16]; + super.n_nonce_hash1 = [stream readData:16]; } -(TL_dh_gen_ok *)copy { @@ -18727,6 +23355,8 @@ -(TL_dh_gen_ok *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -18740,7 +23370,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -18760,9 +23389,9 @@ -(void)serialize:(SerializedData*)stream { [stream writeData:self.n_nonce_hash2]; } -(void)unserialize:(SerializedData*)stream { - self.nonce = [stream readData:16]; - self.server_nonce = [stream readData:16]; - self.n_nonce_hash2 = [stream readData:16]; + super.nonce = [stream readData:16]; + super.server_nonce = [stream readData:16]; + super.n_nonce_hash2 = [stream readData:16]; } -(TL_dh_gen_retry *)copy { @@ -18775,6 +23404,8 @@ -(TL_dh_gen_retry *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -18788,7 +23419,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -18808,9 +23438,9 @@ -(void)serialize:(SerializedData*)stream { [stream writeData:self.n_nonce_hash3]; } -(void)unserialize:(SerializedData*)stream { - self.nonce = [stream readData:16]; - self.server_nonce = [stream readData:16]; - self.n_nonce_hash3 = [stream readData:16]; + super.nonce = [stream readData:16]; + super.server_nonce = [stream readData:16]; + super.n_nonce_hash3 = [stream readData:16]; } -(TL_dh_gen_fail *)copy { @@ -18823,6 +23453,8 @@ -(TL_dh_gen_fail *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -18836,16 +23468,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLPong -@end +@end + @implementation TL_ping +(TL_ping*)createWithPing_id:(long)ping_id { TL_ping* obj = [[TL_ping alloc] init]; @@ -18856,7 +23487,7 @@ -(void)serialize:(SerializedData*)stream { [stream writeLong:self.ping_id]; } -(void)unserialize:(SerializedData*)stream { - self.ping_id = [stream readLong]; + super.ping_id = [stream readLong]; } -(TL_ping *)copy { @@ -18867,6 +23498,8 @@ -(TL_ping *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -18880,7 +23513,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -18898,8 +23530,8 @@ -(void)serialize:(SerializedData*)stream { [stream writeLong:self.ping_id]; } -(void)unserialize:(SerializedData*)stream { - self.msg_id = [stream readLong]; - self.ping_id = [stream readLong]; + super.msg_id = [stream readLong]; + super.ping_id = [stream readLong]; } -(TL_pong *)copy { @@ -18911,6 +23543,8 @@ -(TL_pong *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -18924,16 +23558,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLBadMsgNotification -@end +@end + @implementation TL_bad_msg_notification +(TL_bad_msg_notification*)createWithBad_msg_id:(long)bad_msg_id bad_msg_seqno:(int)bad_msg_seqno error_code:(int)error_code { TL_bad_msg_notification* obj = [[TL_bad_msg_notification alloc] init]; @@ -18948,9 +23581,9 @@ -(void)serialize:(SerializedData*)stream { [stream writeInt:self.error_code]; } -(void)unserialize:(SerializedData*)stream { - self.bad_msg_id = [stream readLong]; - self.bad_msg_seqno = [stream readInt]; - self.error_code = [stream readInt]; + super.bad_msg_id = [stream readLong]; + super.bad_msg_seqno = [stream readInt]; + super.error_code = [stream readInt]; } -(TL_bad_msg_notification *)copy { @@ -18963,6 +23596,8 @@ -(TL_bad_msg_notification *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -18976,7 +23611,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -18998,10 +23632,10 @@ -(void)serialize:(SerializedData*)stream { [stream writeLong:self.new_server_salt]; } -(void)unserialize:(SerializedData*)stream { - self.bad_msg_id = [stream readLong]; - self.bad_msg_seqno = [stream readInt]; - self.error_code = [stream readInt]; - self.new_server_salt = [stream readLong]; + super.bad_msg_id = [stream readLong]; + super.bad_msg_seqno = [stream readInt]; + super.error_code = [stream readInt]; + super.new_server_salt = [stream readLong]; } -(TL_bad_server_salt *)copy { @@ -19015,6 +23649,8 @@ -(TL_bad_server_salt *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -19028,16 +23664,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLNewSession -@end +@end + @implementation TL_new_session_created +(TL_new_session_created*)createWithFirst_msg_id:(long)first_msg_id unique_id:(long)unique_id server_salt:(long)server_salt { TL_new_session_created* obj = [[TL_new_session_created alloc] init]; @@ -19052,9 +23687,9 @@ -(void)serialize:(SerializedData*)stream { [stream writeLong:self.server_salt]; } -(void)unserialize:(SerializedData*)stream { - self.first_msg_id = [stream readLong]; - self.unique_id = [stream readLong]; - self.server_salt = [stream readLong]; + super.first_msg_id = [stream readLong]; + super.unique_id = [stream readLong]; + super.server_salt = [stream readLong]; } -(TL_new_session_created *)copy { @@ -19067,6 +23702,8 @@ -(TL_new_session_created *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -19080,16 +23717,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLRpcResult -@end +@end + @implementation TL_rpc_result +(TL_rpc_result*)createWithReq_msg_id:(long)req_msg_id result:(TLObject*)result { TL_rpc_result* obj = [[TL_rpc_result alloc] init]; @@ -19102,7 +23738,7 @@ -(void)serialize:(SerializedData*)stream { [ClassStore TLSerialize:self.result stream:stream]; } -(void)unserialize:(SerializedData*)stream { - self.req_msg_id = [stream readLong]; + super.req_msg_id = [stream readLong]; self.result = [ClassStore TLDeserialize:stream]; } @@ -19115,6 +23751,8 @@ -(TL_rpc_result *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -19128,16 +23766,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLRpcError -@end +@end + @implementation TL_rpc_error +(TL_rpc_error*)createWithError_code:(int)error_code error_message:(NSString*)error_message { TL_rpc_error* obj = [[TL_rpc_error alloc] init]; @@ -19150,8 +23787,8 @@ -(void)serialize:(SerializedData*)stream { [stream writeString:self.error_message]; } -(void)unserialize:(SerializedData*)stream { - self.error_code = [stream readInt]; - self.error_message = [stream readString]; + super.error_code = [stream readInt]; + super.error_message = [stream readString]; } -(TL_rpc_error *)copy { @@ -19163,6 +23800,8 @@ -(TL_rpc_error *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -19176,16 +23815,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLRSAPublicKey -@end +@end + @implementation TL_rsa_public_key +(TL_rsa_public_key*)createWithN:(NSData*)n e:(NSData*)e { TL_rsa_public_key* obj = [[TL_rsa_public_key alloc] init]; @@ -19198,8 +23836,8 @@ -(void)serialize:(SerializedData*)stream { [stream writeByteArray:self.e]; } -(void)unserialize:(SerializedData*)stream { - self.n = [stream readByteArray]; - self.e = [stream readByteArray]; + super.n = [stream readByteArray]; + super.e = [stream readByteArray]; } -(TL_rsa_public_key *)copy { @@ -19211,6 +23849,8 @@ -(TL_rsa_public_key *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -19224,16 +23864,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLMsgsAck -@end +@end + @implementation TL_msgs_ack +(TL_msgs_ack*)createWithMsg_ids:(NSMutableArray*)msg_ids { TL_msgs_ack* obj = [[TL_msgs_ack alloc] init]; @@ -19277,6 +23916,8 @@ -(TL_msgs_ack *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -19290,16 +23931,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLRpcDropAnswer -@end +@end + @implementation TL_rpc_drop_answer +(TL_rpc_drop_answer*)createWithReq_msg_id:(long)req_msg_id { TL_rpc_drop_answer* obj = [[TL_rpc_drop_answer alloc] init]; @@ -19310,7 +23950,7 @@ -(void)serialize:(SerializedData*)stream { [stream writeLong:self.req_msg_id]; } -(void)unserialize:(SerializedData*)stream { - self.req_msg_id = [stream readLong]; + super.req_msg_id = [stream readLong]; } -(TL_rpc_drop_answer *)copy { @@ -19321,6 +23961,8 @@ -(TL_rpc_drop_answer *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -19334,7 +23976,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -19361,6 +24002,8 @@ -(TL_rpc_answer_unknown *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -19374,7 +24017,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -19401,6 +24043,8 @@ -(TL_rpc_answer_dropped_running *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -19414,7 +24058,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -19434,9 +24077,9 @@ -(void)serialize:(SerializedData*)stream { [stream writeInt:self.bytes]; } -(void)unserialize:(SerializedData*)stream { - self.msg_id = [stream readLong]; - self.seq_no = [stream readInt]; - self.bytes = [stream readInt]; + super.msg_id = [stream readLong]; + super.seq_no = [stream readInt]; + super.bytes = [stream readInt]; } -(TL_rpc_answer_dropped *)copy { @@ -19449,6 +24092,8 @@ -(TL_rpc_answer_dropped *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -19462,16 +24107,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLFutureSalts -@end +@end + @implementation TL_get_future_salts +(TL_get_future_salts*)createWithNum:(int)num { TL_get_future_salts* obj = [[TL_get_future_salts alloc] init]; @@ -19482,7 +24126,7 @@ -(void)serialize:(SerializedData*)stream { [stream writeInt:self.num]; } -(void)unserialize:(SerializedData*)stream { - self.num = [stream readInt]; + super.num = [stream readInt]; } -(TL_get_future_salts *)copy { @@ -19493,6 +24137,8 @@ -(TL_get_future_salts *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -19506,7 +24152,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -19535,8 +24180,8 @@ -(void)serialize:(SerializedData*)stream { } } -(void)unserialize:(SerializedData*)stream { - self.req_msg_id = [stream readLong]; - self.now = [stream readInt]; + super.req_msg_id = [stream readLong]; + super.now = [stream readInt]; //UNS ShortVector (custom class) //TODO { if(!self.salts) @@ -19562,6 +24207,8 @@ -(TL_future_salts *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -19575,16 +24222,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLFutureSalt -@end +@end + @implementation TL_future_salt +(TL_future_salt*)createWithValid_since:(int)valid_since valid_until:(int)valid_until salt:(long)salt { TL_future_salt* obj = [[TL_future_salt alloc] init]; @@ -19599,9 +24245,9 @@ -(void)serialize:(SerializedData*)stream { [stream writeLong:self.salt]; } -(void)unserialize:(SerializedData*)stream { - self.valid_since = [stream readInt]; - self.valid_until = [stream readInt]; - self.salt = [stream readLong]; + super.valid_since = [stream readInt]; + super.valid_until = [stream readInt]; + super.salt = [stream readLong]; } -(TL_future_salt *)copy { @@ -19614,6 +24260,8 @@ -(TL_future_salt *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -19627,16 +24275,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLDestroySessionRes -@end +@end + @implementation TL_destroy_session +(TL_destroy_session*)createWithSession_id:(long)session_id { TL_destroy_session* obj = [[TL_destroy_session alloc] init]; @@ -19647,7 +24294,7 @@ -(void)serialize:(SerializedData*)stream { [stream writeLong:self.session_id]; } -(void)unserialize:(SerializedData*)stream { - self.session_id = [stream readLong]; + super.session_id = [stream readLong]; } -(TL_destroy_session *)copy { @@ -19658,6 +24305,8 @@ -(TL_destroy_session *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -19671,7 +24320,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -19687,7 +24335,7 @@ -(void)serialize:(SerializedData*)stream { [stream writeLong:self.session_id]; } -(void)unserialize:(SerializedData*)stream { - self.session_id = [stream readLong]; + super.session_id = [stream readLong]; } -(TL_destroy_session_ok *)copy { @@ -19698,6 +24346,8 @@ -(TL_destroy_session_ok *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -19711,7 +24361,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -19727,7 +24376,7 @@ -(void)serialize:(SerializedData*)stream { [stream writeLong:self.session_id]; } -(void)unserialize:(SerializedData*)stream { - self.session_id = [stream readLong]; + super.session_id = [stream readLong]; } -(TL_destroy_session_none *)copy { @@ -19738,6 +24387,8 @@ -(TL_destroy_session_none *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -19751,16 +24402,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLProtoMessageCopy -@end +@end + @implementation TL_msg_copy +(TL_msg_copy*)createWithOrig_message:(TLProtoMessage*)orig_message { TL_msg_copy* obj = [[TL_msg_copy alloc] init]; @@ -19782,6 +24432,8 @@ -(TL_msg_copy *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -19795,7 +24447,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -19811,7 +24462,7 @@ -(void)serialize:(SerializedData*)stream { [stream writeByteArray:self.packed_data]; } -(void)unserialize:(SerializedData*)stream { - self.packed_data = [stream readByteArray]; + super.packed_data = [stream readByteArray]; } -(TL_gzip_packed *)copy { @@ -19822,6 +24473,8 @@ -(TL_gzip_packed *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -19835,16 +24488,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLHttpWait -@end +@end + @implementation TL_http_wait +(TL_http_wait*)createWithMax_delay:(int)max_delay wait_after:(int)wait_after max_wait:(int)max_wait { TL_http_wait* obj = [[TL_http_wait alloc] init]; @@ -19859,9 +24511,9 @@ -(void)serialize:(SerializedData*)stream { [stream writeInt:self.max_wait]; } -(void)unserialize:(SerializedData*)stream { - self.max_delay = [stream readInt]; - self.wait_after = [stream readInt]; - self.max_wait = [stream readInt]; + super.max_delay = [stream readInt]; + super.wait_after = [stream readInt]; + super.max_wait = [stream readInt]; } -(TL_http_wait *)copy { @@ -19874,6 +24526,8 @@ -(TL_http_wait *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -19887,16 +24541,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLMsgsStateReq -@end +@end + @implementation TL_msgs_state_req +(TL_msgs_state_req*)createWithMsg_ids:(NSMutableArray*)msg_ids { TL_msgs_state_req* obj = [[TL_msgs_state_req alloc] init]; @@ -19940,6 +24593,8 @@ -(TL_msgs_state_req *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -19953,16 +24608,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLMsgsStateInfo -@end +@end + @implementation TL_msgs_state_info +(TL_msgs_state_info*)createWithReq_msg_id:(long)req_msg_id info:(NSData*)info { TL_msgs_state_info* obj = [[TL_msgs_state_info alloc] init]; @@ -19975,8 +24629,8 @@ -(void)serialize:(SerializedData*)stream { [stream writeByteArray:self.info]; } -(void)unserialize:(SerializedData*)stream { - self.req_msg_id = [stream readLong]; - self.info = [stream readByteArray]; + super.req_msg_id = [stream readLong]; + super.info = [stream readByteArray]; } -(TL_msgs_state_info *)copy { @@ -19988,6 +24642,8 @@ -(TL_msgs_state_info *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -20001,16 +24657,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLMsgsAllInfo -@end +@end + @implementation TL_msgs_all_info +(TL_msgs_all_info*)createWithMsg_ids:(NSMutableArray*)msg_ids info:(NSData*)info { TL_msgs_all_info* obj = [[TL_msgs_all_info alloc] init]; @@ -20046,7 +24701,7 @@ -(void)unserialize:(SerializedData*)stream { [self.msg_ids addObject:@(obj)]; } } - self.info = [stream readByteArray]; + super.info = [stream readByteArray]; } -(TL_msgs_all_info *)copy { @@ -20058,6 +24713,8 @@ -(TL_msgs_all_info *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -20071,16 +24728,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLMsgDetailedInfo -@end +@end + @implementation TL_msg_detailed_info +(TL_msg_detailed_info*)createWithMsg_id:(long)msg_id answer_msg_id:(long)answer_msg_id bytes:(int)bytes status:(int)status { TL_msg_detailed_info* obj = [[TL_msg_detailed_info alloc] init]; @@ -20097,10 +24753,10 @@ -(void)serialize:(SerializedData*)stream { [stream writeInt:self.status]; } -(void)unserialize:(SerializedData*)stream { - self.msg_id = [stream readLong]; - self.answer_msg_id = [stream readLong]; - self.bytes = [stream readInt]; - self.status = [stream readInt]; + super.msg_id = [stream readLong]; + super.answer_msg_id = [stream readLong]; + super.bytes = [stream readInt]; + super.status = [stream readInt]; } -(TL_msg_detailed_info *)copy { @@ -20114,6 +24770,8 @@ -(TL_msg_detailed_info *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -20127,7 +24785,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @@ -20147,9 +24804,9 @@ -(void)serialize:(SerializedData*)stream { [stream writeInt:self.status]; } -(void)unserialize:(SerializedData*)stream { - self.answer_msg_id = [stream readLong]; - self.bytes = [stream readInt]; - self.status = [stream readInt]; + super.answer_msg_id = [stream readLong]; + super.bytes = [stream readInt]; + super.status = [stream readInt]; } -(TL_msg_new_detailed_info *)copy { @@ -20162,6 +24819,8 @@ -(TL_msg_new_detailed_info *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -20175,16 +24834,15 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - @end - @implementation TLMsgResendReq -@end +@end + @implementation TL_msg_resend_req +(TL_msg_resend_req*)createWithMsg_ids:(NSMutableArray*)msg_ids { TL_msg_resend_req* obj = [[TL_msg_resend_req alloc] init]; @@ -20228,6 +24886,8 @@ -(TL_msg_resend_req *)copy { return objc; } + + -(id)initWithCoder:(NSCoder *)aDecoder { @@ -20241,7 +24901,6 @@ -(id)initWithCoder:(NSCoder *)aDecoder { -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:[ClassStore serialize:self] forKey:@"data"]; } - diff --git a/TelegramTest/MainWindow.m b/TelegramTest/MainWindow.m index 025d6d1f..8053c30a 100644 --- a/TelegramTest/MainWindow.m +++ b/TelegramTest/MainWindow.m @@ -30,7 +30,11 @@ - (void)initialize { self.autoSaver.size = self.frame.size; } - self.rootViewController = [[MainViewController alloc] initWithFrame:((NSView *)self.contentView).bounds]; + MainViewController *mainController = [[MainViewController alloc] initWithFrame:((NSView *)self.contentView).bounds]; + + self.rootViewController = mainController; + + [self setNavigationController:mainController.rightViewController.navigationViewController]; self.styleMask |= NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask; @@ -72,9 +76,15 @@ -(void)windowWillStartLiveResize:(NSNotification *)notification { } +- (void)windowWillClose:(NSNotification *)notification { + // whichever operations are needed when the + // window is about to be closed +} + - (void)sendEvent:(NSEvent *)theEvent { [super sendEvent:theEvent]; + } @end diff --git a/TelegramTest/MapPanel.m b/TelegramTest/MapPanel.m index bf473e2e..2f6bab2d 100644 --- a/TelegramTest/MapPanel.m +++ b/TelegramTest/MapPanel.m @@ -164,8 +164,8 @@ - (id)init { [cancelButton setCursor:[NSCursor pointingHandCursor] forControlState:BTRControlStateHover]; [sendButton setCursor:[NSCursor pointingHandCursor] forControlState:BTRControlStateHover]; - [sendButton setTitleFont:[NSFont fontWithName:@"HelveticaNeue" size:13] forControlState:BTRControlStateNormal]; - [cancelButton setTitleFont:[NSFont fontWithName:@"HelveticaNeue" size:13] forControlState:BTRControlStateNormal]; + [sendButton setTitleFont:TGSystemFont(13) forControlState:BTRControlStateNormal]; + [cancelButton setTitleFont:TGSystemFont(13) forControlState:BTRControlStateNormal]; [cancelButton setTitleColor:BLUE_UI_COLOR forControlState:BTRControlStateNormal]; diff --git a/TelegramTest/MegagroupChatFilter.h b/TelegramTest/MegagroupChatFilter.h new file mode 100644 index 00000000..7961f2a9 --- /dev/null +++ b/TelegramTest/MegagroupChatFilter.h @@ -0,0 +1,13 @@ +// +// MegagroupChatFilter.h +// Telegram +// +// Created by keepcoder on 06/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "HistoryFilter.h" + +@interface MegagroupChatFilter : HistoryFilter + +@end diff --git a/TelegramTest/MegagroupChatFilter.m b/TelegramTest/MegagroupChatFilter.m new file mode 100644 index 00000000..971ae624 --- /dev/null +++ b/TelegramTest/MegagroupChatFilter.m @@ -0,0 +1,21 @@ +// +// MegagroupChatFilter.m +// Telegram +// +// Created by keepcoder on 06/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "MegagroupChatFilter.h" + +@implementation MegagroupChatFilter + +-(int)type { + return HistoryFilterChannelMessage | HistoryFilterNone; +} + ++(int)type { + return HistoryFilterChannelMessage | HistoryFilterNone; +} + +@end diff --git a/TelegramTest/MegagroupHistoryController.h b/TelegramTest/MegagroupHistoryController.h new file mode 100644 index 00000000..27960acd --- /dev/null +++ b/TelegramTest/MegagroupHistoryController.h @@ -0,0 +1,13 @@ +// +// MegagroupHistoryController.h +// Telegram +// +// Created by keepcoder on 06/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "ChannelHistoryController.h" + +@interface MegagroupHistoryController : ChatHistoryController + +@end diff --git a/TelegramTest/MegagroupHistoryController.m b/TelegramTest/MegagroupHistoryController.m new file mode 100644 index 00000000..f0dc43aa --- /dev/null +++ b/TelegramTest/MegagroupHistoryController.m @@ -0,0 +1,19 @@ +// +// MegagroupHistoryController.m +// Telegram +// +// Created by keepcoder on 06/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "MegagroupHistoryController.h" +#import "MegagroupChatFilter.h" +@interface MegagroupHistoryController () +@property (nonatomic,strong) MegagroupChatFilter *megagroupFilter; +@end + +@implementation MegagroupHistoryController + + + +@end diff --git a/TelegramTest/MessageInputGrowingTextView.h b/TelegramTest/MessageInputGrowingTextView.h index ae0829d4..9e9da9e9 100644 --- a/TelegramTest/MessageInputGrowingTextView.h +++ b/TelegramTest/MessageInputGrowingTextView.h @@ -8,6 +8,9 @@ #import "TMGrowingTextView.h" #import "SettingsArchiver.h" +#import "MessagesViewController.h" @interface MessageInputGrowingTextView : TMGrowingTextView +@property (nonatomic,weak) MessagesViewController *controller; + @end diff --git a/TelegramTest/MessageInputGrowingTextView.m b/TelegramTest/MessageInputGrowingTextView.m index 89258c9b..9fdcf47b 100644 --- a/TelegramTest/MessageInputGrowingTextView.m +++ b/TelegramTest/MessageInputGrowingTextView.m @@ -63,6 +63,14 @@ -(BOOL)performDragOperation:(id)sender { return NO; } +-(void)insertText:(id)insertString { + //lol. MessagesBottomView + if(!self.superview.superview.superview.superview.superview.isHidden) { + [super insertText:insertString]; + } + +} + -(NSDragOperation)draggingEntered:(id)sender { NSPasteboard *pst = [sender draggingPasteboard]; @@ -163,6 +171,8 @@ - (IBAction)paste:sender { } else { [super paste:sender]; + [self checkWebpages]; + return; } @@ -268,7 +278,7 @@ -(void)didChangeSettingsMask:(SettingsMask)mask { -(void)updateFont { - self.font = [NSFont fontWithName:@"HelveticaNeue" size:[SettingsArchiver checkMaskedSetting:BigFontSetting] ? 15 : 13]; + self.font = TGSystemFont([SettingsArchiver checkMaskedSetting:BigFontSetting] ? 15 : 13); [self textDidChange:nil]; [self setPlaceholderString:NSLocalizedString(@"Messages.SendPlaceholder", nil)]; } @@ -277,7 +287,6 @@ -(void)textDidChange:(NSNotification *)notification { [super textDidChange:notification]; - [self checkWebpages]; } @@ -392,46 +401,43 @@ -(NSParagraphStyle *)defaultParagraphStyle { -(void)keyDown:(NSEvent *)theEvent { - if([TGMentionPopup isVisibility] || [TGHashtagPopup isVisibility] || [TGBotCommandsPopup isVisibility]) { - - + TGMessagesHintView *hint = self.controller.hintView; + + + if(!hint.isHidden) { if(theEvent.keyCode == 125 || theEvent.keyCode == 126) { if(theEvent.keyCode == 125) { - [TGMentionPopup selectNext]; - [TGHashtagPopup selectNext]; - [TGBotCommandsPopup selectNext]; + [hint selectNext]; } else { - [TGMentionPopup selectPrev]; - [TGHashtagPopup selectPrev]; - [TGBotCommandsPopup selectPrev]; + [hint selectPrev]; } return; } + if([self isEnterEvent:theEvent] || [self isCommandEnterEvent:theEvent]) { BOOL result = [self.growingDelegate TMGrowingTextViewCommandOrControlPressed:self isCommandPressed:[self isCommandEnterEvent:theEvent]]; if(result) { - [TGMentionPopup performSelected]; - [TGHashtagPopup performSelected]; - [TGBotCommandsPopup performSelected]; + [hint performSelected]; return; } } - - - - } - [super keyDown:theEvent]; + //lol. MessagesBottomView + if(!self.superview.superview.superview.superview.superview.isHidden) { + [super keyDown:theEvent]; + } + + diff --git a/TelegramTest/MessageReplyContainer.m b/TelegramTest/MessageReplyContainer.m index 2476ffb6..7add0e10 100644 --- a/TelegramTest/MessageReplyContainer.m +++ b/TelegramTest/MessageReplyContainer.m @@ -31,30 +31,29 @@ -(id)initWithFrame:(NSRect)frameRect { self.nameTextField = [[TMHyperlinkTextField alloc] initWithFrame:NSMakeRect(15, NSHeight(frameRect) - 13, 200, 20)]; [self.nameTextField setBordered:NO]; - [self.nameTextField setFont:[NSFont fontWithName:@"HelveticaNeue-Medium" size:13]]; + [self.nameTextField setFont:TGSystemMediumFont(13)]; [self.nameTextField setDrawsBackground:NO]; + //[self.nameTextField setBackgroundColor:[NSColor redColor]]; [self addSubview:self.nameTextField]; self.dateField = [TMTextField defaultTextField]; [self.dateField setTextColor:GRAY_TEXT_COLOR]; - [self.dateField setFont:[NSFont fontWithName:@"HelveticaNeue" size:12]]; + [self.dateField setFont:TGSystemFont(12)]; // [self addSubview:self.dateField]; _messageField = [[TGCTextView alloc] initWithFrame:NSZeroRect]; + [_messageField setEditable:NO]; + [self.messageField setBackgroundColor:[NSColor whiteColor]]; [self.messageField setFrameOrigin:NSMakePoint(15, 0)]; - - [self addSubview:self.messageField]; - - self.thumbImageView = [[TGImageView alloc] initWithFrame:NSMakeRect(5, 1, NSHeight(self.frame) - 2, NSHeight(self.frame) - 2)]; self.thumbImageView.cornerRadius = 3; @@ -92,7 +91,7 @@ -(NSColor *)color { if(_replyObject.replyHeader.string.length == 0) { - return LINK_COLOR; + return BLUE_SEPARATOR_COLOR; } return [_replyObject.replyHeader attribute:NSForegroundColorAttributeName atIndex:0 effectiveRange:&range]; @@ -103,12 +102,13 @@ -(NSColor *)color { -(void)update { - int xOffset = _replyObject.replyThumb || _replyObject.geoURL ? 40 : 5; + int xOffset = _replyObject.replyThumb || _replyObject.geoURL ? 40 : 6; if(_replyObject.replyThumb) { [self addSubview:self.thumbImageView]; [self.thumbImageView setObject:_replyObject.replyThumb]; + [self.thumbImageView setFrameSize:_replyObject.replyThumb.imageSize]; } else { [self.thumbImageView removeFromSuperview]; } @@ -123,26 +123,21 @@ -(void)update { } [self.nameTextField setAttributedStringValue:[_replyObject replyHeader]]; + [self.nameTextField setFrameSize:NSMakeSize(NSWidth(self.frame) - NSMinX(self.messageField.frame),_replyObject.replyHeaderHeight)]; - [self.nameTextField setFrameOrigin:NSMakePoint(xOffset, NSMinY(self.nameTextField.frame))]; - + [self.nameTextField setFrameOrigin:NSMakePoint(xOffset, NSHeight(self.frame))]; - [self.messageField setFrameSize:NSMakeSize(NSWidth(self.frame) - NSMinX(self.messageField.frame), self.replyObject.replyHeight)]; - [self.messageField setAttributedString:_replyObject.replyText]; - + [self.messageField setFrameSize:NSMakeSize(NSWidth(self.frame) - NSMinX(self.messageField.frame), self.replyObject.replyHeight)]; [self.messageField setFrameOrigin:NSMakePoint(xOffset + 2, 0)]; - [_messageField setEditable:_deleteHandler == nil]; + // [_messageField setEditable:_deleteHandler == nil]; if(_deleteHandler != nil) { - - - _deleteImageView = [[NSImageView alloc] initWithFrame:NSMakeRect(NSWidth(self.frame) - image_CancelReply().size.width, NSHeight(self.frame) - image_CancelReply().size.height, image_CancelReply().size.width, image_CancelReply().size.height)]; _deleteImageView.image = image_CancelReply(); @@ -165,6 +160,8 @@ -(void)update { [self setNeedsDisplay:YES]; + [self setFrame:self.frame]; + } -(void)setFrame:(NSRect)frame { @@ -172,7 +169,7 @@ -(void)setFrame:(NSRect)frame { [self.messageField setFrameSize:NSMakeSize(NSWidth(self.frame) - NSMinX(self.messageField.frame), self.replyObject.replyHeight)]; - [self.nameTextField setFrameOrigin:NSMakePoint(NSMinX(self.nameTextField.frame), NSHeight(frame) - 13)]; + [self.nameTextField setFrameOrigin:NSMakePoint(NSMinX(self.nameTextField.frame), NSHeight(self.frame) - _replyObject.replyHeaderHeight + 6)]; } -(void)setBackgroundColor:(NSColor *)backgroundColor { @@ -184,15 +181,8 @@ -(void)setBackgroundColor:(NSColor *)backgroundColor { -(void)mouseUp:(NSEvent *)theEvent { if(!_deleteHandler) { - - // go to message - - if(_messageField.selectRange.location == NSNotFound) { - if([Telegram rightViewController].messagesViewController.state == MessagesViewControllerStateNone) - [[Telegram rightViewController].messagesViewController showMessage:_replyObject.replyMessage.n_id fromMsgId:_item.message.n_id]; - } - - + if(_item.table.viewController.state == MessagesViewControllerStateNone) + [_item.table.viewController showMessage:_replyObject.replyMessage fromMsg:_item.message flags:ShowMessageTypeReply]; } } diff --git a/TelegramTest/MessageSender.h b/TelegramTest/MessageSender.h index 4502d2ab..dc6b60ed 100644 --- a/TelegramTest/MessageSender.h +++ b/TelegramTest/MessageSender.h @@ -12,7 +12,7 @@ @interface MessageSender : NSObject -+(TL_localMessage *)createOutMessage:(NSString *)message media:(TLMessageMedia *)media conversation:(TL_conversation *)conversation; ++(TL_localMessage *)createOutMessage:(NSString *)msg media:(TLMessageMedia *)media conversation:(TL_conversation *)conversation ; +(int)getFutureMessageId; +(int)getFakeMessageId; +(void)drop; diff --git a/TelegramTest/MessageSender.m b/TelegramTest/MessageSender.m index 2c20999b..5c4196a1 100644 --- a/TelegramTest/MessageSender.m +++ b/TelegramTest/MessageSender.m @@ -54,10 +54,10 @@ +(void)compressVideo:(NSString *)path randomId:(long)randomId completeHandler:(v AVURLAsset *avAsset = [[AVURLAsset alloc] initWithURL:[NSURL fileURLWithPath:path] options:nil]; - AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:avAsset presetName:AVAssetExportPreset640x480]; - + AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:avAsset presetName:NSAppKitVersionNumber > NSAppKitVersionNumber10_10_Max ? AVAssetExportPresetMediumQuality : AVAssetExportPreset640x480]; + exportSession.shouldOptimizeForNetworkUse = YES; exportSession.outputURL = [NSURL fileURLWithPath:compressedPath]; exportSession.outputFileType = AVFileTypeMPEG4; // exportSession @@ -102,8 +102,9 @@ +(void)compressVideo:(NSString *)path randomId:(long)randomId completeHandler:(v [progressTimer invalidate]; progressTimer = nil; - if(!success) + if(!success || fileSize(path) < fileSize(compressedPath)) { + [[NSFileManager defaultManager] removeItemAtPath:compressedPath error:nil]; [[NSFileManager defaultManager] copyItemAtPath:path toPath:compressedPath error:nil]; } @@ -153,7 +154,7 @@ + (NSDictionary *)videoParams:(NSString *)path thumbSize:(NSSize)thumbSize { - NSSize size = NSMakeSize(MIN(640, [asset naturalSize].width), MIN(480,[asset naturalSize].height)); + NSSize size = strongsize([asset naturalSize], 640); return @{@"duration": @(duration), @"image":thumbImg, @"size":NSStringFromSize(size)}; } @@ -231,14 +232,22 @@ +(TL_localMessage *)createOutMessage:(NSString *)msg media:(TLMessageMedia *)med int flags = TGOUTMESSAGE; - if(!conversation.user.isBot) + if(!conversation.user.isBot && conversation.type != DialogTypeChannel) flags|=TGUNREADMESSAGE; if(reply_to_msg_id > 0) flags|=TGREPLYMESSAGE; + + + // channel from_id check this after update server side + flags|=TGFROMIDMESSAGE; + + + TL_localMessage *outMessage = [TL_localMessage createWithN_id:0 flags:flags from_id:UsersManager.currentUserId to_id:[conversation.peer peerOut] fwd_from_id:0 fwd_date:0 reply_to_msg_id:reply_to_msg_id date: (int) [[MTNetwork instance] getTime] message:message media:media fakeId:[MessageSender getFakeMessageId] randomId:rand_long() reply_markup:nil entities:nil views:1 isViewed:NO state:DeliveryStatePending]; + + - TL_localMessage *outMessage = [TL_localMessage createWithN_id:0 flags:flags from_id:UsersManager.currentUserId to_id:[conversation.peer peerOut] fwd_from_id:0 fwd_date:0 reply_to_msg_id:reply_to_msg_id date: (int) [[MTNetwork instance] getTime] message:message media:media fakeId:[MessageSender getFakeMessageId] randomId:rand_long() reply_markup:nil state:DeliveryStatePending]; if(webpage) { @@ -248,7 +257,7 @@ +(TL_localMessage *)createOutMessage:(NSString *)msg media:(TLMessageMedia *)med if(reply_to_msg_id != 0) { [[Storage manager] addSupportMessages:@[replyMessage]]; - [[MessagesManager sharedManager] addSupportMessages:@[replyMessage]]; + [MessagesManager addSupportMessages:@[replyMessage]]; } @@ -299,7 +308,7 @@ +(NSData *)getEncrypted:(EncryptedParams *)params messageData:(NSData *)messageD +(void)insertEncryptedServiceMessage:(NSString *)title chat:(TLEncryptedChat *)chat { - TL_localMessageService *msg = [TL_localMessageService createWithN_id:[MessageSender getFutureMessageId] flags:TGNOFLAGSMESSAGE from_id:chat.admin_id to_id:[TL_peerSecret createWithChat_id:chat.n_id] date:[[MTNetwork instance] getTime] action:[TL_messageActionEncryptedChat createWithTitle:title] fakeId:[MessageSender getFakeMessageId] randomId:rand_long() dstate:DeliveryStatePending]; + TL_localMessageService *msg = [TL_localMessageService createWithFlags:TGNOFLAGSMESSAGE n_id:[MessageSender getFutureMessageId] from_id:chat.admin_id to_id:[TL_peerSecret createWithChat_id:chat.n_id] date:[[MTNetwork instance] getTime] action:[TL_messageActionEncryptedChat createWithTitle:title] fakeId:[MessageSender getFakeMessageId] randomId:rand_long() dstate:DeliveryStatePending]; [MessagesManager addAndUpdateMessage:msg]; } @@ -368,7 +377,7 @@ +(void)startEncryptedChat:(TLUser *)user callback:(dispatch_block_t)callback { [params save]; - TL_conversation *dialog = [TL_conversation createWithPeer:[TL_peerSecret createWithChat_id:params.n_id] top_message:-1 unread_count:0 last_message_date:[[MTNetwork instance] getTime] notify_settings:[TL_peerNotifySettingsEmpty create] last_marked_message:0 top_message_fake:-1 last_marked_date:[[MTNetwork instance] getTime] sync_message_id:0 ]; + TL_conversation *dialog = [TL_conversation createWithPeer:[TL_peerSecret createWithChat_id:params.n_id] top_message:-1 unread_count:0 last_message_date:[[MTNetwork instance] getTime] notify_settings:[TL_peerNotifySettingsEmpty create] last_marked_message:0 top_message_fake:-1 last_marked_date:[[MTNetwork instance] getTime] sync_message_id:0 read_inbox_max_id:0 unread_important_count:0 lastMessage:nil]; [[DialogsManager sharedManager] insertDialog:dialog]; @@ -378,7 +387,7 @@ +(void)startEncryptedChat:(TLUser *)user callback:(dispatch_block_t)callback { dispatch_async(dispatch_get_main_queue(), ^{ if(callback) callback(); - [[Telegram sharedInstance] showMessagesFromDialog:dialog sender:self]; + [appWindow().navigationController showMessagesViewController:dialog]; }); } errorHandler:^(RPCRequest *request, RpcError *error) { diff --git a/TelegramTest/MessageSenderItem.h b/TelegramTest/MessageSenderItem.h index d5f32ae8..ca3e73c8 100644 --- a/TelegramTest/MessageSenderItem.h +++ b/TelegramTest/MessageSenderItem.h @@ -11,6 +11,6 @@ #import "SenderItem.h" @interface MessageSenderItem : SenderItem --(id)initWithMessage:(NSString *)message forConversation:(TL_conversation *)conversation noWebpage:(BOOL)noWebpage; +-(id)initWithMessage:(NSString *)message forConversation:(TL_conversation *)conversation noWebpage:(BOOL)noWebpage additionFlags:(int)additionFlags; @end diff --git a/TelegramTest/MessageSenderItem.m b/TelegramTest/MessageSenderItem.m index f0272137..133ab3f1 100644 --- a/TelegramTest/MessageSenderItem.m +++ b/TelegramTest/MessageSenderItem.m @@ -16,12 +16,24 @@ @interface MessageSenderItem () @implementation MessageSenderItem --(id)initWithMessage:(NSString *)message forConversation:(TL_conversation *)conversation noWebpage:(BOOL)noWebpage { +-(id)initWithMessage:(NSString *)message forConversation:(TL_conversation *)conversation noWebpage:(BOOL)noWebpage additionFlags:(int)additionFlags { if(self = [super initWithConversation:conversation]) { self.message = [MessageSender createOutMessage:message media:[TL_messageMediaEmpty create] conversation:conversation]; + NSMutableArray *entities = [NSMutableArray array]; + + self.message.message = [self parseEntities:self.message.message entities:entities backstrips:@"```"]; + + self.message.message = [self parseEntities:self.message.message entities:entities backstrips:@"`"]; + + self.message.entities = entities; + + if(additionFlags & (1 << 4)) + self.message.from_id = 0; + + if(noWebpage) self.message.media = [TL_messageMediaWebPage createWithWebpage:[TL_webPageEmpty createWithN_id:0]]; @@ -32,8 +44,8 @@ -(id)initWithMessage:(NSString *)message forConversation:(TL_conversation *)conv return self; } --(id)initWithMessage:(NSString *)message forConversation:(TL_conversation *)conversation { - if(self = [self initWithMessage:message forConversation:conversation noWebpage:YES]) { +-(id)initWithMessage:(NSString *)message forConversation:(TL_conversation *)conversation additionFlags:(int)additionFlags { + if(self = [self initWithMessage:message forConversation:conversation noWebpage:YES additionFlags:additionFlags]) { } @@ -49,14 +61,11 @@ -(void)performRequest { id request; + + if(self.conversation.type != DialogTypeBroadcast) { - int flags = self.message.reply_to_msg_id != 0 ? 1 : 0; - - flags|=[self.message.media.webpage isKindOfClass:[TL_webPageEmpty class]] ? 2 : 0; - - - request = [TLAPI_messages_sendMessage createWithFlags:flags peer:[self.conversation inputPeer] reply_to_msg_id:self.message.reply_to_msg_id message:[self.message message] random_id:[self.message randomId] reply_markup:[TL_replyKeyboardMarkup createWithFlags:0 rows:[@[]mutableCopy]]]; + request = [TLAPI_messages_sendMessage createWithFlags:[self senderFlags] peer:[self.conversation inputPeer] reply_to_msg_id:self.message.reply_to_msg_id message:[self.message message] random_id:[self.message randomId] reply_markup:[TL_replyKeyboardMarkup createWithFlags:0 rows:nil] entities:self.message.entities]; } else { TL_broadcast *broadcast = self.conversation.broadcast; @@ -64,27 +73,41 @@ -(void)performRequest { request = [TLAPI_messages_sendBroadcast createWithContacts:[broadcast inputContacts] random_id:[broadcast generateRandomIds] message:self.message.message media:[TL_inputMediaEmpty create]]; } - self.rpc_request = [RPCRequest sendRequest:request successHandler:^(RPCRequest *request, TL_messages_sentMessage * response) { + + self.rpc_request = [RPCRequest sendRequest:request successHandler:^(RPCRequest *request, TL_updateShortSentMessage *response) { - if(self.conversation.type != DialogTypeBroadcast) { + [self updateMessageId:response]; + + if([response isKindOfClass:[TL_updates class]]) { - self.message.n_id = response.n_id; - self.message.date = response.date; - self.message.media = response.media; + response = (TL_updateShortSentMessage *)[[self updateNewMessageWithUpdates:response] message]; } + if(self.conversation.type != DialogTypeBroadcast) { + self.message.n_id = response.n_id; + self.message.date = response.date; + self.message.media = response.media; + self.message.entities = response.entities; + } + self.message.dstate = DeliveryStateNormal; [self.message save:YES]; self.state = MessageSendingStateSent; + + if([self.message.media isKindOfClass:[TL_messageMediaWebPage class]]) { - [Notification perform:UPDATE_WEB_PAGE_ITEMS data:@{KEY_MESSAGE_ID_LIST:@[@(self.message.n_id)]}]; + [Notification perform:UPDATE_WEB_PAGE_ITEMS data:@{KEY_DATA:@{@(self.message.peer_id):@[@(self.message.n_id)]},KEY_WEBPAGE:self.message.media.webpage}]; + } + + if(self.message.entities.count > 0) { + [Notification perform:UPDATE_MESSAGE_ENTITIES data:@{KEY_MESSAGE:self.message}]; } @@ -95,9 +118,82 @@ -(void)performRequest { } +-(NSString *)parseEntities:(NSString *)message entities:(NSMutableArray *)entities backstrips:(NSString *)backstrips { + + NSRange startRange = [message rangeOfString:backstrips]; + + if(startRange.location != NSNotFound) { + + NSRange stopRange = [message rangeOfString:backstrips options:0 range:NSMakeRange(startRange.location + startRange.length, message.length - (startRange.location + startRange.length ))]; + + if(stopRange.location != NSNotFound) { + + TLMessageEntity *entity; + + if(backstrips.length == 3) { + entity = [TL_messageEntityPre createWithOffset:(int)startRange.location length:(int)(stopRange.location - startRange.location - startRange.length) language:@""]; + } else + entity = [TL_messageEntityCode createWithOffset:(int)startRange.location length:(int)(stopRange.location - startRange.location - startRange.length)]; + + [entities addObject:entity]; + + + + message = [message stringByReplacingOccurrencesOfString:backstrips withString:@"" options:0 range:NSMakeRange(startRange.location, stopRange.location + stopRange.length - startRange.location)]; + + if(message.length > 0) { + + + int others = 0; + if([[message substringToIndex:1] isEqualToString:@"\n"]) { + message = [message substringFromIndex:1]; + others = 1; + } + + + [entities enumerateObjectsUsingBlock:^(TLMessageEntity *obj, NSUInteger idx, BOOL * _Nonnull stop) { + + if(obj.offset > stopRange.location + stopRange.length) { + obj.offset-=((int)stopRange.length*2); + } + + if(obj.offset > 0) { + obj.offset-=others; + } + + }]; + + if([message rangeOfString:backstrips].location != NSNotFound) { + return [self parseEntities:message entities:entities backstrips:backstrips]; + } + } + + + + } + + + + } + + return message; + +} + -(void)resend { } +/* + self.message.message = @"Hello, world!"; + + NSMutableArray *items = [NSMutableArray array]; + + [items addObject:[TL_messageEntityBold createWithOffset:0 length:5]]; + [items addObject:[TL_messageEntityItalic createWithOffset:7 length:6]]; + + self.message.entities = items; + */ + @end diff --git a/TelegramTest/MessageSenderSecretItem.h b/TelegramTest/MessageSenderSecretItem.h index bd734367..7c3d838f 100644 --- a/TelegramTest/MessageSenderSecretItem.h +++ b/TelegramTest/MessageSenderSecretItem.h @@ -9,5 +9,5 @@ #import #import "SecretSenderItem.h" @interface MessageSenderSecretItem : SecretSenderItem --(id)initWithMessage:(NSString *)message forConversation:(TL_conversation *)conversation noWebpage:(BOOL)noWebpage; +-(id)initWithMessage:(NSString *)message forConversation:(TL_conversation *)conversation noWebpage:(BOOL)noWebpage additionFlags:(int)additionFlags; @end diff --git a/TelegramTest/MessageSenderSecretItem.m b/TelegramTest/MessageSenderSecretItem.m index 37a624f3..c82ac36c 100644 --- a/TelegramTest/MessageSenderSecretItem.m +++ b/TelegramTest/MessageSenderSecretItem.m @@ -32,7 +32,7 @@ -(id)initWithMessage:(NSString *)message forConversation:(TL_conversation *)conv return self; } --(id)initWithMessage:(NSString *)message forConversation:(TL_conversation *)conversation noWebpage:(BOOL)noWebpage { +-(id)initWithMessage:(NSString *)message forConversation:(TL_conversation *)conversation noWebpage:(BOOL)noWebpage additionFlags:(int)additionFlags { if(self = [self initWithMessage:message forConversation:conversation]) { } diff --git a/TelegramTest/MessageStateLayer.m b/TelegramTest/MessageStateLayer.m index 7f07ef72..17b5022c 100644 --- a/TelegramTest/MessageStateLayer.m +++ b/TelegramTest/MessageStateLayer.m @@ -8,6 +8,7 @@ #import "MessageStateLayer.h" #import "TMClockProgressView.h" +#import "NSNumber+NumberFormatter.h" @interface MessageStateLayer () @property (nonatomic,strong) TMClockProgressView *progressView; @property (nonatomic,strong) NSImageView *readOrSentView; @@ -15,6 +16,10 @@ @interface MessageStateLayer () @property (nonatomic,assign) MessageTableCellState state; +@property (nonatomic,strong) TMTextField *viewsCountText; + +@property (nonatomic,strong) NSImageView *channelImageView; + @end @implementation MessageStateLayer @@ -38,7 +43,7 @@ -(void)setState:(MessageTableCellState)state { if(state == MessageTableCellSending) { if(!self.progressView) { - self.progressView = [[TMClockProgressView alloc] initWithFrame:NSMakeRect(1, 4, 15, 15)]; + self.progressView = [[TMClockProgressView alloc] initWithFrame:NSMakeRect(NSWidth(self.frame) - 15- 3, 4, 15, 15)]; [self.layer addSublayer:self.progressView.layer]; } [self.progressView startAnimating]; @@ -52,7 +57,7 @@ -(void)setState:(MessageTableCellState)state { if(state == MessageTableCellSendingError) { if(!self.errorView) { - self.errorView = [[BTRButton alloc] initWithFrame:NSMakeRect(0, 2, image_ChatMessageError().size.width , image_ChatMessageError().size.height)]; + self.errorView = [[BTRButton alloc] initWithFrame:NSMakeRect(NSWidth(self.frame) - image_ChatMessageError().size.width - 3, 2, image_ChatMessageError().size.width , image_ChatMessageError().size.height)]; [self.errorView setBackgroundImage:image_ChatMessageError() forControlState:BTRControlStateNormal]; [self addSubview:self.errorView]; } @@ -70,27 +75,60 @@ -(void)setState:(MessageTableCellState)state { self.errorView = nil; } + [_viewsCountText removeFromSuperview]; + _viewsCountText = nil; + [_channelImageView removeFromSuperview]; - if(state == MessageTableCellUnread || state == MessageTableCellRead) { - - if(!self.readOrSentView) { - self.readOrSentView = [[NSImageView alloc] initWithFrame:NSMakeRect(1, 5, 0, 0)]; - self.readOrSentView.wantsLayer = YES; - } + if((state == MessageTableCellUnread || state == MessageTableCellRead)) { - self.readOrSentView.image = state == MessageTableCellUnread ? image_MessageStateSent() : image_MessageStateRead(); - [self.readOrSentView setFrameSize:self.readOrSentView.image.size]; - [self.readOrSentView setFrameOrigin:NSMakePoint(state == MessageTableCellUnread ? 2 : 1, NSMinY(self.readOrSentView.frame))]; - [self.layer addSublayer:self.readOrSentView.layer]; + if(self.container.item.message.from_id == 0 ) { + + self.readOrSentView.image = nil; + [self.readOrSentView.layer removeFromSuperlayer]; + self.readOrSentView = nil; + + _viewsCountText = [TMTextField defaultTextField]; + [_viewsCountText setFont:TGSystemFont(12)]; + [_viewsCountText setTextColor:GRAY_TEXT_COLOR]; + [_viewsCountText setStringValue:self.container.item.viewsCount]; + [_viewsCountText sizeToFit]; + [_viewsCountText setFrameOrigin:CGPointMake(NSWidth(self.frame) - NSWidth(_viewsCountText.frame) - 2,2)]; + [self addSubview:_viewsCountText]; + + + _channelImageView = imageViewWithImage(image_ChannelViews()); + + [_channelImageView setFrameOrigin:NSMakePoint(NSMinX(_viewsCountText.frame) - NSWidth(_channelImageView.frame), 5)]; + + [self addSubview:_channelImageView]; + } else { + if(!self.readOrSentView) { + self.readOrSentView = [[NSImageView alloc] initWithFrame:NSMakeRect(11, 5, 0, 0)]; + self.readOrSentView.wantsLayer = YES; + } + + self.readOrSentView.image = state == MessageTableCellUnread ? image_MessageStateSent() : image_MessageStateRead(); + [self.readOrSentView setFrameSize:self.readOrSentView.image.size]; + [self.readOrSentView setFrameOrigin:NSMakePoint(NSWidth(self.frame) - NSWidth(_readOrSentView.frame) - 3, NSMinY(self.readOrSentView.frame))]; + [self.layer addSublayer:self.readOrSentView.layer]; + } + } else { self.readOrSentView.image = nil; [self.readOrSentView.layer removeFromSuperlayer]; self.readOrSentView = nil; + + } + + [self setNeedsDisplay:YES]; + } + + @end diff --git a/TelegramTest/MessageTableCell.h b/TelegramTest/MessageTableCell.h index b6f56fae..b3780bf3 100644 --- a/TelegramTest/MessageTableCell.h +++ b/TelegramTest/MessageTableCell.h @@ -13,8 +13,8 @@ @interface MessageTableCell : NSView -@property (nonatomic, strong) MessageTableItem *item; -@property (nonatomic, strong) MessagesViewController *messagesViewController; +@property (nonatomic, weak) MessageTableItem *item; +@property (nonatomic, weak) MessagesViewController *messagesViewController; - (void)setHover:(BOOL)isHover redraw:(BOOL)redraw; - (void)setItem:(MessageTableItem *)item; diff --git a/TelegramTest/MessageTableCell.m b/TelegramTest/MessageTableCell.m index 351288e0..dfb2fcbf 100644 --- a/TelegramTest/MessageTableCell.m +++ b/TelegramTest/MessageTableCell.m @@ -8,6 +8,7 @@ #import "MessageTableCell.h" #import "MessageTableCellTextView.h" +#import "TGMessageViewSender.h" @interface MessageTableCell() @end @@ -27,14 +28,23 @@ - (id)initWithFrame:(NSRect)frameRect { - (void)setItem:(MessageTableItem *)item { self->_item = item; - if(item.message.dstate != DeliveryStateNormal && item.messageSender == nil) { + if(item.message && ( item.message.dstate != DeliveryStateNormal && item.messageSender == nil )) { item.messageSender = [SenderItem senderForMessage:item.message]; + item.messageSender.tableItem = item; if(item.messageSender.state == MessageStateWaitSend) { [item.messageSender send]; } } + if(item.message.isChannelMessage && item.message.from_id == 0 && !item.message.isViewed) { + if(![item.message isKindOfClass:[TL_localMessageService class]]) { + item.message.viewed = YES; + [TGMessageViewSender addItem:item]; + } + + } + } - (void)resizeAndRedraw { @@ -85,12 +95,17 @@ -(NSArray *)defaultMenuItems { NSMutableArray *items = [[NSMutableArray alloc] init]; - if(self.item.message.to_id.class == [TL_peerChat class] || self.item.message.to_id.class == [TL_peerUser class]) { - [items addObject:[NSMenuItem menuItemWithTitle:NSLocalizedString(@"Context.Reply", nil) withBlock:^(id sender) { - - [[Telegram rightViewController].messagesViewController addReplayMessage:self.item.message animated:YES]; - - }]]; + if(self.item.message.to_id.class == [TL_peerChannel class] || self.item.message.to_id.class == [TL_peerChat class] || self.item.message.to_id.class == [TL_peerUser class] ) { + + if([self.item.message.conversation canSendMessage]) { + [items addObject:[NSMenuItem menuItemWithTitle:NSLocalizedString(@"Context.Reply", nil) withBlock:^(id sender) { + + [_messagesViewController addReplayMessage:self.item.message animated:YES]; + + }]]; + } + + } if([self.item canShare]) { @@ -121,34 +136,33 @@ -(NSArray *)defaultMenuItems { if(self.item.message.conversation.type != DialogTypeSecretChat) { [items addObject:[NSMenuItem menuItemWithTitle:NSLocalizedString(@"Context.Forward", nil) withBlock:^(id sender) { - [[Telegram rightViewController].messagesViewController setState:MessagesViewControllerStateNone]; - [[Telegram rightViewController].messagesViewController unSelectAll:NO]; + [_messagesViewController setState:MessagesViewControllerStateNone]; + [_messagesViewController unSelectAll:NO]; - [[Telegram rightViewController].messagesViewController setSelectedMessage:self.item selected:YES]; + [_messagesViewController setSelectedMessage:self.item selected:YES]; - [[Telegram rightViewController] showForwardMessagesModalView:[Telegram rightViewController].messagesViewController.conversation messagesCount:1]; + [[Telegram rightViewController] showForwardMessagesModalView:_messagesViewController.conversation messagesCount:1]; }]]; } - - [items addObject:[NSMenuItem menuItemWithTitle:NSLocalizedString(@"Context.Delete", nil) withBlock:^(id sender) { - - [[Telegram rightViewController].messagesViewController setState:MessagesViewControllerStateNone]; - [[Telegram rightViewController].messagesViewController unSelectAll:NO]; - - [[Telegram rightViewController].messagesViewController setSelectedMessage:self.item selected:YES]; - - [[Telegram rightViewController].messagesViewController deleteSelectedMessages]; - - - }]]; - - + if([MessagesViewController canDeleteMessages:@[self.item.message] inConversation:self.item.message.conversation]) { + [items addObject:[NSMenuItem menuItemWithTitle:NSLocalizedString(@"Context.Delete", nil) withBlock:^(id sender) { + + [_messagesViewController setState:MessagesViewControllerStateNone]; + [_messagesViewController unSelectAll:NO]; + + [_messagesViewController setSelectedMessage:self.item selected:YES]; + + [_messagesViewController deleteSelectedMessages]; + + + }]]; + } return items; @@ -159,8 +173,10 @@ -(void)mouseDown:(NSEvent *)theEvent { BOOL accept = ![self mouseInText:theEvent];; + MTLog(@"message_id:%d",self.item.message.n_id); + if(accept && self.item.message.n_id < TGMINFAKEID && self.item.message.n_id > 0) - [[Telegram rightViewController].messagesViewController addReplayMessage:self.item.message animated:YES]; + [_messagesViewController addReplayMessage:self.item.message animated:YES]; } diff --git a/TelegramTest/MessageTableCellAudioView.m b/TelegramTest/MessageTableCellAudioView.m index f462e9f0..787c3ef0 100644 --- a/TelegramTest/MessageTableCellAudioView.m +++ b/TelegramTest/MessageTableCellAudioView.m @@ -79,7 +79,7 @@ - (id)initWithFrame:(NSRect)frame { [self.durationView setDrawsBackground:NO]; [self.durationView setStringValue:@"00:00 / 00:00"]; [self.durationView sizeToFit]; - [self.durationView setFont:[NSFont fontWithName:@"HelveticaNeue" size:12]]; + [self.durationView setFont:TGSystemFont(12)]; [self.durationView setTextColor:NSColorFromRGB(0xbebebe)]; [self.containerView addSubview:self.durationView]; @@ -89,7 +89,7 @@ - (id)initWithFrame:(NSRect)frame { [self.stateTextField setBordered:NO]; [self.stateTextField setEditable:NO]; [self.stateTextField setDrawsBackground:NO]; - [self.stateTextField setFont:[NSFont fontWithName:@"HelveticaNeue" size:12]]; + [self.stateTextField setFont:TGSystemFont(12)]; [self.stateTextField setTextColor:NSColorFromRGB(0xbebebe)]; @@ -167,7 +167,7 @@ -(void)drawRect:(NSRect)dirtyRect { NSBezierPath *path = [NSBezierPath bezierPath]; - [path appendBezierPathWithRoundedRect:NSMakeRect(NSMinX(self.containerView.frame) + NSWidth(self.durationView.frame) + 3, NSMinY(self.containerView.frame) + NSMinY(self.durationView.frame) + 2, 6, 6) xRadius:3 yRadius:3]; + [path appendBezierPathWithRoundedRect:NSMakeRect(NSMinX(self.containerView.frame) + NSWidth(self.durationView.frame) + 3, NSMinY(self.containerView.frame) + NSMinY(self.durationView.frame) + 4, 6, 6) xRadius:3 yRadius:3]; [path fill]; } @@ -191,7 +191,7 @@ - (void)setCellState:(CellState)cellState { } if(cellState == CellStateSending) { - [self.stateTextField setHidden:NO]; + [self.stateTextField setHidden:self.item.message.fwd_from_id == nil]; } if(cellState == CellStateNeedDownload) { @@ -263,6 +263,8 @@ - (void)setItem:(MessageTableItemAudio *)item { [self.durationView setStringValue:item.duration]; + [self.durationView setFrameSize:NSMakeSize(80, NSHeight(self.durationView.frame))]; + if(item.state != AudioStatePlaying && item.state != AudioStatePaused) [self updateCellState]; else { diff --git a/TelegramTest/MessageTableCellContactView.m b/TelegramTest/MessageTableCellContactView.m index 0993fb06..1dcf9915 100644 --- a/TelegramTest/MessageTableCellContactView.m +++ b/TelegramTest/MessageTableCellContactView.m @@ -37,7 +37,7 @@ - (id)initWithFrame:(NSRect)frame { self.titleTextButton = [[TMTextButton alloc] init]; [[self.titleTextButton cell] setTruncatesLastVisibleLine:YES]; [[self.titleTextButton cell] setLineBreakMode:NSLineBreakByTruncatingTail]; - [self.titleTextButton setFont:[NSFont fontWithName:@"HelveticaNeue" size:12]]; + [self.titleTextButton setFont:TGSystemFont(12)]; [self.titleTextButton setTextColor:LINK_COLOR]; [self.titleTextButton setTapBlock:block]; [self.titleTextButton setFrameOrigin:NSMakePoint(self.contactImageView.bounds.size.width + 10, 20)]; @@ -47,7 +47,7 @@ - (id)initWithFrame:(NSRect)frame { [self.phoneNumberTextView setDrawsBackground:NO]; [self.phoneNumberTextView setEditable:NO]; [self.phoneNumberTextView setFrameOrigin:NSMakePoint(self.contactImageView.bounds.size.width + 8, -3)]; - [self.phoneNumberTextView setFont:[NSFont fontWithName:@"HelveticaNeue" size:12]]; + [self.phoneNumberTextView setFont:TGSystemFont(12)]; [self.containerView addSubview:self.phoneNumberTextView]; self.addButton = [[TMBlueAddButtonView alloc] initWithFrame:NSMakeRect(0, 0, 60, 25)]; @@ -63,7 +63,7 @@ - (void)setItem:(MessageTableItemContact *)item { [super setItem:item]; self.titleTextButton.stringValue = item.contactName; - [self.titleTextButton sizeToFit]; + [self.titleTextButton setFrameSize:item.contactNameSize]; NSPoint point = self.phoneNumberTextView.frame.origin; @@ -74,6 +74,8 @@ - (void)setItem:(MessageTableItemContact *)item { [self.phoneNumberTextView setFrameOrigin:point]; + + if(item.contactUser) { [self.contactImageView setUser:item.contactUser]; } else { @@ -93,7 +95,7 @@ - (void)setItem:(MessageTableItemContact *)item { if(!self.addButton.superview) { [self.addButton setString:NSLocalizedString(@"Messages.AddContact", nil)]; [self.containerView addSubview:self.addButton]; - [self.addButton setFrameOrigin:NSMakePoint(self.phoneNumberTextView.frame.origin.x + self.phoneNumberTextView.frame.size.width + 0, 4)]; + [self.addButton setFrameOrigin:NSMakePoint(MAX(NSMaxX(self.phoneNumberTextView.frame),NSMaxX(_titleTextButton.frame)) + 0, 4)]; } } diff --git a/TelegramTest/MessageTableCellContainerView.m b/TelegramTest/MessageTableCellContainerView.m index 31784a4f..6140345e 100644 --- a/TelegramTest/MessageTableCellContainerView.m +++ b/TelegramTest/MessageTableCellContainerView.m @@ -16,6 +16,8 @@ #import "MessageReplyContainer.h" #import "POPCGUtils.h" #import "MessagesBottomView.h" +#import "TGHeadChatPanel.h" +#import "TGModalForwardView.h" @interface MessageTableCellContainerView() @property (nonatomic, strong) TMHyperlinkTextField *nameTextField; @property (nonatomic, strong) BTRImageView *sendImageView; @@ -28,7 +30,7 @@ @interface MessageTableCellContainerView() @property (nonatomic, strong) NSView *rightView; @property (nonatomic, strong) TMTextLayer *forwardMessagesTextLayer; -@property (nonatomic, strong) TMTextLayer *dateLayer; +@property (nonatomic, strong) TMTextField *dateLayer; @property (nonatomic, strong) BTRButton *selectButton; @property (nonatomic, strong) MessageStateLayer *stateLayer; @@ -36,6 +38,13 @@ @interface MessageTableCellContainerView() @property (nonatomic, strong) MessageReplyContainer *replyContainer; +@property (nonatomic,strong) DownloadEventListener *downloadEventListener; + + +@property (nonatomic,strong) NSImageView *shareImageView; + +@property (nonatomic,strong) TGModalForwardView *forwardModalView; + @end @@ -51,6 +60,13 @@ - (id)initWithFrame:(NSRect)frame { assert(self.layer != nil); + + self.containerView = [[TMView alloc] initWithFrame:NSZeroRect]; + [self.containerView setWantsLayer:YES]; + [self.containerView setAutoresizingMask:NSViewWidthSizable]; + [self.containerView setFrameSize:NSMakeSize(self.bounds.size.width - 160, self.bounds.size.height)]; + [self addSubview:self.containerView]; + self.rightView = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 100, 20)]; [self.rightView setLayer:[CALayer layer]]; [self.rightView.layer disableActions]; @@ -60,27 +76,21 @@ - (id)initWithFrame:(NSRect)frame { - self.dateLayer = [TMTextLayer layer]; - [self.dateLayer disableActions]; - [self.dateLayer setContentsScale:self.layer.contentsScale]; - [self.dateLayer setFrameOrigin:CGPointMake(offserUnreadMark, 0)]; + self.dateLayer = [TMTextField defaultTextField]; + + [self.dateLayer setFrameOrigin:CGPointMake(offserUnreadMark, 2)]; [self.dateLayer setTextColor:GRAY_TEXT_COLOR]; - [self.dateLayer setTextFont:[NSFont fontWithName:@"HelveticaNeue" size:12]]; - [self.dateLayer setBackgroundColor:[NSColor clearColor].CGColor]; - [self.rightView.layer addSublayer:self.dateLayer]; - + [self.dateLayer setFont:TGSystemFont(12)]; + [self.rightView addSubview:self.dateLayer]; - self.stateLayer = [[MessageStateLayer alloc] initWithFrame:NSMakeRect(0, 0, 20, NSHeight(self.rightView.frame))]; + self.stateLayer = [[MessageStateLayer alloc] initWithFrame:NSMakeRect(0, 0, 60, NSHeight(self.rightView.frame))]; + [self.rightView addSubview:self.stateLayer]; - self.containerView = [[TMView alloc] initWithFrame:NSZeroRect]; - [self.containerView setWantsLayer:YES]; - [self.containerView setAutoresizingMask:NSViewWidthSizable]; - [self.containerView setFrameSize:NSMakeSize(self.bounds.size.width - 160, self.bounds.size.height)]; - [self addSubview:self.containerView]; + if(![self isKindOfClass:[MessageTableCellTextView class]] && ![self isKindOfClass:[MessageTableCellGeoView class]]) { @@ -108,22 +118,23 @@ -(void)initForwardContainer { [self.forwardMessagesTextLayer setFrameSize:NSMakeSize(180, 20)]; [self.forwardMessagesTextLayer setContentsScale:self.layer.contentsScale]; [self.forwardMessagesTextLayer setTextColor:NSColorFromRGB(0x9b9b9b)]; - [self.forwardMessagesTextLayer setTextFont:[NSFont fontWithName:@"HelveticaNeue" size:13]]; + [self.forwardMessagesTextLayer setTextFont:TGSystemFont(13)]; [self.forwardMessagesTextLayer setString:NSLocalizedString(@"Messages.ForwardedMessages",nil)]; [self.layer addSublayer:self.forwardMessagesTextLayer]; } if(!self.fwdContainer) { - self.fwdContainer = [[TMView alloc] initWithFrame:NSMakeRect(68, 0, self.bounds.size.width - 130, self.bounds.size.height)]; + self.fwdContainer = [[TMView alloc] initWithFrame:NSMakeRect(self.item.containerOffset +1, 0, self.bounds.size.width - 130, self.bounds.size.height )]; + [self.fwdContainer setDrawBlock:^{ - [GRAY_BORDER_COLOR set]; + [BLUE_SEPARATOR_COLOR set]; - float offset = weakSelf.item.isHeaderMessage ? 26 : 0; + float offset = weakSelf.item.isHeaderMessage ? weakSelf.item.isHeaderForwardedMessage ? 50 : 20 : weakSelf.item.isHeaderForwardedMessage ? 24 : 0; if(weakSelf.item.isHeaderForwardedMessage) { - NSRectFill(NSMakeRect(0, 0, 2, weakSelf.fwdContainer.bounds.size.height - offset - 32)); + NSRectFill(NSMakeRect(0, 0, 2, weakSelf.fwdContainer.bounds.size.height - offset )); } else { - NSRectFill(NSMakeRect(0, 0, 2, weakSelf.fwdContainer.bounds.size.height - offset)); + NSRectFill(NSMakeRect(0, 0, 2, weakSelf.fwdContainer.bounds.size.height)); } }]; @@ -140,14 +151,6 @@ -(void)initForwardContainer { [self.fwdContainer addSubview:self.fwdName]; } - if(!self.fwdAvatar) { - self.fwdAvatar = [TMAvatarImageView standartMessageTableAvatar]; - [self.fwdAvatar setTapBlock:^{ - [[Telegram sharedInstance] showUserInfoWithUserId:weakSelf.item.fwd_user.n_id conversation:weakSelf.item.fwd_user.dialog sender:weakSelf]; - }]; - [self.fwdContainer addSubview:self.fwdAvatar]; - } - } @@ -225,7 +228,10 @@ -(void)initHeader { [self.avatarImageView setTapBlock:^{ - [[Telegram sharedInstance] showUserInfoWithUserId:weakSelf.item.user.n_id conversation:weakSelf.item.user.dialog sender:weakSelf]; + + [appWindow().navigationController showInfoPage:weakSelf.item.user.dialog]; + + // }]; [self addSubview:self.avatarImageView]; } @@ -233,12 +239,15 @@ -(void)initHeader { if(!self.nameTextField) { self.nameTextField = [[TMHyperlinkTextField alloc] initWithFrame:NSMakeRect(0, 0, 200, 20)]; [self.nameTextField setBordered:NO]; - [self.nameTextField setFont:[NSFont fontWithName:@"HelveticaNeue-Medium" size:13]]; + [self.nameTextField setFont:TGSystemMediumFont(13)]; [self.nameTextField setDrawsBackground:NO]; [self addSubview:self.nameTextField]; } + + [_avatarImageView setHidden:NO]; + [_nameTextField setHidden:NO]; } @@ -269,7 +278,7 @@ -(void)checkOperation { return; } - if(self.progressView.state == TMLoaderViewStateNeedDownload) { + if(self.cellState == CellStateNeedDownload && ![self.item isset]) { [self startDownload:YES]; return; } @@ -277,6 +286,9 @@ -(void)checkOperation { if([self.item isset]) { [self open]; return; + } else { + [self updateCellState]; + [self checkOperation]; } } @@ -352,6 +364,8 @@ - (void)searchSelection { [self.layer setBackgroundColor:(self.isSelected ? NSColorFromRGB(0xf7f7f7) : NSColorFromRGB(0xffffff)).CGColor]; }]; + animation.removedOnCompletion = YES; + [self _didChangeBackgroundColorWithAnimation:animation toColor:color]; [self.layer pop_addAnimation:animation forKey:@"background"]; @@ -367,14 +381,17 @@ - (void)stopSearchSelection { - (void)setSelected:(BOOL)isSelected animation:(BOOL)animation { + if(self.isSelected == isSelected) + return; + + if([self isEditable]) [self initSelectButton]; else [self deallocSelectButton]; - if(self.isSelected == isSelected) - return; + self.item.isSelected = isSelected; @@ -433,6 +450,7 @@ - (void)setSelected:(BOOL)isSelected animation:(BOOL)animation { animation.fromValue = (__bridge id)(oldColor.CGColor); animation.toValue = (__bridge id)(color.CGColor); animation.duration = 0.2; + animation.removedOnCompletion = YES; [self _didChangeBackgroundColorWithAnimation:animation toColor:color]; [self.layer pop_addAnimation:animation forKey:@"background"]; @@ -507,7 +525,7 @@ - (void)mouseDown:(NSEvent *)theEvent { NSPoint pos = [self convertPoint:[theEvent locationInWindow] fromView:nil]; if(NSPointInRect(pos, self.rightView.frame)) { - if(self.messagesViewController.bottomView.stateBottom == MessagesBottomViewNormalState) { + if(self.messagesViewController.state == MessagesViewControllerStateNone) { [self.messagesViewController setCellsEditButtonShow:self.messagesViewController.state != MessagesViewControllerStateEditable animated:YES]; [self mouseDown:theEvent]; @@ -615,8 +633,6 @@ - (void)setItem:(MessageTableItem *)item { [super setItem:item]; - - [self.progressView setCurrentProgress:0]; self.stateLayer.container = self; @@ -625,13 +641,15 @@ - (void)setItem:(MessageTableItem *)item { [self initForwardContainer]; + [_fwdContainer setFrame:NSMakeRect(self.item.containerOffset, 0, self.bounds.size.width - 130, self.bounds.size.height )]; + float minus = 0; if(self.item.isHeaderForwardedMessage) { minus = FORWARMESSAGE_TITLE_HEIGHT; - float minus = item.isHeaderMessage ? 30 : 12; - [self.forwardMessagesTextLayer setFrameOrigin:CGPointMake(80, item.viewSize.height - self.forwardMessagesTextLayer.frame.size.height - minus)]; + float minus = item.isHeaderMessage ? 30 : 5; + [self.forwardMessagesTextLayer setFrameOrigin:CGPointMake(item.containerOffset+1, item.viewSize.height - self.forwardMessagesTextLayer.frame.size.height - minus)]; [CATransaction begin]; [CATransaction setDisableActions:YES]; @@ -644,18 +662,13 @@ - (void)setItem:(MessageTableItem *)item { [CATransaction commit]; } - - [self.fwdAvatar setUser:item.fwd_user]; - if(self.item.isHeaderMessage) { - [self.fwdAvatar setFrameOrigin:NSMakePoint(12, (item.viewSize.height - self.fwdAvatar.bounds.size.height - 8 - 22 - minus))]; - [self.fwdName setFrameOrigin:NSMakePoint(59, item.viewSize.height - 48 - minus)]; + [self.fwdName setFrameOrigin:NSMakePoint(6, item.viewSize.height - 50 - minus)]; } else { - [self.fwdAvatar setFrameOrigin:NSMakePoint(12, (item.viewSize.height - self.fwdAvatar.bounds.size.height - 8 - minus))]; - [self.fwdName setFrameOrigin:NSMakePoint(59, item.viewSize.height - 24 - minus)]; + [self.fwdName setFrameOrigin:NSMakePoint(6, item.viewSize.height - 24 - minus)]; } - + [self.fwdName setFrameSize:NSMakeSize(NSWidth(self.containerView.frame) , NSHeight(self.fwdName.frame))]; [self.fwdName setAttributedStringValue:item.forwardMessageAttributedString]; } else { @@ -671,16 +684,27 @@ - (void)setItem:(MessageTableItem *)item { if(item.isHeaderMessage) { [self initHeader]; [self.nameTextField setAttributedStringValue:item.headerName]; - [self.nameTextField setFrameOrigin:NSMakePoint(77, item.viewSize.height - 24)]; - [self.avatarImageView setUser:item.user]; + [self.nameTextField setFrameOrigin:NSMakePoint(item.containerOffset - 2, item.viewSize.height - 24)]; + if(item.message.from_id != 0) + [self.avatarImageView setUser:item.user]; + else + [self.avatarImageView setChat:item.message.chat]; [self.avatarImageView setFrameOrigin:NSMakePoint(29, item.viewSize.height - 43)]; + + } else { [self deallocHeader]; } - + + + // [self.containerView setBackgroundColor:[NSColor redColor]]; - [self.containerView setFrame:NSMakeRect(item.containerOffset, item.isHeaderMessage ? item.isForwadedMessage ? 10 : 4 : item.isForwadedMessage ? 10 : roundf((item.viewSize.height - item.blockSize.height)/2), self.containerView.bounds.size.width, item.blockSize.height)]; + [self.containerView setFrame:NSMakeRect(item.isForwadedMessage ? item.containerOffsetForward : item.containerOffset, item.isHeaderMessage ? item.isForwadedMessage ? 4 : 4 : item.isForwadedMessage ? 4 : roundf((item.viewSize.height - item.blockSize.height)/2), NSWidth(self.frame) - 160, item.blockSize.height)]; + // [self.containerView removeAllSubviews]; + + // [self.layer setBackgroundColor:NSColorFromRGB(arc4random() % 16000000).CGColor]; + if([item isReplyMessage]) { @@ -691,7 +715,7 @@ - (void)setItem:(MessageTableItem *)item { [_replyContainer setReplyObject:item.replyObject]; - [_replyContainer setFrame:NSMakeRect(NSMinX(_replyContainer.frame), NSHeight(_containerView.frame) + 10, item.blockWidth - 60 , item.replyObject.containerHeight)]; + [_replyContainer setFrame:NSMakeRect(item.containerOffset + 1, NSHeight(_containerView.frame) + 10, item.blockWidth , item.replyObject.containerHeight)]; } else { @@ -717,14 +741,49 @@ - (void)setItem:(MessageTableItem *)item { // Layers ;) - [self.dateLayer setString:item.dateStr]; + [self.dateLayer setStringValue:item.dateStr]; [self.dateLayer setFrameSize:CGSizeMake(item.dateSize.width, item.dateSize.height)]; - [self.rightView setFrameSize:CGSizeMake(item.dateSize.width + offserUnreadMark + 32, 18)]; - + [self.dateLayer setFrameOrigin:CGPointMake(NSMaxX(_stateLayer.frame), NSMinY(self.dateLayer.frame))]; + [self.rightView setFrameSize:CGSizeMake(item.dateSize.width + offserUnreadMark + NSWidth(self.stateLayer.frame) + 15 , 18)]; [self.rightView setToolTip:self.item.fullDate]; [self setNeedsDisplay:YES]; + + if(item.message.isChannelMessage && item.message.from_id == 0) { + + if(!_shareImageView) { + _shareImageView = imageViewWithImage(image_ChannelShare()); + + weak(); + + [_shareImageView setCallback:^{ + + [weakSelf.forwardModalView close:NO]; + weakSelf.forwardModalView = nil; + + weakSelf.forwardModalView = [[TGModalForwardView alloc] initWithFrame:weakSelf.window.contentView.bounds]; + + [weakSelf.messagesViewController setSelectedMessage:weakSelf.item selected:YES]; + + weakSelf.forwardModalView.messagesViewController = weakSelf.messagesViewController; + + [weakSelf.forwardModalView show:weakSelf.window animated:YES]; + + + }]; + } + + + [self addSubview:_shareImageView]; + [_shareImageView setAutoresizingMask:NSViewMinXMargin]; + // [_shareImageView setFrameOrigin:NSMakePoint(NSMinX(_rightView.frame) + NSWidth(_shareImageView.frame) + NSMaxX(_dateLayer.frame), NSMinY(_rightView.frame) - NSHeight(_shareImageView.frame))]; + + } else { + [_shareImageView removeFromSuperview]; + _shareImageView = nil; + } + } @@ -735,7 +794,7 @@ - (void)setItem:(MessageTableItem *)item { - (void)setRightLayerToEditablePosition:(BOOL)editable { // static int offserUnreadMark = 12; - CGPoint position = CGPointMake(self.bounds.size.width - self.rightView.bounds.size.width , self.item.viewSize.height - self.rightView.bounds.size.height - (self.item.isHeaderMessage ? 12 : 4)); + CGPoint position = CGPointMake(self.bounds.size.width - self.rightView.bounds.size.width , self.item.viewSize.height - self.rightView.bounds.size.height - (self.item.isHeaderMessage ? 7 : 4)); if(editable) position.x -= offsetEditable; @@ -743,6 +802,11 @@ - (void)setRightLayerToEditablePosition:(BOOL)editable { [self.rightView.layer setFrameOrigin:position]; [self.rightView setFrameOrigin:position]; + + if(!editable) + [_shareImageView setFrameOrigin:NSMakePoint(NSMinX(_rightView.frame) + NSWidth(_shareImageView.frame) + NSWidth(_dateLayer.frame) + 35, NSMinY(_rightView.frame) - NSHeight(_shareImageView.frame) - 5)]; + + [_shareImageView setHidden:editable]; } - (void)setEditable:(BOOL)editable animation:(BOOL)animation { @@ -753,6 +817,8 @@ - (void)setEditable:(BOOL)editable animation:(BOOL)animation { [self deallocSelectButton]; + [_shareImageView setHidden:editable]; + if(self.isEditable == editable && animation) return; _isEditable = editable; @@ -812,6 +878,10 @@ - (void)setEditable:(BOOL)editable animation:(BOOL)animation { }]; [self.selectButton.layer pop_addAnimation:opacityAnim forKey:@"slide"]; + + + + } - (void)cancelDownload { @@ -826,11 +896,10 @@ - (void)deleteAndCancel:(MessageTableItem *)item { [item.messageSender cancel]; item.messageSender = nil; - [[Storage manager] deleteMessagesWithRandomIds:@[@(item.message.randomId)] completeHandler:nil]; - [[DialogsManager sharedManager] updateLastMessageForDialog:item.message.conversation]; + + [[DialogsManager sharedManager] deleteMessagesWithRandomMessageIds:@[@(item.message.randomId)] isChannelMessages:self.item.message.isChannelMessage]; + [self.messagesViewController deleteItem:item]; - [Notification perform:DELETE_MESSAGE - data:@{KEY_MESSAGE:item.message}]; } @@ -864,13 +933,12 @@ - (void)updateCellState { } - (void)checkState:(SenderItem *)sender { - if(sender.state == MessageSendingStateSent) { - [self.item.messageSender removeEventListener:self]; - self.cellState = CellStateNormal; - self.item.messageSender = nil; - } + if(sender.state == MessageSendingStateSent) { - [self checkActionState:YES]; + self.cellState = CellStateNormal; + } + + [self checkActionState:YES]; } @@ -897,6 +965,7 @@ - (void)setProgressFrameSize:(NSSize)newsize { - (void)downloadProgressHandler:(DownloadItem *)item { + [self.progressView setProgress:item.progress animated:YES]; } @@ -919,8 +988,15 @@ -(void)updateDownloadState { if(self.item.downloadItem) { [self.progressView setProgress:self.item.downloadItem.progress animated:NO]; + [self.item.downloadItem removeEvent:_downloadEventListener]; + + [_downloadEventListener clear]; - [self.item.downloadListener setCompleteHandler:^(DownloadItem * item) { + _downloadEventListener = [[DownloadEventListener alloc] init]; + + [self.item.downloadItem addEvent:_downloadEventListener]; + + [_downloadEventListener setCompleteHandler:^(DownloadItem * item) { [[ASQueue mainQueue] dispatchOnQueue:^{ @@ -930,13 +1006,14 @@ -(void)updateDownloadState { [weakSelf.item doAfterDownload]; [weakSelf updateCellState]; [weakSelf doAfterDownload]; + [weakSelf.progressView setCurrentProgress:0]; weakSelf.item.downloadItem = nil; }); }]; }]; - [self.item.downloadListener setProgressHandler:^(DownloadItem * item) { + [_downloadEventListener setProgressHandler:^(DownloadItem * item) { [ASQueue dispatchOnMainQueue:^{ if(weakSelf.cellState != CellStateDownloading) @@ -951,22 +1028,18 @@ -(void)updateDownloadState { - (void)onProgressChanged:(SenderItem *)item { - [ASQueue dispatchOnMainQueue:^{ - if(item == self.item.messageSender) { - [self uploadProgressHandler:item animated:YES]; - } - }]; + if(item == self.item.messageSender) { + [self uploadProgressHandler:item animated:YES]; + } } - (void)onAddedListener:(SenderItem *)item { - [ASQueue dispatchOnMainQueue:^{ - if(item == self.item.messageSender) { - [self uploadProgressHandler:item animated:YES]; - [self updateCellState]; - } - }]; + if(item == self.item.messageSender) { + [self uploadProgressHandler:item animated:YES]; + [self updateCellState]; + } } - (void)uploadProgressHandler:(SenderItem *)item animated:(BOOL)animation { @@ -978,28 +1051,25 @@ - (void)doAfterDownload { } - (void)onRemovedListener:(SenderItem *)item { - + if(item.canRelease) { + self.item.messageSender = nil; + + [self updateCellState]; + } } - (void)onStateChanged:(SenderItem *)item { - [ASQueue dispatchOnMainQueue:^{ - if(item == self.item.messageSender) { - [self checkState:item]; - [self uploadProgressHandler:item animated:NO]; - [self updateCellState]; - - - if(item.state == MessageSendingStateError) { - [self checkState:item]; - } - - if(item.state == MessageSendingStateCancelled) { - [self deleteAndCancel]; - } - } else - [self.item.messageSender removeEventListener:self]; - }]; + if(item == self.item.messageSender) { + [self checkState:item]; + [self uploadProgressHandler:item animated:NO]; + [self updateCellState]; + + if(item.state == MessageSendingStateCancelled) { + [self deleteAndCancel]; + } + } else + [item removeEventListener:self]; } @@ -1010,10 +1080,10 @@ - (void)checkActionState:(BOOL)redraw { if(self.item.messageSender.state == MessageSendingStateError) { state = MessageTableCellSendingError; - } else if(self.item.message.dstate == DeliveryStatePending) { + } else if(self.item.messageSender.state == MessageStateSending) { state = MessageTableCellSending; } else { - state = MessageTableCellUnread; + state = self.item.message.unread ? MessageTableCellUnread : MessageTableCellRead; } } else { if(self.item.message.n_out) { @@ -1021,11 +1091,14 @@ - (void)checkActionState:(BOOL)redraw { state = MessageTableCellRead; else state = MessageTableCellUnread; + } else { + state = MessageTableCellUnread; } + } - [self.stateLayer setHidden:!self.item.message.n_out]; + [self.stateLayer setHidden:!self.item.message.n_out && self.item.message.from_id != 0]; if(!self.stateLayer.isHidden) [self.stateLayer setState:state]; @@ -1067,6 +1140,7 @@ -(void)_didChangeBackgroundColorWithAnimation:(POPBasicAnimation *)anim toColor: animation.toValue = anim.toValue; animation.fromValue = anim.fromValue; animation.duration = anim.duration; + animation.removedOnCompletion = YES; [_replyContainer.messageField pop_addAnimation:animation forKey:@"background"]; } @@ -1087,9 +1161,8 @@ -(void)_colorAnimationEvent { } -(void)dealloc { - [self.item.downloadListener setCompleteHandler:nil]; - [self.item.downloadListener setProgressHandler:nil]; - [self.item.downloadListener setErrorHandler:nil]; + + // assert([NSThread isMainThread]); [self.item.messageSender removeEventListener:self]; } diff --git a/TelegramTest/MessageTableCellDocumentView.m b/TelegramTest/MessageTableCellDocumentView.m index 6f7dd64c..44794b58 100644 --- a/TelegramTest/MessageTableCellDocumentView.m +++ b/TelegramTest/MessageTableCellDocumentView.m @@ -230,11 +230,11 @@ - (id)initWithFrame:(NSRect)frame { [self.fileNameTextField setEditable:NO]; [self.fileNameTextField setSelectable:NO]; [self.fileNameTextField setTextColor:NSColorFromRGB(0x333333)]; - [self.fileNameTextField setFont:[NSFont fontWithName:@"HelveticaNeue-Medium" size:13]]; + [self.fileNameTextField setFont:TGSystemMediumFont(13)]; [self.fileNameTextField setDrawsBackground:NO]; // [self.fileNameTextField setBackgroundColor:[NSColor redColor]]; - [[self.fileNameTextField cell] setLineBreakMode:NSLineBreakByCharWrapping]; + [[self.fileNameTextField cell] setLineBreakMode:NSLineBreakByTruncatingMiddle]; [[self.fileNameTextField cell] setTruncatesLastVisibleLine:YES]; [self.containerView addSubview:self.fileNameTextField]; @@ -244,7 +244,7 @@ - (id)initWithFrame:(NSRect)frame { [self.fileSizeTextField setEditable:NO]; [self.fileSizeTextField setSelectable:NO]; [self.fileSizeTextField setTextColor:NSColorFromRGB(0x9b9b9b)]; - [self.fileSizeTextField setFont:[NSFont fontWithName:@"HelveticaNeue" size:12]]; + [self.fileSizeTextField setFont:TGSystemFont(12)]; [self.fileSizeTextField setDrawsBackground:NO]; [self.fileSizeTextField setBackgroundColor:[NSColor grayColor]]; [self.containerView addSubview:self.fileSizeTextField]; @@ -299,7 +299,7 @@ - (void)setProgressStringValue:(float)progress format:(NSString *)format { NSString *downloadString = [NSString stringWithFormat:format, progress]; - [self.actionsTextField setAttributedStringValue:[[NSAttributedString alloc] initWithString:downloadString attributes:@{NSFontAttributeName: [NSFont fontWithName:@"HelveticaNeue" size:14], NSForegroundColorAttributeName: NSColorFromRGB(0x9b9b9b)}]]; + [self.actionsTextField setAttributedStringValue:[[NSAttributedString alloc] initWithString:downloadString attributes:@{NSFontAttributeName: TGSystemFont(14), NSForegroundColorAttributeName: NSColorFromRGB(0x9b9b9b)}]]; [CATransaction commit]; } @@ -630,7 +630,7 @@ - (void)open { PreviewObject *previewObject = [[PreviewObject alloc] initWithMsdId:self.item.message.n_id media:self.item.message peer_id:self.item.message.peer_id]; if([self.item.message.media.document.mime_type hasPrefix:@"image"]) { - [[TGPhotoViewer viewer] show:previewObject]; + [[TGPhotoViewer viewer] showDocuments:previewObject conversation:self.item.message.conversation]; } else { TMPreviewDocumentItem *item = [[TMPreviewDocumentItem alloc] initWithItem:previewObject]; [[TMMediaController controller] show:item]; @@ -646,8 +646,7 @@ -(void)mouseDown:(NSEvent *)theEvent { if([_attachButton mouse:_startDragLocation inRect:_attachButton.frame]) return; - if(self.isEditable) - [super mouseDown:theEvent]; + [super mouseDown:theEvent]; } -(void)mouseDragged:(NSEvent *)theEvent { @@ -690,7 +689,7 @@ -(void)mouseDragged:(NSEvent *)theEvent { static NSAttributedString *instance; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - instance = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"Message.File.Download", nil) attributes:@{NSForegroundColorAttributeName:LINK_COLOR, NSLinkAttributeName: @"download", NSFontAttributeName: [NSFont fontWithName:@"HelveticaNeue" size:13]}]; + instance = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"Message.File.Download", nil) attributes:@{NSForegroundColorAttributeName:LINK_COLOR, NSLinkAttributeName: @"download", NSFontAttributeName: TGSystemFont(13)}]; }); return instance; } @@ -706,7 +705,7 @@ -(void)mouseDragged:(NSEvent *)theEvent { [mutableAttributedString setLink:@"finder" forRange:range]; - [mutableAttributedString setFont:[NSFont fontWithName:@"HelveticaNeue" size:13] forRange:mutableAttributedString.range]; + [mutableAttributedString setFont:TGSystemFont(13) forRange:mutableAttributedString.range]; instance = mutableAttributedString; }); diff --git a/TelegramTest/MessageTableCellGifView.m b/TelegramTest/MessageTableCellGifView.m index 3e1e77f6..4dbc9617 100644 --- a/TelegramTest/MessageTableCellGifView.m +++ b/TelegramTest/MessageTableCellGifView.m @@ -7,7 +7,6 @@ // #import "MessageTableCellGifView.h" -#import "TMGifImageView.h" #import "ImageUtils.h" #import "TMCircularProgress.h" #import "MessageTableCellVideoView.h" @@ -91,6 +90,11 @@ - (id)initWithFrame:(NSRect)frame return self; } +-(void)mouseDown:(NSEvent *)theEvent { + if(![self.containerView mouse:[self.containerView convertPoint:[theEvent locationInWindow] fromView:nil] inRect:self.imageView.frame]) + [super mouseDown:theEvent]; +} + -(void)checkOperation { [super checkOperation]; self.needOpenAfterDownload = YES; @@ -144,20 +148,45 @@ - (void)playAnimation { if(!self.animatedPlayer) { self.animatedPlayer = [[TGModernAnimatedImagePlayer alloc] initWithSize:self.imageView.frame.size path:item.path]; + _imageView.image = self.animatedPlayer.poster; + [self.animatedPlayer setFrameReady:^(NSImage *image) { - weakSelf.imageView.image = image; + + NSRange visibleRange = [weakSelf.messagesViewController.table rowsInRect:weakSelf.messagesViewController.table.visibleRect]; + + if(visibleRange.location > 0) { + visibleRange.location--; + visibleRange.length++; + } + + NSUInteger idx = [weakSelf.messagesViewController.table indexOfItem:item]; + + if(idx > visibleRange.location && idx <= visibleRange.location + visibleRange.length) { + if(weakSelf.window.isKeyWindow) + weakSelf.imageView.image = image; + } + }]; [self.animatedPlayer play]; [self.playImage setHidden:YES]; } else { - [self animationDidStop:nil finished:YES]; + // [self.animatedPlayer play]; } } } + +-(void)viewDidMoveToSuperview { + if(self.superview != nil) { + [self playAnimation]; + } else { + [self animationDidStop:nil finished:YES]; + } +} + - (void)animationDidStart:(CAAnimation *)theAnimation { } @@ -197,7 +226,7 @@ -(void)drawRect:(NSRect)dirtyRect { -(void)doAfterDownload { - if(self.visibleRect.size.width > 0 && self.visibleRect.size.height > 0 && self.needOpenAfterDownload) { + if(self.superview.window) { [self open]; } } @@ -205,25 +234,31 @@ -(void)doAfterDownload { - (void)open { if(!self.animatedPlayer.isPlaying) { [self playAnimation]; - } else { - [self animationDidStop:nil finished:YES]; } } - (void)resumeAnimation { // [self.gifAnimationLayer resumeAnimating]; - [self.animatedPlayer play]; + + if(!_animatedPlayer) { + [self playAnimation]; + } else if(!_animatedPlayer.isPlaying) { + [_animatedPlayer play]; + } + + } - (void)pauseAnimation { // [self.gifAnimationLayer pauseAnimating]; [self.animatedPlayer pause]; + //[self animationDidStop:nil finished:YES]; } - (void)setCellState:(CellState)cellState { [super setCellState:cellState]; - [self.playImage setHidden:!(cellState == CellStateNormal)]; + [self.playImage setHidden:YES]; [self.progressView setState:cellState]; } @@ -233,26 +268,33 @@ - (void) setItem:(MessageTableItemGif *)item { self.needOpenAfterDownload = NO; - [self updateDownloadState]; + [self updateDownloadState]; - [self.animatedPlayer stop]; - self.animatedPlayer = nil; + [_animatedPlayer stop]; + _animatedPlayer = nil; + + if(item.isset) { + + [self playAnimation]; + } else { + + if(item.cachedThumb) { + [self.imageView setImage:item.cachedThumb]; + } else { + self.imageView.object = item.imageObject; + } + } + + [self.imageView setFrameSize:item.blockSize]; + [self.progressView setCenterByView:self.imageView]; - [self.imageView setFrameSize:item.blockSize]; - [self.progressView setCenterByView:self.imageView]; - if(item.cachedThumb) { - [self.imageView setImage:item.cachedThumb]; - } else { - self.imageView.object = item.imageObject; - } } - @end diff --git a/TelegramTest/MessageTableCellHoleView.h b/TelegramTest/MessageTableCellHoleView.h new file mode 100644 index 00000000..ac791a63 --- /dev/null +++ b/TelegramTest/MessageTableCellHoleView.h @@ -0,0 +1,13 @@ +// +// MessageTableCellHoleCellView.h +// Telegram +// +// Created by keepcoder on 27.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "MessageTableCell.h" +#import "MessageTableItemHole.h" +@interface MessageTableCellHoleView : MessageTableCell + +@end diff --git a/TelegramTest/MessageTableCellHoleView.m b/TelegramTest/MessageTableCellHoleView.m new file mode 100644 index 00000000..c767b794 --- /dev/null +++ b/TelegramTest/MessageTableCellHoleView.m @@ -0,0 +1,82 @@ +// +// MessageTableCellHoleCellView.m +// Telegram +// +// Created by keepcoder on 27.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "MessageTableCellHoleView.h" +#import "TGCTextView.h" + +@interface TGCustomTextView : TGCTextView +@property (nonatomic,weak) MessageTableItemHole *holeItem; +@property (nonatomic,weak) MessagesViewController *controller; +@end + + +@implementation TGCustomTextView + +-(void)open_link:(NSString *)link itsReal:(BOOL)itsReal { + if([link isEqualToString:@"showNewMessages"]) + [_controller jumpToLastMessages:YES]; + else if([link isEqualToString:@"showComments"]) { + + [_controller showMessage:_holeItem.message fromMsg:nil switchDiscussion:YES]; + } +} + +@end + +@interface MessageTableCellHoleView () +@property (nonatomic,strong) TGCustomTextView *textView; +@end + +@implementation MessageTableCellHoleView + +-(instancetype)initWithFrame:(NSRect)frameRect { + if(self = [super initWithFrame:frameRect]) { + _textView = [[TGCustomTextView alloc] initWithFrame:NSZeroRect]; + + [self addSubview:_textView]; + + + + } + + return self; +} + +- (void)drawRect:(NSRect)dirtyRect { + [super drawRect:dirtyRect]; + + // Drawing code here. +} + + +-(void)setItem:(MessageTableItemHole *)item { + [super setItem:item]; + + _textView.holeItem = item; + + _textView.controller = self.messagesViewController; + + [_textView setFrameSize:item.textSize]; + [_textView setAttributedString:item.text]; + + + + [_textView setCenteredXByView:_textView.superview]; + + [_textView setFrameOrigin:NSMakePoint(NSMinX(_textView.frame), roundf((item.viewSize.height - NSHeight(_textView.frame))/2))]; +} + +-(void)mouseDown:(NSEvent *)theEvent { + +} + +-(NSMenu *)contextMenu { + return nil; +} + +@end diff --git a/TelegramTest/MessageTableCellPhotoView.m b/TelegramTest/MessageTableCellPhotoView.m index ab39aa38..6ec5e1d1 100644 --- a/TelegramTest/MessageTableCellPhotoView.m +++ b/TelegramTest/MessageTableCellPhotoView.m @@ -76,7 +76,7 @@ - (id)initWithFrame:(NSRect)frame { object.reservedObject = weakSelf.imageView.image; - [[TGPhotoViewer viewer] show:object conversation:weakSelf.messagesViewController.conversation]; + [[TGPhotoViewer viewer] show:object conversation:weakSelf.messagesViewController.conversation isReversed:YES]; if([weakSelf.item.message isKindOfClass:[TL_destructMessage class]]) { @@ -212,10 +212,10 @@ - (void) setItem:(MessageTableItemPhoto *)item { [super setItem:item]; - [self.imageView setFrameSize:item.imageSize]; - self.imageView.object = item.imageObject; + + [self.imageView setFrameSize:item.imageSize]; [self updateCellState]; @@ -249,6 +249,8 @@ - (void) setItem:(MessageTableItemPhoto *)item { [_captionView setAttributedString:item.caption fieldSize:item.captionSize]; + [_captionView setItem:item]; + } else { [self deallocCaptionTextView]; } @@ -366,6 +368,7 @@ -(void)_didChangeBackgroundColorWithAnimation:(POPBasicAnimation *)anim toColor: animation.toValue = anim.toValue; animation.fromValue = anim.fromValue; animation.duration = anim.duration; + animation.removedOnCompletion = YES; [_captionView.textView pop_addAnimation:animation forKey:@"background"]; @@ -389,6 +392,8 @@ -(void)_colorAnimationEvent { -(void)dealloc { MessageTableItemPhoto *item = (MessageTableItemPhoto *) self.item; + [self.progressView pop_removeAllAnimations]; + [item.imageObject.supportDownloadListener setCompleteHandler:nil]; [item.imageObject.supportDownloadListener setProgressHandler:nil]; } diff --git a/TelegramTest/MessageTableCellServiceMessage.m b/TelegramTest/MessageTableCellServiceMessage.m index 0cf1d463..a1d908ab 100644 --- a/TelegramTest/MessageTableCellServiceMessage.m +++ b/TelegramTest/MessageTableCellServiceMessage.m @@ -28,15 +28,16 @@ - (id)initWithFrame:(NSRect)frame // [self.textField setEditable:YES]; - [self addSubview:self.textField]; - self.photoImageView = [[TGImageView alloc] initWithFrame:NSZeroRect]; - [self.photoImageView setRoundSize:4]; + self.photoImageView = [[TGImageView alloc] initWithFrame:NSMakeRect(0, 0, 60, 60)]; + + self.photoImageView.layer.cornerRadius = 30; + self.photoImageView.wantsLayer = YES; [self addSubview:self.photoImageView]; self.wantsLayer = YES; - + weak(); [self.photoImageView setTapBlock:^ { @@ -58,19 +59,19 @@ -(NSArray *)defaultMenuItems { if(self.item.message.to_id.class == [TL_peerChat class] || self.item.message.to_id.class == [TL_peerUser class]) { [items addObject:[NSMenuItem menuItemWithTitle:NSLocalizedString(@"Context.Reply", nil) withBlock:^(id sender) { - [[Telegram rightViewController].messagesViewController addReplayMessage:self.item.message animated:YES]; + [self.messagesViewController addReplayMessage:self.item.message animated:YES]; }]]; } [items addObject:[NSMenuItem menuItemWithTitle:NSLocalizedString(@"Context.Delete", nil) withBlock:^(id sender) { - [[Telegram rightViewController].messagesViewController setState:MessagesViewControllerStateNone]; - [[Telegram rightViewController].messagesViewController unSelectAll:NO]; + [self.messagesViewController setState:MessagesViewControllerStateNone]; + [self.messagesViewController unSelectAll:NO]; - [[Telegram rightViewController].messagesViewController setSelectedMessage:self.item selected:YES]; + [self.messagesViewController setSelectedMessage:self.item selected:YES]; - [[Telegram rightViewController].messagesViewController deleteSelectedMessages]; + [self.messagesViewController deleteSelectedMessages]; }]]; @@ -81,23 +82,24 @@ -(NSArray *)defaultMenuItems { - (void) setItem:(MessageTableItemServiceMessage *)item { [super setItem:item]; + + [self setHidden:item.viewSize.height == 1]; if(item.type == MessageTableItemServiceMessageAction) { [self.textField setAttributedString:item.messageAttributedString]; [self.textField setFrameSize:item.textSize]; - - - [self.textField setFrameOrigin:NSMakePoint(roundf((self.bounds.size.width - item.textSize.width) / 2), (item.photoSize.height ? (item.photoSize.height + 5) : 0))]; + + [self.textField setFrameOrigin:NSMakePoint(roundf((NSWidth(self.messagesViewController.view.frame) - item.textSize.width) / 2), (item.photoSize.height ? (item.photoSize.height + 5) : roundf((item.viewSize.height - NSHeight(_textField.frame))/2)))]; if(item.photo) { - [self.photoImageView setHidden:NO]; - [self.photoImageView setFrameOrigin:NSMakePoint(roundf((self.bounds.size.width - item.photoSize.width) / 2), 5)]; - [self.photoImageView setFrameSize:item.photoSize]; - + [self.photoImageView setFrameSize:item.photoSize]; self.photoImageView.object = item.imageObject; + [self.photoImageView setHidden:NO]; + [self.photoImageView setFrameOrigin:NSMakePoint(roundf((NSWidth(self.messagesViewController.view.frame) - _photoImageView.frame.size.width) / 2), 0)]; + } else { [self.photoImageView setHidden:YES]; } @@ -107,13 +109,13 @@ - (void) setItem:(MessageTableItemServiceMessage *)item { [self.textField setAttributedString:item.messageAttributedString]; [self.textField setFrameOrigin:NSMakePoint(78, 0)]; - + [_textField setFrameOrigin:NSMakePoint(NSMinX(_textField.frame), roundf((item.viewSize.height - NSHeight(_textField.frame))/2))]; } else { [self.photoImageView setHidden:YES]; [self.textField setAttributedString:item.messageAttributedString]; [self.textField setFrameSize:item.textSize]; - [self.textField setFrameOrigin:NSMakePoint(74, 8)]; + [_textField setFrameOrigin:NSMakePoint(NSMinX(_textField.frame), roundf((item.viewSize.height - NSHeight(_textField.frame))/2))]; } diff --git a/TelegramTest/MessageTableCellStickerView.m b/TelegramTest/MessageTableCellStickerView.m index c22f0dad..3bf916d5 100644 --- a/TelegramTest/MessageTableCellStickerView.m +++ b/TelegramTest/MessageTableCellStickerView.m @@ -10,6 +10,7 @@ #import "TGImageView.h" #import "StickersPanelView.h" #import "EmojiViewController.h" +#import "TGStickerPackModalView.h" @interface MessageTableCellStickerView () @property (nonatomic,strong) TGImageView *imageView; @end @@ -91,6 +92,7 @@ - (NSMenu *)contextMenu { } + -(void)mouseUp:(NSEvent *)theEvent { [super mouseUp:theEvent]; @@ -102,11 +104,18 @@ -(void)mouseUp:(NSEvent *)theEvent { if(![attr.stickerset isKindOfClass:[TL_inputStickerSetEmpty class]]) { - NSArray *check = [[EmojiViewController allSets] filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.n_id == %ld",attr.stickerset.n_id]]; - - if(check.count == 0) { + TL_stickerSet *set = [EmojiViewController setWithId:attr.stickerset.n_id]; + NSMutableArray *stickers = (NSMutableArray *) [EmojiViewController stickersWithId:attr.stickerset.n_id]; + if(set && stickers.count > 0) { + TGStickerPackModalView *modalView = [[TGStickerPackModalView alloc] init]; + + [modalView setStickerPack:[TL_messages_stickerSet createWithSet:set packs:nil documents:stickers]]; + + [modalView show:self.window animated:YES]; + } else add_sticker_pack_by_name(attr.stickerset); - } + + } diff --git a/TelegramTest/MessageTableCellTextView.m b/TelegramTest/MessageTableCellTextView.m index b1a32986..cd52c52c 100644 --- a/TelegramTest/MessageTableCellTextView.m +++ b/TelegramTest/MessageTableCellTextView.m @@ -93,7 +93,6 @@ - (void)updateCellState { -(void)mouseDown:(NSEvent *)theEvent { [super mouseDown:theEvent]; - MessageTableItemText *item = (MessageTableItemText *)[self item]; } @@ -101,7 +100,7 @@ - (void) setItem:(MessageTableItemText *)item { [super setItem:item]; - + if([item isWebPage]) { @@ -213,6 +212,7 @@ -(void)_didChangeBackgroundColorWithAnimation:(POPBasicAnimation *)anim toColor: animation.toValue = anim.toValue; animation.fromValue = anim.fromValue; animation.duration = anim.duration; + animation.removedOnCompletion = YES; [self.textView pop_addAnimation:animation forKey:@"background"]; [self.webpageContainerView.descriptionField pop_addAnimation:animation forKey:@"background"]; @@ -232,7 +232,9 @@ -(void)_colorAnimationEvent { } + -(void)setSelected:(BOOL)selected animation:(BOOL)animation { + if(selected == self.isSelected) return; diff --git a/TelegramTest/MessageTableCellUnreadMarkView.m b/TelegramTest/MessageTableCellUnreadMarkView.m index a441fdba..3ed499df 100644 --- a/TelegramTest/MessageTableCellUnreadMarkView.m +++ b/TelegramTest/MessageTableCellUnreadMarkView.m @@ -23,7 +23,7 @@ - (id)initWithFrame:(NSRect)frame { [self.textField setEnabled:NO]; [self.textField setEditable:NO]; [self.textField setStringValue:@"2 unread messages"]; - [self.textField setFont:[NSFont fontWithName:@"HelveticaNeue" size:13]]; + [self.textField setFont:TGSystemFont(13)]; [self.textField setTextColor:NSColorFromRGB(0x9b9b9b)]; [self.textField setDrawsBackground:NO]; [self.textField setAlignment:NSCenterTextAlignment]; @@ -39,6 +39,8 @@ - (void)setItem:(MessageTableItemUnreadMark *)item { [self.textField setStringValue:item.text]; + [self.textField sizeToFit]; + if(item.removeType == RemoveUnreadMarkAfterSecondsType) { @@ -54,7 +56,7 @@ - (void)setItem:(MessageTableItemUnreadMark *)item { -(void)setFrameSize:(NSSize)newSize { [super setFrameSize:newSize]; - [self.textField setFrameSize:NSMakeSize(newSize.width, 26)]; + [self.textField setFrameOrigin:NSMakePoint(roundf((NSWidth(self.messagesViewController.view.frame) - NSWidth(_textField.frame))/2), roundf((self.item.viewSize.height - NSHeight(_textField.frame))/2))]; } - (void)drawRect:(NSRect)dirtyRect { diff --git a/TelegramTest/MessageTableCellVideoView.m b/TelegramTest/MessageTableCellVideoView.m index e0fc1e7a..2b700690 100644 --- a/TelegramTest/MessageTableCellVideoView.m +++ b/TelegramTest/MessageTableCellVideoView.m @@ -180,7 +180,7 @@ - (void)setCellState:(CellState)cellState { [self.playImage setCenterByView:self.imageView]; - BOOL needBlur = self.item.message.media.video.thumb.w != 250; + BOOL needBlur = self.item.message.media.video.thumb.w <= 90; if(self.imageView.isAlwaysBlur != needBlur) [self.imageView setIsAlwaysBlur:needBlur]; @@ -232,6 +232,7 @@ - (void) setItem:(MessageTableItemVideo *)item { [_captionView setFrame:NSMakeRect(0, NSHeight(self.containerView.frame) - item.captionSize.height , item.videoSize.width, item.captionSize.height)]; [_captionView setAttributedString:item.caption fieldSize:item.captionSize]; + [_captionView setItem:item]; } else { [self deallocCaptionTextView]; @@ -298,6 +299,7 @@ -(void)_didChangeBackgroundColorWithAnimation:(POPBasicAnimation *)anim toColor: animation.toValue = anim.toValue; animation.fromValue = anim.fromValue; animation.duration = anim.duration; + animation.removedOnCompletion = YES; [_captionView.textView pop_addAnimation:animation forKey:@"background"]; @@ -323,10 +325,9 @@ -(void)mouseDown:(NSEvent *)theEvent { _startDragLocation = [self.containerView convertPoint:[theEvent locationInWindow] fromView:nil]; if([_imageView mouse:_startDragLocation inRect:_imageView.frame]) - return; + return; - if(self.isEditable) - [super mouseDown:theEvent]; + [super mouseDown:theEvent]; } -(void)mouseDragged:(NSEvent *)theEvent { diff --git a/TelegramTest/MessageTableElements.h b/TelegramTest/MessageTableElements.h index be41b9ae..d5f151cb 100644 --- a/TelegramTest/MessageTableElements.h +++ b/TelegramTest/MessageTableElements.h @@ -20,4 +20,5 @@ #import "MessageTableCellUnreadMarkView.h" #import "MessageTablecellAudioDocumentView.h" #import "MessageTableCellSocialView.h" -#import "MessageTableCellStickerView.h" \ No newline at end of file +#import "MessageTableCellStickerView.h" +#import "MessageTableCellHoleView.h" \ No newline at end of file diff --git a/TelegramTest/MessageTableItem.h b/TelegramTest/MessageTableItem.h index da197b27..86d32af1 100644 --- a/TelegramTest/MessageTableItem.h +++ b/TelegramTest/MessageTableItem.h @@ -10,11 +10,11 @@ #import "SenderHeader.h" #import "DownloadItem.h" #import "TGReplyObject.h" -#define FORWARMESSAGE_TITLE_HEIGHT 28 +#define FORWARMESSAGE_TITLE_HEIGHT 20 @interface MessageTableItem : NSObject -@property (nonatomic,weak) TMTableView *table; +@property (nonatomic,weak) MessagesTableView *table; @property (nonatomic, strong) TL_localMessage *message; @@ -27,30 +27,37 @@ @property (nonatomic, strong) NSString *dateStr; @property (nonatomic, strong) TLUser *fwd_user; +@property (nonatomic, strong) TLChat *fwd_chat; @property (nonatomic) BOOL isForwadedMessage; @property (nonatomic) BOOL isSelected; @property (nonatomic) BOOL isHeaderMessage; @property (nonatomic) BOOL isHeaderForwardedMessage; +@property (nonatomic,assign,readonly) int containerOffsetForward; @property (nonatomic,assign,readonly) int containerOffset; +@property (nonatomic,assign,readonly) int makeSize; @property (nonatomic) NSSize blockSize; @property (nonatomic) NSSize previewSize; @property (nonatomic) NSSize dateSize; @property (nonatomic, strong) DownloadItem *downloadItem; -@property (nonatomic,strong) DownloadEventListener *downloadListener; @property (nonatomic,assign,readonly) int blockWidth; -@property (nonatomic,strong,readonly) TGReplyObject *replyObject; + +@property (nonatomic,strong) TGReplyObject *replyObject; + +@property (nonatomic,strong,readonly) NSString *viewsCount; + +-(BOOL)updateViews; - (id) initWithObject:(id)object; + (id) messageItemFromObject:(id)object; - ++ (NSArray *)messageTableItemsFromMessages:(NSArray *)input; - (NSSize)viewSize; - (void)setViewSize:(NSSize)size; @@ -77,5 +84,7 @@ -(BOOL)isReplyMessage; -(BOOL)isFwdMessage; +-(int)fontSize; + @end diff --git a/TelegramTest/MessageTableItem.m b/TelegramTest/MessageTableItem.m index 8b8da665..8ad366b6 100644 --- a/TelegramTest/MessageTableItem.m +++ b/TelegramTest/MessageTableItem.m @@ -20,12 +20,29 @@ #import "MessageTableItemAudioDocument.h" #import "MessageTableItemServiceMessage.h" #import "MessageTableItemSticker.h" +#import "MessageTableItemHole.h" #import "TGDateUtils.h" #import "PreviewObject.h" #import "NSString+Extended.h" #import "MessageTableHeaderItem.h" #import "MessageTableItemSocial.h" -@interface MessageTableItem() +#import "TL_localMessage_old32.h" +#import "TL_localMessage_old34.h" +#import "NSNumber+NumberFormatter.h" + +@interface TGItemCache : NSObject +@property (nonatomic,strong) NSAttributedString *header; +@property (nonatomic,strong) TLUser *user; +@end + + +@implementation TGItemCache + + + +@end + +@interface MessageTableItem() @property (nonatomic) BOOL isChat; @property (nonatomic) NSSize _viewSize; @property (nonatomic,assign) BOOL autoStart; @@ -33,46 +50,84 @@ @interface MessageTableItem() @implementation MessageTableItem + +static NSCache *cItems; + - (id)initWithObject:(TL_localMessage *)object { self = [super init]; if(self) { self.message = object; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + cItems = [[NSCache alloc] init]; + [cItems setCountLimit:100]; + }); + if(object.peer.peer_id == [UsersManager currentUserId]) object.flags&= ~TGUNREADMESSAGE; + //&& ![self.message.media isKindOfClass:[TL_messageMediaPhoto class]] && ![self.message.media isKindOfClass:[TL_messageMediaVideo class]] + self.isForwadedMessage = (self.message.fwd_from_id != nil ) && (![self.message.media isKindOfClass:[TL_messageMediaDocument class]] || (![self.message.media.document isSticker] && ![self.message.media.document.mime_type isEqualToString:@"image/gif"] && ![self.message.media.document attributeWithClass:[TL_documentAttributeAudio class]])); + - self.isForwadedMessage = (self.message.fwd_from_id != 0 ) && ![self.message.media isKindOfClass:[TL_messageMediaPhoto class]] && ![self.message.media isKindOfClass:[TL_messageMediaVideo class]] && (![self.message.media isKindOfClass:[TL_messageMediaDocument class]] || (![self.message.media.document isSticker] && ![self.message.media.document.mime_type isEqualToString:@"image/gif"])) && ([self.message.media.document attributeWithClass:[TL_documentAttributeAudio class]] == nil); + self.isChat = [self.message.to_id isKindOfClass:[TL_peerChat class]] || [self.message.to_id isKindOfClass:[TL_peerChannel class]]; + _containerOffset = 79; - self.isChat = self.message.conversation.type == DialogTypeChat; + _containerOffsetForward = 87; - _containerOffset = self.isForwadedMessage ? 129 : 79; if(self.message) { + + if(self.message.from_id == 0) { + [self updateViews]; + } + + TGItemCache *cache = [cItems objectForKey:@(channelMsgId(_isChat ? 1 : 0, object.from_id == 0 ? object.peer_id : object.from_id))]; - self.user = [[UsersManager sharedManager] find:object.from_id]; + if(cache) { + _user = cache.user; + _headerName = cache.header; + } else { + [self buildHeaderAndSaveToCache]; + } + + if(self.isForwadedMessage) { - self.fwd_user = [[UsersManager sharedManager] find:object.fwd_from_id]; + if([object.fwd_from_id isKindOfClass:[TL_peerUser class]]) { + self.fwd_user = [[UsersManager sharedManager] find:object.fwd_from_id.user_id]; + } else { + self.fwd_chat = [[ChatsManager sharedManager] find:object.fwd_from_id.chat_id == 0 ? object.fwd_from_id.channel_id : object.fwd_from_id.chat_id]; + } + } + [self headerStringBuilder]; + [self rebuildDate]; - [self headerStringBuilder]; + } } return self; } -- (void) headerStringBuilder { -// if(!self.headerString) { -// self.headerString = [[NSMutableAttributedString alloc] init]; -// } -// -// [[self.headerString mutableString] setString:@""]; - +-(int)makeSize { + return MAX(NSWidth(((MessagesTableView *)self.table).viewController.view.frame) - 150,100); +} + +-(void)buildHeaderAndSaveToCache { + _user = [[UsersManager sharedManager] find:self.message.from_id]; NSString *name = self.isChat ? self.user.fullName : self.user.dialogFullName; + + + if(self.message.from_id == 0) + { + name = self.message.conversation.chat.title; + } + NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init]; style.lineBreakMode = NSLineBreakByTruncatingTail; @@ -92,17 +147,14 @@ - (void) headerStringBuilder { }); - NSColor *nameColor = LINK_COLOR; - int uid = self.user.n_id; - if(self.isChat && self.user.n_id != [UsersManager currentUserId]) { - int colorMask = [TMAvatarImageView colorMask:self.user]; + int colorMask = [TMAvatarImageView colorMask:self.user]; nameColor = colors[colorMask % (sizeof(colors) / sizeof(colors[0]))]; @@ -114,17 +166,33 @@ - (void) headerStringBuilder { [header appendString:name withColor:nameColor]; - [header setFont:[NSFont fontWithName:@"HelveticaNeue-Medium" size:13] forRange:header.range]; + // if(self.message.from_id == 0) { + // [header appendAttributedString:[NSAttributedString attributedStringWithAttachment:channelIconAttachment()]]; + // } + + [header setFont:TGSystemMediumFont(13) forRange:header.range]; - [header addAttribute:NSLinkAttributeName value:[TMInAppLinks userProfile:uid] range:header.range]; + [header addAttribute:NSLinkAttributeName value:[TMInAppLinks peerProfile:self.message.from_id == 0 ? self.message.peer : [TL_peerUser createWithUser_id:self.message.from_id]] range:header.range]; self.headerName = header; + TGItemCache *item = [[TGItemCache alloc] init]; + item.user = _user; + item.header = header; + + [cItems setObject:item forKey:@(channelMsgId(_isChat ? 1 : 0, _message.from_id == 0 ? _message.peer_id : _message.from_id))]; +} + +- (void) headerStringBuilder { + + + + [self buildHeaderAndSaveToCache]; if([self isReplyMessage]) { - _replyObject = [[TGReplyObject alloc] initWithReplyMessage:self.message.replyMessage]; + _replyObject = [[TGReplyObject alloc] initWithReplyMessage:self.message.replyMessage fromMessage:self.message tableItem:self]; } @@ -133,24 +201,37 @@ - (void) headerStringBuilder { self.forwardMessageAttributedString = [[NSMutableAttributedString alloc] init]; // [self.forwardMessageAttributedString appendString:NSLocalizedString(@"Message.ForwardedFrom", nil) withColor:NSColorFromRGB(0x909090)]; - TLUser *user = self.fwd_user; + NSString *title = self.fwd_user ? self.fwd_user.fullName : self.fwd_chat.title; NSRange rangeUser = NSMakeRange(0, 0); - if(user) { - rangeUser = [self.forwardMessageAttributedString appendString:user.fullName withColor:LINK_COLOR]; - [self.forwardMessageAttributedString setLink:[TMInAppLinks userProfile:user.n_id] forRange:rangeUser]; + if(title) { + rangeUser = [self.forwardMessageAttributedString appendString:title withColor:LINK_COLOR]; + [self.forwardMessageAttributedString setLink:[TMInAppLinks peerProfile:self.message.fwd_from_id] forRange:rangeUser]; } [self.forwardMessageAttributedString appendString:@" " withColor:NSColorFromRGB(0x909090)]; [self.forwardMessageAttributedString appendString:[TGDateUtils stringForLastSeen:self.message.fwd_date] withColor:NSColorFromRGB(0xbebebe)]; - [self.forwardMessageAttributedString setFont:[NSFont fontWithName:@"HelveticaNeue" size:12] forRange:self.forwardMessageAttributedString.range]; - [self.forwardMessageAttributedString setFont:[NSFont fontWithName:@"HelveticaNeue-Medium" size:13] forRange:rangeUser]; + [self.forwardMessageAttributedString setFont:TGSystemFont(12) forRange:self.forwardMessageAttributedString.range]; + [self.forwardMessageAttributedString setFont:TGSystemMediumFont(13) forRange:rangeUser]; + + NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init]; + style.lineBreakMode = NSLineBreakByTruncatingTail; + [self.forwardMessageAttributedString addAttribute:NSParagraphStyleAttributeName value:style range:self.forwardMessageAttributedString.range]; } } +static NSTextAttachment *channelIconAttachment() { + static NSTextAttachment *instance; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + instance = [NSMutableAttributedString textAttachmentByImage:[image_newConversationBroadcast() imageWithInsets:NSEdgeInsetsMake(0, 1, 0, 4)]]; + }); + return instance; +} + - (void)setViewSize:(NSSize)viewSize { self._viewSize = viewSize; } @@ -158,12 +239,12 @@ - (void)setViewSize:(NSSize)viewSize { - (NSSize)viewSize { NSSize viewSize = self._viewSize; - if(![self isKindOfClass:[MessageTableItemServiceMessage class]] && ![self isKindOfClass:[MessageTableItemUnreadMark class]] && ![self isKindOfClass:[MessageTableHeaderItem class]]) { + if(!self.message.hole && ![self isKindOfClass:[MessageTableItemServiceMessage class]] && ![self isKindOfClass:[MessageTableItemUnreadMark class]] && ![self isKindOfClass:[MessageTableHeaderItem class]]) { if(self.isHeaderMessage) { viewSize.height += 32; if(self.isForwadedMessage) - viewSize.height += 24; + viewSize.height += 20; if(viewSize.height < 44) viewSize.height = 44; @@ -171,7 +252,8 @@ - (NSSize)viewSize { viewSize.height += 10; if(self.isForwadedMessage) - viewSize.height += 24; + viewSize.height += 18; + } if([self isReplyMessage]) { @@ -182,6 +264,13 @@ - (NSSize)viewSize { viewSize.height += FORWARMESSAGE_TITLE_HEIGHT; } + if(viewSize.height < 0) + viewSize.height = 32; + + + if([self.message.action isKindOfClass:[TL_messageActionChatMigrateTo class]]) { + viewSize.height = 1; + } return viewSize; } @@ -192,68 +281,86 @@ - (void) setBlockSize:(NSSize)blockSize { self.viewSize = NSMakeSize(blockSize.width, blockSize.height); } -+ (id) messageItemFromObject:(TLMessage *)object { - id objectReturn = nil; - - if(object.class == [TL_localMessage class] || object.class == [TL_destructMessage class]) { - TLMessage *message = object; - - - - if([message.media isKindOfClass:[TL_messageMediaEmpty class]] || [message.media isMemberOfClass:[TL_messageMediaWebPage class]]) { - - // Class socialClass = [MessageTableItem socialClass:message.message]; - - // if(socialClass == [NSNull class]) - objectReturn = [[MessageTableItemText alloc] initWithObject:object]; - // else - // objectReturn = [[MessageTableItemSocial alloc] initWithObject:object socialClass:socialClass]; - - } else if([message.media isKindOfClass:[TL_messageMediaUnsupported class]]) { - - object.message = @"This message is not supported on your version of Telegram. Update the app to view: https://telegram.org/dl/osx"; - objectReturn = [[MessageTableItemText alloc] initWithObject:object ]; - - } else if([message.media isKindOfClass:[TL_messageMediaPhoto class]]) { - - objectReturn = [[MessageTableItemPhoto alloc] initWithObject:object ]; - - } else if([message.media isKindOfClass:[TL_messageMediaVideo class]]) { ++ (NSArray *)messageTableItemsFromMessages:(NSArray *)input { + NSMutableArray *array = [NSMutableArray array]; + for(TLMessage *message in input) { + MessageTableItem *item = [MessageTableItem messageItemFromObject:message]; + if(item) { + //[item makeSizeByWidth:self.table.containerSize.width]; + item.isSelected = NO; + [array insertObject:item atIndex:0]; + } + } + return array; +} - objectReturn = [[MessageTableItemVideo alloc] initWithObject:object ]; - - } else if([message.media isKindOfClass:[TL_messageMediaDocument class]]) { ++ (id) messageItemFromObject:(TL_localMessage *)message { + id objectReturn = nil; + + @try { + if(message.class == [TL_localMessage_old34 class] || message.class == [TL_localMessage_old32 class] || message.class == [TL_localMessage class] || message.class == [TL_destructMessage class]) { - TLDocument *document = message.media.document; - if([document.mime_type isEqualToString:@"image/gif"] && ![document.thumb isKindOfClass:[TL_photoSizeEmpty class]]) { - objectReturn = [[MessageTableItemGif alloc] initWithObject:object]; - } else if([document.mime_type hasPrefix:@"audio/"]) { - objectReturn = [[MessageTableItemAudioDocument alloc] initWithObject:object]; - } else if([document isSticker]) { - objectReturn = [[MessageTableItemSticker alloc] initWithObject:object]; - } else { - objectReturn = [[MessageTableItemDocument alloc] initWithObject:object]; + if((message.media == nil || [message.media isKindOfClass:[TL_messageMediaEmpty class]]) || [message.media isMemberOfClass:[TL_messageMediaWebPage class]]) { + + objectReturn = [[MessageTableItemText alloc] initWithObject:message]; + + } else if([message.media isKindOfClass:[TL_messageMediaUnsupported class]]) { + + message.message = @"This message is not supported on your version of Telegram. Update the app to view: https://telegram.org/dl/osx"; + objectReturn = [[MessageTableItemText alloc] initWithObject:message ]; + + } else if([message.media isKindOfClass:[TL_messageMediaPhoto class]]) { + + objectReturn = [[MessageTableItemPhoto alloc] initWithObject:message ]; + + } else if([message.media isKindOfClass:[TL_messageMediaVideo class]]) { + + objectReturn = [[MessageTableItemVideo alloc] initWithObject:message ]; + + } else if([message.media isKindOfClass:[TL_messageMediaDocument class]]) { + + TLDocument *document = message.media.document; + + if([document.mime_type isEqualToString:@"image/gif"] && ![document.thumb isKindOfClass:[TL_photoSizeEmpty class]]) { + objectReturn = [[MessageTableItemGif alloc] initWithObject:message]; + } else if([document.mime_type hasPrefix:@"audio/"]) { + objectReturn = [[MessageTableItemAudioDocument alloc] initWithObject:message]; + } else if([document isSticker]) { + objectReturn = [[MessageTableItemSticker alloc] initWithObject:message]; + } else { + objectReturn = [[MessageTableItemDocument alloc] initWithObject:message]; + } + + } else if([message.media isKindOfClass:[TL_messageMediaContact class]]) { + + objectReturn = [[MessageTableItemContact alloc] initWithObject:message]; + + } else if([message.media isKindOfClass:[TL_messageMediaGeo class]] || [message.media isKindOfClass:[TL_messageMediaVenue class]]) { + + objectReturn = [[MessageTableItemGeo alloc] initWithObject:message]; + + } else if([message.media isKindOfClass:[TL_messageMediaAudio class]]) { + + objectReturn = [[MessageTableItemAudio alloc] initWithObject:message]; + } + } else if(message.hole != nil) { + objectReturn = [[MessageTableItemHole alloc] initWithObject:message]; + } else if([message isKindOfClass:[TL_localMessageService class]] || [message isKindOfClass:[TL_secretServiceMessage class]]) { - } else if([message.media isKindOfClass:[TL_messageMediaContact class]]) { - - objectReturn = [[MessageTableItemContact alloc] initWithObject:object]; - - } else if([message.media isKindOfClass:[TL_messageMediaGeo class]] || [message.media isKindOfClass:[TL_messageMediaVenue class]]) { - - objectReturn = [[MessageTableItemGeo alloc] initWithObject:object]; - - } else if([message.media isKindOfClass:[TL_messageMediaAudio class]]) { - - objectReturn = [[MessageTableItemAudio alloc] initWithObject:object]; - + objectReturn = [[MessageTableItemServiceMessage alloc] initWithObject:message ]; } - } else if([object isKindOfClass:[TL_localMessageService class]] || [object isKindOfClass:[TL_secretServiceMessage class]]) { - objectReturn = [[MessageTableItemServiceMessage alloc] initWithObject:object ]; + + } + @catch (NSException *exception) { + int bp = 0; } + if(objectReturn == nil) { + int bp = 0; + } return objectReturn; } @@ -303,12 +410,8 @@ -(void)clean { self.downloadItem = nil; } --(void)setDownloadItem:(DownloadItem *)downloadItem { - self->_downloadItem = downloadItem; - - self.downloadListener = [[DownloadEventListener alloc] init]; - - [self.downloadItem addEvent:self.downloadListener]; +-(DownloadItem *)downloadItem { + return [DownloadQueue find:self.message.n_id]; } -(void)rebuildDate { @@ -318,8 +421,8 @@ -(void)rebuildDate { time -= [[MTNetwork instance] getTime] - [[NSDate date] timeIntervalSince1970]; self.dateStr = [TGDateUtils stringForMessageListDate:time]; - NSSize dateSize = [self.dateStr sizeWithAttributes:@{NSFontAttributeName: [NSFont fontWithName:@"HelveticaNeue" size:12]}]; - dateSize.width = roundf(dateSize.width); + NSSize dateSize = [self.dateStr sizeWithAttributes:@{NSFontAttributeName: TGSystemFont(12)}]; + dateSize.width = roundf(dateSize.width)+5; dateSize.height = roundf(dateSize.height); self.dateSize = dateSize; @@ -369,19 +472,16 @@ - (void)checkStartDownload:(SettingsMask)setting size:(int)size { if(size > [SettingsArchiver autoDownloadLimitSize]) self.autoStart = NO; - - if(!self.downloadItem || self.downloadItem.downloadState == DownloadStateCompleted || self.downloadItem.downloadState == DownloadStateCanceled) - if(![self isset]) - self.downloadItem = [[[self downloadClass] alloc] initWithObject:self.message]; - - + + if((self.autoStart && !self.downloadItem && !self.isset) || (self.downloadItem && self.downloadItem.downloadState != DownloadStateCanceled)) { [self startDownload:NO force:NO]; } - } + + -(id)identifier { return @(self.message.n_id); } @@ -393,18 +493,20 @@ -(NSString *)string { - (void)startDownload:(BOOL)cancel force:(BOOL)force { - if(!self.downloadItem) { - self.downloadItem = [[[self downloadClass] alloc] initWithObject:self.message]; + DownloadItem *downloadItem = self.downloadItem; + + if(!downloadItem) { + downloadItem = [[[self downloadClass] alloc] initWithObject:self.message]; } - if((self.downloadItem.downloadState == DownloadStateCanceled || self.downloadItem.downloadState == DownloadStateWaitingStart) && (force || self.autoStart)) - [self.downloadItem start]; + if((downloadItem.downloadState == DownloadStateCanceled || downloadItem.downloadState == DownloadStateWaitingStart) && (force || self.autoStart)) + [downloadItem start]; } -(BOOL)isReplyMessage { - return self.message.replyMessage != nil && [self.message.replyMessage isKindOfClass:[TL_localMessage class]]; + return self.message.reply_to_msg_id != 0 && ![self.message.replyMessage isKindOfClass:[TL_localEmptyMessage class]]; } -(BOOL)isFwdMessage { @@ -416,10 +518,33 @@ - (BOOL)makeSizeByWidth:(int)width { return NO; } --(void)dealloc { +-(int)fontSize { + return [SettingsArchiver checkMaskedSetting:BigFontSetting] ? 15 : 13; } +-(BOOL)updateViews { + + NSString *o = _viewsCount; + + _viewsCount = [@(MAX(1,self.message.views)) prettyNumber]; + + return ![_viewsCount isEqualToString:o]; + +} + +-(id)copy { + MessageTableItem *item = [MessageTableItem messageItemFromObject:self.message]; + + item.messageSender = self.messageSender; + + return item; +} + +-(id)copyWithZone:(NSZone *)zone { + return [self copy]; +} + + (NSDateFormatter *)dateFormatter { static NSDateFormatter *dateF = nil; static dispatch_once_t onceToken; diff --git a/TelegramTest/MessageTableItemAudio.m b/TelegramTest/MessageTableItemAudio.m index 52dc990f..b31dd8b5 100644 --- a/TelegramTest/MessageTableItemAudio.m +++ b/TelegramTest/MessageTableItemAudio.m @@ -13,6 +13,7 @@ #import "DownloadAudioItem.h" #import "MessagetableCellAudioController.h" #import "TGAudioPlayerWindow.h" +#import "DownloadQueue.h" @implementation MessageTableItemAudio - (id)initWithObject:(TLMessage *)object { @@ -91,6 +92,10 @@ - (void)audioPlayerDidStartPlaying:(TGAudioPlayer *)audioPlayer { } +-(DownloadItem *)downloadItem { + return [DownloadQueue find:self.message.media.audio.n_id]; +} + - (int)size { return self.message.media.audio.size; } diff --git a/TelegramTest/MessageTableItemAudioDocument.m b/TelegramTest/MessageTableItemAudioDocument.m index 25750c60..66f53725 100644 --- a/TelegramTest/MessageTableItemAudioDocument.m +++ b/TelegramTest/MessageTableItemAudioDocument.m @@ -11,6 +11,7 @@ #import "NSStringCategory.h" #import "NSString+Extended.h" #import +#import "DownloadQueue.h" @implementation MessageTableItemAudioDocument - (id)initWithObject:(TLMessage *)object { @@ -33,7 +34,7 @@ - (id)initWithObject:(TLMessage *)object { } -(void)checkStartDownload:(SettingsMask)setting size:(int)size { - [super checkStartDownload:[self.message.to_id isKindOfClass:[TL_peerChat class]] ? AutoGroupDocuments : AutoPrivateDocuments size:[self size]]; + [super checkStartDownload:[self.message.to_id isKindOfClass:[TL_peerChat class]] || [self.message.to_id isKindOfClass:[TL_peerChannel class]] ? AutoGroupDocuments : AutoPrivateDocuments size:[self size]]; } -(BOOL)canShare { @@ -49,7 +50,7 @@ -(void)doAfterDownload { TL_documentAttributeAudio *audio = (TL_documentAttributeAudio *) [self.message.media.document attributeWithClass:[TL_documentAttributeAudio class]]; if(audio && ([audio.title trim].length > 0 && [audio.performer trim].length > 0)) { - self.duration = [NSString stringWithFormat:@"%@ - %@",audio.performer,audio.title]; + self.duration = [NSString stringWithFormat:@"%@\n%@",audio.performer,audio.title]; } else { self.duration = self.message.media.document.file_name; } @@ -126,6 +127,14 @@ -(void)setDownloadItem:(DownloadItem *)downloadItem { _secondDownloadListener = [[DownloadEventListener alloc] init]; } +-(DownloadItem *)downloadItem { + return [DownloadQueue find:self.message.media.document.n_id]; +} + +-(void)dealloc { + [self.downloadItem removeAllEvents]; +} + - (int)size { return self.message.media.document.size; } @@ -137,7 +146,9 @@ -(NSString *)fileName { -(BOOL)makeSizeByWidth:(int)width { [super makeSizeByWidth:width]; - self.blockSize = NSMakeSize(width - 200, 60); + + + self.blockSize = NSMakeSize(width - self.dateSize.width - 20, 50); return NO; } diff --git a/TelegramTest/MessageTableItemContact.h b/TelegramTest/MessageTableItemContact.h index d2c49a13..2891c18d 100644 --- a/TelegramTest/MessageTableItemContact.h +++ b/TelegramTest/MessageTableItemContact.h @@ -16,6 +16,7 @@ @property (nonatomic, strong) TLUser *contactUser; @property (nonatomic, strong) NSString *contactText; @property (nonatomic, strong) NSString *contactName; +@property (nonatomic, assign) NSSize contactNameSize; @property (nonatomic, strong) NSAttributedString *contactNumber; @property (nonatomic, strong) NSString *contactNumberString; diff --git a/TelegramTest/MessageTableItemContact.m b/TelegramTest/MessageTableItemContact.m index 485fc46b..8dbfc06a 100644 --- a/TelegramTest/MessageTableItemContact.m +++ b/TelegramTest/MessageTableItemContact.m @@ -41,7 +41,7 @@ - (id) initWithObject:(TLMessage *)object { NSString *phoneNumber = contact.phone_number.length ? [RMPhoneFormat formatPhoneNumber:contact.phone_number] : NSLocalizedString(@"User.Hidden", nil); self.contactNumberString = phoneNumber; - self.contactNumber = [[NSAttributedString alloc] initWithString:phoneNumber attributes:@{NSFontAttributeName: [NSFont fontWithName:@"HelveticaNeue" size:12]}]; + self.contactNumber = [[NSAttributedString alloc] initWithString:phoneNumber attributes:@{NSFontAttributeName: TGSystemFont(12)}]; self.contactNumberSize = [self.contactNumber sizeForWidth:FLT_MAX height:FLT_MAX]; @@ -50,6 +50,16 @@ - (id) initWithObject:(TLMessage *)object { return self; } +-(BOOL)makeSizeByWidth:(int)width { + [super makeSizeByWidth:width]; + + NSAttributedString *attr = [[NSAttributedString alloc] initWithString:_contactName attributes:@{NSFontAttributeName:TGSystemFont(13)}]; + + _contactNameSize = [attr sizeForTextFieldForWidth:width]; + + return YES; +} + -(NSString *)contactName { if(self->_contactName == nil) return @""; diff --git a/TelegramTest/MessageTableItemDocument.m b/TelegramTest/MessageTableItemDocument.m index d8dfa7f5..7e3f282c 100644 --- a/TelegramTest/MessageTableItemDocument.m +++ b/TelegramTest/MessageTableItemDocument.m @@ -101,8 +101,10 @@ - (void)doAfterDownload { [super doAfterDownload]; self.state = DocumentStateDownloaded; - - +} + +-(DownloadItem *)downloadItem { + return [DownloadQueue find:self.message.media.document.n_id]; } - (BOOL)canDownload { diff --git a/TelegramTest/MessageTableItemGeo.m b/TelegramTest/MessageTableItemGeo.m index 9a10ffc4..e864156b 100644 --- a/TelegramTest/MessageTableItemGeo.m +++ b/TelegramTest/MessageTableItemGeo.m @@ -48,9 +48,13 @@ -(BOOL)makeSizeByWidth:(int)width { width-=50; } - self.blockSize = NSMakeSize(width - ([self.message.media isKindOfClass:[TL_messageMediaVenue class]] ? 100 : 60), [self.message.media isKindOfClass:[TL_messageMediaVenue class]] ? 60 : 130); + NSSize size = NSMakeSize(width - ([self.message.media isKindOfClass:[TL_messageMediaVenue class]] ? 100 : 60), [self.message.media isKindOfClass:[TL_messageMediaVenue class]] ? 60 : 130); - return YES; + BOOL makeNew = self.blockSize.width != size.width || self.blockSize.height != size.height; + + self.blockSize = size; + + return makeNew; } @end diff --git a/TelegramTest/MessageTableItemGif.m b/TelegramTest/MessageTableItemGif.m index f5b94707..eb363438 100644 --- a/TelegramTest/MessageTableItemGif.m +++ b/TelegramTest/MessageTableItemGif.m @@ -8,6 +8,26 @@ #import "MessageTableItemGif.h" #import "ImageUtils.h" +#import "DownloadQueue.h" +@interface TGGifImageObject : TGImageObject + +@end + + +@implementation TGGifImageObject + +-(void)_didDownloadImage:(DownloadItem *)item { + NSImage *image = [[NSImage alloc] initWithData:item.result]; + + image = [ImageUtils blurImage:image blurRadius:60 frameSize:self.imageSize]; + + [[ASQueue mainQueue] dispatchOnQueue:^{ + [self.delegate didDownloadImage:image object:self]; + }]; +} + + +@end @implementation MessageTableItemGif @@ -28,7 +48,7 @@ - (id)initWithObject:(TL_localMessage *)object { self.cachedThumb = [ImageUtils roundCorners:self.cachedThumb size:NSMakeSize(3, 3)]; } else { - self.imageObject = [[TGImageObject alloc] initWithLocation:self.previewLocation placeHolder:self.cachedThumb sourceId:object.peer_id size:thumb.size]; + self.imageObject = [[TGGifImageObject alloc] initWithLocation:self.previewLocation placeHolder:self.cachedThumb sourceId:object.peer_id size:thumb.size]; } [self makeSizeByWidth:310]; @@ -64,11 +84,17 @@ -(BOOL)makeSizeByWidth:(int)width { size.height = MAX(60, size.height); + BOOL makeNew = self.blockSize.width != size.width || self.blockSize.height != size.height; + self.blockSize = size; self.imageObject.imageSize = self.blockSize; - return YES; + return makeNew; +} + +-(DownloadItem *)downloadItem { + return [DownloadQueue find:self.message.media.document.n_id]; } -(Class)downloadClass { diff --git a/TelegramTest/MessageTableItemHole.h b/TelegramTest/MessageTableItemHole.h new file mode 100644 index 00000000..a6e0f257 --- /dev/null +++ b/TelegramTest/MessageTableItemHole.h @@ -0,0 +1,18 @@ +// +// MessageTableitemMessagesHole.h +// Telegram +// +// Created by keepcoder on 27.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "MessageTableItem.h" + +@interface MessageTableItemHole : MessageTableItem + +@property (nonatomic,strong,readonly) NSAttributedString *text; +@property (nonatomic,assign,readonly) NSSize textSize; + +-(void)updateWithHole:(TGMessageHole *)hole; + +@end diff --git a/TelegramTest/MessageTableItemHole.m b/TelegramTest/MessageTableItemHole.m new file mode 100644 index 00000000..b3012434 --- /dev/null +++ b/TelegramTest/MessageTableItemHole.m @@ -0,0 +1,63 @@ +// +// MessageTableitemMessagesHole.m +// Telegram +// +// Created by keepcoder on 27.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "MessageTableItemHole.h" + +@interface MessageTableItemHole () +@end + +@implementation MessageTableItemHole + +-(id)initWithObject:(TL_localMessage *)object { + if(self = [super init]) { + self.message = object; + [self updateWithHole:object.hole]; + + } + + return self; +} + +-(void)updateWithHole:(TGMessageHole *)hole { + + self.message.hole = hole; + + NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] init]; + + if([hole isKindOfClass:[TGMessageGroupHole class]]) { + NSRange range = [attr appendString: (self.message.hole.messagesCount == 1 ? [NSString stringWithFormat:NSLocalizedString(@"Channel.oneComment", nil),self.message.hole.messagesCount] : [NSString stringWithFormat:NSLocalizedString(@"Channel.manyComments", nil),self.message.hole.messagesCount]) withColor:LINK_COLOR]; + + [attr addAttribute:NSLinkAttributeName value:@"showComments" range:range]; + + } else { + NSRange range = [attr appendString:NSLocalizedString(@"Channel.GotoNewMessages", nil) withColor:LINK_COLOR]; + [attr addAttribute:NSLinkAttributeName value:@"showNewMessages" range:range]; + } + + _text = [attr copy]; + + [self makeSizeByWidth:self.blockWidth]; + +} + + +-(BOOL)makeSizeByWidth:(int)width { + [super makeSizeByWidth:width]; + + + _textSize = [_text coreTextSizeForTextFieldForWidth:width]; + + + self.blockSize = NSMakeSize(width, _textSize.height); + + + return YES; + +} + +@end diff --git a/TelegramTest/MessageTableItemPhoto.m b/TelegramTest/MessageTableItemPhoto.m index 6d0b1f5b..42ff0500 100644 --- a/TelegramTest/MessageTableItemPhoto.m +++ b/TelegramTest/MessageTableItemPhoto.m @@ -67,9 +67,9 @@ - (id) initWithObject:(TL_localMessage *)object { [c appendString:[[self.message.media.caption trim] fixEmoji] withColor:TEXT_COLOR]; - [c setFont:[NSFont fontWithName:@"HelveticaNeue" size:13] forRange:c.range]; + [c setFont:TGSystemFont(13) forRange:c.range]; - [c detectAndAddLinks:URLFindTypeHashtags | URLFindTypeLinks | URLFindTypeMentions]; + [c detectAndAddLinks:URLFindTypeHashtags | URLFindTypeLinks | URLFindTypeMentions | (self.user.isBot || self.message.peer.isChat ? URLFindTypeBotCommands : 0)]; _caption = c; } @@ -108,13 +108,11 @@ -(void)doAfterDownload { -(BOOL)makeSizeByWidth:(int)width { [super makeSizeByWidth:width]; - if(self.isForwadedMessage) - width-=50; TLPhotoSize *photoSize = ((TLPhotoSize *)[self.message.media.photo.sizes lastObject]); _imageSize = strongsize(NSMakeSize(photoSize.w, photoSize.h), MIN(MIN_IMG_SIZE.width,width - 40)); - + if(_caption) { _captionSize = [_caption coreTextSizeForTextFieldForWidth:_imageSize.width ]; _captionSize.width = _imageSize.width ; @@ -131,4 +129,7 @@ -(BOOL)needUploader { return YES; } + + + @end diff --git a/TelegramTest/MessageTableItemServiceMessage.m b/TelegramTest/MessageTableItemServiceMessage.m index ba519485..2c4ccb59 100644 --- a/TelegramTest/MessageTableItemServiceMessage.m +++ b/TelegramTest/MessageTableItemServiceMessage.m @@ -12,6 +12,40 @@ #import "ImageUtils.h" #import "TGDateUtils.h" #import "NSAttributedString+Hyperlink.h" +#import "TGImageObject.h" +#import "TMImageUtils.h" + + +@interface TGImageGroupPhotoObject : TGImageObject + +@end + +@implementation TGImageGroupPhotoObject + + +-(void)_didDownloadImage:(DownloadItem *)item { + __block NSImage *imageOrigin = [[NSImage alloc] initWithData:item.result]; + + NSImage *image = renderedImage(imageOrigin, imageOrigin.size.width == 0 || imageOrigin.size.height ? self.imageSize : imageOrigin.size); + + [TGCache cacheImage:image forKey:self.location.cacheKey groups:@[IMGCACHE]]; + + image = [TMImageUtils roundedImageNew:image size:self.imageSize]; + + [TGCache cacheImage:image forKey:[self cacheKey] groups:@[IMGCACHE]]; + + [ASQueue dispatchOnMainQueue:^{ + [self.delegate didDownloadImage:image object:self]; + }]; +} + +-(NSString *)cacheKey { + return [NSString stringWithFormat:@"group:%lu:%@",self.location.hashCacheKey,NSStringFromSize(self.imageSize)]; +} + +@end + + @implementation MessageTableItemServiceMessage - (id) initWithDate:(int)date { @@ -22,7 +56,7 @@ - (id) initWithDate:(int)date { self.viewSize = NSMakeSize(0, 10); NSDictionary *attributes = @{ - NSFontAttributeName: [NSFont fontWithName:@"HelveticaNeue" size:13], + NSFontAttributeName: TGSystemFont(13), NSForegroundColorAttributeName: NSColorFromRGB(0xbbbbbb) }; @@ -44,7 +78,8 @@ - (id)initWithObject:(TL_localMessage *)object { self = [super initWithObject:object]; if(self) { self.messageAttributedString = [[MessagesUtils serviceAttributedMessage:object forAction:object.action] mutableCopy]; - [self.messageAttributedString detectAndAddLinks:URLFindTypeAll]; + + self.type = MessageTableItemServiceMessageAction; if([object.action isKindOfClass:[TL_messageActionBotDescription class]]) { @@ -74,15 +109,14 @@ - (id)initWithObject:(TL_localMessage *)object { TLPhotoSize *photoSize = ((TLPhotoSize *)[self.photo.sizes objectAtIndex:MIN(2, self.photo.sizes.count) - 1]); self.photoLocation = photoSize.location; - self.photoSize = strongsizeWithMinMax(NSMakeSize(photoSize.w, photoSize.h), 40, 250); } - self.imageObject = [[TGImageObject alloc] initWithLocation:self.photoLocation placeHolder:self.cachePhoto]; + self.imageObject = [[TGImageGroupPhotoObject alloc] initWithLocation:self.photoLocation placeHolder:self.cachePhoto]; self.imageObject.imageSize = self.photoSize; } - - [self.messageAttributedString detectAndAddLinks:URLFindTypeLinks | URLFindTypeMentions | URLFindTypeHashtags | (object.conversation.user.isBot || object.conversation.type == DialogTypeChat ? URLFindTypeBotCommands : 0)]; + if([self.message.action isKindOfClass:[TL_messageActionBotDescription class]]) + [self.messageAttributedString detectAndAddLinks:URLFindTypeAll]; } return self; } @@ -91,13 +125,13 @@ -(BOOL)makeSizeByWidth:(int)width { [super makeSizeByWidth:width]; - NSSize size = [self.messageAttributedString sizeForTextFieldForWidth:width]; + NSSize size = [self.messageAttributedString coreTextSizeForTextFieldForWidth:width]; _textSize = size; size.width = width; size.height += 10; - size.height += self.photoSize.height ? self.photoSize.height + 10 : 0; + size.height += self.photoSize.height ? self.photoSize.height : 0; self.blockSize = size; return YES; diff --git a/TelegramTest/MessageTableItemSticker.m b/TelegramTest/MessageTableItemSticker.m index 5c0c25b0..1114a737 100644 --- a/TelegramTest/MessageTableItemSticker.m +++ b/TelegramTest/MessageTableItemSticker.m @@ -45,4 +45,6 @@ -(id)initWithObject:(TL_localMessage *)object { return self; } + + @end diff --git a/TelegramTest/MessageTableItemText.h b/TelegramTest/MessageTableItemText.h index 3311ce67..38692683 100644 --- a/TelegramTest/MessageTableItemText.h +++ b/TelegramTest/MessageTableItemText.h @@ -19,12 +19,14 @@ @property (nonatomic,assign) NSSize textSize; @property (nonatomic,strong,readonly) TGWebpageObject *webpage; - +@property (nonatomic,strong,readonly) NSArray *links; +@property (nonatomic,strong,readonly) NSAttributedString *allAttributedLinks; +@property (nonatomic,assign,readonly) NSSize allAttributedLinksSize; -(void)updateMessageFont; -(void)updateWebPage; - +-(void)updateEntities; -(BOOL)isWebPage; diff --git a/TelegramTest/MessageTableItemText.m b/TelegramTest/MessageTableItemText.m index 20aa3f9b..be1abd4c 100644 --- a/TelegramTest/MessageTableItemText.m +++ b/TelegramTest/MessageTableItemText.m @@ -20,6 +20,8 @@ @interface MessageTableItemText() @property (nonatomic, strong) NSMutableAttributedString *forwardAttributedString; @property (nonatomic,strong) id requestKey; +@property (nonatomic,assign) BOOL isEmojiMessage; + @end @@ -32,19 +34,31 @@ - (id) initWithObject:(TL_localMessage *)object { NSString *message = [[object.message trim] fixEmoji]; +// NSArray *emoji = [message getEmojiFromString:NO]; +// +// if(emoji.count <= 5) { +// NSMutableString *c = [message mutableCopy]; +// +// [emoji enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { +// +// [c replaceOccurrencesOfString:obj withString:@"" options:0 range:NSMakeRange(0, c.length)]; +// +// }]; +// +// _isEmojiMessage = [c trim].length == 0; +// } +// [self.textAttributed appendString:message withColor:TEXT_COLOR]; + [self.textAttributed setAlignment:NSLeftTextAlignment range:self.textAttributed.range]; + [self updateEntities]; - [self updateMessageFont]; - - [SettingsArchiver addEventListener:self]; + // [SettingsArchiver addEventListener:self]; - [self.textAttributed detectAndAddLinks:URLFindTypeLinks | URLFindTypeMentions | URLFindTypeHashtags | (object.conversation.user.isBot || object.conversation.type == DialogTypeChat ? URLFindTypeBotCommands : 0)]; - [self updateWebPage]; @@ -55,22 +69,183 @@ - (id) initWithObject:(TL_localMessage *)object { } +-(void)updateLinkAttributesByMessageEntities { + + + + [self.textAttributed removeAttribute:NSLinkAttributeName range:self.textAttributed.range]; + + _links = [[NSArray alloc] init]; + + NSMutableArray *links = [NSMutableArray array]; + + if(self.message.entities.count > 0) + { + + __block NSRange nextRange = NSMakeRange(0, self.textAttributed.string.length); + + [self.message.entities enumerateObjectsUsingBlock:^(TLMessageEntity *obj, NSUInteger idx, BOOL *stop) { + + if([obj isKindOfClass:[TL_messageEntityUrl class]] ||[obj isKindOfClass:[TL_messageEntityTextUrl class]] || [obj isKindOfClass:[TL_messageEntityMention class]] || [obj isKindOfClass:[TL_messageEntityBotCommand class]] || [obj isKindOfClass:[TL_messageEntityHashtag class]] || [obj isKindOfClass:[TL_messageEntityEmail class]] || [obj isKindOfClass:[TL_messageEntityPre class]] || [obj isKindOfClass:[TL_messageEntityCode class]]) { + + if([obj isKindOfClass:[TL_messageEntityBotCommand class]] && (!self.message.conversation.user.isBot && self.message.conversation.type != DialogTypeChat && (self.message.conversation.type != DialogTypeChannel && !self.message.chat.isMegagroup)) ) + return; + + if([obj isKindOfClass:[TL_messageEntityBotCommand class]] && self.message.conversation.type == DialogTypeChat) { + if(self.message.chat.chatFull && self.message.chat.chatFull.bot_info.count == 0) + return; + } + + NSRange range = [self checkAndReturnEntityRange:obj]; + + NSString *link = [self.message.message substringWithRange:range]; + + + //range = [self.textAttributed.string rangeOfString:link options:NSCaseInsensitiveSearch range:nextRange]; + + + nextRange = NSMakeRange(range.location + range.length, self.textAttributed.length - (range.location + range.length)); + + if(range.location != NSNotFound) { + + if([obj isKindOfClass:[TL_messageEntityTextUrl class]]) { + link = obj.url; + } + if([obj isKindOfClass:[TL_messageEntityTextUrl class]] || [obj isKindOfClass:[TL_messageEntityUrl class]]) + [links addObject:link]; + + + if([obj isKindOfClass:[TL_messageEntityCode class]]) { + [self.textAttributed addAttribute:NSForegroundColorAttributeName value:[NSColor redColor] range:range]; + + } else if([obj isKindOfClass:[TL_messageEntityPre class]]) { + [self.textAttributed addAttribute:NSForegroundColorAttributeName value:DARK_GREEN range:range]; + } else { + [self.textAttributed addAttribute:NSLinkAttributeName value:link range:range]; + [self.textAttributed addAttribute:NSForegroundColorAttributeName value:LINK_COLOR range:range]; + } + + } + + } --(void)updateMessageFont { - [self.textAttributed setFont:[NSFont fontWithName:@"HelveticaNeue" size:[SettingsArchiver checkMaskedSetting:BigFontSetting] ? 15 : 13] forRange:self.textAttributed.range]; + }]; + + } else { + links = (NSMutableArray *) [self.textAttributed detectAndAddLinks:URLFindTypeLinks | URLFindTypeMentions | URLFindTypeHashtags | (self.message.conversation.user.isBot || (self.message.conversation.type == DialogTypeChat || (self.message.conversation.type == DialogTypeChannel && self.message.chat.isMegagroup)) ? URLFindTypeBotCommands : 0)]; + } -// static NSMutableParagraphStyle *paragraph; -// -// static dispatch_once_t onceToken; -// dispatch_once(&onceToken, ^{ -// paragraph = [[NSMutableParagraphStyle alloc] init]; -// -// }); -// -// [paragraph setLineSpacing:[SettingsArchiver checkMaskedSetting:BigFontSetting] ? 1 : 2]; -// -// [self.textAttributed addAttribute:NSParagraphStyleAttributeName value:paragraph range:self.textAttributed.range]; + _links = links; + + NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] init]; + + + + [_links enumerateObjectsUsingBlock:^(NSString *obj, NSUInteger idx, BOOL *stop) { + + if(idx == 0) { + + NSString *header = obj; + + if(![obj hasPrefix:@"http://"] && ![obj hasPrefix:@"https://"] && ![obj hasPrefix:@"ftp://"]) + header = obj; + else { + NSURLComponents *components = [[NSURLComponents alloc] initWithString:obj]; + header = components.host; + } + + + + NSRange r = [attr appendString:[header stringByAppendingString:@"\n\n"] withColor:TEXT_COLOR]; + [attr setCTFont:TGSystemMediumFont(13) forRange:r]; + + NSRange range = [attr appendString:obj]; + + [attr addAttribute:NSLinkAttributeName value:obj range:range]; + [attr addAttribute:NSForegroundColorAttributeName value:LINK_COLOR range:range]; + [attr addAttribute:NSCursorAttributeName value:[NSCursor pointingHandCursor] range:range]; + [attr addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInt:NSUnderlineStyleNone] range:range]; + + + [attr addAttribute:NSFontAttributeName value:TGSystemFont(12.5) range:range]; + + if(idx != _links.count - 1) + [attr appendString:@"\n"]; + } else { + *stop = YES; + } + + + + }]; + + + + _allAttributedLinks = [attr copy]; + + + +} + +-(void)updateEntities { + [self updateLinkAttributesByMessageEntities]; + [self updateFontAttributesByEntities]; +} + +-(void)updateFontAttributesByEntities { + [self.textAttributed removeAttribute: (NSString *)kCTFontAttributeName range:self.textAttributed.range]; + + + [self.textAttributed setCTFont:TGSystemFont([self fontSize]) forRange:self.textAttributed.range]; + + + NSMutableParagraphStyle *style = [NSMutableParagraphStyle new]; + style.lineSpacing = 0; + style.alignment = NSLeftTextAlignment; + + [self.textAttributed addAttribute:NSParagraphStyleAttributeName value:style range:self.textAttributed.range]; + + [self.message.entities enumerateObjectsUsingBlock:^(TLMessageEntity *obj, NSUInteger idx, BOOL *stop) { + + NSRange range = [self checkAndReturnEntityRange:obj]; + + if([obj isKindOfClass:[TL_messageEntityBold class]]) { + + NSString *link = [self.message.message substringWithRange:range]; + + range = [self.textAttributed.string rangeOfString:link]; + + [self.textAttributed addAttribute:NSFontAttributeName value:TGSystemMediumFont([self fontSize]) range:range]; + } else if([obj isKindOfClass:[TL_messageEntityItalic class]]) { + + NSString *link = [self.message.message substringWithRange:range]; + + range = [self.textAttributed.string rangeOfString:link]; + + + [self.textAttributed addAttribute:NSFontAttributeName value:TGSystemItalicFont([self fontSize]) range:range]; + } else if([obj isKindOfClass:[TL_messageEntityCode class]] || [obj isKindOfClass:[TL_messageEntityPre class]]) { + [self.textAttributed setCTFont:[NSFont fontWithName:@"Courier" size:[self fontSize]] forRange:range]; + } + + }]; +} + + +-(NSRange)checkAndReturnEntityRange:(TLMessageEntity *)obj { + + int location = MIN((int)self.message.message.length, obj.offset); + + int length = ((int)self.message.message.length - (location + obj.length)) >= 0 ? obj.length : 0; + + return NSMakeRange(location, length); +} + +-(void)updateMessageFont { + + [self updateFontAttributesByEntities]; + if(self.blockWidth != 0) [self makeSizeByWidth:self.blockWidth]; @@ -82,19 +257,20 @@ -(void)didChangeSettingsMask:(SettingsMask)mask { - (BOOL)makeSizeByWidth:(int)width { - width = MAX(100,width); [super makeSizeByWidth:width]; - [_webpage makeSize:width]; + [_webpage makeSize:width - 30]; width -= self.dateSize.width+10; + if(self.isForwadedMessage) { - width -= 50; + width -= 6; } + _allAttributedLinksSize = [_allAttributedLinks coreTextSizeForTextFieldForWidth:width]; _textSize = [_textAttributed coreTextSizeForTextFieldForWidth:width]; _textSize.width = width; @@ -139,9 +315,12 @@ -(void)updateWebPage { self.message.media = msg.media; } - [[Storage manager] updateMessages:@[self.message]]; - [Notification perform:UPDATE_WEB_PAGE_ITEMS data:@{KEY_MESSAGE_ID_LIST:@[@(self.message.n_id)]}]; + [self.message save:NO]; + + if([self.message.media.webpage isKindOfClass:[TL_webPage class]]) { + [Notification perform:UPDATE_WEB_PAGE_ITEMS data:@{KEY_DATA:@{@(self.message.peer_id):@[@(self.message.n_id)]},KEY_WEBPAGE:self.message.media.webpage}]; + } } @@ -183,8 +362,15 @@ -(BOOL)isset { +-(int)fontSize { + if(_isEmojiMessage) + return 36; + else + return [super fontSize]; +} + -(void)dealloc { - [SettingsArchiver removeEventListener:self]; + //[SettingsArchiver removeEventListener:self]; } @end diff --git a/TelegramTest/MessageTableItemVideo.m b/TelegramTest/MessageTableItemVideo.m index ab1fcee5..678f4a97 100644 --- a/TelegramTest/MessageTableItemVideo.m +++ b/TelegramTest/MessageTableItemVideo.m @@ -69,8 +69,6 @@ -(BOOL)makeSizeByWidth:(int)width { [super makeSizeByWidth:width]; - if(self.isForwadedMessage) - width-=50; _videoSize = NSMakeSize(MIN(width - 60,250), self.message.media.video.thumb.h + (MIN(width - 60,250) - self.message.media.video.thumb.w)); @@ -86,6 +84,9 @@ -(BOOL)makeSizeByWidth:(int)width { return YES; } +-(DownloadItem *)downloadItem { + return [DownloadQueue find:self.message.media.video.n_id]; +} - (Class)downloadClass { return [DownloadVideoItem class]; diff --git a/TelegramTest/MessageTableNavigationTitleView.h b/TelegramTest/MessageTableNavigationTitleView.h index 451a2f25..c9e1318c 100644 --- a/TelegramTest/MessageTableNavigationTitleView.h +++ b/TelegramTest/MessageTableNavigationTitleView.h @@ -10,9 +10,15 @@ @interface MessageTableNavigationTitleView : TMView + +@property (nonatomic,weak) MessagesViewController *controller; + @property (nonatomic, strong) TL_conversation *dialog; @property (nonatomic, strong) dispatch_block_t tapBlock; +@property (nonatomic,assign,readonly) BOOL discussForceSwitched; +@property (nonatomic,assign,readonly) BOOL discussIsEnabled; +-(void)enableDiscussion:(BOOL)enable force:(BOOL)force; @end diff --git a/TelegramTest/MessageTableNavigationTitleView.m b/TelegramTest/MessageTableNavigationTitleView.m index e0982daa..664080d4 100644 --- a/TelegramTest/MessageTableNavigationTitleView.m +++ b/TelegramTest/MessageTableNavigationTitleView.m @@ -12,6 +12,7 @@ #import "ImageUtils.h" #import "TGAnimationBlockDelegate.h" #import "TGTimerTarget.h" +#import "ITSwitch.h" @interface MessageTableNavigationTitleView() @property (nonatomic, strong) TMNameTextField *nameTextField; @property (nonatomic, strong) TMStatusTextField *statusTextField; @@ -24,6 +25,7 @@ @interface MessageTableNavigationTitleView()_dialog = dialog; + + // [_searchButton setHidden:self.dialog.type == DialogTypeChannel]; + [self enableDiscussion:_discussionSwitch.isOn force:NO]; + - if(self.dialog.type == DialogTypeChat) { - TLChat *chat = self.dialog.chat; - [self.nameTextField setChat:chat]; - [self.statusTextField setChat:chat]; - } else if(self.dialog.type == DialogTypeSecretChat) { - TLUser *user = self.dialog.encryptedChat.peerUser; - [self.nameTextField setUser:user isEncrypted:YES]; - [self.statusTextField setUser:user]; - } else if(self.dialog.type == DialogTypeBroadcast) { - - TL_broadcast *broadcast = self.dialog.broadcast; - [self.nameTextField setBroadcast:broadcast]; - - [self.statusTextField setBroadcast:broadcast]; - - } else { - TLUser *user = self.dialog.user; - [self.nameTextField setUser:user isEncrypted:NO]; - [self.statusTextField setUser:user]; - } + [self.nameTextField updateWithConversation:self.dialog]; + + [self.statusTextField updateWithConversation:self.dialog]; + + + - [self sizeToFit]; } @@ -141,12 +176,44 @@ - (void)buildForSize:(NSSize)size { [self.nameTextField sizeToFit]; - [self.nameTextField setFrame:NSMakeRect(10, self.bounds.size.height - self.nameTextField.bounds.size.height - 4, self.bounds.size.width - 40, self.nameTextField.bounds.size.height)]; + + [self.nameTextField setFrameSize:NSMakeSize(MIN(NSWidth(self.frame) - 60,NSWidth(self.nameTextField.frame)), NSHeight(self.nameTextField.frame))]; + + [_nameTextField setCenteredXByView:_nameTextField.superview]; + [_nameTextField setFrameOrigin:NSMakePoint(NSMinX(_nameTextField.frame), self.bounds.size.height - self.nameTextField.bounds.size.height - 6)]; - [self.statusTextField setFrame:NSMakeRect(10, 9, self.bounds.size.width - 40, self.statusTextField.frame.size.height)]; + // [self.statusTextField setFrame:NSMakeRect(10, 9, self.bounds.size.width - 40, self.statusTextField.frame.size.height)]; + + [self.statusTextField setFrameOrigin:NSMakePoint(NSMinX(self.statusTextField.frame), 7)]; + [_searchButton setFrameOrigin:NSMakePoint(NSWidth(self.container.frame) - NSWidth(_searchButton.frame) +5, 10)]; + + [_discussionSwitch setCenteredXByView:_discussionSwitch.superview]; + + + + if(!_discussionSwitch.isHidden) + { + [_statusTextField setStringValue:NSLocalizedString(@"Channel.showcomments", nil)]; + + [self.statusTextField sizeToFit]; + + [_discussionSwitch setFrameOrigin:NSMakePoint(NSMinX(_discussionSwitch.frame) - roundf(NSWidth(_statusTextField.frame)/2), 6)]; + + [self.statusTextField setFrameOrigin:NSMakePoint(NSMaxX(self.discussionSwitch.frame), 7)]; + + } else { + [self.statusTextField sizeToFit]; + [self.statusTextField setCenteredXByView:self.statusTextField.superview]; + } + + + + + + } diff --git a/TelegramTest/MessageTablecellAudioDocumentView.m b/TelegramTest/MessageTablecellAudioDocumentView.m index 93875e58..b0f1a227 100644 --- a/TelegramTest/MessageTablecellAudioDocumentView.m +++ b/TelegramTest/MessageTablecellAudioDocumentView.m @@ -46,10 +46,14 @@ - (id)initWithFrame:(NSRect)frame { [self.playerButton addBlock:^(BTRControlEvents events) { - [TGAudioPlayerWindow show:weakSelf.item.message.conversation]; - [TGAudioPlayerWindow setCurrentItem:(MessageTableItemAudioDocument *)weakSelf.item]; - - + if(weakSelf.item.isset) { + [TGAudioPlayerWindow show:weakSelf.item.message.conversation]; + [TGAudioPlayerWindow setCurrentItem:(MessageTableItemAudioDocument *)weakSelf.item]; + + } else { + [weakSelf checkOperation]; + } + } forControlEvents:BTRControlEventClick]; [self.containerView addSubview:self.playerButton]; @@ -62,7 +66,7 @@ - (id)initWithFrame:(NSRect)frame { [self.durationView setStringValue:@"00:00 / 00:00"]; [[self.durationView cell] setLineBreakMode:NSLineBreakByTruncatingTail]; - [self.durationView setFont:[NSFont fontWithName:@"HelveticaNeue" size:12]]; + [self.durationView setFont:TGSystemFont(13)]; [self.durationView sizeToFit]; [self.durationView setTextColor:DARK_BLACK]; [self.containerView addSubview:self.durationView]; @@ -72,7 +76,7 @@ - (id)initWithFrame:(NSRect)frame { [self.stateTextField setBordered:NO]; [self.stateTextField setEditable:NO]; [self.stateTextField setDrawsBackground:NO]; - [self.stateTextField setFont:[NSFont fontWithName:@"HelveticaNeue" size:12]]; + [self.stateTextField setFont:TGSystemFont(12)]; [self.stateTextField setTextColor:NSColorFromRGB(0xbebebe)]; @@ -93,6 +97,8 @@ - (id)initWithFrame:(NSRect)frame { return self; } + + -(void)dealloc { [TGAudioPlayerWindow removeEventListener:self]; } @@ -126,7 +132,10 @@ - (NSRect)progressRect { -(void)setDurationTextFieldString:(NSString *)string { [self.durationView setStringValue:self.item.duration]; - [self.durationView setFrameSize:NSMakeSize([self progressWidth] - self.stateTextField.frame.size.width , NSHeight(self.durationView.frame))]; + [self.durationView sizeToFit]; + [self.durationView setFrameSize:NSMakeSize(MIN(NSWidth(self.containerView.frame) - NSMinX(self.durationView.frame) - NSWidth(self.stateTextField.frame) - 15,NSWidth(self.durationView.frame)), NSHeight(self.durationView.frame))]; + + [self.durationView setCenteredYByView:self.durationView.superview]; } -(void)drawRect:(NSRect)dirtyRect { @@ -161,7 +170,7 @@ - (void)setCellState:(CellState)cellState { break; } - if(self.cellState == CellStateDownloading || self.cellState == CellStateNeedDownload || self.cellState == CellStateDownloading) + if(self.cellState == CellStateDownloading || self.cellState == CellStateNeedDownload || self.cellState == CellStateDownloading || self.item.messageSender != nil) { [self.playerButton setImage:nil forControlState:BTRControlStateNormal]; } @@ -244,12 +253,12 @@ - (void)setItem:(MessageTableItemAudioDocument *)item { [self updateDownloadState]; - [self setStateTextFieldString:[NSString sizeToTransformedValuePretty:self.item.size]]; + [self setStateTextFieldString:item.fileSize]; [self setDurationTextFieldString:item.duration]; - [self.stateTextField setFrameOrigin:NSMakePoint(self.durationView.frame.origin.x + self.durationView.frame.size.width, self.durationView.frame.origin.y )]; - + [self.stateTextField setFrameOrigin:NSMakePoint(NSMaxX(self.durationView.frame) + 2, self.durationView.frame.origin.y )]; + [self.stateTextField setHidden:YES]; if(item.state != AudioStatePlaying && item.state != AudioStatePaused) [self updateCellState]; else { diff --git a/TelegramTest/MessageTypingView.m b/TelegramTest/MessageTypingView.m index 788f91a4..a2489aad 100644 --- a/TelegramTest/MessageTypingView.m +++ b/TelegramTest/MessageTypingView.m @@ -51,7 +51,7 @@ - (id)initWithFrame:(NSRect)frame { [self addSubview:self.typingView]; self.attributedString = [[NSMutableAttributedString alloc] init]; - self.textField = [[TMTextField alloc] initWithFrame:NSMakeRect(77, 10, 0, 0)]; + self.textField = [[TMTextField alloc] initWithFrame:NSMakeRect(77, 10, 0,20)]; [self.textField setBordered:NO]; [self.textField setEditable:NO]; [self.textField setEnabled:NO]; @@ -72,21 +72,23 @@ - (void) setDialog:(TL_conversation *) dialog { [Notification removeObserver:self]; [Notification addObserver:self selector:@selector(typingRedrawNotification:) name:[Notification notificationNameByDialog:dialog action:@"typing"]]; + [TGModernTypingManager asyncTypingWithConversation:dialog handler:^(TMTypingObject *typing) { + + [self redrawByArray:[typing currentActions] animated:NO]; + + }]; - [self redrawByArray:[[TGModernTypingManager typingForConversation:dialog] currentActions]]; } - (void) typingRedrawNotification:(NSNotification *)notification { NSArray *users = (NSArray *)([notification.userInfo objectForKey:@"users"]); - [self redrawByArray:users]; + [self redrawByArray:users animated:YES]; } -- (void) redrawByArray:(NSArray *)actions { +- (void) redrawByArray:(NSArray *)actions animated:(BOOL)animated { [[self.attributedString mutableString] setString:@""]; - - NSString *string = nil; if(actions.count) { @@ -96,14 +98,14 @@ - (void) redrawByArray:(NSArray *)actions { TGActionTyping *action = actions[0]; - TLUser *user = [[UsersManager sharedManager] find:action.user_id]; + TLUser *user = action.user; if(user) string =[NSString stringWithFormat:NSLocalizedString(NSStringFromClass(action.action.class), nil),user.fullName]; } else { NSMutableArray *usersStrings = [[NSMutableArray alloc] init]; for(TGActionTyping *action in actions) { - TLUser *user = [[UsersManager sharedManager] find:action.user_id]; + TLUser *user = action.user; if(user) { [usersStrings addObject:user.fullName]; } @@ -120,11 +122,25 @@ - (void) redrawByArray:(NSArray *)actions { self.needDots = 0; } - [self.textField setFont:[NSFont fontWithName:@"HelveticaNeue" size:12]]; + if(animated && self.textField.attributedStringValue.length == 0 && string.length > 0) { + [self.textField setFrameOrigin:NSMakePoint(NSMinX(_textField.frame), -20)]; + } + + [self.textField setFont:TGSystemFont(12)]; self.textField.attributedStringValue = self.attributedString; self.endString = (int) self.attributedString.length; [self.textField sizeToFit]; + + id typingF = animated ? [self.typingView animator] : self.typingView; + + + [typingF setFrameOrigin:NSMakePoint(NSMinX(_typingView.frame), string.length > 0 ? 10 : - 20)]; + + id fieldF = animated ? [self.textField animator] : self.textField; + + [fieldF setFrameOrigin:NSMakePoint(NSMinX(_textField.frame), string.length > 0 ? 10 : - 20)]; + int maxWidth = NSWidth(self.frame)-NSMinX(self.textField.frame) - 20; [self.textField setFrameSize:NSMakeSize(maxWidth, NSHeight(self.textField.frame))]; diff --git a/TelegramTest/MessagesBottomView.h b/TelegramTest/MessagesBottomView.h index f5984d5f..0cc0cd31 100644 --- a/TelegramTest/MessagesBottomView.h +++ b/TelegramTest/MessagesBottomView.h @@ -25,7 +25,7 @@ typedef enum { @property (nonatomic) BOOL forwardEnabled; @property (nonatomic) MessagesBottomViewState stateBottom; -@property (nonatomic, strong) MessagesViewController *messagesViewController; +@property (nonatomic, weak) MessagesViewController *messagesViewController; @property (nonatomic, strong) TL_conversation *dialog; @property (nonatomic,copy) dispatch_block_t onClickToLockedView; @@ -38,7 +38,7 @@ typedef enum { - (void)setInputMessageString:(NSString *)message disableAnimations:(BOOL)disableAnimations; - (NSString *)inputMessageString; -- (void)setSectedMessagesCount:(NSUInteger)count; +- (void)setSectedMessagesCount:(NSUInteger)count enable:(BOOL)enable; -(void)closeEmoji; @@ -49,6 +49,11 @@ typedef enum { -(void)addAttachment:(TGImageAttachment *)attachment; +-(BOOL)sendMessageAsAdmin; + -(NSUInteger)attachmentsCount; +-(void)selectInputTextByText:(NSString *)text; + + @end diff --git a/TelegramTest/MessagesBottomView.m b/TelegramTest/MessagesBottomView.m index 1ec09ed2..1faff4f6 100644 --- a/TelegramTest/MessagesBottomView.m +++ b/TelegramTest/MessagesBottomView.m @@ -48,6 +48,8 @@ @interface MessagesBottomView() @property (nonatomic, strong) BTRButton *smileButton; @property (nonatomic, strong) BTRButton *botKeyboardButton; @property (nonatomic, strong) BTRButton *botCommandButton; +@property (nonatomic, strong) BTRButton *channelAdminButton; +@property (nonatomic, strong) BTRButton *secretTimerButton; @property (nonatomic, strong) TMButton *sendButton; @@ -105,8 +107,6 @@ - (id)initWithFrame:(NSRect)frameRect { [self setState:MessagesBottomViewNormalState animated:NO]; - - [[EmojiViewController instance] loadView]; [self normalView]; } @@ -119,8 +119,25 @@ - (void)addSubview:(NSView *)aView { } - (void)didChangeBlockedUser:(NSNotification *)notification { + + TL_contactBlocked *contact = notification.userInfo[KEY_USER]; + + if(self.dialog.user.n_id != contact.user_id || self.dialog.user.isBot) + return; + + if(self.dialog && self.dialog.type == DialogTypeUser) { - [self setState:self.stateBottom animated:YES]; + [self setState:MessagesBottomViewNormalState animated:YES]; + } +} + +-(void)didChannelUpdatedFlags:(NSNotification *)notification { + TLChat *chat = notification.userInfo[KEY_CHAT]; + + if(chat.n_id == self.dialog.chat.n_id) { + + [self setState:self.stateBottom animated:NO]; + } } @@ -185,10 +202,10 @@ - (void)setDialog:(TL_conversation *)dialog { [Notification addObserver:self selector:@selector(didChangeBlockedUser:) name:USER_BLOCK]; + [Notification addObserver:self selector:@selector(didChannelUpdatedFlags:) name:CHAT_FLAGS_UPDATED]; //botKeyboard - if(self.dialog.type == DialogTypeSecretChat) { weakify(); ; @@ -215,6 +232,9 @@ - (void)setDialog:(TL_conversation *)dialog { _userFull = nil; _chatFull = nil; + [_channelAdminButton setSelected:NO]; + [self channelAdminButtonAction:_channelAdminButton]; + [self updateBotButtons]; @@ -238,11 +258,13 @@ - (void)setDialog:(TL_conversation *)dialog { }]; - } else if(self.dialog.type == DialogTypeChat) { - [[FullChatManager sharedManager] performLoad:self.dialog.peer.chat_id force:self.dialog.fullChat.class == [TL_chatFull_old29 class] && !self.dialog.fullChat.isLastLayerUpdated callback:^(TLChatFull * chatFull) { + } else if(self.dialog.type == DialogTypeChat || self.dialog.type == DialogTypeChannel) { + [[FullChatManager sharedManager] performLoad:self.dialog.chat.n_id force:(self.dialog.fullChat.class == [TL_chatFull_old29 class] && !self.dialog.fullChat.isLastLayerUpdated) || dialog.type == DialogTypeChannel callback:^(TLChatFull * chatFull) { _chatFull = chatFull; + [[FullChatManager sharedManager] loadParticipantsWithMegagroupId:chatFull.n_id]; + [self updateBotButtons]; }]; @@ -255,14 +277,22 @@ - (void)setDialog:(TL_conversation *)dialog { [self setHiddenRecoderControllers]; + + +} + +-(void)setMessagesViewController:(MessagesViewController *)controller { + _messagesViewController = controller; + _inputMessageTextField.controller = controller; } -(void)updateBotButtons { if(self.dialog.type == DialogTypeUser) { [self.botCommandButton setHidden:!self.dialog.user.isBot]; - } else if(self.dialog.type == DialogTypeChat) { + } else if(self.dialog.type == DialogTypeChat || self.dialog.type == DialogTypeChannel) { [self.botCommandButton setHidden:_chatFull.bot_info.count == 0]; - } + } else + [self.botCommandButton setHidden:YES]; if(!_botCommandButton.isHidden) @@ -273,6 +303,17 @@ -(void)updateBotButtons { } + [_channelAdminButton setHidden:!self.dialog.canSendChannelMessageAsAdmin || (!self.dialog.canSendChannelMessageAsUser && self.dialog.canSendChannelMessageAsAdmin)]; + + + if(!_channelAdminButton.isHidden) { + [_channelAdminButton setFrameOrigin:NSMakePoint(self.inputMessageTextField.containerView.frame.size.width - (_botCommandButton.isHidden ? 60 : 120), NSMinY(_channelAdminButton.frame))]; + + } + + + [_secretTimerButton setHidden:self.dialog.type != DialogTypeSecretChat]; + } - (TMView *)actionsView { @@ -301,7 +342,7 @@ - (TMView *)actionsView { self.messagesSelectedCount = [TMTextButton standartUserProfileNavigationButtonWithTitle:@""]; self.messagesSelectedCount.textColor = DARK_BLACK; - self.messagesSelectedCount.font = [NSFont fontWithName:@"HelveticaNeue" size:14]; + self.messagesSelectedCount.font = TGSystemFont(14); [self.messagesSelectedCount setAutoresizingMask:NSViewMinXMargin | NSViewMaxXMargin]; [self.actionsView addSubview:self.messagesSelectedCount]; @@ -314,7 +355,9 @@ - (TMView *)actionsView { // strongify(); - [[Telegram rightViewController] showForwardMessagesModalView:strongSelf.messagesViewController.conversation messagesCount:strongSelf.messagesViewController.selectedMessages.count]; + [self.messagesViewController showForwardMessagesModalView]; + + }]; [self.actionsView setDrawBlock:^{ @@ -343,7 +386,7 @@ -(void)updateFwdMessage:(BOOL)updateHeight animated:(BOOL)animated { [self checkFwdMessages:updateHeight animated:animated]; } -- (void)setSectedMessagesCount:(NSUInteger)count { +- (void)setSectedMessagesCount:(NSUInteger)count enable:(BOOL)enable { if(count == 0) { [self.messagesSelectedCount setHidden:YES]; [self.forwardButton setDisable:YES]; @@ -352,7 +395,10 @@ - (void)setSectedMessagesCount:(NSUInteger)count { } else { if(self.forwardEnabled) [self.forwardButton setDisable:NO]; - [self.deleteButton setDisable:NO]; + + + + [self.deleteButton setDisable:!enable]; } [self.messagesSelectedCount setHidden:NO]; @@ -401,6 +447,7 @@ - (TMView *)normalView { self.inputMessageTextField = [[MessageInputGrowingTextView alloc] initWithFrame:NSMakeRect(0, 0, 0, 0)]; [self.inputMessageTextField setEditable:YES]; [self.inputMessageTextField setRichText:NO]; + _inputMessageTextField.controller = _messagesViewController; // [self.inputMessageTextField.scrollView setFrameSize:NSMakeSize(100-30,100-10)]; @@ -413,7 +460,7 @@ - (TMView *)normalView { [self.attachButton setBackgroundImage:image_AttachHighlighted() forControlState:BTRControlStateSelected | BTRControlStateHover]; [self.attachButton setBackgroundImage:image_AttachHighlighted() forControlState:BTRControlStateHighlighted]; [self.attachButton addTarget:self action:@selector(attachButtonPressed) forControlEvents:BTRControlEventMouseEntered]; - +[self.attachButton addTarget:self action:@selector(attachButtonPressed) forControlEvents:BTRControlEventMouseDownInside]; [self.normalView addSubview:self.attachButton]; @@ -422,7 +469,7 @@ - (TMView *)normalView { [self.sendButton setAutoresizingMask:NSViewMinXMargin]; [self.sendButton setTarget:self selector:@selector(sendButtonAction)]; [self.sendButton setText:NSLocalizedString(@"Message.Send", nil)]; - [self.sendButton setTextFont:[NSFont fontWithName:@"HelveticaNeue-Medium" size:14]]; + [self.sendButton setTextFont:TGSystemMediumFont(14)]; NSSize size = [self.sendButton sizeOfText]; [self.sendButton setFrameSize:size]; [self.sendButton setFrameOrigin:NSMakePoint(self.bounds.size.width - size.width - 17, 19)]; @@ -460,7 +507,7 @@ - (TMView *)normalView { [self.recordDurationLayer disableActions]; self.recordDurationLayer.contentsScale = self.normalView.layer.contentsScale; [self.recordDurationLayer setTextColor:[NSColor blackColor]]; - [self.recordDurationLayer setTextFont:[NSFont fontWithName:@"HelveticaNeue" size:14]]; + [self.recordDurationLayer setTextFont:TGSystemFont(14)]; [self.recordDurationLayer setString:@"00:34"]; [self.recordDurationLayer sizeToFit]; [self.recordDurationLayer setFrameOrigin:CGPointMake(52, roundf( (self.bounds.size.height - self.recordDurationLayer.bounds.size.height) / 2.f) - 1)]; @@ -469,7 +516,7 @@ - (TMView *)normalView { self.recordHelpLayer = [TMTextLayer layer]; [self.recordHelpLayer disableActions]; self.recordHelpLayer.contentsScale = self.normalView.layer.contentsScale; - [self.recordHelpLayer setTextFont:[NSFont fontWithName:@"HelveticaNeue" size:14]]; + [self.recordHelpLayer setTextFont:TGSystemFont(14)]; [self.normalView.layer addSublayer:self.recordHelpLayer]; @@ -524,6 +571,34 @@ - (TMView *)normalView { [self.inputMessageTextField.containerView addSubview:self.botCommandButton]; + + + + self.channelAdminButton = [[BTRButton alloc] initWithFrame:NSMakeRect(self.inputMessageTextField.containerView.frame.size.width - 90, 7, image_ChannelMessageAsAdmin().size.width, image_ChannelMessageAsAdmin().size.height)]; + [self.channelAdminButton setAutoresizingMask:NSViewMinXMargin | NSViewMinYMargin]; + [self.channelAdminButton.layer disableActions]; + + [self.channelAdminButton addTarget:self action:@selector(channelAdminButtonAction:) forControlEvents:BTRControlEventMouseDownInside]; + [self.channelAdminButton setBackgroundImage: image_ChannelMessageAsAdmin() forControlState:BTRControlStateNormal]; + + + [self.inputMessageTextField.containerView addSubview:self.channelAdminButton]; + + + + self.secretTimerButton = [[BTRButton alloc] initWithFrame:NSMakeRect(self.inputMessageTextField.containerView.frame.size.width - 60, 2, 30, 30)]; + [self.secretTimerButton setAutoresizingMask:NSViewMinXMargin | NSViewMinYMargin]; + [self.secretTimerButton.layer disableActions]; + + [self.secretTimerButton addTarget:self action:@selector(secretTimerAction:) forControlEvents:BTRControlEventMouseDownInside]; + [self.secretTimerButton setImage: image_ModernConversationSecretAccessoryTimer() forControlState:BTRControlStateNormal]; + + + [self.inputMessageTextField.containerView addSubview:self.secretTimerButton]; + + + + [self.smileButton addTarget:self action:@selector(smileButtonClick:) forControlEvents:BTRControlEventMouseEntered]; [self.inputMessageTextField.containerView addSubview:self.smileButton]; @@ -540,6 +615,10 @@ - (TMView *)normalView { return self.normalView; } +-(BOOL)sendMessageAsAdmin { + return _channelAdminButton.isSelected && [self.dialog canSendChannelMessageAsAdmin]; +} + -(void)botKeyboardButtonAction:(BTRButton *)button { [self.botKeyboard setHidden:!self.botKeyboard.isHidden]; @@ -551,11 +630,42 @@ -(void)botKeyboardButtonAction:(BTRButton *)button { [self updateBottomHeight:YES]; } +static RBLPopover *popover; + +-(void)secretTimerAction:(BTRButton *)button { + + NSMenu *menu = [MessagesViewController destructMenu:^ { + // [self.setTTLButton setLocked:NO]; + + } click:^{ + [popover close]; + popover = nil; + }]; + + + [popover close]; + popover = nil; + + TMMenuController *controller = [[TMMenuController alloc] initWithMenu:menu]; + + popover = [[RBLPopover alloc] initWithContentViewController:controller]; + + [popover showRelativeToRect:button.bounds ofView:button preferredEdge:CGRectMinYEdge]; + +} + -(void)botCommandButtonAction:(BTRButton *)button { [self.inputMessageTextField setString:@"/"]; [self.inputMessageTextField textDidChange:nil]; } + +-(void)channelAdminButtonAction:(BTRButton *)button { + [_channelAdminButton setSelected:!_channelAdminButton.isSelected]; + + [_channelAdminButton setBackgroundImage:!_channelAdminButton.isSelected ? image_ChannelMessageAsAdmin() : image_ChannelMessageAsAdminHighlighted() forControlState:BTRControlStateNormal]; +} + -(NSMenu *)attachMenu { NSMenu *theMenu = [[NSMenu alloc] init]; @@ -766,6 +876,8 @@ -(void)closeEmoji { - (void)smileButtonClick:(BTRButton *)button { EmojiViewController *emojiViewController = [EmojiViewController instance]; + + emojiViewController.messagesViewController = self.messagesViewController; weak(); if(!self.smilePopover) { @@ -773,7 +885,9 @@ - (void)smileButtonClick:(BTRButton *)button { [self.smilePopover setHoverView:self.smileButton]; [self.smilePopover setDidCloseBlock:^(RBLPopover *popover){ [weakSelf.smileButton setSelected:NO]; + [[EmojiViewController instance] close]; }]; + } [emojiViewController setInsertEmoji:^(NSString *emoji) { @@ -810,24 +924,73 @@ - (TMView *)secretInfoView { [_secretInfoView setCallback:^{ - - if(!weakSelf.dialog.canSendMessage && weakSelf.dialog.user.isBot && _onClickToLockedView == nil) - { + if(weakSelf.dialog.isInvisibleChannel) { - [TMViewController showModalProgress]; + [weakSelf.messagesViewController showModalProgress]; + + [RPCRequest sendRequest:[TLAPI_channels_joinChannel createWithChannel:weakSelf.dialog.chat.inputPeer] successHandler:^(RPCRequest *request, id response) { + + + TL_localMessage *msg = [TL_localMessageService createWithFlags:TGMENTIONMESSAGE n_id:0 from_id:[UsersManager currentUserId] to_id:weakSelf.dialog.peer date:[[MTNetwork instance] getTime] action:([TL_messageActionChatAddUser createWithUsers:[@[@([UsersManager currentUserId])] mutableCopy]]) fakeId:[MessageSender getFakeMessageId] randomId:rand_long() dstate:DeliveryStateNormal]; + + [MessagesManager addAndUpdateMessage:msg]; + + weakSelf.dialog.invisibleChannel = NO; + + [weakSelf.dialog save]; + + [[DialogsManager sharedManager] updateLastMessageForDialog:weakSelf.dialog]; + + + [ASQueue dispatchOnMainQueue:^{ + [weakSelf.messagesViewController setState:MessagesViewControllerStateNone]; + [weakSelf.messagesViewController tryRead]; + [weakSelf.messagesViewController hideModalProgressWithSuccess]; + }]; + + + } errorHandler:^(RPCRequest *request, RpcError *error) { + + [ASQueue dispatchOnMainQueue:^{ + [weakSelf.messagesViewController hideModalProgress]; + }]; + + + } timeout:0 queue:[ASQueue globalQueue].nativeQueue]; + + + } else if(weakSelf.dialog.chat.isBroadcast && !(weakSelf.dialog.chat.left || weakSelf.dialog.chat.isKicked)) { + + + [weakSelf.dialog muteOrUnmute:^{ + + [weakSelf setState:weakSelf.stateBottom animated:YES]; + + } until:weakSelf.dialog.isMute ? 0 : 365*24*60*60]; + + + } else if(weakSelf.dialog.type == DialogTypeChannel && (weakSelf.dialog.chat.left || weakSelf.dialog.chat.isKicked || weakSelf.dialog.chat.type == TLChatTypeForbidden)) { + [[DialogsManager sharedManager] deleteDialog:weakSelf.dialog completeHandler:nil]; + + } else if(!weakSelf.dialog.canSendMessage && weakSelf.dialog.user.isBot && _onClickToLockedView == nil) { + + [weakSelf.messagesViewController showModalProgress]; [[BlockedUsersManager sharedManager] unblock:weakSelf.dialog.user.n_id completeHandler:^(BOOL response){ [TMViewController hideModalProgress]; [weakSelf.messagesViewController sendMessage:@"/start" forConversation:weakSelf.dialog]; + + [weakSelf setState:MessagesBottomViewNormalState animated:YES]; }]; return; + } else if(weakSelf.dialog.type == DialogTypeUser && weakSelf.dialog.user.isBlocked) { + [[BlockedUsersManager sharedManager] unblock:weakSelf.dialog.user.n_id completeHandler:nil]; } - if(_onClickToLockedView != nil) { weakSelf.onClickToLockedView(); @@ -848,8 +1011,9 @@ - (void)setState:(MessagesBottomViewState)state animated:(BOOL)animated { } } - if(!self.dialog.canSendMessage) + if(!self.dialog.canSendMessage || self.dialog.isInvisibleChannel) state = MessagesBottomViewBlockChat; + } @@ -898,10 +1062,10 @@ - (void)setState:(MessagesBottomViewState)state animated:(BOOL)animated { [self.encryptedStateTextField setTextColor:[self.encryptedStateTextField.stringValue isEqualToString:[self.dialog blockedText]] ? LINK_COLOR : GRAY_TEXT_COLOR]; - if(self.dialog.type == DialogTypeUser) - { - [self.encryptedStateTextField setTextColor:[NSColor redColor]]; - } +// if(self.dialog.type == DialogTypeUser && !self.dialog.user.isBot) +// { +// [self.encryptedStateTextField setTextColor:[NSColor redColor]]; +// } [self.encryptedStateTextField sizeToFit]; @@ -956,6 +1120,9 @@ - (void)setState:(MessagesBottomViewState)state animated:(BOOL)animated { [self becomeFirstResponder]; + + [self TMGrowingTextViewHeightChanged:self.inputMessageTextField height:NSHeight(self.inputMessageTextField.containerView.frame) cleared:animated]; + } - (void)sendButtonAction { @@ -980,10 +1147,12 @@ - (void)sendButtonAction { - (BOOL) TMGrowingTextViewCommandOrControlPressed:(id)textView isCommandPressed:(BOOL)isCommandPressed { BOOL isNeedSend = ([SettingsArchiver checkMaskedSetting:SendEnter] && !isCommandPressed) || ([SettingsArchiver checkMaskedSetting:SendCmdEnter] && isCommandPressed); - if(isNeedSend && ![TGMentionPopup isVisibility] && ![TGHashtagPopup isVisibility] && ![TGBotCommandsPopup isVisibility]) { + + + if(isNeedSend && self.messagesViewController.hintView.isHidden) { [self sendButtonAction]; } - return isNeedSend || ([TGMentionPopup isVisibility] || [TGHashtagPopup isVisibility] || [TGBotCommandsPopup isVisibility]); + return isNeedSend || (!self.messagesViewController.hintView.isHidden); } - (void) TMGrowingTextViewFirstResponder:(id)textView isFirstResponder:(BOOL)isFirstResponder { @@ -1049,10 +1218,6 @@ -(void)checkMentionsOrTags { rect.origin.x += 100; - [TGMentionPopup close]; - [TGHashtagPopup close]; - [TGBotCommandsPopup close]; - NSRange range; NSString *search; @@ -1114,29 +1279,33 @@ -(void)checkMentionsOrTags { }; - + if(type == 1) { - if(self.dialog.type == DialogTypeChat) - [TGMentionPopup show:search chat:self.dialog.chat view:self.window.contentView ofRect:rect callback:callback]; + if(self.dialog.type == DialogTypeChat || self.dialog.type == DialogTypeChannel) { + + [self.messagesViewController.hintView showMentionPopupWithQuery:search conversation:self.dialog chat:self.dialog.chat choiceHandler:callback]; + + } + } else if(type == 2) { - [TGHashtagPopup show:search peer_id:self.dialog.peer_id view:self.window.contentView ofRect:rect callback:callback]; + + [self.messagesViewController.hintView showHashtagHintsWithQuery:search conversation:self.dialog peer_id:self.dialog.peer_id choiceHandler:callback]; + } else if(type == 3 && [self.inputMessageTextField.string rangeOfString:@"/"].location == 0) { if([_dialog.user isBot] || _dialog.fullChat.bot_info != nil) { - [TGBotCommandsPopup show:search botInfo:_userFull ? @[_userFull.bot_info] : _dialog.fullChat.bot_info view:self.window.contentView ofRect:rect callback:^(NSString *command) { - + + [self.messagesViewController.hintView showCommandsHintsWithQuery:search conversation:self.dialog botInfo:_userFull ? @[_userFull.bot_info] : _dialog.fullChat.bot_info choiceHandler:^(NSString *command) { callback(command); - - [[Telegram rightViewController].messagesViewController sendMessage]; - + [self sendButtonAction]; }]; } } } else { - + [self.messagesViewController.hintView hide]; } @@ -1296,7 +1465,7 @@ -(void)checkReplayMessage:(BOOL)updateHeight animated:(BOOL)animated { if(replyMessage) { int startX = self.attachButton.frame.origin.x + self.attachButton.frame.size.width + 21; - TGReplyObject *replyObject = [[TGReplyObject alloc] initWithReplyMessage:replyMessage]; + TGReplyObject *replyObject = [[TGReplyObject alloc] initWithReplyMessage:replyMessage fromMessage:nil tableItem:nil]; _replyContainer = [[MessageReplyContainer alloc] initWithFrame:NSMakeRect(startX, NSHeight(self.inputMessageTextField.containerView.frame) + NSMinX(self.inputMessageTextField.frame) + 20 , NSWidth(self.inputMessageTextField.containerView.frame), replyObject.containerHeight)]; @@ -1404,32 +1573,37 @@ - (void) TMGrowingTextViewHeightChanged:(id)textView height:(int)height cleared: height = height % 2 == 1 ? height + 1 : height; // MTLog(@"height %d", height); - if(_imageAttachmentsController.isShown ) { - height += 75; - } - - - if(self.replyContainer != nil) { - height+= self.replyContainer.replyObject.containerHeight + 5; - } - - if(self.fwdContainer != nil) { - height+= 35; - } - if(self.webpageAttach != nil && self.inputMessageString.length > 0) { - height+= 35; - } + - if(_botKeyboard != nil) { - height+= (!_botKeyboard.isHidden ? NSHeight(_botKeyboard.frame) : 0); + if(self.stateBottom == MessagesBottomViewNormalState) { + + if(_imageAttachmentsController.isShown ) { + height += 75; + } + + if(self.replyContainer != nil || self.fwdContainer != nil || (self.webpageAttach != nil && self.inputMessageString.length > 0)) { + height+= 40; + } + + [_webpageAttach setHidden:_fwdContainer != nil]; + [_replyContainer setHidden:self.fwdContainer != nil || (self.webpageAttach != nil && self.inputMessageString.length > 0)]; + + + if(_botKeyboard != nil) { + height+= (!_botKeyboard.isHidden ? NSHeight(_botKeyboard.frame) : 0); + } + + } else { + height = 58; } + NSSize layoutSize = NSMakeSize(self.bounds.size.width, height); if(self.stateBottom == MessagesBottomViewNormalState) { [self.layer setNeedsDisplay]; - NSSize layoutSize = NSMakeSize(self.bounds.size.width, height); + if(isCleared) { @@ -1452,9 +1626,9 @@ - (void) TMGrowingTextViewHeightChanged:(id)textView height:(int)height cleared: [[_replyContainer animator] setFrameOrigin:NSMakePoint(NSMinX(_replyContainer.frame), NSHeight(self.inputMessageTextField.containerView.frame) + offset )]; - [[_fwdContainer animator] setFrameOrigin:NSMakePoint(NSMinX(_fwdContainer.frame), NSHeight(self.inputMessageTextField.containerView.frame) + offset + (_replyContainer ? 40 : 0))]; + [[_fwdContainer animator] setFrameOrigin:NSMakePoint(NSMinX(_fwdContainer.frame), NSHeight(self.inputMessageTextField.containerView.frame) + offset )]; - [[_webpageAttach animator] setFrameOrigin:NSMakePoint(NSMinX(_webpageAttach.frame), NSHeight(self.inputMessageTextField.containerView.frame) + offset + (_fwdContainer ? (_replyContainer ? 80 : 40) : _replyContainer ? 40 : 0))]; + [[_webpageAttach animator] setFrameOrigin:NSMakePoint(NSMinX(_webpageAttach.frame), NSHeight(self.inputMessageTextField.containerView.frame) + offset )]; } else { @@ -1472,12 +1646,12 @@ - (void) TMGrowingTextViewHeightChanged:(id)textView height:(int)height cleared: [_imageAttachmentsController setFrameOrigin:NSMakePoint(NSMinX(_imageAttachmentsController.frame), NSHeight(self.inputMessageTextField.containerView.frame) + 20 )]; - [_replyContainer setFrameOrigin:NSMakePoint(NSMinX(_replyContainer.frame), NSHeight(self.inputMessageTextField.containerView.frame) + offset )]; + [_replyContainer setFrameOrigin:NSMakePoint(NSMinX(_replyContainer.frame), NSHeight(self.inputMessageTextField.containerView.frame) + offset)]; - [_fwdContainer setFrameOrigin:NSMakePoint(NSMinX(_fwdContainer.frame), NSHeight(self.inputMessageTextField.containerView.frame) + offset + (_replyContainer ? 40 : 0))]; + [_fwdContainer setFrameOrigin:NSMakePoint(NSMinX(_fwdContainer.frame), NSHeight(self.inputMessageTextField.containerView.frame) + offset)]; - [_webpageAttach setFrameOrigin:NSMakePoint(NSMinX(_webpageAttach.frame), NSHeight(self.inputMessageTextField.containerView.frame) + offset + (_fwdContainer ? _replyContainer ? 80 : 40 : _replyContainer ? 40 : 0))]; + [_webpageAttach setFrameOrigin:NSMakePoint(NSMinX(_webpageAttach.frame), NSHeight(self.inputMessageTextField.containerView.frame) + offset)]; } @@ -1485,6 +1659,9 @@ - (void) TMGrowingTextViewHeightChanged:(id)textView height:(int)height cleared: // [self.layer setNeedsDisplay]; + } else { + [self setFrameSize:layoutSize]; + [self.messagesViewController bottomViewChangeSize:height animated:isCleared]; } } @@ -1495,7 +1672,15 @@ -(void)setFrame:(NSRect)frame { [self updateTextFieldContainer]; - [self.inputMessageTextField textDidChange:nil]; +// [self.inputMessageTextField textDidChange:nil]; + + [_botKeyboard setFrameSize:NSMakeSize(NSWidth(self.inputMessageTextField.containerView.frame), NSHeight(_botKeyboard.frame))]; +} + +-(void)selectInputTextByText:(NSString *)text { + [self.inputMessageTextField setSelectedRange:[self.inputMessageTextField.string rangeOfString:text]]; + + [self updateWebpage:NO]; } @@ -1505,7 +1690,9 @@ -(void)updateTextFieldContainer { self.inputMessageTextField.containerView.frame = NSMakeRect(offsetX, 11, self.bounds.size.width - offsetX - self.sendButton.frame.size.width - 33, NSHeight(self.inputMessageTextField.containerView.frame)); - [self.inputMessageTextField setFrameSize:NSMakeSize(NSWidth(self.inputMessageTextField.containerView.frame) - 40 - (_botKeyboardButton.isHidden ? 0 : 30) - (_botCommandButton.isHidden ? 0 : 30),NSHeight(self.inputMessageTextField.frame))]; + [self.inputMessageTextField setFrameSize:NSMakeSize(NSWidth(self.inputMessageTextField.containerView.frame) - 40 - (_botKeyboardButton.isHidden ? 0 : 30) - (_botCommandButton.isHidden ? 0 : 30) - (_channelAdminButton.isHidden ? 0 : 30) - (_secretTimerButton.isHidden ? 0 : 30),NSHeight(self.inputMessageTextField.frame))]; + + } diff --git a/TelegramTest/MessagesDelegate.h b/TelegramTest/MessagesDelegate.h index 14a4fc9e..e4868bab 100644 --- a/TelegramTest/MessagesDelegate.h +++ b/TelegramTest/MessagesDelegate.h @@ -12,13 +12,17 @@ @required -(void)receivedMessage:(MessageTableItem *)message position:(int)position itsSelf:(BOOL)force; --(void)deleteMessages:(NSArray *)ids; +-(void)deleteItems:(NSArray *)items orMessageIds:(NSArray *)ids; -(void)flushMessages; -(void)receivedMessageList:(NSArray *)list inRange:(NSRange)range itsSelf:(BOOL)force; - (void)didAddIgnoredMessages:(NSArray *)items; - --(TL_conversation *)conversation; -(NSArray *)messageTableItemsFromMessages:(NSArray *)messages; +-(void)jumpToLastMessages:(BOOL)force; +-(TL_conversation *)conversation; -(void)updateLoading; + +@optional +-(void)forceAddUnreadMark; +-(void)requestNextHistory; @end diff --git a/TelegramTest/MessagesManager.h b/TelegramTest/MessagesManager.h index 929c4a3d..ddd26104 100644 --- a/TelegramTest/MessagesManager.h +++ b/TelegramTest/MessagesManager.h @@ -12,22 +12,20 @@ --(void)addSupportMessages:(NSArray *)supportMessages; --(TL_localMessage *)supportMessage:(int)n_id; ++(void)addSupportMessages:(NSArray *)supportMessages; + ++(TL_localMessage *)supportMessage:(int)n_id peer_id:(int)peer_id; --(TL_localMessage *)findWithRandomId:(long)random_id; --(NSArray *)findWithWebPageId:(long)webpage_id; --(void)addMessage:(TLMessage *)message; --(void)TGsetMessage:(TLMessage *)message; --(void)markAllInDialog:(TLDialog*)dialog callback:(void (^)(NSArray *ids))callback; --(void)markAllInConversation:(TL_conversation *)conversation max_id:(int)max_id callback:(void (^)(NSArray *ids))callback; +-(TL_localMessage *)findWithRandomId:(long)random_id; + +-(NSArray *)findWithWebPageId:(long)webpage_id; -(void)readMessagesContent:(NSArray *)msg_ids; -+ (void)notifyConversation:(int)peer_id title:(NSString *)title text:(NSString *)text; ++(void)notifyConversation:(int)peer_id title:(NSString *)title text:(NSString *)text; +(void)addAndUpdateMessage:(TL_localMessage *)message; +(void)addAndUpdateMessage:(TL_localMessage *)message notify:(BOOL)notify; +(void)notifyMessage:(TL_localMessage *)message update_real_date:(BOOL)update_real_date; diff --git a/TelegramTest/MessagesManager.m b/TelegramTest/MessagesManager.m index d3a799e4..924edfb2 100644 --- a/TelegramTest/MessagesManager.m +++ b/TelegramTest/MessagesManager.m @@ -56,7 +56,11 @@ -(void)addSupportMessages:(NSArray *)supportMessages { [supportMessages enumerateObjectsUsingBlock:^(TL_localMessage *obj, NSUInteger idx, BOOL *stop) { - _supportMessages[@(obj.n_id)] = obj; + if(!_supportMessages[@(obj.peer_id)]) { + _supportMessages[@(obj.peer_id)] = [[NSMutableDictionary alloc] init]; + } + + _supportMessages[@(obj.peer_id)][@(obj.n_id)] = obj; }]; @@ -65,13 +69,13 @@ -(void)addSupportMessages:(NSArray *)supportMessages { } --(TL_localMessage *)supportMessage:(int)n_id { +-(TL_localMessage *)supportMessage:(int)n_id peer_id:(int)peer_id { __block TL_localMessage *message; [self.queue dispatchOnQueue:^{ - message = _supportMessages[@(n_id)]; + message = _supportMessages[@(peer_id)][@(n_id)]; } synchronous:YES]; @@ -79,6 +83,14 @@ -(TL_localMessage *)supportMessage:(int)n_id { } ++(void)addSupportMessages:(NSArray *)supportMessages { + [[self sharedManager] addSupportMessages:supportMessages]; +} + ++(TL_localMessage *)supportMessage:(int)n_id peer_id:(int)peer_id { + return [[self sharedManager] supportMessage:n_id peer_id:peer_id]; +} + -(void)dealloc { [Notification removeObserver:self]; } @@ -86,6 +98,7 @@ -(void)dealloc { +(void)addAndUpdateMessage:(TL_localMessage *)message { + [[Storage manager] insertMessages:@[message]]; [self addAndUpdateMessage:message notify:YES]; } @@ -99,18 +112,15 @@ +(void)addAndUpdateMessage:(TL_localMessage *)message notify:(BOOL)notify { -(void)notifyMessage:(TL_localMessage *)message update_real_date:(BOOL)update_real_date notify:(BOOL)notify { [self.queue dispatchOnQueue:^{ - if(!message || [self find:message.n_id]) + if(!message) return; - - [self addMessage:message]; - TL_conversation *conversation = message.conversation; - [Notification perform:MESSAGE_UPDATE_TOP_MESSAGE data:@{KEY_MESSAGE:message,@"update_real_date":@(update_real_date)}]; + [Notification performOnStageQueue:MESSAGE_UPDATE_TOP_MESSAGE data:@{KEY_MESSAGE:message,@"update_real_date":@(update_real_date)}]; - if(message.from_id == [UsersManager currentUserId]) { + if(message.n_out || (message.isChannelMessage && (!message.isImportantMessage && !message.chat.isMegagroup))) { return; } @@ -119,12 +129,13 @@ -(void)notifyMessage:(TL_localMessage *)message update_real_date:(BOOL)update_re return; + TLUser *fromUser = [[UsersManager sharedManager] find:message.from_id]; - TLChat *chat = [[ChatsManager sharedManager] find:message.to_id.chat_id]; + TLChat *chat = [[ChatsManager sharedManager] find:message.chat.n_id]; - NSString *title = [message.to_id isSecret] || [TGPasslock isVisibility] ? appName() : [fromUser fullName]; + NSString *title = message.isChannelMessage && !message.chat.isMegagroup ? (chat.title) : ( [message.to_id isSecret] || [TGPasslock isVisibility] ? appName() : [fromUser fullName] ); NSString *msg = message.message; if(message.action) { msg = [MessagesUtils serviceMessage:message forAction:message.action]; @@ -141,7 +152,7 @@ -(void)notifyMessage:(TL_localMessage *)message update_real_date:(BOOL)update_re if(![message.to_id isSecret] && ![TGPasslock isVisibility]) { NSString *cacheKey = [fromUser.photo.photo_small cacheKey]; - if(message.to_id.chat_id != 0) { + if(chat != nil) { cacheKey = [chat.photo.photo_small cacheKey]; } @@ -179,7 +190,7 @@ -(void)notifyMessage:(TL_localMessage *)message update_real_date:(BOOL)update_re NSString *text = [TMAvatarImageView text:chat ? chat : fromUser]; - image = [TMAvatarImageView generateTextAvatar:colorMask size:NSMakeSize(100, 100) text:text type:chat ? TMAvatarTypeChat : TMAvatarTypeUser font:[NSFont fontWithName:@"HelveticaNeue" size:30] offsetY:0]; + image = [TMAvatarImageView generateTextAvatar:colorMask size:NSMakeSize(100, 100) text:text type:chat ? TMAvatarTypeChat : TMAvatarTypeUser font:TGSystemFont(30) offsetY:0]; [TGCache cacheImage:image forKey:p groups:@[AVACACHE]]; } @@ -191,19 +202,16 @@ -(void)notifyMessage:(TL_localMessage *)message update_real_date:(BOOL)update_re - if(message.to_id.chat_id != 0) { - if(![message.to_id isSecret]) { - subTitle = title; - title = [chat title]; - } + if(message.peer_id < 0 && message.from_id != 0) { + subTitle = title; + title = [chat title]; } - if ([NSUserNotification class] && [NSUserNotificationCenter class] && [SettingsArchiver checkMaskedSetting:PushNotifications]) { - if([TGPasslock isVisibility] || [message.to_id isSecret]) + if([TGPasslock isVisibility] || [message.to_id isSecret] || ![SettingsArchiver checkMaskedSetting:MessagesNotificationPreview]) { title = appName(); subTitle = nil; @@ -223,7 +231,7 @@ -(void)notifyMessage:(TL_localMessage *)message update_real_date:(BOOL)update_re notification.soundName = [SettingsArchiver soundNotification]; if (floor(NSAppKitVersionNumber) > 1187) { - if(![message.to_id isSecret]) + if(![message.to_id isSecret] && (!message.isChannelMessage || message.chat.dialog.canSendMessage)) notification.hasReplyButton = YES; notification.contentImage = image; } @@ -336,7 +344,6 @@ -(void)add:(NSArray *)all { [self.queue dispatchOnQueue:^{ for (TLMessage *message in all) { assert([message isKindOfClass:[TL_localMessage class]]); - [self TGsetMessage:message]; } }]; @@ -349,36 +356,6 @@ -(TLMessage *)localMessageForId:(int)n_id { --(void)addMessage:(TLMessage *)message { - [self TGsetMessage:message]; - [[Storage manager] insertMessage:message completeHandler:nil]; -} - --(void)TGsetMessage:(TL_localMessage *)message { - - [self.queue dispatchOnQueue:^{ - if(!message || message.n_id == 0) return; - - TL_localMessage *m = self.messages[@(message.n_id)]; - - - if(m) { - m.message = message.message; - m.flags = message.flags; - m.dstate = message.dstate; - m.media = message.media; - m.action = message.action; - m.randomId = message.randomId; - m.fakeId = message.fakeId; - } else { - [self.messages setObject:message forKey:@(message.n_id)]; - - [self.messages_with_random_ids setObject:message forKey:@(message.randomId)]; - } - - }]; -} - -(id)find:(NSInteger)_id { @@ -392,37 +369,7 @@ -(id)find:(NSInteger)_id { } --(void)markAllInDialog:(TL_conversation *)dialog callback:(void (^)(NSArray *ids))callback { - [self markAllInConversation:dialog max_id:dialog.top_message callback:callback]; -} - --(void)markAllInConversation:(TL_conversation *)conversation max_id:(int)max_id callback:(void (^)(NSArray *ids))callback{ - - dispatch_queue_t queue = dispatch_get_current_queue(); - - [self.queue dispatchOnQueue:^{ - - [[Storage manager] markAllInConversation:conversation max_id:max_id completeHandler:^(NSArray *ids) { - - [ids enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - - TL_localMessage *message = self.messages[obj]; - message.flags&=~TGUNREADMESSAGE; - - }]; - - dispatch_async(queue, ^{ - callback(ids); - }); - - - }]; - - }]; - - -} -(void)readMessagesContent:(NSArray *)msg_ids { @@ -449,7 +396,7 @@ -(void)readMessagesContent:(NSArray *)msg_ids { } -(void)setUnread_count:(int)unread_count { - _unread_count = unread_count > 0 ? unread_count : 0; + _unread_count = MAX(0,unread_count); } +(void)updateUnreadBadge { @@ -461,7 +408,7 @@ +(void)updateUnreadBadge { NSString *str = [[self sharedManager] unread_count] > 0 ? [NSString stringWithFormat:@"%d",count] : nil; [[[NSApplication sharedApplication] dockTile] setBadgeLabel:str]; [Notification perform:UNREAD_COUNT_CHANGED data:@{@"count":@(count)}]; - }]; + } includeMuted:[SettingsArchiver checkMaskedSetting:IncludeMutedUnreadCount]]; } diff --git a/TelegramTest/MessagesTableView.h b/TelegramTest/MessagesTableView.h index c76cda10..e2735fcc 100644 --- a/TelegramTest/MessagesTableView.h +++ b/TelegramTest/MessagesTableView.h @@ -12,7 +12,7 @@ @class MessagesViewController; @interface MessagesTableView : TMTableView -@property (nonatomic, strong) MessagesViewController *viewController; +@property (nonatomic, weak) MessagesViewController *viewController; - (NSSize)containerSize; diff --git a/TelegramTest/MessagesTableView.m b/TelegramTest/MessagesTableView.m index bb7b25b7..0516b809 100644 --- a/TelegramTest/MessagesTableView.m +++ b/TelegramTest/MessagesTableView.m @@ -124,7 +124,7 @@ - (void)setFrameSize:(NSSize)newSize { for(NSInteger i = visibleRows.location; i < count; i++) { MessageTableItem *item = (MessageTableItem *)[self itemByPosition:i]; - if([item makeSizeByWidth:MAX(NSWidth([Telegram rightViewController].view.frame) - 150,100)]) { + if([item makeSizeByWidth:item.makeSize]) { id view = [self viewAtColumn:0 row:i makeIfNecessary:NO]; // if([view isKindOfClass:[MessageTableCellTextView class]]) { if(view) @@ -164,7 +164,7 @@ - (void)fixedResize { for(NSUInteger i = 0; i < self.viewController.messagesCount; i++) { MessageTableItem *item = (MessageTableItem *)[self itemByPosition:i]; - [item makeSizeByWidth:MAX(NSWidth([Telegram rightViewController].view.frame) - 150,100)]; + [item makeSizeByWidth:item.makeSize]; } // [self reloadData]; @@ -324,11 +324,13 @@ -(void)mouseDragged:(NSEvent *)theEvent { TGCTextView *textView = ((MessageTableCellTextView *)view).textView; - NSPoint startConverted = NSMakePoint(_startSelectPosition.x - rect.origin.x - item.containerOffset, _startSelectPosition.y - rect.origin.y - NSMinY(view.containerView.frame)); + NSPoint startConverted = NSMakePoint(_startSelectPosition.x - rect.origin.x - (item.isForwadedMessage ? item.containerOffsetForward : item.containerOffset), _startSelectPosition.y - rect.origin.y - NSMinY(view.containerView.frame)); - NSPoint currentConverted = NSMakePoint(startTablePoint.x - rect.origin.x - item.containerOffset, startTablePoint.y - rect.origin.y - NSMinY(view.containerView.frame)); + NSPoint currentConverted = NSMakePoint(startTablePoint.x - rect.origin.x - (item.isForwadedMessage ? item.containerOffsetForward : item.containerOffset), startTablePoint.y - rect.origin.y - NSMinY(view.containerView.frame)); + + if(i > startRow && i < endRow) { startPoint = NSMakePoint(textItem.blockSize.width, 0); @@ -400,7 +402,7 @@ -(void)rightMouseDown:(NSEvent *)theEvent { - (void)viewDidEndLiveResize { for(NSUInteger i = 0; i < self.viewController.messagesCount; i++) { MessageTableItem *item = (MessageTableItem *)[self itemByPosition:i]; - [item makeSizeByWidth:MAX(NSWidth([Telegram rightViewController].view.frame) - 150,100)]; + [item makeSizeByWidth:item.makeSize]; } [self reloadData]; diff --git a/TelegramTest/MessagesTopInfoView.h b/TelegramTest/MessagesTopInfoView.h index 7dce794f..67a3e876 100644 --- a/TelegramTest/MessagesTopInfoView.h +++ b/TelegramTest/MessagesTopInfoView.h @@ -14,13 +14,14 @@ typedef enum { MessagesTopInfoActionAddContact, MessagesTopInfoActionUnblockUser, MessagesTopInfoActionShareContact, + MessagesTopInfoActionReportSpam, MessagesTopInfoActionNone } MessagesTopInfoAction; @property (nonatomic,assign) MessagesTopInfoAction action; -@property (nonatomic,strong) MessagesViewController *controller; +@property (nonatomic,weak) MessagesViewController *controller; @property (nonatomic,strong) TL_conversation *conversation; @property (nonatomic,assign,readonly) BOOL isShown; diff --git a/TelegramTest/MessagesTopInfoView.m b/TelegramTest/MessagesTopInfoView.m index ad02e30d..c123b4c6 100644 --- a/TelegramTest/MessagesTopInfoView.m +++ b/TelegramTest/MessagesTopInfoView.m @@ -13,6 +13,8 @@ @interface MessagesTopInfoView () @property (nonatomic,strong) NSProgressIndicator *progress; @property (nonatomic,assign) BOOL locked; + +@property (nonatomic,strong) BTRButton *cancel; @end @implementation MessagesTopInfoView @@ -51,6 +53,27 @@ - (id)initWithFrame:(NSRect)frame self.field.url_delegate = self; + + _cancel = [[BTRButton alloc] initWithFrame:NSMakeRect(0, 0, 72, NSHeight(frame))]; + [_cancel setTitle:NSLocalizedString(@"Messages.MessagesTopInfoActionReportSpam.ButtonCancel", nil) forControlState:BTRControlStateNormal]; + [_cancel setTitleFont:TGSystemMediumFont(13) forControlState:BTRControlStateNormal]; + [_cancel setTitleColor:LINK_COLOR forControlState:BTRControlStateNormal]; + + weak(); + + [_cancel addBlock:^(BTRControlEvents events) { + + [[NSUserDefaults standardUserDefaults] setBool:NO forKey:[NSString stringWithFormat:@"showreport_%d",weakSelf.conversation.user.n_id]]; + + [weakSelf setConversation:weakSelf.conversation]; + + } forControlEvents:BTRControlEventClick]; + + + [_cancel setHidden:YES]; + + [self addSubview:_cancel]; + } return self; } @@ -88,6 +111,10 @@ -(void)setFrame:(NSRect)frameRect { - (void)didChangeUserBlock:(NSNotification *)notification { + + return; + + TL_contactBlocked *contact = notification.userInfo[KEY_USER]; if(_conversation.user.n_id != contact.user_id || _conversation.user.isBot) @@ -170,14 +197,19 @@ -(void)setConversation:(TL_conversation *)conversation { newAction = MessagesTopInfoActionNone;//MessagesTopInfoActionShareContact; } - if(user.isBlocked) { - newAction = MessagesTopInfoActionUnblockUser; - } + // if(user.isBlocked) { + // newAction = MessagesTopInfoActionUnblockUser; + // } if(user.isBot) { newAction = MessagesTopInfoActionNone; } + BOOL showReport = [[NSUserDefaults standardUserDefaults] boolForKey:[NSString stringWithFormat:@"showreport_%d",self.conversation.user.n_id]]; + + if(showReport && newAction == MessagesTopInfoActionAddContact) { + newAction = MessagesTopInfoActionReportSpam; + } if(cache[@(newAction)] && cache[@(newAction)][@(conversation.peer.peer_id)]) { @@ -211,22 +243,25 @@ -(void)setAction:(MessagesTopInfoAction)action { static NSString * const localizations[] = { [MessagesTopInfoActionAddContact] = @"Messages.MessagesTopInfoActionAddContact", [MessagesTopInfoActionShareContact] = @"Messages.MessagesTopInfoActionShareContact", - [MessagesTopInfoActionUnblockUser] = @"Messages.MessagesTopInfoActionUnblockUser" + [MessagesTopInfoActionUnblockUser] = @"Messages.MessagesTopInfoActionUnblockUser", + [MessagesTopInfoActionReportSpam] = @"" }; static NSString * const buttonLocalization[] = { [MessagesTopInfoActionAddContact] = @"Messages.MessagesTopInfoActionAddContact.Button", [MessagesTopInfoActionShareContact] = @"Messages.MessagesTopInfoActionShareContact.Button", - [MessagesTopInfoActionUnblockUser] = @"Messages.MessagesTopInfoActionUnblockUser.Button" + [MessagesTopInfoActionUnblockUser] = @"Messages.MessagesTopInfoActionUnblockUser.Button", + [MessagesTopInfoActionReportSpam] = @"Messages.MessagesTopInfoActionReportSpam.Button" }; [string appendString:NSLocalizedString(localizations[action], nil) withColor:NSColorFromRGB(0xa9a9a9)]; NSRange range = [string appendString:NSLocalizedString(buttonLocalization[action], nil) withColor:BLUE_UI_COLOR]; - [string addAttributes:@{NSLinkAttributeName:@""} range:range]; + [string addAttributes:@{NSLinkAttributeName:@"first"} range:range]; + + [_cancel setHidden:action != MessagesTopInfoActionReportSpam]; - [string setFont:[NSFont fontWithName:@"HelveticaNeue" size:13] forRange:NSMakeRange(0, string.length)]; [self.field setAttributedStringValue:string]; @@ -273,6 +308,34 @@ - (void)textField:(id)textField handleURLClick:(NSString *)url { }]; } + if(self.action == MessagesTopInfoActionReportSpam) { + + confirm(appName(), NSLocalizedString(@"ReportSpam.ConfirmDescription", nil), ^{ + + self.locked = YES; + + [RPCRequest sendRequest:[TLAPI_messages_reportSpam createWithPeer:self.conversation.user.inputPeer] successHandler:^(id request, id response) { + + [[NSUserDefaults standardUserDefaults] setBool:YES forKey:[NSString stringWithFormat:@"always_showreport1_%d",self.conversation.user.n_id]]; + + self.locked = NO; + self.conversation = self.conversation; + + + + } errorHandler:^(id request, RpcError *error) { + self.locked = NO; + self.conversation = self.conversation; + }]; + + }, ^{ + + }); + + + + } + } @@ -281,6 +344,12 @@ -(void)mouseUp:(NSEvent *)theEvent // [self.controller hideTopInfoView]; } +-(void)setFrameSize:(NSSize)newSize { + [super setFrameSize:newSize]; + + [_cancel setFrameOrigin:NSMakePoint(newSize.width - NSWidth(_cancel.frame), 2)]; +} + - (void)drawRect:(NSRect)dirtyRect { [super drawRect:dirtyRect]; diff --git a/TelegramTest/MessagesUtils.m b/TelegramTest/MessagesUtils.m index f0d269b1..6fa9bc27 100644 --- a/TelegramTest/MessagesUtils.m +++ b/TelegramTest/MessagesUtils.m @@ -14,24 +14,60 @@ #import "TGDateUtils.h" @implementation MessagesUtils -+(NSString *)serviceMessage:(TLMessage *)message forAction:(TLMessageAction *)action { + ++(NSString *)joinUsersByUsers:(NSArray *)users { + __block NSString *resUsers; + + [users enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + TLUser *userAdd = [[UsersManager sharedManager] find:[obj intValue]]; + + + resUsers = [NSString stringWithFormat:@"%@",[userAdd fullName]]; + + if(idx != users.count -1 ) { + resUsers = [resUsers stringByAppendingString:@", "]; + } + + + }]; + + return resUsers; + +} + ++(NSString *)serviceMessage:(TL_localMessage *)message forAction:(TLMessageAction *)action { TLUser *user = [[UsersManager sharedManager] find:message.from_id]; NSString *text; if([action isKindOfClass:[TL_messageActionChatEditTitle class]]) { - text = [NSString stringWithFormat:NSLocalizedString(@"MessageAction.ServiceMessage.ChangedGroupName", nil), [user fullName], action.title]; + text = [NSString stringWithFormat:NSLocalizedString(message.isChannelMessage && !message.chat.isMegagroup ? @"MessageAction.Service.ChannelGroupName" : @"MessageAction.ServiceMessage.ChangedGroupName", nil), message.isChannelMessage && !message.chat.isMegagroup ? message.chat.title : [user fullName], action.title]; } else if([action isKindOfClass:[TL_messageActionChatDeletePhoto class]]) { - text = [NSString stringWithFormat:NSLocalizedString(@"MessageAction.ServiceMessage.RemovedGroupPhoto", nil), [user fullName]]; + text = [NSString stringWithFormat:NSLocalizedString(message.isChannelMessage && !message.chat.isMegagroup ? @"MessageAction.ServiceMessage.RemovedChannelPhoto" : @"MessageAction.ServiceMessage.RemovedGroupPhoto", nil), message.isChannelMessage && !message.chat.isMegagroup ? message.chat.title : [user fullName]]; } else if([action isKindOfClass:[TL_messageActionChatEditPhoto class]]) { - text = [NSString stringWithFormat:NSLocalizedString(@"MessageAction.ServiceMessage.ChangedGroupPhoto", nil), [user fullName]]; + text = [NSString stringWithFormat:NSLocalizedString(message.isChannelMessage && !message.chat.isMegagroup ? @"MessageAction.ServiceMessage.ChangedChannelPhoto" : @"MessageAction.ServiceMessage.ChangedGroupPhoto", nil), message.isChannelMessage && !message.chat.isMegagroup ? message.chat.title : [user fullName]]; } else if([action isKindOfClass:[TL_messageActionChatAddUser class]]) { - TLUser *userAdd = [[UsersManager sharedManager] find:action.user_id]; - if(action.user_id != message.from_id) { - text = [NSString stringWithFormat:NSLocalizedString(@"MessageAction.ServiceMessage.InvitedGroup", nil), [user fullName], [userAdd fullName]]; + + if(message.isChannelMessage && !message.chat.isMegagroup ) { + + if(action.users.count == 1 && [action.users[0] intValue] == [UsersManager currentUserId]) { + text = NSLocalizedString(@"MessageAction.Service.InvitedYouToChannel",nil); + } else { + + text = [NSString stringWithFormat:NSLocalizedString(@"MessageAction.ServiceMessage.InvitedGroup", nil), [user fullName], [self joinUsersByUsers:action.users]]; + } + + if(message.from_id == [UsersManager currentUserId]) { + text = NSLocalizedString(@"MessageAction.Service.YouChoinedToChannel", nil); + } + } else { - text = [NSString stringWithFormat:NSLocalizedString(@"MessageAction.ServiceMessage.JoinedGroup", nil), [user fullName]]; + + text = [NSString stringWithFormat:NSLocalizedString(@"MessageAction.ServiceMessage.InvitedGroup", nil), [user fullName], [self joinUsersByUsers:action.users]]; } - text = [NSString stringWithFormat:NSLocalizedString(@"MessageAction.ServiceMessage.InvitedGroup", nil), [user fullName], [userAdd fullName]]; + + + + }else if([action isKindOfClass:[TL_messageActionChatCreate class]]) { text = [NSString stringWithFormat:NSLocalizedString(@"MessageAction.ServiceMessage.CreatedChat", nil), [user fullName],action.title]; } else if([action isKindOfClass:[TL_messageActionChatDeleteUser class]]) { @@ -45,10 +81,17 @@ +(NSString *)serviceMessage:(TLMessage *)message forAction:(TLMessageAction *)ac text = action.title; } else if([action isKindOfClass:[TL_messageActionChatJoinedByLink class]]) { + NSString *fullName = message.from_id == 0 ? message.chat.title : [user fullName]; - text = [NSString stringWithFormat:@"%@ %@", [user fullName],NSLocalizedString(@"MessageAction.Service.JoinedGroupByLink", nil)]; + text = [NSString stringWithFormat:@"%@ %@", fullName,NSLocalizedString(@"MessageAction.Service.JoinedGroupByLink", nil)]; + }else if([action isKindOfClass:[TL_messageActionChannelCreate class]]) { + text = message.isChannelMessage && !message.chat.isMegagroup ? NSLocalizedString(@"MessageAction.Service.ChannelCreated", nil) : NSLocalizedString(@"MessageAction.ServiceMessage.CreatedChat", nil); + + } else if([action isKindOfClass:[TL_messageActionChatMigrateTo class]] || [action isKindOfClass:[TL_messageActionChannelMigrateFrom class]]) { + text = NSLocalizedString(@"MessageAction.Service.ChatMigrated", nil); } + return text; } @@ -149,16 +192,16 @@ +(NSMutableAttributedString *)conversationLastText:(TL_localMessage *)message co if(message) { NSString *msgText = @""; - TLUser *userSecond = nil; + NSMutableArray *users = [NSMutableArray array]; TLUser *userLast; NSString *chatUserNameString; - if(message.conversation.type == DialogTypeChat && !message.action ) { + if(((message.conversation.type == DialogTypeChannel && message.from_id != 0) || message.conversation.type == DialogTypeChat) && !message.action ) { if(!message.n_out) { - userLast = [[UsersManager sharedManager] find:message.from_id]; + userLast = message.fromUser; chatUserNameString = [userLast ? userLast.fullName : @"" stringByAppendingString:@"\n"]; } else { chatUserNameString = [NSLocalizedString(@"Profile.You", nil) stringByAppendingString:@"\n"]; @@ -171,35 +214,55 @@ +(NSMutableAttributedString *)conversationLastText:(TL_localMessage *)message co if(message.action) { isAction = YES; - if(!userLast) - userLast = [[UsersManager sharedManager] find:message.from_id]; - // if(userLast == [UsersManager currentUser]) - // chatUserNameString = NSLocalizedString(@"Profile.You", nil); - // else - if(message.conversation.type != DialogTypeSecretChat) + if(!userLast && message.from_id != 0) + userLast = message.fromUser; + if(message.conversation.type != DialogTypeSecretChat && userLast) chatUserNameString = userLast ? userLast.fullName : NSLocalizedString(@"MessageAction.Service.LeaveChat", nil); + + TLMessageAction *action = message.action; if([action isKindOfClass:[TL_messageActionChatEditTitle class]]) { - msgText = NSLocalizedString(@"MessageAction.Service.ChangedGroupName", nil); + msgText =message.isChannelMessage && !message.chat.isMegagroup ? NSLocalizedString(@"MessageAction.Service.ChannelGroupName", nil) : NSLocalizedString(@"MessageAction.Service.ChangedGroupName", nil); } else if([action isKindOfClass:[TL_messageActionChatDeletePhoto class]]) { - msgText = NSLocalizedString(@"MessageAction.Service.RemovedGroupPhoto", nil); + msgText =message.isChannelMessage && !message.chat.isMegagroup ? NSLocalizedString(@"MessageAction.Service.RemovedChannelPhoto", nil) : NSLocalizedString(@"MessageAction.Service.RemovedGroupPhoto", nil); } else if([action isKindOfClass:[TL_messageActionChatEditPhoto class]]) { - msgText = NSLocalizedString(@"MessageAction.Service.ChangedGroupPhoto", nil); + msgText =message.isChannelMessage && !message.chat.isMegagroup ? NSLocalizedString(@"MessageAction.Service.ChangedChannelPhoto", nil) : NSLocalizedString(@"MessageAction.Service.ChangedGroupPhoto", nil); } else if([action isKindOfClass:[TL_messageActionChatAddUser class]]) { - userSecond = [[UsersManager sharedManager] find:action.user_id]; - if(action.user_id == message.from_id) { - userSecond = nil; - msgText = NSLocalizedString(@"MessageAction.Service.JoinedGroup", nil); + + if(message.isChannelMessage && !message.chat.isMegagroup ) { + + if(action.users.count == 1 && [action.users[0] intValue] == [UsersManager currentUserId]) { + msgText = NSLocalizedString(@"MessageAction.Service.InvitedYouToChannel",nil); + } else { + msgText = NSLocalizedString(@"MessageAction.Service.InvitedGroup", nil); + [users addObjectsFromArray:action.users]; + } + + if(message.from_id == [UsersManager currentUserId]) { + msgText = NSLocalizedString(@"MessageAction.Service.YouChoinedToChannel", nil); + } } else { - msgText = NSLocalizedString(@"MessageAction.Service.InvitedGroup", nil); + + if(action.users.count == 1 && [action.users[0] intValue] == message.from_id) { + msgText = NSLocalizedString(@"MessageAction.Service.JoinedGroup", nil); + } else { + msgText = NSLocalizedString(@"MessageAction.Service.InvitedGroup", nil); + [users addObjectsFromArray:action.users]; + } + } + + + + } else if([action isKindOfClass:[TL_messageActionChatCreate class]]) { msgText = [NSString stringWithFormat:NSLocalizedString(@"MessageAction.Service.CreatedChat", nil),action.title]; } else if([action isKindOfClass:[TL_messageActionChatDeleteUser class]]) { if(action.user_id != message.from_id) { - userSecond = [[UsersManager sharedManager] find:action.user_id]; + + [users addObject:@(action.user_id)]; msgText = NSLocalizedString(@"MessageAction.Service.KickedGroup", nil); } else { @@ -214,16 +277,21 @@ +(NSMutableAttributedString *)conversationLastText:(TL_localMessage *)message co msgText = NSLocalizedString(@"MessageAction.Service.JoinedGroupByLink", nil); + } else if([action isKindOfClass:[TL_messageActionChannelCreate class]]) { + + msgText = NSLocalizedString(@"MessageAction.Service.ChannelCreated", nil); + + } else if([action isKindOfClass:[TL_messageActionChannelMigrateFrom class]] || [action isKindOfClass:[TL_messageActionChatMigrateTo class]]) { + msgText = NSLocalizedString(@"MessageAction.Service.ChatMigrated", nil); + chatUserNameString = nil; } - + if(chatUserNameString) msgText = [NSString stringWithFormat:@" %@", msgText]; } - - if(chatUserNameString) [messageText appendString:chatUserNameString withColor:DARK_BLACK]; @@ -248,15 +316,17 @@ +(NSMutableAttributedString *)conversationLastText:(TL_localMessage *)message co [messageText appendString:msgText withColor:GRAY_TEXT_COLOR]; } - if(userSecond) { - [messageText appendString:[NSString stringWithFormat:@" %@", userSecond.fullName] withColor:GRAY_TEXT_COLOR]; + NSString *joinUsers = [self joinUsersByUsers:users]; + + if(joinUsers.length > 0) { + [messageText appendString:[NSString stringWithFormat:@" %@",joinUsers] withColor:GRAY_TEXT_COLOR]; } } else { [messageText appendString:@"" withColor:LIGHT_GRAY]; } - [messageText setFont:[NSFont fontWithName:@"HelveticaNeue" size:13] forRange:messageText.range]; + [messageText setFont:TGSystemFont(13) forRange:messageText.range]; static NSMutableParagraphStyle *paragraph; @@ -280,38 +350,75 @@ +(NSMutableAttributedString *)conversationLastText:(TL_localMessage *)message co return messageText; } -+ (NSAttributedString *) serviceAttributedMessage:(TLMessage *)message forAction:(TLMessageAction *)action { ++ (NSAttributedString *) serviceAttributedMessage:(TL_localMessage *)message forAction:(TLMessageAction *)action { TLUser *user = [[UsersManager sharedManager] find:message.from_id]; NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] init]; - TLUser *user2; + NSMutableArray *users = [NSMutableArray array]; NSString *actionText; NSString *title; if([action isKindOfClass:[TL_messageActionChatEditTitle class]]) { - actionText = NSLocalizedString(@"MessageAction.Service.ChangedGroupName",nil); + actionText = NSLocalizedString(message.isChannelMessage && !message.chat.isMegagroup ? @"MessageAction.Service.ChannelGroupName" : @"MessageAction.Service.ChangedGroupName",nil); title = action.title; } else if([action isKindOfClass:[TL_messageActionChatDeletePhoto class]]) { - actionText = NSLocalizedString(@"MessageAction.Service.RemovedGroupPhoto",nil);; + actionText = NSLocalizedString(message.isChannelMessage && !message.chat.isMegagroup ? @"MessageAction.Service.RemovedChannelPhoto" : @"MessageAction.Service.RemovedGroupPhoto",nil); } else if([action isKindOfClass:[TL_messageActionChatEditPhoto class]]) { - actionText = NSLocalizedString(@"MessageAction.Service.ChangedGroupPhoto",nil); + actionText = NSLocalizedString(message.isChannelMessage && !message.chat.isMegagroup ? @"MessageAction.Service.ChangedChannelPhoto" : @"MessageAction.Service.ChangedGroupPhoto",nil); } else if([action isKindOfClass:[TL_messageActionChatAddUser class]]) { - if(action.user_id != message.from_id) { - user2 = [[UsersManager sharedManager] find:action.user_id]; - actionText = NSLocalizedString(@"MessageAction.Service.InvitedGroup",nil); + if(message.isChannelMessage && !message.chat.isMegagroup ) { + + if(action.users.count == 1 && [action.users[0] intValue] == [UsersManager currentUserId]) { + actionText = NSLocalizedString(@"MessageAction.Service.InvitedYouToChannel",nil); + } else { + + [action.users enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + TLUser *user = [[UsersManager sharedManager] find:[obj intValue]]; + + if(user != nil) { + [users addObject:user]; + } + }]; + + actionText = NSLocalizedString(@"MessageAction.Service.Invited",nil); + + } + + + if(message.from_id == [UsersManager currentUserId]) { + actionText = NSLocalizedString(@"MessageAction.Service.YouChoinedToChannel", nil); + } } else { - actionText = NSLocalizedString(@"MessageAction.Service.JoinedGroup", nil); + + + + if(action.users.count == 1 && [action.users[0] intValue] == message.from_id) { + actionText = NSLocalizedString(@"MessageAction.Service.JoinedGroup", nil); + + } else { + actionText = NSLocalizedString(@"MessageAction.Service.InvitedGroup",nil); + + [action.users enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + TLUser *user = [[UsersManager sharedManager] find:[obj intValue]]; + + if(user != nil) { + [users addObject:user]; + } + }]; + } } + + } else if([action isKindOfClass:[TL_messageActionChatCreate class]]) { actionText = [NSString stringWithFormat:NSLocalizedString(@"MessageAction.Service.CreatedChat",nil), action.title]; @@ -319,7 +426,13 @@ + (NSAttributedString *) serviceAttributedMessage:(TLMessage *)message forAction } else if([action isKindOfClass:[TL_messageActionChatDeleteUser class]]) { if(action.user_id != message.from_id) { - user2 = [[UsersManager sharedManager] find:action.user_id]; + + TLUser *user = [[UsersManager sharedManager] find:action.user_id]; + + if(user != nil) { + [users addObject:user]; + } + actionText = NSLocalizedString(@"MessageAction.Service.KickedGroup",nil); } else { actionText = NSLocalizedString(@"MessageAction.Service.LeftGroup",nil); @@ -333,8 +446,12 @@ + (NSAttributedString *) serviceAttributedMessage:(TLMessage *)message forAction actionText = NSLocalizedString(@"MessageAction.Service.JoinedGroupByLink", nil); + } else if([action isKindOfClass:[TL_messageActionChannelCreate class]]) { + actionText = NSLocalizedString(@"MessageAction.Service.ChannelCreated", nil); + } else if([action isKindOfClass:[TL_messageActionChannelMigrateFrom class]] || [action isKindOfClass:[TL_messageActionChatMigrateTo class]]) { + actionText = NSLocalizedString(@"MessageAction.Service.ChatMigrated", nil); + user = nil; } - static float size = 11.5; if([action isKindOfClass:[TL_messageActionBotDescription class]]) { @@ -359,32 +476,41 @@ + (NSAttributedString *) serviceAttributedMessage:(TLMessage *)message forAction - NSRange start; - // if(user != [UsersManager currentUser]) { - start = [attributedString appendString:[user fullName] withColor:LINK_COLOR]; - [attributedString setLink:[TMInAppLinks userProfile:user.n_id] forRange:start]; - [attributedString setFont:[NSFont fontWithName:@"HelveticaNeue-Medium" size:size] forRange:start]; - // } else { - // start = [attributedString appendString:NSLocalizedString(@"Profile.You", nil) withColor:NSColorFromRGB(0xaeaeae)]; - // [attributedString setLink:[TMInAppLinks userProfile:user.n_id] forRange:start]; - // [attributedString setFont:[NSFont fontWithName:@"HelveticaNeue-Bold" size:size] forRange:start]; - // } + NSRange start = NSMakeRange(NSNotFound, 0); + // if(user != [UsersManager currentUser]) { + if(user) + start = [attributedString appendString:[user fullName] withColor:LINK_COLOR]; + if(message.from_id > 0 && start.location != NSNotFound) { + [attributedString setLink:[TMInAppLinks userProfile:user.n_id] forRange:start]; + [attributedString setFont:TGSystemMediumFont(size) forRange:start]; + } start = [attributedString appendString:[NSString stringWithFormat:@" %@ ", actionText] withColor:NSColorFromRGB(0xaeaeae)]; - [attributedString setFont:[NSFont fontWithName:@"HelveticaNeue" size:size] forRange:start]; + [attributedString setFont:TGSystemFont(size) forRange:start]; - if(user2) { - start = [attributedString appendString:[user2 fullName] withColor:LINK_COLOR]; - [attributedString setLink:[TMInAppLinks userProfile:user2.n_id] forRange:start]; - [attributedString setFont:[NSFont fontWithName:@"HelveticaNeue-Medium" size:size] forRange:start]; + if(users.count > 0) { + + [users enumerateObjectsUsingBlock:^(TLUser *obj, NSUInteger idx, BOOL * _Nonnull stop) { + + NSRange start = [attributedString appendString:[obj fullName] withColor:LINK_COLOR]; + [attributedString setLink:[TMInAppLinks userProfile:obj.n_id] forRange:start]; + [attributedString setFont:TGSystemMediumFont(size) forRange:start]; + + if(idx != users.count -1) { + [attributedString appendString:@", " withColor:NSColorFromRGB(0xaeaeae)]; + } + + }]; + } + if(title) { start = [attributedString appendString:[NSString stringWithFormat:@"\"%@\"", title] withColor:NSColorFromRGB(0xaeaeae)]; - [attributedString setFont:[NSFont fontWithName:@"HelveticaNeue-Medium" size:size] forRange:start]; + [attributedString setFont:TGSystemMediumFont(size) forRange:start]; } // [attributedString appendString:@"wqeqoeqwe wqkeqwoewkq keqwoei qoioiweiqwioeoqweiwqoi qoiweoiqwoiewqoieoiqweoiwqeoiwqoeiwqoieoiw oiqweoiqwoieqwoieoqwi"]; @@ -466,7 +592,7 @@ + (NSString *) mediaMessage:(TLMessage *)message { return [self serviceMessage:message forAction:message.action]; } - if([message.media isKindOfClass:[TL_messageMediaWebPage class]]) { + if([message.media isKindOfClass:[TL_messageMediaEmpty class]] || message.media == nil || [message.media isKindOfClass:[TL_messageMediaWebPage class]]) { return message.message; } @@ -534,6 +660,7 @@ +(NSDictionary *)conversationLastData:(TL_conversation *)conversation { [dateText appendString:@"" withColor:NSColorFromRGB(0xaeaeae)]; } + [dateText setFont:TGSystemFont(12) forRange:dateText.range]; data[@"dateText"] = dateText; @@ -561,7 +688,7 @@ +(NSDictionary *)conversationLastData:(TL_conversation *)conversation { NSDictionary *attributes =@{ NSForegroundColorAttributeName: [NSColor whiteColor], - NSFontAttributeName: [NSFont fontWithName:@"HelveticaNeue-Bold" size:10] + NSFontAttributeName: TGSystemBoldFont(10) }; unreadText = unreadTextCount; NSSize size = [unreadTextCount sizeWithAttributes:attributes]; diff --git a/TelegramTest/MessagesViewController.h b/TelegramTest/MessagesViewController.h index ef2f4f47..a708eea3 100644 --- a/TelegramTest/MessagesViewController.h +++ b/TelegramTest/MessagesViewController.h @@ -15,7 +15,7 @@ #import "ConnectionStatusViewControllerView.h" #import #import "TGCTextMark.h" - +#import "TGMessagesHintView.h" @class MessagesBottomView; @interface SearchSelectItem : NSObject @@ -40,7 +40,11 @@ typedef enum { @property (nonatomic, strong,readonly) MessagesTableView *table; @property (nonatomic, strong) MessagesBottomView *bottomView; - +typedef enum { + ShowMessageTypeReply = 1 << 0, + ShowMessageTypeSearch = 1 << 1, + ShowMessageTypeUnreadMark = 1 << 2 +} ShowMessageType; -(void)setConversation:(TL_conversation *)conversation; @@ -60,28 +64,36 @@ typedef enum { - (void)bottomViewChangeSize:(int)height animated:(BOOL)animated; - (void)setStringValueToTextField:(NSString *)stringValue; - (NSString *)inputText; + +- (void)showForwardMessagesModalView; + - (void)drop; //- (void)updateHeaderHeight:(BOOL)update animated:(BOOL)animated; -- (void)jumpToLastMessages; +- (void)jumpToLastMessages:(BOOL)force; - (void)saveInputText; -- (void)setCurrentConversation:(TL_conversation *)dialog withJump:(int)messageId historyFilter:(Class)historyFilter; -- (void)setCurrentConversation:(TL_conversation *)dialog withJump:(int)messageId historyFilter:(Class)historyFilter force:(BOOL)force; +- (void)setCurrentConversation:(TL_conversation *)dialog withMessageJump:(TL_localMessage *)message; +- (void)setCurrentConversation:(TL_conversation *)dialog withMessageJump:(TL_localMessage *)message force:(BOOL)force; - (void)setCurrentConversation:(TL_conversation *)dialog; -- (void)showMessage:(int)messageId fromMsgId:(int)msgId; -- (void)showMessage:(int)messageId fromMsgId:(int)msgId animated:(BOOL)animated selectText:(NSString *)text; + + +- (void)showMessage:(TL_localMessage *)message fromMsg:(TL_localMessage *)fromMsg flags:(int)flags; +- (void)showMessage:(TL_localMessage *)message fromMsg:(TL_localMessage *)fromMsg switchDiscussion:(BOOL)switchDiscussion; +- (void)showMessage:(TL_localMessage *)message fromMsg:(TL_localMessage *)fromMsg animated:(BOOL)animated selectText:(NSString *)text switchDiscussion:(BOOL)switchDiscussion flags:(int)flags; - (void)setHistoryFilter:(Class)filter force:(BOOL)force; - (void)updateLoading; - (MessageTableItem *)objectAtIndex:(NSUInteger)position; - (NSUInteger)indexOfObject:(MessageTableItem *)item; -- (MessageTableItem *)itemOfMsgId:(int)msg_id; +- (MessageTableItem *)itemOfMsgId:(long)msg_id; +(NSMenu *)destructMenu:(dispatch_block_t)ttlCallback click:(dispatch_block_t)click; +(NSMenu *)notifications:(dispatch_block_t)callback conversation:(TL_conversation *)conversation click:(dispatch_block_t)click; ++(BOOL)canDeleteMessages:(NSArray *)messages inConversation:(TL_conversation *)conversation; + - (NSUInteger)messagesCount; - (void)clearHistory:(TL_conversation *)dialog; @@ -122,7 +134,7 @@ typedef enum { - (void)sendAudio:(NSString *)file_path forConversation:(TL_conversation *)conversation; - (void)sendMessage:(NSString *)message forConversation:(TL_conversation *)conversation; - (void)sendLocation:(CLLocationCoordinate2D)coordinates forConversation:(TL_conversation *)conversation; -- (void)forwardMessages:(NSArray *)messages forConversation:(TL_conversation *)conversation callback:(dispatch_block_t)callback; +- (void)forwardMessages:(NSArray *)messages conversation:(TL_conversation *)conversation callback:(dispatch_block_t)callback; - (void)shareContact:(TLUser *)contact forConversation:(TL_conversation *)conversation callback:(dispatch_block_t)callback; - (void)sendSecretTTL:(int)ttl forConversation:(TL_conversation *)conversation; - (void)sendSecretTTL:(int)ttl forConversation:(TL_conversation *)conversation callback:(dispatch_block_t)callback; @@ -156,4 +168,13 @@ typedef enum { -(void)markAsNoWebpage; -(BOOL)noWebpage:(NSString *)message; + +-(void)showOrHideChannelDiscussion; + +-(void)tryRead; + +-(void)selectInputTextByText:(NSString *)text; + +-(TGMessagesHintView *)hintView; + @end diff --git a/TelegramTest/MessagesViewController.m b/TelegramTest/MessagesViewController.m index 7d6a3f3e..2fbbadf9 100644 --- a/TelegramTest/MessagesViewController.m +++ b/TelegramTest/MessagesViewController.m @@ -42,7 +42,7 @@ #import "EncryptedKeyWindow.h" #import "ChatHistoryController.h" -#import "OnlineNotificationManager.h" +#import "ChannelHistoryController.h" #import "TMBottomScrollView.h" #import "ReadHistroryTask.h" @@ -52,6 +52,7 @@ #import "DocumentHistoryFilter.h" #import "VideoHistoryFilter.h" #import "AudioHistoryFilter.h" +#import "ChannelFilter.h" #import "NoMessagesView.h" #import "TMAudioRecorder.h" #import "MessagesTopInfoView.h" @@ -70,6 +71,14 @@ #import "StartBotSenderItem.h" #import "TGHelpPopup.h" #import "TGAudioPlayerWindow.h" +#import "MessagesUtils.h" +#import "ChannelImportantFilter.h" +#import "TGModalDeleteChannelMessagesView.h" +#import "ComposeActionDeleteChannelMessagesBehavior.h" + +#import "TGModernUserViewController.h" +#import "TGModernChatInfoViewController.h" +#import "TGModernChannelInfoViewController.h" #define HEADER_MESSAGES_GROUPING_TIME (10 * 60) #define SCROLLDOWNBUTTON_OFFSET 1500 @@ -97,7 +106,7 @@ -(void)clear { @end -@interface MessagesViewController () { +@interface MessagesViewController () { __block SMDelayedBlockHandle _delayedBlockHandle; } @@ -110,7 +119,7 @@ @interface MessagesViewController () { @property (nonatomic, strong) SelfDestructionController *destructionController; @property (nonatomic, strong) RPCRequest *typingRequest; -@property (nonatomic,assign) int jumpMessageId; +@property (nonatomic,strong) TL_localMessage *jumpMessage; //Bottom @property (nonatomic, strong) MessageTypingView *typingView; @@ -122,8 +131,6 @@ @interface MessagesViewController () { @property (nonatomic, strong) NoMessagesView *noMessagesView; @property (nonatomic, strong) TMBottomScrollView *jumpToBottomButton; -@property (nonatomic, strong) TelegramPopover *popover; - @property (nonatomic, assign) BOOL isMarkIsset; @@ -166,6 +173,8 @@ @interface MessagesViewController () { @property (nonatomic, strong) TL_conversation *conversation; +@property (nonatomic, strong) TGMessagesHintView *hintView; + @property (nonatomic,assign) BOOL needNextRequest; @end @@ -200,24 +209,26 @@ - (NoMessagesView *)noMessagesView { return self.noMessagesView; } -- (void)jumpToLastMessages { +- (void)jumpToLastMessages:(BOOL)force { BOOL animated = YES; - if(self.replyMsgsStack.count > 0) - { - int msg_id = [[self.replyMsgsStack lastObject] intValue]; - - [self.replyMsgsStack removeObject:[self.replyMsgsStack lastObject]]; - - [self showMessage:msg_id fromMsgId:0 animated:YES selectText:nil]; - return; + if(!force) { + if(self.replyMsgsStack.count > 0) + { + TL_localMessage *msg = [self.replyMsgsStack lastObject]; + + [self.replyMsgsStack removeObject:[self.replyMsgsStack lastObject]]; + + [self showMessage:msg fromMsg:nil animated:YES selectText:nil switchDiscussion:NO flags:ShowMessageTypeReply]; + return; + } } - if(_historyController.prevState != ChatHistoryStateFull) { - - + + + if(_historyController.prevState != ChatHistoryStateFull || force) { [self flushMessages]; @@ -227,7 +238,7 @@ - (void)jumpToLastMessages { self.historyController = nil; - self.historyController = [[ChatHistoryController alloc] initWithController:self]; + self.historyController = [[[self hControllerClass] alloc] initWithController:self historyFilter:self.defHFClass]; animated = NO; @@ -237,6 +248,14 @@ - (void)jumpToLastMessages { [self.table.scrollView scrollToPoint:NSMakePoint(0, 0) animation:animated]; } +-(Class)hControllerClass { + return self.conversation.type == DialogTypeChannel ? [ChannelHistoryController class] : [ChatHistoryController class]; +} + +-(Class)defHFClass { + return self.conversation.type == DialogTypeChannel ? (self.conversation.chat.isMegagroup || self.conversation.chat.type == TLChatTypeForbidden ? [ChannelFilter class] : [ChannelImportantFilter class]) : [HistoryFilter class]; +} + -(NSArray *)messageList { return [self.messages copy]; @@ -249,6 +268,7 @@ -(void)reloadData { } - (void)loadView { + [super loadView]; _replyMsgsStack = [[NSMutableArray alloc] init]; @@ -262,6 +282,12 @@ - (void)loadView { [Notification addObserver:self selector:@selector(messageTableItemUpdate:) name:UPDATE_MESSAGE_ITEM]; [Notification addObserver:self selector:@selector(messageTableItemsWebPageUpdate:) name:UPDATE_WEB_PAGE_ITEMS]; [Notification addObserver:self selector:@selector(messageTableItemsReadContents:) name:UPDATE_READ_CONTENTS]; + [Notification addObserver:self selector:@selector(messageTableItemsEntitiesUpdate:) name:UPDATE_MESSAGE_ENTITIES]; + [Notification addObserver:self selector:@selector(messageTableItemsHoleUpdate:) name:UPDATE_MESSAGE_GROUP_HOLE]; + + [Notification addObserver:self selector:@selector(didChangeDeleteDialog:) name:DIALOG_DELETE]; + + [Notification addObserver:self selector:@selector(updateMessageViews:) name:UPDATE_MESSAGE_VIEWS]; [self.view setAutoresizesSubviews:YES]; [self.view setAutoresizingMask:NSViewHeightSizable | NSViewWidthSizable]; @@ -270,18 +296,17 @@ - (void)loadView { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowBecomeNotification:) name:NSWindowDidResignKeyNotification object:self.view.window]; - [Notification addObserver:self selector:@selector(changeDialogSelectionNotification:) name:@"ChangeDialogSelection"]; [Notification addObserver:self selector:@selector(updateChat:) name:CHAT_UPDATE_TYPE]; self.messages = [[NSMutableArray alloc] init]; self.selectedMessages = [[NSMutableArray alloc] init]; - __block MessagesViewController *strongSelf = self; + weak(); //Navigation self.normalNavigationRightView = [TMTextButton standartMessageNavigationButtonWithTitle:NSLocalizedString(@"Profile.Edit", nil)]; [self.normalNavigationRightView setTapBlock:^{ - [strongSelf setCellsEditButtonShow:YES animated:YES]; + [weakSelf setCellsEditButtonShow:YES animated:YES]; }]; [self.normalNavigationRightView setDisableColor:NSColorFromRGB(0xa0a0a0)]; @@ -290,7 +315,7 @@ - (void)loadView { self.filtredNavigationCenterView = [TMTextButton standartUserProfileButtonWithTitle:@"nil"]; - [self.filtredNavigationCenterView setFont:[NSFont fontWithName:@"HelveticaNeue" size:14]]; + [self.filtredNavigationCenterView setFont:TGSystemFont(14)]; [self.filtredNavigationCenterView setAlignment:NSCenterTextAlignment]; [self.filtredNavigationCenterView setTextColor:BLUE_UI_COLOR]; @@ -298,49 +323,20 @@ - (void)loadView { [self.filtredNavigationCenterView setFrameOrigin:NSMakePoint(0, -13)]; - [self.filtredNavigationCenterView setTapBlock:^ { - NSMenu *menu = [strongSelf filterMenu]; - - [menu popUpForView:strongSelf.filtredNavigationCenterView center:YES]; - - }]; - - - [self.filtredNavigationCenterView setStringValue:NSLocalizedString(@"Shared Media", nil)]; self.filtredNavigationLeftView = [TMTextButton standartMessageNavigationButtonWithTitle:NSLocalizedString(@"Profile.Cancel", nil)]; - [self.filtredNavigationLeftView setTapBlock:^{ - [strongSelf setHistoryFilter:[HistoryFilter class] force:NO]; + [self.filtredNavigationLeftView setTapBlock:^{ + [weakSelf setHistoryFilter:[weakSelf defHFClass] force:NO]; }]; self.normalNavigationCenterView = [[MessageTableNavigationTitleView alloc] initWithFrame:NSZeroRect]; - + [self.normalNavigationCenterView setController:self]; [self.normalNavigationCenterView setTapBlock:^{ - switch (strongSelf.conversation.type) { - case DialogTypeChat: - if(strongSelf.conversation.chat.type == TLChatTypeNormal && !strongSelf.conversation.chat.left) - [[Telegram rightViewController] showChatInfoPage:strongSelf.conversation.chat]; - break; - - case DialogTypeSecretChat: - [[Telegram sharedInstance] showUserInfoWithUserId:strongSelf.conversation.encryptedChat.peerUser.n_id conversation:strongSelf.conversation sender:strongSelf]; - break; - - case DialogTypeUser: { - [[Telegram sharedInstance] showUserInfoWithUserId:strongSelf.conversation.user.n_id conversation:strongSelf.conversation sender:strongSelf]; - break; - } - - case DialogTypeBroadcast: - [[Telegram rightViewController] showBroadcastInfoPage:strongSelf.conversation.broadcast]; - - default: - break; - } + [weakSelf.navigationViewController showInfoPage:weakSelf.conversation]; }]; self.centerNavigationBarView = self.normalNavigationCenterView; @@ -349,13 +345,13 @@ - (void)loadView { self.editableNavigationLeftView = [TMTextButton standartMessageNavigationButtonWithTitle:NSLocalizedString(@"Profile.DeleteAll", nil)]; [self.editableNavigationLeftView setTapBlock:^{ - [strongSelf clearHistory:strongSelf.conversation]; + [weakSelf clearHistory:weakSelf.conversation]; }]; self.editableNavigationRightView = [TMTextButton standartMessageNavigationButtonWithTitle:NSLocalizedString(@"Profile.Done", nil)]; [self.editableNavigationRightView setTapBlock:^{ - [strongSelf unSelectAll]; + [weakSelf unSelectAll]; }]; @@ -391,7 +387,7 @@ - (void)loadView { [self.jumpToBottomButton setAutoresizingMask:NSViewMinXMargin]; [self.jumpToBottomButton setHidden:YES]; [self.jumpToBottomButton setCallback:^{ - [strongSelf jumpToLastMessages]; + [weakSelf jumpToLastMessages:NO]; }]; [self.view addSubview:self.jumpToBottomButton]; @@ -416,31 +412,54 @@ - (void)loadView { self.searchItems = [[NSMutableArray alloc] init]; - [self.historyController drop:NO]; - - self.historyController = nil; - - self.historyController = [[ChatHistoryController alloc] initWithController:self]; [self.searchMessagesView setHidden:YES]; self.stickerPanel = [[StickersPanelView alloc] initWithFrame:NSMakeRect(0, NSHeight(self.bottomView.frame), NSWidth(self.view.frame), 76)]; - + self.stickerPanel.messagesViewController = self; [self.view addSubview:self.stickerPanel]; [self.stickerPanel hide:NO]; + + + self.hintView = [[TGMessagesHintView alloc] initWithFrame:NSMakeRect(0, NSHeight(self.bottomView.frame), NSWidth(self.view.frame), 100)]; + + [self.hintView setHidden:YES]; + + [self.view addSubview:self.hintView]; + +} + +-(void)didChangeDeleteDialog:(NSNotification *)notification { + TL_conversation *conversation = notification.userInfo[KEY_DIALOG]; + + if(conversation.peer_id == _conversation.peer_id) { + [self.navigationViewController goBackWithAnimation:YES]; + } + } +-(void)_didStackRemoved { + + self.conversation = nil; + [self.historyController stopChannelPolling]; + [self flushMessages]; + + + +} -(void)messageTableItemUpdate:(NSNotification *)notification { MessageTableItem *item = notification.userInfo[@"item"]; + [item makeSizeByWidth:item.makeSize]; + NSUInteger index = [self indexOfObject:item]; if(index != NSNotFound) @@ -451,102 +470,161 @@ -(void)messageTableItemUpdate:(NSNotification *)notification { -(void)messageTableItemsReadContents:(NSNotification *)notification { NSArray *messages = notification.userInfo[KEY_MESSAGE_ID_LIST]; - - NSPredicate *predicate = [NSPredicate predicateWithFormat:@"self.message.n_id IN (%@)", messages]; - - NSArray *items = [[HistoryFilter messageItems:self.conversation.peer_id] filteredArrayUsingPredicate:predicate]; - - [items enumerateObjectsUsingBlock:^(MessageTableItemText *obj, NSUInteger idx, BOOL *stop) { - NSUInteger index = [self indexOfObject:obj]; + [self.historyController items:messages complete:^(NSArray *items) { - if(index != NSNotFound) { - [self.table reloadDataForRowIndexes:[NSIndexSet indexSetWithIndex:index] columnIndexes:[NSIndexSet indexSetWithIndex:0]]; - } + [items enumerateObjectsUsingBlock:^(TL_localMessage *obj, NSUInteger idx, BOOL *stop) { + + MessageTableItem *item = [self itemOfMsgId:obj.channelMsgId]; + + NSUInteger index = [self indexOfObject:item]; + + if(index != NSNotFound) { + [self.table reloadDataForRowIndexes:[NSIndexSet indexSetWithIndex:index] columnIndexes:[NSIndexSet indexSetWithIndex:0]]; + } + + }]; }]; } - -(void)messageTableItemsWebPageUpdate:(NSNotification *)notification { - NSArray *messages = notification.userInfo[KEY_MESSAGE_ID_LIST]; - + NSArray *messages = notification.userInfo[KEY_DATA][@(self.conversation.peer_id)]; - NSArray *items = [HistoryFilter items:messages]; + TLWebPage *webpage = notification.userInfo[KEY_WEBPAGE]; - [items enumerateObjectsUsingBlock:^(MessageTableItemText *obj, NSUInteger idx, BOOL *stop) { - - NSUInteger index = [self indexOfObject:obj]; - - - - [obj updateWebPage]; - - obj.isHeaderMessage = obj.isHeaderMessage || obj.webpage != nil; + [self.historyController items:messages complete:^(NSArray *items) { - if(index != NSNotFound) { - [self.table noteHeightOfRowsWithIndexesChanged:[NSIndexSet indexSetWithIndex:index]]; + [items enumerateObjectsUsingBlock:^(TL_localMessage *obj, NSUInteger idx, BOOL *stop) { - [self.table reloadDataForRowIndexes:[NSIndexSet indexSetWithIndex:index] columnIndexes:[NSIndexSet indexSetWithIndex:0]]; - } + MessageTableItemText *item = (MessageTableItemText *) [self itemOfMsgId:obj.channelMsgId]; + + NSUInteger index = [self indexOfObject:item]; + + item.message.media.webpage = webpage; + + [item updateWebPage]; + + item.isHeaderMessage = item.isHeaderMessage || item.webpage != nil; + + if(index != NSNotFound) { + [self.table noteHeightOfRowsWithIndexesChanged:[NSIndexSet indexSetWithIndex:index]]; + + [self.table reloadDataForRowIndexes:[NSIndexSet indexSetWithIndex:index] columnIndexes:[NSIndexSet indexSetWithIndex:0]]; + } + + }]; }]; - } - --(void)showSearchBox { +-(void)updateMessageViews:(NSNotification *)notification { - if(!self.searchMessagesView.isHidden) { - [self.searchMessagesView becomeFirstResponder]; - return; + + if(self.conversation.peer_id == [notification.userInfo[KEY_PEER_ID] intValue]) { + [self.historyController items:notification.userInfo[KEY_MESSAGE_ID_LIST] complete:^(NSArray *items) { + NSDictionary *data = notification.userInfo[KEY_DATA]; + + [items enumerateObjectsUsingBlock:^(TL_localMessage *message, NSUInteger idx, BOOL *stop) { + + MessageTableItem *item = [self itemOfMsgId:message.channelMsgId]; + + NSUInteger index = [self indexOfObject:item]; + + item.message.views = [data[@(item.message.n_id)] intValue]; + + BOOL upd = [item updateViews]; + + if(upd && index != NSNotFound) { + [self.table reloadDataForRowIndexes:[NSIndexSet indexSetWithIndex:index] columnIndexes:[NSIndexSet indexSetWithIndex:0]]; + } + }]; + + }]; } +} + +-(void)messageTableItemsHoleUpdate:(NSNotification *)notification { + + if(self.historyController.filter.class == [ChannelImportantFilter class]) { + TGMessageGroupHole *hole = notification.userInfo[KEY_GROUP_HOLE]; + + if(hole.peer_id == self.conversation.peer_id) { + [self.historyController items:@[@(hole.uniqueId)] complete:^(NSArray *items) { + + MessageTableItemHole *item; + + if(items.count == 1) { + + item = (MessageTableItemHole *) [self itemOfMsgId:[[items firstObject] channelMsgId]]; + + if(hole.messagesCount != 0) { + + NSUInteger index = [self indexOfObject:item]; + + [item updateWithHole:hole]; + + if(index != NSNotFound) { + [self.table reloadDataForRowIndexes:[NSIndexSet indexSetWithIndex:index] columnIndexes:[NSIndexSet indexSetWithIndex:0]]; + } + } else { + [Notification perform:MESSAGE_DELETE_EVENT data:@{KEY_DATA:@[@{KEY_PEER_ID:@(hole.peer_id),KEY_MESSAGE_ID:@(hole.uniqueId)}]}]; + } + } else { + [Notification performOnStageQueue:MESSAGE_RECEIVE_EVENT data:@{KEY_MESSAGE:[TL_localMessageService createWithHole:hole]}]; + } + }]; + } + } + +} + +-(void)messageTableItemsEntitiesUpdate:(NSNotification *)notification { - __block int currentId = 0; + TL_localMessage *message = notification.userInfo[KEY_MESSAGE]; - dispatch_block_t clearItems = ^ { - [self.searchItems enumerateObjectsUsingBlock:^(SearchSelectItem *obj, NSUInteger idx, BOOL *stop) { - - [obj clear]; - - [self.table reloadDataForRowIndexes:[NSIndexSet indexSetWithIndex:[self.messages indexOfObject:obj.item]] columnIndexes:[NSIndexSet indexSetWithIndex:0]]; + if(message.peer_id == self.conversation.peer_id) { + [self.historyController items:@[@(message.n_id)] complete:^(NSArray *items){ + [items enumerateObjectsUsingBlock:^(TL_localMessage *obj, NSUInteger idx, BOOL *stop) { + + MessageTableItemText *item = (MessageTableItemText *) [self itemOfMsgId:obj.channelMsgId]; + + NSUInteger index = [self indexOfObject:item]; + + [item updateEntities]; + + if(index != NSNotFound) { + [self.table reloadDataForRowIndexes:[NSIndexSet indexSetWithIndex:index] columnIndexes:[NSIndexSet indexSetWithIndex:0]]; + } + + }]; }]; - - - [self.searchItems removeAllObjects]; - currentId = -1; - }; + } - dispatch_block_t next = ^ { - if(self.searchItems.count > 0) { - - SearchSelectItem *searchItem = self.searchItems[currentId]; - - [self.table clearSelection]; - - NSUInteger row = [self.messages indexOfObject:searchItem.item]; - - NSRect rowRect = [self.table rectOfRow:row]; - - [self.table.scrollView scrollToPoint:rowRect.origin animation:NO]; - - [self scrollToRect:rowRect isCenter:YES animated:NO]; - - } - }; - [self.searchMessagesView showSearchBox:^(int msg_id, NSString *searchString) { +} + + +-(void)showSearchBox { + + if(!self.searchMessagesView.isHidden) { + [self.searchMessagesView becomeFirstResponder]; + return; + } + + + [self.searchMessagesView showSearchBox:^(TL_localMessage *msg, NSString *searchString) { - [self showMessage:msg_id fromMsgId:0 animated:NO selectText:searchString]; + [self showMessage:msg fromMsg:nil animated:NO selectText:searchString switchDiscussion:NO flags:ShowMessageTypeReply]; } closeCallback:^{ [self hideSearchBox:YES]; @@ -578,88 +656,14 @@ -(BOOL)searchBoxIsVisible { return !self.searchMessagesView.isHidden; } -/* - [self.searchMessagesView showSearchBox:^(NSString *search) { - - clearItems(); - - [self.messages enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(MessageTableItem *obj, NSUInteger idx, BOOL *stop) { - - if([obj isKindOfClass:[MessageTableItemText class]]) { - - SearchSelectItem *searchItem = [[SearchSelectItem alloc] init]; - - searchItem.item = obj; - - - NSRange range = [obj.message.message rangeOfString:search options:NSCaseInsensitiveSearch]; - while(range.location != NSNotFound) - { - TGCTextMark *mark = [[TGCTextMark alloc] initWithRange:range color:NSColorFromRGBWithAlpha(0xe5bf29, 0.3) isReal:NO]; - - [searchItem.marks addObject:mark]; - - ((MessageTableItemText *)obj).mark = searchItem; - - [self.searchItems addObject:searchItem]; - - [self.table reloadDataForRowIndexes:[NSIndexSet indexSetWithIndex:idx] columnIndexes:[NSIndexSet indexSetWithIndex:0]]; - - - range = [obj.message.message rangeOfString:search options:NSCaseInsensitiveSearch range:NSMakeRange(range.location + 1, [obj.message.message length] - range.location - 1)]; - } - - } - - }]; - - if(self.searchItems.count > 0) { - currentId++; - next(); - } - - - - } next:^ { - - currentId++; - - if(currentId >= self.searchItems.count) - currentId = 0; - - next(); - - - - } prevCallback:^{ - - currentId--; - - if(currentId < 0) - currentId = (int) self.searchItems.count - 1; - - next(); - - - - - } closeCallback:^{ - - [self hideSearchBox:YES]; - - }]; - */ -(void)hideSearchBox:(BOOL)animated { - - - if(self.searchMessagesView.isHidden) return; - if(self.historyController.prevState != ChatHistoryStateFull) - [self jumpToLastMessages]; + if(self.historyController != nil && self.historyController.prevState != ChatHistoryStateFull) + [self jumpToLastMessages:YES]; [self.searchItems enumerateObjectsUsingBlock:^(SearchSelectItem *obj, NSUInteger idx, BOOL *stop) { @@ -697,13 +701,17 @@ -(void)hideSearchBox:(BOOL)animated { [self.searchMessagesView setNeedsDisplay:YES]; [self.searchMessagesView setHidden:YES]; } + } - (void)setCellsEditButtonShow:(BOOL)show animated:(BOOL)animated { - if(self.bottomView.stateBottom == MessagesBottomViewNormalState || self.bottomView.stateBottom == MessagesBottomViewActionsState) - { + if(![self acceptState: show ? MessagesViewControllerStateEditable : MessagesViewControllerStateNone]) + return; + + // if(self.bottomView.stateBottom == MessagesBottomViewNormalState || self.bottomView.stateBottom == MessagesBottomViewActionsState) + // { [self setState: show ? MessagesViewControllerStateEditable : MessagesViewControllerStateNone animated:animated]; for(int i = 0; i < self.messages.count; i++) { MessageTableCellContainerView *cell = (MessageTableCellContainerView *)[self cellForRow:i]; @@ -711,15 +719,13 @@ - (void)setCellsEditButtonShow:(BOOL)show animated:(BOOL)animated { [cell setEditable:show animation:animated]; } } - } + // } } --(void)_didStackRemoved { - [self flushMessages]; -} + -(NSAttributedString *)stringForSharedMedia:(NSString *)mediaString { @@ -727,7 +733,7 @@ -(NSAttributedString *)stringForSharedMedia:(NSString *)mediaString { [string appendString:mediaString withColor:BLUE_UI_COLOR]; - [string setFont:[NSFont fontWithName:@"HelveticaNeue" size:14] forRange:NSMakeRange(0, string.length)]; + [string setFont:TGSystemFont(14) forRange:NSMakeRange(0, string.length)]; [string appendAttributedString:[NSAttributedString attributedStringWithAttachment:headerMediaIcon()]]; @@ -770,7 +776,7 @@ - (void)showNoMessages:(BOOL)show { if(nState != self.bottomView.stateBottom) { [self.bottomView setStateBottom:nState]; - [self.bottomView setSectedMessagesCount:self.selectedMessages.count]; + [self.bottomView setSectedMessagesCount:self.selectedMessages.count enable:[self canDeleteMessages]]; } @@ -784,8 +790,11 @@ - (void)showNoMessages:(BOOL)show { [CATransaction begin]; [CATransaction setDisableActions:YES]; [self.noMessagesView setHidden:!show]; + [self.table.containerView setHidden:show]; [CATransaction commit]; + + [self updateLoading]; }]; } @@ -802,6 +811,9 @@ -(void)updateLoading { -(void)showBotStartButton:(NSString *)startParam bot:(TLUser *)bot { [self.bottomView setStateBottom:MessagesBottomViewBlockChat]; self.bottomView.botStartParam = startParam; + + + weak(); [self.bottomView setOnClickToLockedView:^{ @@ -809,7 +821,7 @@ -(void)showBotStartButton:(NSString *)startParam bot:(TLUser *)bot { [ASQueue dispatchOnStageQueue:^{ - StartBotSenderItem *sender = [[StartBotSenderItem alloc] initWithMessage:conversation.type == DialogTypeChat ? [NSString stringWithFormat:@"/start@%@",bot.username] : @"/start" forConversation:conversation bot:bot startParam:startParam]; + StartBotSenderItem *sender = [[StartBotSenderItem alloc] initWithMessage:conversation.type == DialogTypeChat || conversation.type == DialogTypeChannel ? [NSString stringWithFormat:@"/start@%@",bot.username] : @"/start" forConversation:conversation bot:bot startParam:startParam]; sender.tableItem = [[weakSelf messageTableItemsFromMessages:@[sender.message]] lastObject]; [weakSelf.historyController addItem:sender.tableItem conversation:conversation callback:nil sentControllerCallback:nil]; @@ -824,14 +836,14 @@ -(void)showBotStartButton:(NSString *)startParam bot:(TLUser *)bot { }]; + + + if(startParam.length > 0 && ![[startParam lowercaseString] isEqualToString:@"start"]) { + self.bottomView.onClickToLockedView(); + } } -- (void)changeDialogSelectionNotification:(NSNotification *)notify { - if([[notify.userInfo objectForKey:KEY_DIALOG] class] == [NSNull class]) - self.conversation = nil; -} - - (void)updateChat:(NSNotification *)notify { TLChat *chat = [notify.userInfo objectForKey:KEY_CHAT]; @@ -842,18 +854,21 @@ - (void)updateChat:(NSNotification *)notify { - (void)setState:(MessagesViewControllerState)state { [self setState:state animated:NO]; + +} + +-(BOOL)acceptState:(MessagesViewControllerState)state { + return self.conversation.canEditConversation || state == MessagesViewControllerStateNone; } - (void)setState:(MessagesViewControllerState)state animated:(BOOL)animated { + self->_state = state; id rightView, leftView, centerView; centerView = self.normalNavigationCenterView; - if(state == MessagesViewControllerStateNone && self.historyController.filter.class != HistoryFilter.class) { - state = MessagesViewControllerStateFiltred; - } if(state == MessagesViewControllerStateNone) { rightView = self.normalNavigationRightView; @@ -871,10 +886,13 @@ - (void)setState:(MessagesViewControllerState)state animated:(BOOL)animated { } else { rightView = self.editableNavigationRightView; - leftView = self.editableNavigationLeftView; + leftView = self.conversation.type == DialogTypeChannel ? [self standartLeftBarView] : self.editableNavigationLeftView; [self.bottomView setState:MessagesBottomViewActionsState animated:animated]; } + if(!self.conversation.canEditConversation) + rightView = nil; + if(self.rightNavigationBarView != rightView) [self setRightNavigationBarView:rightView animated:YES]; @@ -884,6 +902,7 @@ - (void)setState:(MessagesViewControllerState)state animated:(BOOL)animated { if(self.centerNavigationBarView != centerView) { [self setCenterNavigationBarView:centerView]; } + } - (void)rightButtonAction { @@ -893,43 +912,11 @@ - (void)rightButtonAction { [[[Telegram sharedInstance] firstController] closeAllPopovers]; - - if(self.conversation.type == DialogTypeChat) { - if(self.conversation.chat.type == TLChatTypeNormal && !self.conversation.chat.left) - [[Telegram rightViewController] showChatInfoPage:self.conversation.chat]; - } else if(self.conversation.type == DialogTypeSecretChat) { - TLUser *user = self.conversation.encryptedChat.peerUser; - [[Telegram sharedInstance] showUserInfoWithUserId:user.n_id conversation:self.conversation sender:self]; - } else { - TLUser *user = self.conversation.user; - [[Telegram sharedInstance] showUserInfoWithUserId:user.n_id conversation:self.conversation sender:self]; - } + [self.navigationViewController showInfoPage:self.conversation]; } --(NSMenu *)filterMenu { - NSMenu *filterMenu = [[NSMenu alloc] init]; - - - [filterMenu addItem:[NSMenuItem menuItemWithTitle:NSLocalizedString(@"Conversation.Filter.Photos",nil) withBlock:^(id sender) { - [[Telegram rightViewController] showCollectionPage:self.conversation]; - }]]; - - [filterMenu addItem:[NSMenuItem menuItemWithTitle:NSLocalizedString(@"Conversation.Filter.Video",nil) withBlock:^(id sender) { - [self setHistoryFilter:[VideoHistoryFilter class] force:NO]; - }]]; - - - [filterMenu addItem:[NSMenuItem menuItemWithTitle:NSLocalizedString(@"Conversation.Filter.Files",nil) withBlock:^(id sender) { - [self setHistoryFilter:[DocumentHistoryFilter class] force:NO]; - }]]; - - [filterMenu addItem:[NSMenuItem menuItemWithTitle:NSLocalizedString(@"Conversation.Filter.Audio",nil) withBlock:^(id sender) { - [self setHistoryFilter:[AudioHistoryFilter class] force:NO]; - }]]; - - return filterMenu; -} + +(NSMenu *)destructMenu:(dispatch_block_t)ttlCallback click:(dispatch_block_t)click { NSMenu *submenu = [[NSMenu alloc] init]; @@ -1117,12 +1104,15 @@ - (void)setHistoryFilter:(Class)filter force:(BOOL)force { assert([NSThread isMainThread]); + if(self.conversation.type == DialogTypeChannel) + filter = self.historyController.filter.class; + if(self.historyController.filter.class != filter || force) { self.ignoredCount = 0; - self.historyController.filter = [[filter alloc] initWithController:self.historyController]; [self flushMessages]; + _historyController = [[self.historyController.class alloc] initWithController:self historyFilter:filter]; [self loadhistory:0 toEnd:YES prev:NO isFirst:YES]; - self.state = filter != HistoryFilter.class ? MessagesViewControllerStateFiltred : MessagesViewControllerStateNone; + self.state = MessagesViewControllerStateNone; } } @@ -1139,11 +1129,16 @@ - (void) viewDidAppear:(BOOL)animated { - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; + if(self.conversation.type == DialogTypeChannel) { + [[FullChatManager sharedManager] performLoad:self.conversation.chat.n_id force:YES callback:nil]; + } + +// [self.table reloadData]; [self setState:self.state]; if(self.state == MessagesViewControllerStateEditable) - [self.bottomView setSectedMessagesCount:self.selectedMessages.count]; + [self.bottomView setSectedMessagesCount:self.selectedMessages.count enable:[self canDeleteMessages]]; #ifdef __MAC_10_10 @@ -1174,40 +1169,56 @@ - (void)viewWillAppear:(BOOL)animated { - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; + [Notification perform:@"ChangeDialogSelection" data:@{}]; [self.table.scrollView setHasVerticalScroller:NO]; + + if(![globalAudioPlayer().delegate isKindOfClass:[TGAudioPlayerWindow class]]) { + [globalAudioPlayer() stop]; + [globalAudioPlayer().delegate audioPlayerDidFinishPlaying:globalAudioPlayer()]; + } + } -(void)viewDidDisappear:(BOOL)animated { - if(NSClassFromString(@"NSUserActivity")) { [self.activity invalidate]; } + } -- (void)scrollDidStart { - for(int i = 0; i < self.messages.count; i++) { - MessageTableCellGifView *view = [self.table viewAtColumn:0 row:i makeIfNecessary:NO]; - if(view && [view isKindOfClass:[MessageTableCellGifView class]]) { - [view pauseAnimation]; - } - } -} - -- (void)scrollDidEnd { - for(int i = 0; i < self.messages.count; i++) { - MessageTableCellGifView *view = [self.table viewAtColumn:0 row:i makeIfNecessary:NO]; - if(view && [view isKindOfClass:[MessageTableCellGifView class]]) { - [view resumeAnimation]; - } - } -} -- (void)setStringValueToTextField:(NSString *)stringValue { +- (void)scrollDidChange { + +// int bp = 0; +// +// [self.messages enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { +// +// MessageTableCellGifView *view = [self.table viewAtColumn:0 row:idx makeIfNecessary:NO]; +// +// if(view && [view isKindOfClass:[MessageTableCellGifView class]]) { +// NSRange visibleRange = [_table rowsInRect:_table.visibleRect]; +// +// if(idx < visibleRange.location || idx > visibleRange.location + visibleRange.length) { +// [view pauseAnimation]; +// } else { +// [view resumeAnimation]; +// } +// } +// +// +// +// }]; + +} + + + +- (void)setStringValueToTextField:(NSString *)stringValue { if(stringValue) [self.bottomView setInputMessageString:stringValue disableAnimations:NO]; } @@ -1245,12 +1256,13 @@ - (void)bottomViewChangeSize:(int)height animated:(BOOL)animated { [[self.noMessagesView animator] setFrame:newFrame]; [[self.stickerPanel animator] setFrameOrigin:NSMakePoint(NSMinX(self.stickerPanel.frame), height)]; - + [[self.hintView animator] setFrameOrigin:NSMakePoint(NSMinX(self.hintView.frame), height)]; } else { [self.table.scrollView setFrame:newFrame]; [self.noMessagesView setFrame:newFrame]; [self.stickerPanel setFrameOrigin:NSMakePoint(NSMinX(self.stickerPanel.frame), height)]; + [self.hintView setFrameOrigin:NSMakePoint(NSMinX(self.hintView.frame), height)]; } @@ -1308,6 +1320,45 @@ - (void)hideTopInfoView:(BOOL)animated { [self.topInfoView setFrameOrigin:newPoint]; } +} + +-(void)showOrHideChannelDiscussion { + + + [self.replyMsgsStack removeAllObjects]; + + if(self.table.scrollView.documentOffset.y > 0) { + NSRange range = [self.table rowsInRect:[self.table visibleRect]]; + __block MessageTableItem *item; + + [self.messages enumerateObjectsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:range] options:NSEnumerationReverse usingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + + if(![obj isKindOfClass:[MessageTableItemHole class]] && idx >= 2) { + item = obj; + *stop = YES; + } + + + }]; + + + if(item) { + [self showMessage:item.message fromMsg:nil flags:0]; + return; + } + + } + + + Class f = !self.normalNavigationCenterView.discussIsEnabled ? [ChannelImportantFilter class] : [ChannelFilter class]; + + [self.historyController setFilter:[[f alloc] initWithController:self.historyController peer:_conversation.peer]]; + + [self flushMessages]; + [self loadhistory:0 toEnd:YES prev:NO isFirst:YES]; + + + } //- (void)showConnectionController:(BOOL)animated { @@ -1364,6 +1415,9 @@ - (void)hideTopInfoView:(BOOL)animated { // //} +- (void)showForwardMessagesModalView { + [[Telegram rightViewController] showForwardMessagesModalView:self.conversation messagesCount:self.selectedMessages.count]; +} - (void)jumpToBottomButtonDisplay { @@ -1380,7 +1434,7 @@ - (void)updateScrollBtn { - if(fabsf(_lastBottomScrollOffset - offset) < 100 || [self.table.scrollView isAnimating]) + if([self.table.scrollView isAnimating]) return; _lastBottomScrollOffset = offset; @@ -1398,9 +1452,7 @@ - (void)updateScrollBtn { hide = self.jumpToBottomButton.messagesCount == 0; } // -// if(hide) { -// hide = self.historyController.prevState == ChatHistoryStateFull; -// } +// if(hide) { @@ -1408,43 +1460,69 @@ - (void)updateScrollBtn { if(!hide) { - MessageTableItem *item = [self itemOfMsgId:[[_replyMsgsStack lastObject] intValue]]; + MessageTableItem *item = [self itemOfMsgId:[[_replyMsgsStack lastObject] channelMsgId]]; + + if(item) { + NSRect rowRect = [self.table rectOfRow:[self indexOfObject:item]]; + + hide = CGRectContainsRect([self.table visibleRect], rowRect) || self.table.scrollView.documentOffset.y < rowRect.origin.y; + + + if(hide) { + [_replyMsgsStack removeLastObject]; + } + } - NSRect rowRect = [self.table rectOfRow:[self indexOfObject:item]]; + - hide = CGRectContainsRect([self.table visibleRect], rowRect) || self.table.scrollView.documentOffset.y < rowRect.origin.y; + } + } + + if(hide) { + [self.historyController prevStateAsync:^(ChatHistoryState state) { + BOOL h = hide || state == ChatHistoryStateFull; - if(hide) { - [_replyMsgsStack removeLastObject]; + if(self.jumpToBottomButton.isHidden != h) { + [self.jumpToBottomButton setHidden:h]; + [self jumpToBottomButtonDisplay]; } + }]; + } else { + if(self.jumpToBottomButton.isHidden != hide) { + [self.jumpToBottomButton setHidden:hide]; + [self jumpToBottomButtonDisplay]; } } - - if(self.jumpToBottomButton.isHidden != hide) { - [self.jumpToBottomButton setHidden:hide]; - [self jumpToBottomButtonDisplay]; - } - } - (void)scrollViewDocumentOffsetChangingNotificationHandler:(NSNotification *)aNotification { [self updateScrollBtn]; - if([self.table.scrollView isNeedUpdateTop] && - self.historyController.prevState != ChatHistoryStateFull) { + [self scrollDidChange]; + + if([self.table.scrollView isNeedUpdateTop] && [self.historyController filterWithNext:NO].prevState != ChatHistoryStateFull) { + + [self.historyController prevStateAsync:^(ChatHistoryState state) { + if(state != ChatHistoryStateFull) { + [self loadhistory:0 toEnd:NO prev:YES isFirst:NO]; + } + }]; + + } else if([self.table.scrollView isNeedUpdateBottom]) { + + [self.historyController nextStateAsync:^(ChatHistoryState state) { + if(state != ChatHistoryStateFull) { + [self loadhistory:0 toEnd:NO prev:NO isFirst:NO]; + } + }]; + - [self loadhistory:0 toEnd:NO prev:YES isFirst:NO]; - return; } - if(self.historyController.nextState == ChatHistoryStateFull || ![self.table.scrollView isNeedUpdateBottom]) - return; - - [self loadhistory:0 toEnd:NO prev:NO isFirst:NO]; } - (void) dealloc { @@ -1454,12 +1532,12 @@ - (void) dealloc { - (void) drop { self.conversation = nil; // [self.historyController setDialog:nil]; - [ChatHistoryController drop]; [self.historyController drop:YES]; self.historyController = nil; [self.messages removeAllObjects]; [self.table deselectRow:self.table.selectedRow]; [self.table reloadData]; + [Notification removeObserver:self]; } -(void)dialogDeleteNotification:(NSNotification *)notify { @@ -1470,48 +1548,6 @@ -(void)dialogDeleteNotification:(NSNotification *)notify { } } -- (void)sendTypingWithAction:(TLSendMessageAction *)action { - - - - NSMutableDictionary *list = [_typingReservation objectForKey:@(self.conversation.peer_id)]; - - - if(!list) - { - list = [[NSMutableDictionary alloc] init]; - [_typingReservation setObject:list forKey:@(self.conversation.peer_id)]; - } - - if(list[NSStringFromClass(action.class)] == nil) { - - [list setObject:action forKey:NSStringFromClass(action.class)]; - - if(self.conversation.type == DialogTypeBroadcast) - return; - - - [self.typingRequest cancelRequest]; - - id request; - - if(self.conversation.type == DialogTypeSecretChat) - request = [TLAPI_messages_setEncryptedTyping createWithPeer:(TLInputEncryptedChat *)[self.conversation.encryptedChat inputPeer] typing:YES]; - else - request = [TLAPI_messages_setTyping createWithPeer:[self.conversation inputPeer] action:action]; - - - self.typingRequest = [RPCRequest sendRequest:request successHandler:^(RPCRequest *request, id response) { - - dispatch_after_seconds(4, ^{ - [list removeObjectForKey:NSStringFromClass(action.class)]; - }); - - - } errorHandler:nil]; - } -} - - (void)windowBecomeNotification:(NSNotification *)notify { [self becomeFirstResponder]; [self tryRead]; @@ -1535,17 +1571,27 @@ - (void)messageReadNotification:(NSNotification *)notify { NSArray *readed = [notify.userInfo objectForKey:KEY_MESSAGE_ID_LIST]; - NSPredicate *predicate = [NSPredicate predicateWithFormat:@"self.message.n_id IN %@", readed]; - - NSArray *filtred = [self.messages filteredArrayUsingPredicate:predicate]; + [ASQueue dispatchOnMainQueue:^{ + [self.historyController items:readed complete:^(NSArray * filtred) { + + [filtred enumerateObjectsUsingBlock:^(TL_localMessage *obj, NSUInteger idx, BOOL * _Nonnull stop) { + + MessageTableItem *item = [self itemOfMsgId:obj.channelMsgId]; + + item.message.flags&= ~TGUNREADMESSAGE; + + NSUInteger index = [self indexOfObject:item]; + + if(index != NSNotFound) { + [self.table reloadDataForRowIndexes:[NSIndexSet indexSetWithIndex:index] columnIndexes:[NSIndexSet indexSetWithIndex:0]]; + } + + }]; + + + }]; + }]; - for (MessageTableItem *msg in filtred) { - msg.message.flags&= ~TGUNREADMESSAGE; - MessageTableCellContainerView *view = (MessageTableCellContainerView *)[self cellForRow:[self.messages indexOfObject:msg]]; - if([view isKindOfClass:[MessageTableCellContainerView class]]) { - [view checkActionState:YES]; - } - } } - (MessageTableCell *)cellForRow:(NSInteger)row { @@ -1555,6 +1601,7 @@ - (MessageTableCell *)cellForRow:(NSInteger)row { - (void)receivedMessage:(MessageTableItem *)message position:(int)position itsSelf:(BOOL)force { + NSArray *items; NSRange range = [self insertMessageTableItemsToList:@[message] startPosition:position needCheckLastMessage:YES backItems:&items checkActive:!force]; @@ -1598,13 +1645,23 @@ -(void)setIgnoredCount:(int)ignoredCount { [CATransaction commit]; } + +-(void)forceAddUnreadMark { + if(!_unreadMark) + { + _unreadMark = [[MessageTableItemUnreadMark alloc] initWithCount:0 type:RemoveUnreadMarkAfterSecondsType]; + } + + [self messagesLoadedTryToInsert:@[_unreadMark] pos:0 next:NO]; +} + - (void)insertAndGoToEnd:(NSRange)range forceEnd:(BOOL)forceEnd items:(NSArray *)items { // [CATransaction begin]; StandartViewController *controller = (StandartViewController *) [[Telegram leftViewController] currentTabController]; if([controller isKindOfClass:[StandartViewController class]] && controller.isSearchActive && forceEnd) { - [(StandartViewController *)controller searchByString:@""]; + [(StandartViewController *)controller hideSearchViewControllerWithConversationUsed:self.conversation]; } NSRect prevRect; @@ -1638,16 +1695,14 @@ - (void)insertAndGoToEnd:(NSRange)range forceEnd:(BOOL)forceEnd items:(NSArray * if(isScrollToEnd || forceEnd) { if(_historyController.prevState != ChatHistoryStateFull) { - [self jumpToLastMessages]; + [self jumpToLastMessages:YES]; return; } else { [self.table.scrollView scrollToEndWithAnimation:YES]; } } - - - MessageTypingView *typingCell = [self.table viewAtColumn:0 row:0 makeIfNecessary:NO]; + MessageTypingView *typingCell = [self.table viewAtColumn:0 row:0 makeIfNecessary:NO]; if([typingCell isKindOfClass:[MessageTypingView class]]) { @@ -1659,9 +1714,6 @@ - (void)insertAndGoToEnd:(NSRange)range forceEnd:(BOOL)forceEnd items:(NSArray * } } - - - __block BOOL addAnimation = YES; NSRange visibleRange = [self.table rowsInRect:self.table.visibleRect]; @@ -1772,6 +1824,8 @@ - (void)insertAndGoToEnd:(NSRange)range forceEnd:(BOOL)forceEnd items:(NSArray * - (void)receivedMessageList:(NSArray *)list inRange:(NSRange)range itsSelf:(BOOL)force { + + NSArray *items; NSRange r = [self insertMessageTableItemsToList:list startPosition:range.location needCheckLastMessage:YES backItems:&items checkActive:!force]; @@ -1784,52 +1838,120 @@ - (void)receivedMessageList:(NSArray *)list inRange:(NSRange)range itsSelf:(BOOL } - (void) deleteSelectedMessages { - NSMutableArray *array = [[NSMutableArray alloc] init]; - NSMutableArray *random = [[NSMutableArray alloc] init]; - for(MessageTableItem *item in self.selectedMessages) { - if(item.message.n_id && item.message.dstate == DeliveryStateNormal) { - [array addObject:@(item.message.n_id)]; + + if(![self canDeleteMessages]) + return; + + NSMutableDictionary *peers = [NSMutableDictionary dictionary]; + + [self.selectedMessages enumerateObjectsUsingBlock:^(MessageTableItem *item, NSUInteger idx, BOOL * _Nonnull stop) { + + NSMutableDictionary *data = peers[@(item.message.peer_id)]; + + if(!data) { + data = [NSMutableDictionary dictionary]; + peers[@(item.message.peer_id)] = data; + data[@"conversation"] = item.message.conversation; + data[@"ids"] = [NSMutableArray array]; + data[@"messages"] = [NSMutableArray array]; } - if([item.message isKindOfClass:[TL_destructMessage class]]) { - [random addObject:@(item.message.randomId)]; + if(item.message.dstate == DeliveryStateNormal) { + + if([item.message isChannelMessage]) + [data[@"ids"] addObject:@(item.message.channelMsgId)]; + else if([item.message isKindOfClass:[TL_destructMessage class]]) + [data[@"ids"] addObject:@(item.message.randomId)]; + else + [data[@"ids"] addObject:@(item.message.n_id)]; + + [data[@"messages"] addObject:item]; + } - } - - - id request = [TLAPI_messages_deleteMessages createWithN_id:array]; + + + }]; - dispatch_block_t completeBlock = ^ { - [[Storage manager] deleteMessages:array completeHandler:nil]; - [Notification perform:MESSAGE_DELETE_EVENT data:@{KEY_MESSAGE_ID_LIST:array}]; - [self unSelectAll]; - }; - if(self.conversation.type == DialogTypeSecretChat) { - - if(!self.conversation.canSendMessage) - { - completeBlock(); - return; - } + [peers enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, NSDictionary *obj, BOOL * _Nonnull stop) { + TL_conversation *conversation = obj[@"conversation"]; + NSMutableArray *array = obj[@"ids"]; + NSMutableArray *messages = obj[@"messages"]; - DeleteRandomMessagesSenderItem *sender = [[DeleteRandomMessagesSenderItem alloc] initWithConversation:self.conversation random_ids:random]; + id request = [TLAPI_messages_deleteMessages createWithN_id:array]; - [sender send]; + if(conversation.type == DialogTypeChannel) { + + + request = [TLAPI_channels_deleteMessages createWithChannel:[TL_inputChannel createWithChannel_id:conversation.peer.channel_id access_hash:conversation.chat.access_hash] n_id:array]; + + if(array.count > 0 && ![[(MessageTableItem *)messages[0] message] n_out] && [[(MessageTableItem *)messages[0] message] from_id] != 0) { + TGModalDeleteChannelMessagesView *modalDeleteView = [[TGModalDeleteChannelMessagesView alloc] initWithFrame:[[[NSApp delegate] mainWindow].contentView bounds]]; + + ComposeAction *action = [[ComposeAction alloc] initWithBehaviorClass:[ComposeActionDeleteChannelMessagesBehavior class] filter:@[] object:conversation.chat reservedObjects:@[array]]; + + action.result = [[ComposeResult alloc] initWithMultiObjects:@[@(YES),@(YES),@(NO),@(NO)]]; + + + action.result.singleObject = [[(MessageTableItem *)messages[0] message] fromUser]; + + [modalDeleteView showWithAction:action]; + + return; + + } + + + } - completeBlock(); + dispatch_block_t completeBlock = ^ { + + if(conversation.type != DialogTypeChannel) { + [[DialogsManager sharedManager] deleteMessagesWithMessageIds:array]; + } + + }; - } else { - [RPCRequest sendRequest:request successHandler:^(RPCRequest *request, id response) { + if(conversation.type == DialogTypeSecretChat) { - completeBlock(); + if(!conversation.canSendMessage) + { + completeBlock(); + return; + } + + + DeleteRandomMessagesSenderItem *sender = [[DeleteRandomMessagesSenderItem alloc] initWithConversation:self.conversation random_ids:array]; + + [sender send]; + + [[DialogsManager sharedManager] deleteMessagesWithRandomMessageIds:array isChannelMessages:NO]; - } errorHandler:^(RPCRequest *request, RpcError *error) { completeBlock(); - }]; - } + + } else { + [RPCRequest sendRequest:request successHandler:^(RPCRequest *request, id response) { + + if(conversation.type == DialogTypeChannel) + { + [[MTNetwork instance].updateService.proccessor addUpdate:[TL_updateDeleteChannelMessages createWithChannel_id:conversation.peer.channel_id messages:array pts:[response pts] pts_count:[response pts_count]]]; + } + + completeBlock(); + + + + } errorHandler:^(RPCRequest *request, RpcError *error) { + completeBlock(); + }]; + } + + }]; + + + [self unSelectAll]; } @@ -1847,24 +1969,35 @@ -(void)flushMessages { } -- (void)deleteMessages:(NSArray *)ids { +- (void)deleteItems:(NSArray *)messages orMessageIds:(NSArray *)ids { // [self.table beginUpdates]; if(self.messages.count > 0) { NSUInteger count = self.selectedMessages.count; - for (NSNumber *msg_id in ids) { - MessageTableItem *message = [self findMessageItemById:[msg_id intValue]]; + + [messages enumerateObjectsUsingBlock:^(TL_localMessage *obj, NSUInteger idx, BOOL * _Nonnull stop) { - if(message != nil) { - NSUInteger row = [self.messages indexOfObject:message]; + MessageTableItem *item = [self itemOfMsgId:obj.channelMsgId]; + + NSUInteger row = [self.messages indexOfObject:item]; + + if(row != NSNotFound) { [self.messages removeObjectAtIndex:row]; - [self.selectedMessages removeObject:message]; + [self.selectedMessages removeObject:item]; [self.table removeRowsAtIndexes:[NSIndexSet indexSetWithIndex:row] withAnimation:NSTableViewAnimationEffectFade]; - [message clean]; + [item clean]; } + + + }]; + + + if(_unreadMark && [self indexOfObject:_unreadMark] == 1) { + [self.messages removeObjectAtIndex:1]; + [self.table removeRowsAtIndexes:[NSIndexSet indexSetWithIndex:1] withAnimation:NSTableViewAnimationEffectFade]; } @@ -1887,7 +2020,7 @@ - (void)deleteMessages:(NSArray *)ids { if(count != self.selectedMessages.count) { if(self.selectedMessages.count) - [self.bottomView setSectedMessagesCount:self.selectedMessages.count]; + [self.bottomView setSectedMessagesCount:self.selectedMessages.count enable:[self canDeleteMessages]]; else [self.bottomView setStateBottom:MessagesBottomViewNormalState]; } @@ -1897,8 +2030,37 @@ - (void)deleteMessages:(NSArray *)ids { } -- (MessageTableItem *) findMessageItemById:(int)msgId { - NSPredicate *predicate = [NSPredicate predicateWithFormat:@"self.message.n_id == %d", msgId]; +-(BOOL)canDeleteMessages { + + NSMutableArray *msgs = [[NSMutableArray alloc] init]; + + [self.selectedMessages enumerateObjectsUsingBlock:^(MessageTableItem *obj, NSUInteger idx, BOOL *stop) { + [msgs addObject:obj.message]; + }]; + + return [MessagesViewController canDeleteMessages:msgs inConversation:self.conversation]; +} + ++(BOOL)canDeleteMessages:(NSArray *)messages inConversation:(TL_conversation *)conversation { + + __block BOOL accept = YES; + + [messages enumerateObjectsUsingBlock:^(TL_localMessage *obj, NSUInteger idx, BOOL *stop) { + + accept =obj.conversation.type == DialogTypeChannel ? ( obj.chat.isCreator || (obj.chat.isEditor && (obj.from_id != 0 || obj.n_out)) || (obj.chat.isModerator && obj.from_id != 0) || obj.n_out) : YES; + + if(!accept) { + *stop = YES; + } + + }]; + + return accept; + +} + +- (MessageTableItem *) findMessageItemById:(long)msgId { + NSPredicate *predicate = [NSPredicate predicateWithFormat:@"self.message.channelMsgId == %ld", msgId]; NSArray *filtred = [self.messages filteredArrayUsingPredicate:predicate]; @@ -1924,7 +2086,7 @@ - (void)setSelectedMessage:(MessageTableItem *)item selected:(BOOL)selected { [self.selectedMessages removeObject:item]; } - [self.bottomView setSectedMessagesCount:self.selectedMessages.count]; + [self.bottomView setSectedMessagesCount:self.selectedMessages.count enable:[self canDeleteMessages]]; } -(void)unSelectAll { @@ -1984,103 +2146,244 @@ - (void)saveInputText { { emoji = [self.bottomView.inputMessageString getEmojiFromString:YES]; - [self.stickerPanel showAndSearch:[emoji lastObject] animated:YES]; - } else - { - [self.stickerPanel hide:YES]; - } - - -} - -- (void)showMessage:(int)messageId fromMsgId:(int)msgId { - [self showMessage:messageId fromMsgId:msgId animated:YES selectText:nil]; -} - -- (void)showMessage:(int)messageId fromMsgId:(int)fromMsgId animated:(BOOL)animated selectText:(NSString *)text { - - MessageTableItem *item = [self itemOfMsgId:messageId]; - - if(fromMsgId != 0) - [_replyMsgsStack addObject:@(fromMsgId)]; + [self.stickerPanel showAndSearch:[emoji lastObject] animated:YES]; + } else + { + [self.stickerPanel hide:YES]; + } + + +} + +- (void)showMessage:(TL_localMessage *)message fromMsg:(TL_localMessage *)fromMsg flags:(int)flags { + [self showMessage:message fromMsg:fromMsg animated:YES selectText:nil switchDiscussion:NO flags:flags]; +} + +- (void)showMessage:(TL_localMessage *)message fromMsg:(TL_localMessage *)fromMsg switchDiscussion:(BOOL)switchDiscussion { + [self showMessage:message fromMsg:fromMsg animated:YES selectText:nil switchDiscussion:switchDiscussion flags:0]; +} + +- (void)showMessage:(TL_localMessage *)message fromMsg:(TL_localMessage *)fromMsg animated:(BOOL)animated selectText:(NSString *)text switchDiscussion:(BOOL)switchDiscussion flags:(int)flags { + + _needNextRequest = YES; + + + if(fromMsg != nil) + [_replyMsgsStack addObject:fromMsg]; + + MessageTableItem *item = message.hole != nil ? [self itemOfMsgId:channelMsgId(message.hole.min_id, message.peer_id)] : [self itemOfMsgId:message.channelMsgId]; + + if(item && (flags & ShowMessageTypeReply) > 0) { + [self scrollToItem:item animated:YES centered:YES highlight:YES]; + + return; + } + + TL_conversation *conversation = self.conversation; + + __block TL_localMessage *msg = conversation.type == DialogTypeChannel && fromMsg == nil && ((flags & ShowMessageTypeUnreadMark) == 0 && (flags & ShowMessageTypeSearch) == 0) ? [[Storage manager] lastImportantMessageAroundMinId: message.hole ? channelMsgId(message.hole.min_id, message.peer_id) : message.channelMsgId] : [[Storage manager] messageById:message.hole ? message.hole.min_id : message.n_id inChannel:-message.to_id.channel_id]; + + if((flags & ShowMessageTypeUnreadMark) > 0 && conversation.type == DialogTypeChannel && !msg) { + [self flushMessages]; + } + + + dispatch_block_t block = ^{ + + if(conversation != self.conversation || !msg) { + _needNextRequest = NO; + return; + } + + if(switchDiscussion) + [self.normalNavigationCenterView enableDiscussion:!self.normalNavigationCenterView.discussIsEnabled force:YES]; + + + self.historyController = [[[self hControllerClass] alloc] initWithController:self historyFilter:conversation.type == DialogTypeChannel ? ( flags == 0 ? self.normalNavigationCenterView.discussIsEnabled || conversation.chat.isMegagroup ? [ChannelFilter class] : [ChannelImportantFilter class] : msg.isImportantMessage ? self.historyController.filter.class : [ChannelFilter class]) : [HistoryFilter class]]; + + [self.normalNavigationCenterView enableDiscussion:[self.historyController.filter isKindOfClass:[ChannelFilter class]] force:YES]; + + + NSUInteger index = [self indexOfObject:[self itemOfMsgId:msg.channelMsgId]]; + + __block NSRect rect = NSZeroRect; + + int yTopOffset = 0; + + if(index != NSNotFound) { + rect = [self.table rectOfRow:index]; + + yTopOffset = self.table.scrollView.documentOffset.y + NSHeight(self.table.containerView.frame) - (rect.origin.y); + + } + + [self removeScrollEvent]; + + + if((flags & ShowMessageTypeUnreadMark) > 0 && msg.isChannelMessage ) { + [self flushMessages]; + } + + + int count = NSHeight(self.table.containerView.frame)/20; + + self.historyController.selectLimit = count/2 + 20; + + [self.historyController loadAroundMessagesWithMessage:msg prevLimit:count nextLimit:(flags & ShowMessageTypeUnreadMark) > 0 ? 1 : count selectHandler:^(NSArray *result, NSRange range, id controller) { + + if(controller == self.historyController && _conversation.peer_id == conversation.peer_id) { + [self flushMessages]; + + _needNextRequest = NO; + + + NSUInteger index = [result indexOfObjectPassingTest:^BOOL(MessageTableItem *obj, NSUInteger idx, BOOL * _Nonnull stop) { + + BOOL res = obj.message.channelMsgId == msg.channelMsgId; + + *stop = res; + + return res; + }]; + + MessageTableItem *item = result[index]; + + if((flags & ShowMessageTypeUnreadMark) > 0) { + + if(index != 0 && index != NSNotFound) { + _unreadMark = [[MessageTableItemUnreadMark alloc] initWithCount:0 type:RemoveUnreadMarkAfterSecondsType]; + + NSMutableArray *copy = [result mutableCopy]; + [copy insertObject:_unreadMark atIndex:index]; + + result = copy; + } + + } + + [self messagesLoadedTryToInsert:result pos:range.location next:YES]; + + + + [self.table setNeedsDisplay:YES]; + [self.table display]; + + if((flags & ShowMessageTypeUnreadMark) > 0) { + + [self scrollToUnreadItem:NO]; + + } else if(rect.origin.y == 0 || ((flags & ShowMessageTypeReply) > 0 || (flags & ShowMessageTypeSearch) > 0)) { + [self scrollToItem:item animated:NO centered:YES highlight:fromMsg != nil]; + } else { + + __block NSRect drect = [self.table rectOfRow:[self indexOfObject:item]]; + + + dispatch_block_t block = ^{ + + drect.origin.y -= (NSHeight(self.table.containerView.frame) -yTopOffset); + + drect.origin.y = MAX(0,drect.origin.y); + + [self.table.scrollView scrollToPoint:drect.origin animation:NO]; + + }; + + if(NSEqualRects(drect, NSZeroRect)) { + + dispatch_async(dispatch_get_main_queue(), block); + } else { + block(); + } + + + } + + if(index < 10) { + [self requestNextHistory]; + } + + [self addScrollEvent]; + } + + }]; + + }; - if(item) - { - [self scrollToItem:item animated:animated centered:YES highlight:YES]; - } else { + if(!msg) { + _needNextRequest = YES; + + [self flushMessages]; - dispatch_block_t block = ^{ - - - - [self.historyController drop:NO]; - - self.historyController = [[ChatHistoryController alloc] initWithController:self historyFilter:[HistoryFilter class]]; - - self.historyController.min_id = messageId; - self.historyController.start_min = messageId; - self.historyController.max_id = messageId; - self.historyController.need_save_to_db = NO; - self.historyController.maxDate = 0; - self.historyController.minDate = 0; - [self.historyController removeAllItems]; - - - [self flushMessages]; - - [self loadhistory:messageId toEnd:YES prev:messageId != 0 isFirst:YES]; - }; - TL_localMessage *msg = [[Storage manager] messageById:messageId]; + id request = [TLAPI_messages_getMessages createWithN_id:[@[@(message.n_id)] mutableCopy]]; + + if(self.conversation.type == DialogTypeChannel) { + request = [TLAPI_channels_getMessages createWithChannel:message.conversation.inputPeer n_id:[@[@(message.hole ? message.hole.min_id : message.n_id)] mutableCopy]]; + } - if(!msg) { + [RPCRequest sendRequest:request successHandler:^(RPCRequest *request, TL_messages_messages * response) { - [RPCRequest sendRequest:[TLAPI_messages_getMessages createWithN_id:[@[@(messageId)] mutableCopy]] successHandler:^(RPCRequest *request, TL_messages_messages * response) { + _needNextRequest = NO; + + if(response.messages.count > 0 && ![response.messages[0] isKindOfClass:[TL_messageEmpty class]]) { + msg = [TL_localMessage convertReceivedMessage:response.messages[0]]; - if(response.messages.count > 0) { - TLMessage *msg = response.messages[0]; - - if(![msg isKindOfClass:[TL_messageEmpty class]]) { - block(); + [response.messages removeAllObjects]; + [SharedManager proccessGlobalResponse:response]; + + if(![msg isKindOfClass:[TL_messageEmpty class]]) { + block(); + } else { + if((flags & ShowMessageTypeUnreadMark)) { + [self jumpToLastMessages:YES]; } } - - - - - } errorHandler:^(RPCRequest *request, RpcError *error) { - - - } timeout:10]; + } + } errorHandler:^(RPCRequest *request, RpcError *error) { - } else { - block(); - } - + [self jumpToLastMessages:YES]; + + } timeout:10]; - - + } else { + block(); } } -- (void)setCurrentConversation:(TL_conversation *)dialog withJump:(int)messageId historyFilter:(Class)historyFilter force:(BOOL)force { + +-(void)selectInputTextByText:(NSString *)text { + [self.bottomView selectInputTextByText:text]; +} + +- (void)setCurrentConversation:(TL_conversation *)dialog withMessageJump:(TL_localMessage *)message force:(BOOL)force { + + [self loadViewIfNeeded]; + [self hideSearchBox:NO]; + + if(![globalAudioPlayer().delegate isKindOfClass:[TGAudioPlayerWindow class]]) { + [globalAudioPlayer() stop]; + [globalAudioPlayer().delegate audioPlayerDidFinishPlaying:globalAudioPlayer()]; + } + + + if(!self.locked && (((message != nil && message.channelMsgId != _jumpMessage.channelMsgId) || force) || [self.conversation.peer peer_id] != [dialog.peer peer_id] )) { + + self.jumpMessage = message; + self.conversation = dialog; - if(!self.locked && (((messageId != 0 && messageId != self.jumpMessageId) || force) || [self.conversation.peer peer_id] != [dialog.peer peer_id] || self.historyController.filter.class != historyFilter)) { + [Notification perform:@"ChangeDialogSelection" data:@{KEY_DIALOG:self.conversation, @"sender":self}]; - [TGHelpPopup popover].fadeDuration = 0; - [TGHelpPopup close]; + [self.normalNavigationCenterView enableDiscussion:NO force:NO]; [_replyMsgsStack removeAllObjects]; - self.jumpMessageId = messageId; - self.conversation = dialog; - NSString *cachedText = [self.cacheTextForPeer objectForKey:dialog.cacheKey]; [self becomeFirstResponder]; @@ -2097,38 +2400,16 @@ - (void)setCurrentConversation:(TL_conversation *)dialog withJump:(int)messageId [self.typingView setDialog:dialog]; - - if(!historyFilter) - historyFilter = [HistoryFilter class]; - [self.historyController drop:NO]; - self.historyController = [[ChatHistoryController alloc] initWithController:self historyFilter:historyFilter]; - - - - if(messageId != 0) { - self.historyController.min_id = messageId; - self.historyController.start_min = messageId; - self.historyController.max_id = messageId; - self.historyController.need_save_to_db = NO; - self.historyController.maxDate = 0; - self.historyController.minDate = 0; - [self.historyController removeAllItems]; - } - - if(dialog.top_message != dialog.last_marked_message) { - [self.historyController removeAllItems]; - } - - - [self.normalNavigationCenterView setDialog:dialog]; [self.bottomView setDialog:dialog]; + self.historyController = [[[self hControllerClass] alloc] initWithController:self historyFilter:[self defHFClass]]; + self.state = MessagesViewControllerStateNone; @@ -2136,53 +2417,75 @@ - (void)setCurrentConversation:(TL_conversation *)dialog withJump:(int)messageId [self unSelectAll:NO]; - - [self.typingReservation removeAllObjects]; [self removeScrollEvent]; - [self flushMessages]; + + + if(message != nil) { + [self showMessage:message fromMsg:nil flags:ShowMessageTypeSearch]; + } else if(dialog.last_marked_message != -1 && dialog.last_marked_message < dialog.universalTopMessage && dialog.universalTopMessage < TGMINFAKEID) { + + TL_localMessage *msg = [[TL_localMessage alloc] init]; + + msg.n_id = dialog.last_marked_message; + msg.to_id = dialog.peer; + + [self showMessage:msg fromMsg:nil flags:ShowMessageTypeUnreadMark]; + + } else { + + + [self flushMessages]; + + [self loadhistory:0 toEnd:YES prev:NO isFirst:YES]; + } - [self loadhistory:messageId toEnd:YES prev:messageId != 0 isFirst:YES]; [self addScrollEvent]; + if(self.conversation.type == DialogTypeChannel) { + [self.historyController startChannelPolling]; + + } } } --(void)setCurrentConversation:(TL_conversation *)dialog withJump:(int)messageId historyFilter:(__unsafe_unretained Class)historyFilter { +-(void)setCurrentConversation:(TL_conversation *)dialog withMessageJump:(TL_localMessage *)message { - [self setCurrentConversation:dialog withJump:messageId historyFilter:historyFilter force:NO]; + [self setCurrentConversation:dialog withMessageJump:message force:NO]; } -(void)setCurrentConversation:(TL_conversation *)dialog { - [self setCurrentConversation:dialog withJump:0 historyFilter:[HistoryFilter class]]; + [self setCurrentConversation:dialog withMessageJump:nil]; } - (void)cancelSelectionAndScrollToBottom { - [self unSelectAll]; + [self unSelectAll:NO]; self.state = MessagesViewControllerStateNone; [self.table.scrollView scrollToEndWithAnimation:YES]; } - (void)tryRead { - if(!self.view.isHidden && self.view.window.isKeyWindow && self.historyController.filter.class == HistoryFilter.class && ![TGPasslock isVisibility]) { + if(!self.view.isHidden && self.view.window.isKeyWindow && ![TGPasslock isVisibility]) { if(_delayedBlockHandle) _delayedBlockHandle(YES); - if(self.conversation.last_marked_message != self.conversation.top_message) { - self.conversation.last_marked_message = self.conversation.top_message; - self.conversation.last_marked_date = [[MTNetwork instance] getTime]; - [self.conversation save]; - } - + [ASQueue dispatchOnStageQueue:^{ + if(self.conversation.last_marked_message != self.conversation.top_message) { + self.conversation.last_marked_message = self.conversation.top_message; + self.conversation.last_marked_date = [[MTNetwork instance] getTime]; + [self.conversation save]; + } + }]; + _delayedBlockHandle = perform_block_after_delay(0.2f, ^{ _delayedBlockHandle = nil; - if(self.conversation.unread_count > 0 || self.conversation.peer.user_id == [UsersManager currentUserId]) { + if(self.conversation.unread_count > 0 || (self.conversation.unread_important_count > 0) || self.conversation.peer.user_id == [UsersManager currentUserId]) { [self readHistory:0]; } }); @@ -2192,24 +2495,24 @@ - (void)tryRead { - (void)readHistory:(int)offset{ - if(!self.conversation || self.conversation.unread_count == 0) + if(!self.conversation || (self.conversation.unread_count == 0 && self.conversation.unread_important_count == 0) || (self.conversation.type != DialogTypeSecretChat && (self.conversation.chat.isKicked || self.conversation.chat.left))) return; - [(MessagesManager *)[MessagesManager sharedManager] markAllInDialog:self.conversation callback:^(NSArray *ids) { - if(ids.count > 0) { - [Notification perform:MESSAGE_READ_EVENT data:@{KEY_MESSAGE_ID_LIST:ids}]; - } - }]; + [[DialogsManager sharedManager] markAllMessagesAsRead:self.conversation]; self.conversation.unread_count = 0; + self.conversation.unread_important_count = 0; + _conversation.read_inbox_max_id = self.conversation.type == DialogTypeChannel ? self.conversation.top_important_message : self.conversation.top_message; [self.conversation save]; + [Notification perform:[Notification notificationNameByDialog:self.conversation action:@"unread_count"] data:@{KEY_LAST_CONVRESATION_DATA:[MessagesUtils conversationLastData:self.conversation],KEY_DIALOG:self.conversation}]; + [MessagesManager updateUnreadBadge]; - ReadHistroryTask *task = [[ReadHistroryTask alloc] initWithParams:@{@"peer":self.conversation.peer}]; + ReadHistroryTask *task = [[ReadHistroryTask alloc] initWithParams:@{@"conversation":self.conversation}]; [TMTaskRequest addTask:task]; @@ -2263,7 +2566,7 @@ - (void)messagesLoadedTryToInsert:(NSArray *) array pos:(NSUInteger)pos next:(BO [[FullUsersManager sharedManager] loadUserFull:_conversation.user callback:^(TL_userFull *userFull) { if(userFull.bot_info.n_description.length > 0) { - TL_localMessageService *service = [TL_localMessageService createWithN_id:0 flags:0 from_id:0 to_id:_conversation.peer date:0 action:[TL_messageActionBotDescription createWithTitle:userFull.bot_info.n_description] fakeId:0 randomId:rand_long() dstate:DeliveryStateNormal]; + TL_localMessageService *service = [TL_localMessageService createWithFlags:0 n_id:0 from_id:0 to_id:_conversation.peer date:0 action:[TL_messageActionBotDescription createWithTitle:userFull.bot_info.n_description] fakeId:0 randomId:rand_long() dstate:DeliveryStateNormal]; NSArray *items; @@ -2285,6 +2588,13 @@ - (void)messagesLoadedTryToInsert:(NSArray *) array pos:(NSUInteger)pos next:(BO - (void)didUpdateTable { [self showNoMessages:self.messages.count == 1 || (self.conversation.user.isBot && self.messages.count == 2 && [self.messages[1] isKindOfClass:[MessageTableItemServiceMessage class]])]; + + if(self.conversation.user.isBot && (self.messages.count == 1 || (self.messages.count == 2 && [self.messages[1] isKindOfClass:[MessageTableItemServiceMessage class]]))) { + [self showBotStartButton:@"start" bot:self.conversation.user]; + } else if(self.conversation.user.isBot) { + [self.bottomView setStateBottom:MessagesBottomViewNormalState]; + } + BOOL isHaveMessages = NO; for(MessageTableItem *item in self.messages) { if(item.message && !item.message.action) { @@ -2301,152 +2611,83 @@ - (void)didUpdateTable { [self updateScrollBtn]; + [self.table setNeedsDisplay:YES]; + [self.table display]; + + + if(self.conversation.type == DialogTypeUser && (self.conversation.user.type == TLUserTypeRequest)) { + + __block BOOL showReport = [[NSUserDefaults standardUserDefaults] boolForKey:[NSString stringWithFormat:@"showreport_%d",self.conversation.user.n_id]]; + + __block BOOL alwaysShowReport = [[NSUserDefaults standardUserDefaults] boolForKey:[NSString stringWithFormat:@"always_showreport1_%d",self.conversation.user.n_id]]; + + if(self.messages.count > 1 && (!showReport && !alwaysShowReport)) { + if(self.messages.count > 2 || self.historyController.nextState == ChatHistoryStateFull) { + + showReport = YES; + + [self.messages enumerateObjectsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(1, self.messages.count - 1)] options:0 usingBlock:^(MessageTableItem* _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + + if(obj.message.n_out) { + showReport = NO; + *stop = YES; + } + + }]; + + alwaysShowReport = showReport; + + [[NSUserDefaults standardUserDefaults] setBool:showReport forKey:[NSString stringWithFormat:@"showreport_%d",self.conversation.user.n_id]]; + } + } + + if(showReport) { + [_topInfoView setConversation:self.conversation]; + } + + } + } - +-(void)requestNextHistory { + [self loadhistory:0 toEnd:NO prev:NO isFirst:NO]; +} - (void)loadhistory:(int)message_id toEnd:(BOOL)toEnd prev:(BOOL)prev isFirst:(BOOL)isFirst { - if(!self.conversation || self.historyController.isProccessing || _locked) + if(!self.conversation || _locked) return; - prev = prev || (isFirst && _historyController.conversation.top_message != _historyController.conversation.last_marked_message && _historyController.conversation.last_marked_message != 0 && _historyController.conversation.unread_count > 0); - - if(!prev && isFirst) { - _historyController.prevState = ChatHistoryStateFull; - } - + NSSize size = self.table.scrollView.documentSize; int count = size.height/20; self.historyController.selectLimit = isFirst ? count : 50; - + [self removeScrollEvent]; _needNextRequest = NO; - [self.historyController request:!prev anotherSource:YES sync:isFirst selectHandler:^(NSArray *prevResult, NSRange range) { - - if(prevResult.count > 0) { - MessageTableItem *item = prevResult[0]; - if(self.conversation.peer_id != item.message.peer_id) - return; - } - - - // assert(prevResult.count > 0); - - if(message_id != 0 && prev && self.historyController.prevState == ChatHistoryStateRemote) { - self.historyController.nextState = self.historyController.prevState; - } + + + [self.historyController request:!prev anotherSource:YES sync:isFirst selectHandler:^(NSArray *prevResult, NSRange range1, id controller) { + NSUInteger pos = prev ? 0 : self.messages.count; - NSUInteger pos = prev ? 0 : self.messages.count; - if(isFirst && prev) { - - _needNextRequest = YES; - - [_historyController request:YES anotherSource:YES sync:isFirst selectHandler:^(NSArray *result, NSRange range) { - - _needNextRequest = NO; - - self.isMarkIsset = YES; - - [self updateScrollBtn]; - - self.unreadMark = [[MessageTableItemUnreadMark alloc] initWithCount:_historyController.conversation.unread_count type:RemoveUnreadMarkAfterSecondsType]; - - - NSArray *completeResult = message_id == 0 && self.historyController.filter.class == HistoryFilter.class && prevResult.count > 0 ? [prevResult arrayByAddingObject:self.unreadMark] : prevResult; - - NSArray *nextResult = [completeResult arrayByAddingObjectsFromArray:result]; - - - [self messagesLoadedTryToInsert:nextResult pos:0 next:NO]; - - - id item = message_id == 0 ? self.unreadMark : [self findMessageItemById:message_id]; - - NSUInteger index = [self indexOfObject:item]; - NSRect rect = [self.table rectOfRow:index]; - - [self scrollToRect:rect isCenter:message_id != 0 animated:NO]; - //bug fix - - - - if([item isKindOfClass:[MessageTableItemText class]] && [self searchBoxIsVisible]) { - MessageTableItemText *textItem = item; - - [self.searchItems enumerateObjectsUsingBlock:^(SearchSelectItem *obj, NSUInteger idx, BOOL *stop) { - - [obj clear]; - - }]; - - NSRange range = [textItem.message.message rangeOfString:self.searchMessagesView.currentString options:NSCaseInsensitiveSearch]; - - if(range.location != NSNotFound) - { - SearchSelectItem *searchItem = [[SearchSelectItem alloc] init]; - searchItem.item = textItem; - - searchItem.isCurrent = YES; - - [searchItem.marks addObject:[[TGCTextMark alloc] initWithRange:range color:NSColorFromRGBWithAlpha(0xe5bf29, 0.3) isReal:NO]]; - - [textItem setMark:searchItem]; - - [self.searchItems addObject:searchItem]; - - } - - - } - - dispatch_async(dispatch_get_main_queue(), ^{ - NSUInteger idx = [self indexOfObject:item]; - if(message_id && idx != NSNotFound) { - MessageTableCellContainerView *cell = (MessageTableCellContainerView *)[self cellForRow:idx]; - - if(cell && [cell isKindOfClass:[MessageTableCellContainerView class]]) { - - for(int i = 0; i < self.messages.count; i++) { - MessageTableCellContainerView *cell2 = (MessageTableCellContainerView *)[self cellForRow:i]; - if(cell2 && [cell2 isKindOfClass:[MessageTableCellContainerView class]]) { - [cell2 stopSearchSelection]; - } - } - - [cell searchSelection]; - - if([item isKindOfClass:[MessageTableItemText class]] && [(MessageTableItemText *)item mark] != nil) { - [cell setItem:item]; - } - } - } - }); - - - if(result.count < _historyController.selectLimit) - [self loadhistory:0 toEnd:YES prev:NO isFirst:NO]; - - - - }]; - - } else { + if(self.historyController == controller) { [self messagesLoadedTryToInsert:prevResult pos:pos next:!prev]; if(self.didUpdatedTable) { self.didUpdatedTable(); } - if(prevResult.count < _historyController.selectLimit) { - [self loadhistory:0 toEnd:YES prev:NO isFirst:NO]; + if(prevResult.count+1 < 10 && prevResult.count > 0) { + [self loadhistory:0 toEnd:YES prev:prev isFirst:NO]; } + + [self addScrollEvent]; } - + }]; } @@ -2464,6 +2705,9 @@ -(void)scrollToRect:(NSRect)rect isCenter:(BOOL)isCenter animated:(BOOL)animated [self.table.scrollView scrollToPoint:rect.origin animation:animated]; + + [self updateScrollBtn]; + } @@ -2490,9 +2734,6 @@ - (void)scrollToItem:(MessageTableItem *)item animated:(BOOL)animated centered:( rect.origin.y -= roundf((self.table.containerView.frame.size.height - rect.size.height) / 2) ; else rect.origin.y += roundf((self.table.containerView.frame.size.height - rect.size.height) / 2) ; - // - // if(rect.origin.y < 0) - // rect.origin.y = 0; [self.table.scrollView.clipView scrollRectToVisible:rect animated:animated completion:^(BOOL scrolled) { if(highlight) { @@ -2533,7 +2774,7 @@ - (NSArray *)messageTableItemsFromMessages:(NSArray *)input{ if(item) { //[item makeSizeByWidth:self.table.containerSize.width]; item.isSelected = NO; - [array insertObject:item atIndex:0]; + [array addObject:item]; } } return array; @@ -2551,7 +2792,8 @@ - (NSRange)insertMessageTableItemsToList:(NSArray *)array startPosition:(NSInteg if(!self.unreadMark) { _unreadMark = [[MessageTableItemUnreadMark alloc] initWithCount:0 type:RemoveUnreadMarkNoneType]; - array = [array arrayByAddingObjectsFromArray:@[_unreadMark]]; + if(array.count > 0) + array = [array arrayByAddingObjectsFromArray:@[_unreadMark]]; } } @@ -2580,9 +2822,14 @@ - (NSRange)insertMessageTableItemsToList:(NSArray *)array startPosition:(NSInteg NSMutableIndexSet *rld = [[NSMutableIndexSet alloc] init]; + + [self.messages enumerateObjectsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:range] options:NSEnumerationReverse usingBlock:^(MessageTableItem *current, NSUInteger idx, BOOL *stop) { + [current setTable:_table]; + [backItem setTable:_table]; + BOOL isCHdr = current.isHeaderMessage; BOOL isCFwdHdr = current.isHeaderForwardedMessage; @@ -2607,8 +2854,8 @@ - (NSRange)insertMessageTableItemsToList:(NSArray *)array startPosition:(NSInteg } - [current makeSizeByWidth:MAX(NSWidth([Telegram rightViewController].view.frame) - 150,100)]; - [backItem makeSizeByWidth:MAX(NSWidth([Telegram rightViewController].view.frame) - 150,100)]; + [current makeSizeByWidth:current.makeSize]; + [backItem makeSizeByWidth:backItem.makeSize]; backItem = current; }]; @@ -2648,6 +2895,10 @@ - (void)isHeaderMessage:(MessageTableItem *)item prevItem:(MessageTableItem *)pr item.isHeaderMessage = YES; item.isHeaderForwardedMessage = YES; + if(item.message.isChannelMessage && item.message.from_id == 0) { + return; + } + if(prevItem.message && item.message && ![item isReplyMessage] && (!item.message.media.webpage || [item.message.media.webpage isKindOfClass:[TL_webPageEmpty class]])) { if(!prevItem.message.action && !item.message.action) { if(prevItem.message.from_id == item.message.from_id && ABS(prevItem.message.date - item.message.date) < HEADER_MESSAGES_GROUPING_TIME) { @@ -2700,9 +2951,10 @@ - (void)resendItem:(MessageTableItem *)item { [self.messages insertObject:item atIndex:nRow]; - [self isHeaderMessage:item prevItem:[self.messages objectAtIndex:nRow+1]]; + [self isHeaderMessage:item prevItem:[self.messages objectAtIndex:MIN(self.messages.count-1,nRow+1)]]; - [self.table moveRowAtIndex:row toIndex:nRow]; + if(row != nRow) + [self.table moveRowAtIndex:row toIndex:nRow]; [self.table noteHeightOfRowsWithIndexesChanged:set]; @@ -2736,17 +2988,35 @@ - (MessageTableItem *)lastMessageItem { return nil; } +-(void)setConversation:(TL_conversation *)conversation { + _conversation = conversation; +} - (void)sendMessage { NSString *message = [self.bottomView.inputMessageString trim]; - if([message isEqualToString:@"performcrash"]) { - [ASQueue dispatchOnStageQueue:^{ - [(TMView *)self.conversation becomeFirstResponder]; - }]; + + NSCharacterSet *set = [NSCharacterSet whitespaceCharacterSet]; + if ([[message stringByTrimmingCharactersInSet: set] length] == 0) { + return; + } else if([message stringByReplacingOccurrencesOfString:@"\n" withString:@""].length == 0) { + return; + } + + +#ifdef TGDEBUG + if([message isEqualToString:@"send100messages"]) { + + TL_conversation *conversation = _conversation; + for (int i = 1; i <= 100; i++) { + [self sendMessage:[NSString stringWithFormat:@"messageId:%d",i] forConversation:conversation]; + } + return; } +#endif + if(!self.conversation.canSendMessage) { NSBeep(); return; @@ -2776,7 +3046,7 @@ - (void)sendMessage:(NSString *)message forConversation:(TL_conversation *)conve BOOL noWebpage = [self noWebpage:message]; - [self setHistoryFilter:HistoryFilter.class force:self.historyController.prevState != ChatHistoryStateFull]; + [self setHistoryFilter:self.defHFClass force:self.historyController.prevState != ChatHistoryStateFull]; if([SettingsArchiver checkMaskedSetting:EmojiReplaces]) @@ -2800,7 +3070,7 @@ - (void)sendMessage:(NSString *)message forConversation:(TL_conversation *)conve NSMutableArray *preparedItems = [[NSMutableArray alloc] init]; if (message.length <= messagePartLimit) { - MessageSenderItem *sender = [[cs alloc] initWithMessage:message forConversation:conversation noWebpage:noWebpage]; + MessageSenderItem *sender = [[cs alloc] initWithMessage:message forConversation:conversation noWebpage:noWebpage additionFlags:self.senderFlags]; sender.tableItem = [[self messageTableItemsFromMessages:@[sender.message]] lastObject]; [self.historyController addItem:sender.tableItem conversation:conversation callback:callback sentControllerCallback:nil]; @@ -2813,7 +3083,7 @@ - (void)sendMessage:(NSString *)message forConversation:(TL_conversation *)conve NSString *substring = [message substringWithRange:NSMakeRange(i, MIN(messagePartLimit, message.length - i))]; if (substring.length != 0) { - MessageSenderItem *sender = [[cs alloc] initWithMessage:substring forConversation:conversation noWebpage:noWebpage]; + MessageSenderItem *sender = [[cs alloc] initWithMessage:substring forConversation:conversation noWebpage:noWebpage additionFlags:self.senderFlags]; sender.tableItem = [[self messageTableItemsFromMessages:@[sender.message]] lastObject]; [preparedItems insertObject:sender.tableItem atIndex:0]; @@ -2831,17 +3101,18 @@ - (void)sendMessage:(NSString *)message forConversation:(TL_conversation *)conve }]; } + - (void)sendLocation:(CLLocationCoordinate2D)coordinates forConversation:(TL_conversation *)conversation { if(!conversation.canSendMessage) return; - [self setHistoryFilter:HistoryFilter.class force:self.historyController.prevState != ChatHistoryStateFull]; + [self setHistoryFilter:self.defHFClass force:self.historyController.prevState != ChatHistoryStateFull]; [ASQueue dispatchOnStageQueue:^{ Class cs = self.conversation.type == DialogTypeSecretChat ? [LocationSenderItem class] : [LocationSenderItem class]; - LocationSenderItem *sender = [[cs alloc] initWithCoordinates:coordinates conversation:conversation]; + LocationSenderItem *sender = [[cs alloc] initWithCoordinates:coordinates conversation:conversation additionFlags:self.senderFlags]; sender.tableItem = [[self messageTableItemsFromMessages:@[sender.message]] lastObject]; [self.historyController addItem:sender.tableItem]; @@ -2856,7 +3127,7 @@ - (void)sendVideo:(NSString *)file_path forConversation:(TL_conversation *)conve -(void)sendVideo:(NSString *)file_path forConversation:(TL_conversation *)conversation addCompletionHandler:(dispatch_block_t)completeHandler { if(!conversation.canSendMessage) return; - [self setHistoryFilter:HistoryFilter.class force:self.historyController.prevState != ChatHistoryStateFull]; + [self setHistoryFilter:self.defHFClass force:self.historyController.prevState != ChatHistoryStateFull]; [ASQueue dispatchOnStageQueue:^{ SenderItem *sender; @@ -2869,7 +3140,7 @@ -(void)sendVideo:(NSString *)file_path forConversation:(TL_conversation *)conver if(self.conversation.type == DialogTypeSecretChat) { sender = [[FileSecretSenderItem alloc] initWithPath:file_path uploadType:UploadVideoType forConversation:conversation]; } else { - sender = [[VideoSenderItem alloc] initWithPath:file_path forConversation:conversation]; + sender = [[VideoSenderItem alloc] initWithPath:file_path forConversation:conversation additionFlags:self.senderFlags]; } sender.tableItem = [[self messageTableItemsFromMessages:@[sender.message]] lastObject]; [self.historyController addItem:sender.tableItem sentControllerCallback:completeHandler]; @@ -2884,7 +3155,7 @@ - (void)sendDocument:(NSString *)file_path forConversation:(TL_conversation *)co - (void)sendDocument:(NSString *)file_path forConversation:(TL_conversation *)conversation addCompletionHandler:(dispatch_block_t)completeHandler { if(!conversation.canSendMessage) return; - [self setHistoryFilter:HistoryFilter.class force:self.historyController.prevState != ChatHistoryStateFull]; + [self setHistoryFilter:self.defHFClass force:self.historyController.prevState != ChatHistoryStateFull]; [ASQueue dispatchOnStageQueue:^{ @@ -2897,7 +3168,7 @@ - (void)sendDocument:(NSString *)file_path forConversation:(TL_conversation *)co if(self.conversation.type == DialogTypeSecretChat) { sender = [[FileSecretSenderItem alloc] initWithPath:file_path uploadType:UploadDocumentType forConversation:conversation]; } else { - sender = [[DocumentSenderItem alloc] initWithPath:file_path forConversation:conversation]; + sender = [[DocumentSenderItem alloc] initWithPath:file_path forConversation:conversation additionFlags:self.senderFlags]; } sender.tableItem = [[self messageTableItemsFromMessages:@[sender.message]] lastObject]; @@ -2927,21 +3198,18 @@ -(void)sendSticker:(TLDocument *)sticker forConversation:(TL_conversation *)conv }]; - [self setHistoryFilter:HistoryFilter.class force:self.historyController.prevState != ChatHistoryStateFull]; + [self setHistoryFilter:self.defHFClass force:self.historyController.prevState != ChatHistoryStateFull]; [self.bottomView closeEmoji]; - - - [ASQueue dispatchOnStageQueue:^{ SenderItem *sender; if(self.conversation.type != DialogTypeSecretChat) { - sender = [[StickerSenderItem alloc] initWithDocument:sticker forConversation:conversation]; + sender = [[StickerSenderItem alloc] initWithDocument:sticker forConversation:conversation additionFlags:self.senderFlags]; } else { sender = [[ExternalDocumentSecretSenderItem alloc] initWithConversation:conversation document:sticker]; } @@ -2959,7 +3227,7 @@ - (void)sendAudio:(NSString *)file_path forConversation:(TL_conversation *)conve if(!conversation.canSendMessage) return; - [self setHistoryFilter:HistoryFilter.class force:self.historyController.prevState != ChatHistoryStateFull]; + [self setHistoryFilter:self.defHFClass force:self.historyController.prevState != ChatHistoryStateFull]; [ASQueue dispatchOnStageQueue:^{ @@ -2972,7 +3240,7 @@ - (void)sendAudio:(NSString *)file_path forConversation:(TL_conversation *)conve if(self.conversation.type == DialogTypeSecretChat) { sender = [[FileSecretSenderItem alloc] initWithPath:file_path uploadType:UploadAudioType forConversation:conversation]; } else { - sender = [[AudioSenderItem alloc] initWithPath:file_path forConversation:conversation]; + sender = [[AudioSenderItem alloc] initWithPath:file_path forConversation:conversation additionFlags:self.senderFlags]; } sender.tableItem = [[self messageTableItemsFromMessages:@[sender.message]] lastObject]; @@ -2985,13 +3253,13 @@ - (void)forwardMessages:(NSArray *)messages conversation:(TL_conversation *)conv if(!conversation.canSendMessage) return; - [self setHistoryFilter:HistoryFilter.class force:self.historyController.prevState != ChatHistoryStateFull]; + [self setHistoryFilter:self.defHFClass force:self.historyController.prevState != ChatHistoryStateFull]; [ASQueue dispatchOnStageQueue:^{ void (^fwd_blck) (NSArray *fwd_msgs) = ^(NSArray *fwd_messages) { - ForwardSenterItem *sender = [[ForwardSenterItem alloc] initWithMessages:fwd_messages forConversation:conversation]; + ForwardSenterItem *sender = [[ForwardSenterItem alloc] initWithMessages:fwd_messages forConversation:conversation additionFlags:self.senderFlags]; sender.tableItems = [[self messageTableItemsFromMessages:sender.fakes] reversedArray]; [self.historyController addItems:sender.tableItems conversation:conversation callback:callback sentControllerCallback:nil]; }; @@ -3024,11 +3292,11 @@ - (void)shareContact:(TLUser *)contact forConversation:(TL_conversation *)conver if(!self.conversation.canSendMessage) return; - [self setHistoryFilter:HistoryFilter.class force:self.historyController.prevState != ChatHistoryStateFull]; + [self setHistoryFilter:self.defHFClass force:self.historyController.prevState != ChatHistoryStateFull]; [ASQueue dispatchOnStageQueue:^{ - ShareContactSenterItem *sender = [[ShareContactSenterItem alloc] initWithContact:contact forConversation:conversation]; + ShareContactSenterItem *sender = [[ShareContactSenterItem alloc] initWithContact:contact forConversation:conversation additionFlags:self.senderFlags]; sender.tableItem = [[self messageTableItemsFromMessages:@[sender.message]] lastObject]; [self.historyController addItem:sender.tableItem conversation:conversation callback:callback sentControllerCallback:nil]; @@ -3041,12 +3309,12 @@ - (void)sendSecretTTL:(int)ttl forConversation:(TL_conversation *)conversation { - (void)sendSecretTTL:(int)ttl forConversation:(TL_conversation *)conversation callback:(dispatch_block_t)callback { - if(!conversation.canSendMessage) { + if(!conversation.canSendMessage || conversation.type != DialogTypeSecretChat) { if(callback) callback(); return; } - [self setHistoryFilter:HistoryFilter.class force:self.historyController.prevState != ChatHistoryStateFull]; + [self setHistoryFilter:self.defHFClass force:self.historyController.prevState != ChatHistoryStateFull]; NSUInteger lastTTL = [EncryptedParams findAndCreate:conversation.peer.peer_id].ttl; @@ -3073,7 +3341,7 @@ - (void)sendAttachments:(NSArray *)attachments forConversation:(TL_conversation if(!conversation.canSendMessage || conversation.type == DialogTypeSecretChat) return; - [self setHistoryFilter:HistoryFilter.class force:self.historyController.prevState != ChatHistoryStateFull]; + [self setHistoryFilter:self.defHFClass force:self.historyController.prevState != ChatHistoryStateFull]; [ASQueue dispatchOnStageQueue:^{ @@ -3081,7 +3349,7 @@ - (void)sendAttachments:(NSArray *)attachments forConversation:(TL_conversation [attachments enumerateObjectsUsingBlock:^(TGAttachObject *obj, NSUInteger idx, BOOL *stop) { - SenderItem *sender = [[[obj senderClass] alloc] initWithConversation:conversation attachObject:obj]; + SenderItem *sender = [[[obj senderClass] alloc] initWithConversation:conversation attachObject:obj additionFlags:self.senderFlags]; sender.tableItem = [[self messageTableItemsFromMessages:@[sender.message]] lastObject]; @@ -3097,7 +3365,7 @@ - (void)sendAttachments:(NSArray *)attachments forConversation:(TL_conversation } - (void)addImageAttachment:(NSString *)file_path forConversation:(TL_conversation *)conversation file_data:(NSData *)data addCompletionHandler:(dispatch_block_t)completeHandler { - if(self.conversation.type == DialogTypeSecretChat) + if(self.conversation.type == DialogTypeSecretChat || (!file_path && !data)) return; [[Storage yap] asyncReadWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { @@ -3137,7 +3405,7 @@ -(void)sendImage:(NSString *)file_path forConversation:(TL_conversation *)conver } - [self setHistoryFilter:HistoryFilter.class force:self.historyController.prevState != ChatHistoryStateFull]; + [self setHistoryFilter:self.defHFClass force:self.historyController.prevState != ChatHistoryStateFull]; [ASQueue dispatchOnStageQueue:^{ @@ -3192,7 +3460,7 @@ -(void)sendImage:(NSString *)file_path forConversation:(TL_conversation *)conver if(self.conversation.type == DialogTypeSecretChat) { sender = [[FileSecretSenderItem alloc] initWithImage:originImage uploadType:UploadImageType forConversation:conversation]; } else { - sender = [[ImageSenderItem alloc] initWithImage:originImage jpegData:imageData forConversation:conversation]; + sender = [[ImageSenderItem alloc] initWithImage:originImage jpegData:imageData forConversation:conversation additionFlags:self.senderFlags]; } sender.tableItem = [[self messageTableItemsFromMessages:@[sender.message]] lastObject]; @@ -3203,7 +3471,7 @@ -(void)sendImage:(NSString *)file_path forConversation:(TL_conversation *)conver - (void)addReplayMessage:(TL_localMessage *)message animated:(BOOL)animated { - if(message.to_id.class == [TL_peerChat class] || message.to_id.class == [TL_peerUser class]) { + if((message.to_id.class == [TL_peerChannel class] || message.to_id.class == [TL_peerChat class] || message.to_id.class == [TL_peerUser class]) && message.peer_id == _conversation.peer_id) { [[Storage yap] readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { [transaction setObject:message forKey:self.conversation.cacheKey inCollection:REPLAY_COLLECTION]; @@ -3212,9 +3480,10 @@ - (void)addReplayMessage:(TL_localMessage *)message animated:(BOOL)animated { [self.bottomView updateReplayMessage:YES animated:animated]; - if([Telegram rightViewController].navigationViewController.currentController != self) + if(self.navigationViewController.currentController != self) { - [[Telegram rightViewController] showByDialog:message.conversation sender:self]; + [self setCurrentConversation:message.conversation]; + [self.navigationViewController gotoViewController:self]; } } } @@ -3246,6 +3515,13 @@ -(TL_localMessage *)replyMessage { } +-(int)senderFlags { + if(self.conversation.type != DialogTypeChannel) + return self.historyController.filter.additionSenderFlags; + + return [self.bottomView sendMessageAsAdmin] ? self.historyController.filter.additionSenderFlags : self.conversation.canSendChannelMessageAsUser ? 0 : self.historyController.filter.additionSenderFlags; +} + -(void)markAsNoWebpage { _noWebpageString = [self.inputText webpageLink]; @@ -3341,8 +3617,17 @@ - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn MessageTableItem *item = [self.messages objectAtIndex:row]; MessageTableCell *cell = nil; - - if(item.class == [MessageTableItemServiceMessage class]) { + if(item.message.hole != nil) { + + static NSString *const kRowIdentifier = @"holeItem"; + cell = [self.table makeViewWithIdentifier:kRowIdentifier owner:self]; + if(!cell) { + cell = [[MessageTableCellHoleView alloc] initWithFrame:self.view.bounds]; + cell.identifier = kRowIdentifier; + cell.messagesViewController = self; + } + + } else if(item.class == [MessageTableItemServiceMessage class]) { static NSString *const kRowIdentifier = @"service"; cell = [self.table makeViewWithIdentifier:kRowIdentifier owner:self]; @@ -3479,7 +3764,6 @@ - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn NSDate *start = [NSDate new]; [cell setItem:item]; - if([cell isKindOfClass:[MessageTableCellContainerView class]]) { @@ -3495,6 +3779,7 @@ - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn return cell; } + - (void)backOrClose:(NSMenuItem *)sender { if(self.state == MessagesViewControllerStateEditable) { [self unSelectAll]; @@ -3511,21 +3796,20 @@ - (NSUInteger)indexOfObject:(MessageTableItem *)item { return [self.messages indexOfObject:item]; } -- (MessageTableItem *)itemOfMsgId:(int)msg_id { +- (MessageTableItem *)itemOfMsgId:(long)msg_id { return [self findMessageItemById:msg_id]; } - (void)clearHistory:(TL_conversation *)dialog { - weakify(); + weak(); NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Conversation.Confirm.ClearHistory", nil) informativeText:NSLocalizedString(@"Conversation.Confirm.UndoneAction", nil) block:^(NSNumber *result) { if([result intValue] == 1000) { [[DialogsManager sharedManager] clearHistory:dialog completeHandler:^{ - if(strongSelf.conversation == dialog) { - [strongSelf.historyController removeAllItems]; - strongSelf.conversation = nil; - [strongSelf setCurrentConversation:dialog]; + if(weakSelf.conversation == dialog) { + weakSelf.conversation = nil; + [weakSelf setCurrentConversation:dialog]; } }]; } @@ -3563,7 +3847,9 @@ - (void)leaveOrReturn:(TL_conversation *)dialog { } - (void)deleteDialog:(TL_conversation *)dialog callback:(dispatch_block_t)callback startDeleting:(dispatch_block_t)startDeleting { - weakify(); + + + weak(); if(!dialog) @@ -3574,12 +3860,12 @@ - (void)deleteDialog:(TL_conversation *)dialog callback:(dispatch_block_t)callba dispatch_block_t block = ^{ [[DialogsManager sharedManager] deleteDialog:dialog completeHandler:^{ - if(dialog == strongSelf.conversation) { - [strongSelf.historyController removeAllItems]; + + if(callback) callback(); + + if(dialog == weakSelf.conversation) { [[Telegram sharedInstance] showNotSelectedDialog]; - strongSelf.conversation = nil; - - if(callback) callback(); + weakSelf.conversation = nil; } }]; }; @@ -3596,7 +3882,7 @@ - (void)deleteDialog:(TL_conversation *)dialog callback:(dispatch_block_t)callba return; } - NSAlert *alert = [NSAlert alertWithMessageText:dialog.type == DialogTypeChat && dialog.chat.type == TLChatTypeNormal ? NSLocalizedString(@"Conversation.Confirm.LeaveAndClear", nil) : NSLocalizedString(@"Conversation.Confirm.DeleteAndClear", nil) informativeText:NSLocalizedString(@"Conversation.Confirm.UndoneAction", nil) block:^(NSNumber *result) { + NSAlert *alert = [NSAlert alertWithMessageText:dialog.type == DialogTypeChannel && dialog.chat.isCreator ? (NSLocalizedString(dialog.chat.isMegagroup ? @"Conversation.Confirm.DeleteGroup" : @"Conversation.Confirm.DeleteChannel", nil)) : (dialog.type == DialogTypeChat && dialog.chat.type == TLChatTypeNormal ? NSLocalizedString(@"Conversation.Confirm.LeaveAndClear", nil) : NSLocalizedString(@"Conversation.Confirm.DeleteAndClear", nil)) informativeText:dialog.type == DialogTypeChannel && dialog.chat.isCreator ? NSLocalizedString(dialog.chat.isMegagroup ? @"Conversation.Confirm.DeleteSupergroupInfo" : @"Conversation.Confirm.DeleteChannelInfo", nil) : NSLocalizedString(@"Conversation.Confirm.UndoneAction", nil) block:^(NSNumber *result) { if([result intValue] == 1000) { if(startDeleting != nil) startDeleting(); @@ -3604,7 +3890,7 @@ - (void)deleteDialog:(TL_conversation *)dialog callback:(dispatch_block_t)callba } }]; - NSString *buttonText = dialog.type == DialogTypeChat && dialog.chat.type == TLChatTypeNormal ? NSLocalizedString(@"Conversation.DeleteAndExit", nil) : NSLocalizedString(@"Conversation.Delete", nil); + NSString *buttonText = dialog.type == DialogTypeChannel && dialog.chat.isAdmin && !dialog.chat.isMegagroup ? NSLocalizedString(@"Conversation.Confirm.DeleteChannel", nil) : (dialog.type == DialogTypeChat && dialog.chat.type == TLChatTypeNormal ? NSLocalizedString(@"Conversation.DeleteAndExit", nil) : NSLocalizedString(@"Conversation.Delete", nil)); [alert addButtonWithTitle:buttonText]; [alert addButtonWithTitle:NSLocalizedString(@"Profile.Cancel", nil)]; diff --git a/TelegramTest/MessagetableCellAudioController.m b/TelegramTest/MessagetableCellAudioController.m index 526b9aac..be42b026 100644 --- a/TelegramTest/MessagetableCellAudioController.m +++ b/TelegramTest/MessagetableCellAudioController.m @@ -137,6 +137,7 @@ - (void)drawRect:(NSRect)dirtyRect { -(void)setDurationTextFieldString:(NSString *)string { [self.durationView setStringValue:string]; + [self.durationView setFrameSize:NSMakeSize(NSWidth(self.containerView.frame) - NSMinX(self.durationView.frame) - NSWidth(self.stateTextField.frame), NSHeight(self.durationView.frame))]; } @@ -238,7 +239,7 @@ - (void)setStateTextFieldString:(NSString *)string { [self.stateTextField setHidden:NO]; [self.stateTextField setStringValue:string]; [self.stateTextField sizeToFit]; - [self.stateTextField setFrameOrigin:NSMakePoint(self.durationView.frame.origin.x + self.durationView.frame.size.width, self.durationView.frame.origin.y - 2)]; + [self.stateTextField setFrameOrigin:NSMakePoint(NSMaxX(self.durationView.frame) + 10, self.durationView.frame.origin.y - 2)]; } diff --git a/TelegramTest/NSAlertCategory.m b/TelegramTest/NSAlertCategory.m index f13de2cf..64ca1455 100644 --- a/TelegramTest/NSAlertCategory.m +++ b/TelegramTest/NSAlertCategory.m @@ -23,7 +23,7 @@ + (NSAlert *)alertWithMessageText:(NSString *)message informativeText:(NSString - (void)show { - [self beginSheetModalForWindow:[[Telegram delegate] mainWindow] + [self beginSheetModalForWindow:[NSApp keyWindow] modalDelegate:self didEndSelector:@selector(testDatabaseConnectionDidEnd:returnCode:contextInfo:) contextInfo:nil]; diff --git a/TelegramTest/NSArray+BlockFiltering.h b/TelegramTest/NSArray+BlockFiltering.h index befc9ede..2eefcd1d 100644 --- a/TelegramTest/NSArray+BlockFiltering.h +++ b/TelegramTest/NSArray+BlockFiltering.h @@ -13,4 +13,5 @@ - (NSArray *)filteredArrayUsingBlock:(BOOL (^)(id obj, NSUInteger idx, BOOL *stop))predicate; - (NSArray *)reversedArray; +-(NSArray *)findElementsWithRecursion:(NSString *)q; @end \ No newline at end of file diff --git a/TelegramTest/NSArrayCategory.h b/TelegramTest/NSArrayCategory.h index bf8ab0ff..4acfcf02 100644 --- a/TelegramTest/NSArrayCategory.h +++ b/TelegramTest/NSArrayCategory.h @@ -9,6 +9,7 @@ #import @interface NSArray (Reverse) +-(NSArray *)findElementsWithRecursion:(NSString *)q; @end @interface NSMutableArray (Reverse) diff --git a/TelegramTest/NSArrayCategory.m b/TelegramTest/NSArrayCategory.m index 96adf6a0..b53f85a8 100644 --- a/TelegramTest/NSArrayCategory.m +++ b/TelegramTest/NSArrayCategory.m @@ -19,6 +19,33 @@ - (NSArray *)reversedArray { return array; } +-(id)firstObject { + return self.count > 0 ? self[0] : nil; +} + +-(NSArray *)findElementsWithRecursion:(NSString *)q { + return [self findElementsWithRecursion:[NSMutableArray array] inside:self q:q]; +} + +-(NSArray *)findElementsWithRecursion:(NSMutableArray *)result inside:(NSArray *)inside q:(NSString *)q { + + [inside enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + + if([obj class] == [NSString class]) { + if([obj rangeOfString:q].location != NSNotFound) { + [result addObject:obj]; + } + } else if([obj isKindOfClass:[NSArray class]]) { + [result addObjectsFromArray:[self findElementsWithRecursion:[NSMutableArray array] inside:obj q:q]]; + } + + + }]; + + + return result; +} + @end @implementation NSMutableArray (Reverse) @@ -37,4 +64,10 @@ - (void)reverse { } } +-(id)firstObject { + return self.count > 0 ? self[0] : nil; +} + + + @end diff --git a/TelegramTest/NSAttributedString+Hyperlink.h b/TelegramTest/NSAttributedString+Hyperlink.h index 4896637a..9a1167d3 100755 --- a/TelegramTest/NSAttributedString+Hyperlink.h +++ b/TelegramTest/NSAttributedString+Hyperlink.h @@ -2,5 +2,6 @@ #import "NSString+FindURLs.h" @interface NSMutableAttributedString (Hyperlink) +(id)hyperlinkFromString:(NSString*)inString withURL:(NSURL*)aURL; --(void)detectAndAddLinks:(URLFindType)urlType; +-(NSArray *)detectAndAddLinks:(URLFindType)urlType; +-(void)detectBoldColorInStringWithFont:(NSFont *)font; @end \ No newline at end of file diff --git a/TelegramTest/NSAttributedString+Hyperlink.m b/TelegramTest/NSAttributedString+Hyperlink.m index 30312865..23a3a1b2 100755 --- a/TelegramTest/NSAttributedString+Hyperlink.m +++ b/TelegramTest/NSAttributedString+Hyperlink.m @@ -17,7 +17,9 @@ +(id)hyperlinkFromString:(NSString*)inString withURL:(NSURL*)aURL return attrString; } --(void)detectAndAddLinks:(URLFindType)urlType { +-(NSArray *)detectAndAddLinks:(URLFindType)urlType { + + NSMutableArray *urls = [[NSMutableArray alloc] init]; NSArray *linkLocations = [NSString textCheckingResultsForText:self.string highlightMentionsAndTags:urlType & URLFindTypeMentions highlightCommands:urlType & URLFindTypeBotCommands];// [[self string] locationsOfLinks:urlType]; @@ -26,20 +28,63 @@ -(void)detectAndAddLinks:(URLFindType)urlType { NSRange range = [link rangeValue]; if(range.location != NSNotFound) { - // NSURL *url = [NSURL URLWithString:link]; - // if(url) { - [self addAttribute:NSLinkAttributeName value:[self.string substringWithRange:range] range:range]; + + NSString *sublink = [self.string substringWithRange:range]; + + [self addAttribute:NSLinkAttributeName value:sublink range:range]; [self addAttribute:NSForegroundColorAttributeName value:LINK_COLOR range:range]; [self addAttribute:NSCursorAttributeName value:[NSCursor pointingHandCursor] range:range]; [self addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInt:NSUnderlineStyleNone] range:range]; - // } + + if(![sublink hasPrefix:@"@"] && ![sublink hasPrefix:@"#"] && ![sublink hasPrefix:@"/"]) { + [urls addObject:sublink]; + } } } [self endEditing]; + return urls; + +} + + +-(void)detectBoldColorInStringWithFont:(NSFont *)font { + [self detectBoldColorInStringWithFont:font string:[self.string copy]]; } +-(void)detectBoldColorInStringWithFont:(NSFont *)font string:(NSString *)string { + NSRange range; + + NSUInteger offset = 0; + + while ((range = [string rangeOfString:@"**" options:0 range:NSMakeRange(offset, string.length - offset)]).location != NSNotFound) { + + + + offset = range.location + range.length; + + + range = [string rangeOfString:@"**" options:0 range:NSMakeRange(offset, string.length - offset)]; + + if(range.location != NSNotFound) { + [self addAttribute:NSFontAttributeName value:font range:NSMakeRange(offset, range.location - offset)]; + + offset+= (range.location - offset) + range.length; + + } + + + } + + while ((range = [self.string rangeOfString:@"**"]).location != NSNotFound) { + [self replaceCharactersInRange:range withString:@""]; + } + + + + +} @end \ No newline at end of file diff --git a/TelegramTest/NSAttributedStringCategory.h b/TelegramTest/NSAttributedStringCategory.h index f04a15c2..ecf8bd68 100644 --- a/TelegramTest/NSAttributedStringCategory.h +++ b/TelegramTest/NSAttributedStringCategory.h @@ -19,4 +19,6 @@ -(NSRange)selectRange:(NSSize)frameSize startPoint:(NSPoint)startPoint currentPoint:(NSPoint)currentPoint; + + @end diff --git a/TelegramTest/NSAttributedStringCategory.m b/TelegramTest/NSAttributedStringCategory.m index efbed454..7e52ad53 100644 --- a/TelegramTest/NSAttributedStringCategory.m +++ b/TelegramTest/NSAttributedStringCategory.m @@ -60,9 +60,6 @@ - (NSSize)coreTextSizeForTextFieldForWidth:(int)width withPaths:(NSArray *)paths [paths enumerateObjectsUsingBlock:^(NSValue *obj, NSUInteger idx, BOOL *stop) { CGPathAddRect(path, NULL, [obj rectValue]); - - - }]; @@ -86,9 +83,12 @@ - (NSSize)coreTextSizeForTextFieldForWidth:(int)width withPaths:(NSArray *)paths CTLineGetTypographicBounds(line, &ascent, &descent, &leading); - height+= floor(ascent + ceil(descent) + leading); + height+= floor(ascent + floor(descent) + leading); } + CFRelease(framesetter); + CFRelease(CTFrame); + CFRelease(path); return NSMakeSize(width, height ); @@ -133,7 +133,6 @@ -(NSRange)selectRange:(NSSize)frameSize startPoint:(NSPoint)startPoint currentPo int currentSelectLineIndex = [self lineIndex:origins count:(int) CFArrayGetCount(lines) location:currentPoint frame:CTFrame frameSize:frameSize]; - int dif = abs(startSelectLineIndex - currentSelectLineIndex); @@ -212,10 +211,9 @@ -(BOOL)isCurrentLine:(NSPoint)position linePosition:(NSPoint)linePosition idx:(i CTLineGetTypographicBounds(line, &ascent, &descent, &leading); - int lineHeight = floor(ascent + ceil(descent) + leading); - + int lineHeight = ceil(ascent + ceil(descent) + leading); - return (position.y > linePosition.y) && position.y < (linePosition.y + lineHeight); + return (position.y > linePosition.y) && position.y <= (linePosition.y + lineHeight); } @@ -231,4 +229,6 @@ -(int)lineIndex:(CGPoint[])origins count:(int)count location:(NSPoint)location f } + + @end diff --git a/TelegramTest/NSDate-Utilities.m b/TelegramTest/NSDate-Utilities.m index 77a4c2f0..78b1b376 100755 --- a/TelegramTest/NSDate-Utilities.m +++ b/TelegramTest/NSDate-Utilities.m @@ -105,7 +105,7 @@ - (BOOL) isSameWeekAsDate: (NSDate *) aDate if (components1.week != components2.week) return NO; // Must have a time interval under 1 week. Thanks @aclark - return (abs([self timeIntervalSinceDate:aDate]) < D_WEEK); + return (fabs([self timeIntervalSinceDate:aDate]) < D_WEEK); } - (BOOL) isThisWeek diff --git a/TelegramTest/NSNotificationCenter+MainThread.h b/TelegramTest/NSNotificationCenter+MainThread.h index 80603a85..daad109e 100644 --- a/TelegramTest/NSNotificationCenter+MainThread.h +++ b/TelegramTest/NSNotificationCenter+MainThread.h @@ -11,4 +11,8 @@ @interface NSNotificationCenter (MainThread) - (void)postNotificationNameOnMainThread:(NSString *)notificationName object:(id)notificationSender; - (void)postNotificationNameOnMainThread:(NSString *)notificationName object:(id)notificationSender userInfo:(NSDictionary *)userInfo; + +- (void)postNotificationNameOnStageThread:(NSString *)notificationName object:(id)notificationSender; +- (void)postNotificationNameOnStageThread:(NSString *)notificationName object:(id)notificationSender userInfo:(NSDictionary *)userInfo; + @end diff --git a/TelegramTest/NSNotificationCenter+MainThread.m b/TelegramTest/NSNotificationCenter+MainThread.m index 8a869601..88254844 100644 --- a/TelegramTest/NSNotificationCenter+MainThread.m +++ b/TelegramTest/NSNotificationCenter+MainThread.m @@ -12,17 +12,27 @@ @implementation NSNotificationCenter (MainThread) - (void)postNotificationNameOnMainThread:(NSString *)notificationName object:(id)notificationSender { - [LoopingUtils runOnMainQueueAsync:^{ + [ASQueue dispatchOnMainQueue:^{ [self postNotificationName:notificationName object:notificationSender]; }]; } - (void)postNotificationNameOnMainThread:(NSString *)notificationName object:(id)notificationSender userInfo:(NSDictionary *)userInfo { + [ASQueue dispatchOnMainQueue:^{ + [self postNotificationName:notificationName object:notificationSender userInfo:userInfo]; + }]; +} + - // MTLog(@"notification perform %@", notificationName); - - [LoopingUtils runOnMainQueueAsync:^{ +- (void)postNotificationNameOnStageThread:(NSString *)notificationName object:(id)notificationSender { + [ASQueue dispatchOnStageQueue:^{ + [self postNotificationName:notificationName object:notificationSender]; + }]; +} +- (void)postNotificationNameOnStageThread:(NSString *)notificationName object:(id)notificationSender userInfo:(NSDictionary *)userInfo { + [ASQueue dispatchOnStageQueue:^{ [self postNotificationName:notificationName object:notificationSender userInfo:userInfo]; }]; } + @end diff --git a/TelegramTest/NSNumber+NumberFormatter.m b/TelegramTest/NSNumber+NumberFormatter.m index cdeb6ae3..acdc333a 100644 --- a/TelegramTest/NSNumber+NumberFormatter.m +++ b/TelegramTest/NSNumber+NumberFormatter.m @@ -23,6 +23,10 @@ -(NSString*)prettyFormatter:(unsigned long)n iteration:(int)iteration { -(NSString *)prettyNumber { + + if([self unsignedLongValue] < 1000) + return [NSString stringWithFormat:@"%@",self]; + return [self prettyFormatter:[self unsignedLongValue] iteration:0]; } @end diff --git a/TelegramTest/NSString+Extended.h b/TelegramTest/NSString+Extended.h index 4c9dc87e..720ae543 100644 --- a/TelegramTest/NSString+Extended.h +++ b/TelegramTest/NSString+Extended.h @@ -15,6 +15,7 @@ - (NSString *)URLDecode; - (NSSize)sizeForTextFieldForWidth:(int)width; - (NSArray *)getEmojiFromString:(BOOL)checkColor; +-(NSString *)emojiString; - (NSString *)replaceSmilesToEmoji; -(NSString *)fixEmoji; diff --git a/TelegramTest/NSString+Extended.m b/TelegramTest/NSString+Extended.m index a21cec47..54d55670 100644 --- a/TelegramTest/NSString+Extended.m +++ b/TelegramTest/NSString+Extended.m @@ -24,17 +24,11 @@ - (NSString *)URLDecode { - (NSString *) trim { - NSString *string = [self stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; + NSString *string = self; - NSRange range = NSMakeRange(0, 1); - while(range.length != 0) { - range = [string rangeOfString:@" "]; - string = [string stringByReplacingOccurrencesOfString:@" " withString:@" "]; - } - - string = [string stringByReplacingOccurrencesOfString:@" -- " withString:@" — "]; - string = [string stringByReplacingOccurrencesOfString:@"<<" withString:@"«"]; - string = [string stringByReplacingOccurrencesOfString:@">>" withString:@"»"]; +// string = [string stringByReplacingOccurrencesOfString:@" -- " withString:@" — "]; +// string = [string stringByReplacingOccurrencesOfString:@"<<" withString:@"«"]; +// string = [string stringByReplacingOccurrencesOfString:@">>" withString:@"»"]; return string; } @@ -991,7 +985,9 @@ -(NSString *)replaceSmilesToEmoji { // 'D83DDC4D': [27, ':like:'], 'D83DDC4E': [28, ':dislike:'], '261D': [29, ':up:'], '270C': [30, ':v:'], 'D83DDC4C': [31, ':ok:'] - +-(NSString *)emojiString { + return [[self getEmojiFromString:YES] componentsJoinedByString:@""]; +} - (NSArray *)getEmojiFromString:(BOOL)checkColor { @@ -1222,7 +1218,16 @@ -(BOOL)searchInStringByWordsSeparated:(NSString *)search { if(range.location != NSNotFound) { - if(range.location == 0 || [[self substringWithRange:NSMakeRange(range.location - 1, 1)] isEqualToString:@" "]) { + NSRange acceptRange = NSMakeRange(0, 0); + + if(range.location != 0) { + NSString *s = [self substringWithRange:NSMakeRange(range.location - 1, 1)]; + + acceptRange = [s rangeOfCharacterFromSet:[NSCharacterSet letterCharacterSet] options:NSCaseInsensitiveSearch]; + } + + + if(range.location == 0 || acceptRange.location == NSNotFound) { result = YES; *stop = YES; } diff --git a/TelegramTest/NSString+FindURLs.h b/TelegramTest/NSString+FindURLs.h index 8b7730df..3c5cd6d2 100755 --- a/TelegramTest/NSString+FindURLs.h +++ b/TelegramTest/NSString+FindURLs.h @@ -19,8 +19,9 @@ typedef enum { - (NSArray *)arrayOfLinks:(NSArray *)results; - (NSArray *)locationsOfLinks:(URLFindType)findType; - (NSArray *)locationsOfHashtags; +- (NSArray *)locationsOfLinks; - (NSString *)webpageLink; - +- (BOOL)isStringWithUrl; + (NSArray *)textCheckingResultsForText:(NSString *)text highlightMentionsAndTags:(bool)highlightMentionsAndTags highlightCommands:(bool)highlightCommands; diff --git a/TelegramTest/NSString+FindURLs.m b/TelegramTest/NSString+FindURLs.m index ebef543e..06f5145f 100755 --- a/TelegramTest/NSString+FindURLs.m +++ b/TelegramTest/NSString+FindURLs.m @@ -25,6 +25,11 @@ - (NSArray *)arrayOfLinks:(NSArray *)results return links; } +-(NSArray *)locationsOfLinks { + NSDataDetector *detect = [[NSDataDetector alloc] initWithTypes:1ULL << 5 error:nil]; + return [detect matchesInString:self options:0 range:NSMakeRange(0, [self length])]; +} + - (NSArray *)locationsOfLinks:(URLFindType)findType { @@ -220,7 +225,7 @@ + (NSArray *)textCheckingResultsForText:(NSString *)text highlightMentionsAndTag NSError *error = nil; static NSDataDetector *dataDetector = nil; if (dataDetector == nil) - dataDetector = [NSDataDetector dataDetectorWithTypes:(int)(NSTextCheckingTypeLink | NSTextCheckingTypePhoneNumber) error:&error]; + dataDetector = [NSDataDetector dataDetectorWithTypes:(int)(NSTextCheckingTypeLink) error:&error]; NSMutableArray *results = [[NSMutableArray alloc] init]; [dataDetector enumerateMatchesInString:text options:0 range:NSMakeRange(0, text.length) usingBlock:^(NSTextCheckingResult *match, __unused NSMatchingFlags flags, __unused BOOL *stop) @@ -364,4 +369,14 @@ -(NSString *)webpageLink } + +- (BOOL)isStringWithUrl +{ + + NSDataDetector *detect = [[NSDataDetector alloc] initWithTypes:1ULL << 5 error:nil]; + + return [detect matchesInString:self options:0 range:NSMakeRange(0, [self length])].count > 0; + +} + @end diff --git a/TelegramTest/NSStringCategory.h b/TelegramTest/NSStringCategory.h index 8935abd9..551536f3 100644 --- a/TelegramTest/NSStringCategory.h +++ b/TelegramTest/NSStringCategory.h @@ -20,7 +20,7 @@ + (NSString *) sizeToTransformedValue:(NSUInteger)value; + (NSString *) durationTransformedValue:(int) elapsedSeconds; + (NSString *) sizeToTransformedValuePretty:(int)value; - +- (NSString *)stringByDecodingURLFormat; +(NSRange)selectRange:(NSPoint)point frameSize:(NSSize)size; diff --git a/TelegramTest/NSStringCategory.m b/TelegramTest/NSStringCategory.m index 03c2563c..84f01e32 100644 --- a/TelegramTest/NSStringCategory.m +++ b/TelegramTest/NSStringCategory.m @@ -79,6 +79,13 @@ + (NSString *) sizeToTransformedValuePretty:(int)value { return [NSString stringWithFormat:@"%4.0f %@", convertedValue, [tokens objectAtIndex:multiplyFactor]]; } +- (NSString *)stringByDecodingURLFormat +{ + NSString *result = [(NSString *)self stringByReplacingOccurrencesOfString:@"+" withString:@" "]; + result = [result stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; + return result; +} + + (NSString *) md5String:(NSString *)string { return [string md5]; } diff --git a/TelegramTest/NSViewCategory.m b/TelegramTest/NSViewCategory.m index aac3e2e7..f40025fb 100644 --- a/TelegramTest/NSViewCategory.m +++ b/TelegramTest/NSViewCategory.m @@ -15,10 +15,14 @@ @implementation NSView (Category) - (void)setCenterByView:(NSView *)view { - float x = (view.bounds.size.width - self.bounds.size.width) / 2; - float y = (view.bounds.size.height - self.bounds.size.height) / 2; + float x = roundf((view.bounds.size.width - self.bounds.size.width) / 2); + float y = roundf((view.bounds.size.height - self.bounds.size.height) / 2); + + + x+= (view.bounds.size.width * self.layer.anchorPoint.x); + y+= (view.bounds.size.height * self.layer.anchorPoint.y); - [self setFrameOrigin:NSMakePoint(roundf(x),roundf(y))]; + [self setFrameOrigin:NSMakePoint(x,y)]; } - (void)setCenteredXByView:(NSView *)view { diff --git a/TelegramTest/NewContactsManager.m b/TelegramTest/NewContactsManager.m index a4491eb2..77c5f334 100644 --- a/TelegramTest/NewContactsManager.m +++ b/TelegramTest/NewContactsManager.m @@ -24,7 +24,7 @@ + (id)sharedManager { static NewContactsManager *instance; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - instance = [[NewContactsManager alloc] initWithQueue:[[ASQueue alloc] initWithName:[NSStringFromClass([self class]) UTF8String]]]; + instance = [[NewContactsManager alloc] initWithQueue:[ASQueue globalQueue]]; }); return instance; } @@ -60,18 +60,17 @@ - (void) fullReload { [[Storage manager] contacts:^(NSArray *contacts) { - [self add:contacts withCustomKey:@"user_id"]; - - - - [Notification perform:CONTACTS_MODIFIED data:@{@"CONTACTS_RELOAD": self->list}]; - - [self remoteCheckContacts:^{ + [self.queue dispatchOnQueue:^{ + [self add:contacts withCustomKey:@"user_id"]; - [self iCloudSync]; + [Notification perform:CONTACTS_MODIFIED data:@{@"CONTACTS_RELOAD": self->list}]; + [self remoteCheckContacts:^{ + + [self iCloudSync]; + + }]; }]; - }]; @@ -105,10 +104,12 @@ -(void)add:(NSArray *)all withCustomKey:(NSString*)key { -(void)sortAndNotify:(BOOL)notify { + NSSortDescriptor * descriptor = [[NSSortDescriptor alloc] initWithKey:@"self.user.lastSeenTime" ascending:NO]; [self->list sortUsingDescriptors:@[descriptor]]; + if(notify) { [Notification perform:CONTACTS_SORT_CHANGED data:@{}]; diff --git a/TelegramTest/NewConversationRowItem.h b/TelegramTest/NewConversationRowItem.h deleted file mode 100644 index af431c90..00000000 --- a/TelegramTest/NewConversationRowItem.h +++ /dev/null @@ -1,28 +0,0 @@ -// -// NewConversationRow.h -// Telegram P-Edition -// -// Created by keepcoder on 20.02.14. -// Copyright (c) 2014 keepcoder. All rights reserved. -// - -#import "TMRowItem.h" -#import "NewConversationViewController.h" -@interface NewConversationRowItem : TMRowItem - -@property (nonatomic,strong) NSMutableAttributedString *title; -@property (nonatomic,assign) NSSize titleSize; -@property (nonatomic,assign) BOOL isChecked; -@property (nonatomic,strong) NSMutableAttributedString *lastSeen; -@property (nonatomic,assign) NSSize lastSeenSize; -@property (nonatomic,assign) NSPoint lastSeenPoint; -@property (nonatomic,assign) NSPoint titlePoint; -@property (nonatomic,assign) NSPoint avatarPoint; -@property (nonatomic,assign) NewConversationAction action; -@property (nonatomic,assign) BOOL animated; -@property (nonatomic,strong) TLFileLocation *location; -@property (nonatomic,strong) TLUser *user; -@property (nonatomic,strong) NewConversationViewController *controller; --(BOOL)canSelect; - -@end diff --git a/TelegramTest/NewConversationRowItem.m b/TelegramTest/NewConversationRowItem.m deleted file mode 100644 index 2163a0e9..00000000 --- a/TelegramTest/NewConversationRowItem.m +++ /dev/null @@ -1,65 +0,0 @@ -// -// NewConversationRow.m -// Telegram P-Edition -// -// Created by keepcoder on 20.02.14. -// Copyright (c) 2014 keepcoder. All rights reserved. -// - -#import "NewConversationRowItem.h" -#import "NS(Attributed)String+Geometrics.h" -#import "NSAttributedString+Hyperlink.h" - -@interface NewConversationRowItem () -@property (nonatomic, strong) TLContact * object; - -@end - -@implementation NewConversationRowItem - -- (id)initWithObject:(TLContact *)object { - if(self = [super initWithObject:object]) { - self.object = object; - self.animated = NO; - self.action = NewConversationActionWrite; - self.title = [[NSMutableAttributedString alloc] init]; - self.lastSeen = [[NSMutableAttributedString alloc] init]; - - - self.location = object.user.photo.photo_small; - self.user = object.user; - self.titleSize = NSZeroSize; - self.lastSeenSize = NSMakeSize(200, 30); - - self.avatarPoint = NSMakePoint(15, (60 - 44) / 2); - - - BOOL isOnline = self.user.isOnline; - - - [self.title appendString:[object.user fullName] withColor:NSColorFromRGB(0x333333)]; - [self.lastSeen appendString:[object.user lastSeen] withColor:!isOnline ? NSColorFromRGB(0xaeaeae) : LINK_COLOR]; - - [self.title setSelectionColor:NSColorFromRGB(0xffffff) forColor:NSColorFromRGB(0x333333)]; - [self.title setSelectionColor:NSColorFromRGB(0xfffffe) forColor:DARK_GREEN]; - - [self.lastSeen setSelectionColor:NSColorFromRGB(0xfffffe) forColor:NSColorFromRGB(0xaeaeae)]; - [self.lastSeen setSelectionColor:NSColorFromRGB(0xffffff) forColor:LINK_COLOR]; - - } - return self; -} - --(BOOL)canSelect { - return YES; -} - -- (NSObject *)itemForHash { - return self.object; -} - -+ (NSUInteger) hash:(TLContact *)object { - return [ @(object.user.n_id) hash]; -} - -@end diff --git a/TelegramTest/NewConversationRowView.h b/TelegramTest/NewConversationRowView.h deleted file mode 100644 index 39904340..00000000 --- a/TelegramTest/NewConversationRowView.h +++ /dev/null @@ -1,13 +0,0 @@ -// -// NewConversationRowView.h -// Telegram P-Edition -// -// Created by keepcoder on 20.02.14. -// Copyright (c) 2014 keepcoder. All rights reserved. -// - -#import "TMRowView.h" - -@interface NewConversationRowView : TMRowView - -@end diff --git a/TelegramTest/NewConversationRowView.m b/TelegramTest/NewConversationRowView.m deleted file mode 100644 index 768ae66e..00000000 --- a/TelegramTest/NewConversationRowView.m +++ /dev/null @@ -1,207 +0,0 @@ -// -// NewConversationRowView.m -// Telegram P-Edition -// -// Created by keepcoder on 20.02.14. -// Copyright (c) 2014 keepcoder. All rights reserved. -// - -#import "NewConversationRowView.h" -#import "TMAvatarImageView.h" -#import "NewConversationRowItem.h" -#import "TMCheckBox.h" -@interface NewConversationRowView () -@property (nonatomic, strong) TMAvatarImageView *avatarImageView; -@property (nonatomic, strong) TMTextField *titleTextField; -@property (nonatomic,strong) TMTextField *lastSeenTextField; -@property (nonatomic,strong) TMCheckBox *checkBox; - --(NewConversationRowItem *)rowItem; -@end - -@implementation NewConversationRowView - -- (id)initWithFrame:(NSRect)frame -{ - self = [super initWithFrame:frame]; - if (self) { - [self setSelectedBackgroundColor:NSColorFromRGB(0x6896ba)]; - self.checkBox = [[TMCheckBox alloc] initWithFrame:NSMakeRect(10, 60/2-10, 20, 20)]; - [self addSubview:self.checkBox]; - - self.avatarImageView = [TMAvatarImageView standartNewConversationTableAvatar]; - [self addSubview:self.avatarImageView]; - - - self.titleTextField = [[TMTextField alloc] init]; - [self.titleTextField setEditable:NO]; - [self.titleTextField setBordered:NO]; - [self.titleTextField setBackgroundColor:[NSColor clearColor]]; - [self.titleTextField setFont:[NSFont fontWithName:@"HelveticaNeue-Medium" size:12]]; - [[self.titleTextField cell] setLineBreakMode:NSLineBreakByCharWrapping]; - [[self.titleTextField cell] setTruncatesLastVisibleLine:YES]; - [self addSubview:self.titleTextField]; - - self.lastSeenTextField = [[TMTextField alloc] init]; - [self.lastSeenTextField setEditable:NO]; - [self.lastSeenTextField setBordered:NO]; - [self.lastSeenTextField setBackgroundColor:[NSColor clearColor]]; - [self.lastSeenTextField setFont:[NSFont fontWithName:@"HelveticaNeue" size:12]]; - [[self.lastSeenTextField cell] setLineBreakMode:NSLineBreakByCharWrapping]; - [[self.lastSeenTextField cell] setTruncatesLastVisibleLine:YES]; - [self addSubview:self.lastSeenTextField]; - - - [self setNormalBackgroundColor:NSColorFromRGB(0xffffff)]; - } - return self; -} - -- (void) redrawRow { - [self setSelected:[self rowItem].isChecked animation:NO]; - - [super redrawRow]; - - - [self.checkBox setSelected:[self rowItem].isChecked]; - [self.checkBox setChecked:[self rowItem].isChecked]; - - float duration = [[self rowItem] animated] ? 0.0 : 0.0f; - - [self.checkBox setHidden:!([self rowItem].action == NewConversationActionCreateGroup || [self rowItem].action == NewConversationActionChoosePeople)]; - - - [self.titleTextField setFrameOrigin:[self rowItem].titlePoint]; - [self.lastSeenTextField setFrameOrigin:[self rowItem].lastSeenPoint]; - - - - [self.avatarImageView setFrameOrigin:[self rowItem].avatarPoint]; - - - [self rowItem].avatarPoint = NSMakePoint(([self rowItem].action == NewConversationActionWrite || [self rowItem].action == NewConversationActionCreateSecretChat) ? 10 : 40, self.avatarImageView.frame.origin.y); - - [self rowItem].titlePoint = NSMakePoint(([self rowItem].action == NewConversationActionWrite || [self rowItem].action == NewConversationActionCreateSecretChat) ? 67 : 97, 31); - - - [self rowItem].lastSeenPoint = NSMakePoint(([self rowItem].action == NewConversationActionWrite || [self rowItem].action == NewConversationActionCreateSecretChat) ? 67 : 97, 2); - - - - [self.titleTextField setAttributedStringValue:[self rowItem].title]; - [self.lastSeenTextField setAttributedStringValue:[self rowItem].lastSeen]; - - if([self rowItem].titleSize.width == 0) { - [self.titleTextField sizeToFit]; - NSSize size = self.titleTextField.frame.size; - - int maxTitleSize = 200 ; - if(size.width > maxTitleSize) - size.width = maxTitleSize; - - [self rowItem].titleSize = size; - } - - - [self.titleTextField setFrameSize:[self rowItem].titleSize]; - [self.lastSeenTextField setFrameSize:[self rowItem].lastSeenSize]; - - [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) { - [context setDuration:duration]; - - [[self.titleTextField animator] setFrameOrigin:[self rowItem].titlePoint]; - [[self.lastSeenTextField animator] setFrameOrigin:[self rowItem].lastSeenPoint]; - - [[self.avatarImageView animator] setFrameOrigin:[self rowItem].avatarPoint]; - - } completionHandler:^{ - - }]; - - - - - [self.avatarImageView setUser:[self rowItem].user]; - [self setNeedsDisplay:YES]; - -} - --(void)mouseDown:(NSEvent *)theEvent { - - if( ([self rowItem].action == NewConversationActionCreateGroup || [self rowItem].action == NewConversationActionChoosePeople) && [[self rowItem] canSelect]) { - - [self rowItem].isChecked = ![self rowItem].isChecked; - - [[self rowItem].title setSelected:[self rowItem].isChecked]; - [[self rowItem].lastSeen setSelected:[self rowItem].isChecked]; - [self.titleTextField setAttributedStringValue:[self rowItem].title]; - [self.lastSeenTextField setAttributedStringValue:[self rowItem].lastSeen]; - [self.checkBox setSelected:[self rowItem].isChecked]; - [self.checkBox setChecked:[self rowItem].isChecked]; - - [self setSelected:[self rowItem].isChecked animation:NO]; - TMTableView *table = [[self rowItem] table]; - if([table.tm_delegate respondsToSelector:@selector(selectionDidChange:item:)]) { - [table.tm_delegate selectionDidChange:0 item:[self rowItem]]; - } - - } - - [super mouseDown:theEvent]; -} - -- (void) setSelected:(BOOL)isSelected animation:(BOOL)animation { - - if(self.isSelected == isSelected) - return; - - self.isSelected = isSelected; - NSColor *color = isSelected ? self.selectedBackgroundColor : self.normalBackgroundColor; - [self setBackgroundColor:color]; - [self setNeedsDisplay:YES]; - /* if(animation) { - - NSColor *oldColor = !isSelected ? self.selectedBackgroundColor : self.normalBackgroundColor; - - [self.layer setBackgroundColor:color.CGColorNew]; - - [self.layer removeAnimationForKey:@"selectionAnimation"]; - - CABasicAnimation *selectionAnimation = [CABasicAnimation animationWithKeyPath:@"backgroundColor"]; - selectionAnimation.duration = 0.1f; - selectionAnimation.fromValue = oldColor; - selectionAnimation.toValue = color; - [self.layer addAnimation:selectionAnimation forKey:@"selectionAnimation"]; - } else { - NSColor *color = isSelected ? self.selectedBackgroundColor : self.normalBackgroundColor; - [self.layer setBackgroundColor:color.CGColorNew]; - } */ -} - -- (void)checkSelected:(BOOL)isSelected { - // if([self rowItem].action != NewConversationActionCreateGroup) { - [[self rowItem].title setSelected:isSelected]; - [[self rowItem].lastSeen setSelected:isSelected]; - //[self.checkBox setSelected:isSelected]; - // if(isSelected) { - // [self.checkBox setChecked:![self rowItem].isChecked]; - // [self rowItem].isChecked = self.checkBox.isChecked; - // } - // } -} - - --(NewConversationRowItem *)rowItem { - return (NewConversationRowItem *) [super rowItem]; -} - -- (void)drawRect:(NSRect)dirtyRect -{ - [super drawRect:dirtyRect]; - - // Drawing code here. -} - - - -@end diff --git a/TelegramTest/NewConversationTableView.h b/TelegramTest/NewConversationTableView.h deleted file mode 100644 index a2d4f4d5..00000000 --- a/TelegramTest/NewConversationTableView.h +++ /dev/null @@ -1,13 +0,0 @@ -// -// NewConversationTableView.h -// Telegram P-Edition -// -// Created by keepcoder on 20.02.14. -// Copyright (c) 2014 keepcoder. All rights reserved. -// - -#import "TMTableView.h" - -@interface NewConversationTableView : TMTableView - -@end diff --git a/TelegramTest/NewConversationTableView.m b/TelegramTest/NewConversationTableView.m deleted file mode 100644 index 403136ab..00000000 --- a/TelegramTest/NewConversationTableView.m +++ /dev/null @@ -1,32 +0,0 @@ -// -// NewConversationTableView.m -// Telegram P-Edition -// -// Created by keepcoder on 20.02.14. -// Copyright (c) 2014 keepcoder. All rights reserved. -// - -#import "NewConversationTableView.h" - - - -@implementation NewConversationTableView - -- (id)initWithFrame:(NSRect)frame -{ - self = [super initWithFrame:frame]; - if (self) { - // Initialization code here. - } - return self; -} - - -- (void)drawRect:(NSRect)dirtyRect -{ - [super drawRect:dirtyRect]; - - // Drawing code here. -} - -@end diff --git a/TelegramTest/NewConversationViewController.h b/TelegramTest/NewConversationViewController.h deleted file mode 100644 index d974c785..00000000 --- a/TelegramTest/NewConversationViewController.h +++ /dev/null @@ -1,37 +0,0 @@ -// -// NewConversationViewController.h -// Telegram P-Edition -// -// Created by keepcoder on 20.02.14. -// Copyright (c) 2014 keepcoder. All rights reserved. -// - -#import "TMViewController.h" - -@interface NewConversationViewController : TMViewController -@property (nonatomic) int typeController; -typedef enum { - NewConversationActionWrite = 0, - NewConversationActionCreateGroup = 1, - NewConversationActionCreateSecretChat = 2, - NewConversationActionChoosePeople = 3, - NewConversationActionAddContact = 4, - NewConversationActionCreateBroadcast = 5 -} NewConversationAction; - -@property (nonatomic,strong) id chooseTarget; -@property (nonatomic,assign) SEL chooseSelector; - -@property (nonatomic,strong) NSArray *filter; - --(void)setChooseButtonTitle:(NSString *)title; - - -@property (nonatomic,assign) NewConversationAction currentAction; - --(void)actionAddChatMembers:(TL_chatFull *)chat completionHandler:(void (^)(NSArray *users))completionHandler; - --(void)actionGoBack; --(void)actionCreateChat; --(void)actionCreateSecretChat; -@end diff --git a/TelegramTest/NewConversationViewController.m b/TelegramTest/NewConversationViewController.m deleted file mode 100644 index e996afd4..00000000 --- a/TelegramTest/NewConversationViewController.m +++ /dev/null @@ -1,929 +0,0 @@ -// -// NewConversationViewController.m -// Telegram P-Edition -// -// Created by keepcoder on 20.02.14. -// Copyright (c) 2014 keepcoder. All rights reserved. -// - -#import "NewConversationViewController.h" -#import "NewConversationTableView.h" -#import "NewConversationRowItem.h" -#import "NewConversationRowView.h" -#import "SearchViewController.h" -#import "Telegram.h" -#import "TMImageView.h" -#import "NSString+Extended.h" -#import "TLPeer+Extensions.h" -#import "SelectUsersTableView.h" -#import "AddContactView.h" - -@interface NewConversationViewController () -@property (nonatomic, strong) TMSearchTextField *searchTextField; -@property (nonatomic,strong) SelectUsersTableView *tableView; -@property (nonatomic,strong) SearchViewController *searchViewController; -@property (nonatomic,strong) TMTextField *textField; -@property (nonatomic,strong) TMView *defaultTopView; -@property (nonatomic,strong) TMView *createChatTopView; -@property (nonatomic,strong) TMView *createSecretChatTopView; -@property (nonatomic,strong) TMView *addMembersBottomView; -@property (nonatomic,strong) TMView *broadcastBottomView; - -@property (nonatomic,strong) TMView *currentTopView; -@property (nonatomic,strong) TMView *currentBottomView; - -@property (nonatomic,strong) TMView *bottomViewForGroupChat; -@property (nonatomic,strong) TMView *prevTopView; - - -@property (nonatomic,strong) TMView *addContactContainerView; - -@property (nonatomic,strong) BTRButton *addMembersButton; -@property (nonatomic,strong) BTRButton *createBroadcastButton; -@property (nonatomic,strong) NSString *chooseMembersTitle; - -@property (nonatomic,strong) TMButton *createButton; -@property (nonatomic,strong) NSString *chatTitle; -@property (nonatomic,strong) NSString *lastSearchText; - -@property (nonatomic,strong) NSDictionary *actionsOffset; -@property (nonatomic,assign) NSSize normalSize; -@property (nonatomic,assign) NSSize addContactSize; -@end - -@implementation NewConversationViewController - - - --(void)loadView { - [super loadView]; - - - self.normalSize = self.view.frame.size; - self.addContactSize = NSMakeSize(self.view.frame.size.width, 240); - - self.actionsOffset = @{@(0):@(194),@(1):@(160),@(2):@(160),@(3):@(40),@(4):@(240),@(5):@(160)}; - - - [self.view setBackgroundColor:[NSColor whiteColor]]; - - self.createChatTopView = [self topViewForGroupChat:[_actionsOffset[@(NewConversationActionCreateGroup)] intValue]]; - self.createSecretChatTopView = [self topViewForSecretChat:[_actionsOffset[@(NewConversationActionCreateSecretChat)] intValue]]; - self.defaultTopView = [self topViewForDefault:[_actionsOffset[@(NewConversationActionWrite)] intValue]]; - self.bottomViewForGroupChat = [self createBottomViewForGroupChat]; - - - self.addContactContainerView = [self createAddContactView:[_actionsOffset[@(NewConversationActionAddContact)] intValue]]; - - - self.addMembersBottomView = [self createBottomViewForAddMembers]; - self.broadcastBottomView = [self createBottomViewForBroadcast]; - - - if(self.currentAction == NewConversationActionCreateGroup) { - self.currentTopView = self.createChatTopView; - self.currentBottomView = self.bottomViewForGroupChat; - } - - if(self.currentAction == NewConversationActionCreateSecretChat) { - self.currentTopView = self.createSecretChatTopView; - } - - if(self.currentAction == NewConversationActionWrite) { - self.currentTopView = self.defaultTopView; - } - - if(self.currentAction == NewConversationActionChoosePeople) { - self.currentBottomView = self.addMembersBottomView; - } - - if(self.currentAction == NewConversationActionAddContact) { - self.currentTopView = self.addContactContainerView; - } - - - - [self.defaultTopView setHidden:NO]; - [self.createSecretChatTopView setHidden:YES]; - [self.createChatTopView setHidden:YES]; - [self.addContactContainerView setHidden:YES]; - - - [self.view addSubview:self.defaultTopView]; - [self.view addSubview:self.createChatTopView]; - [self.view addSubview:self.createSecretChatTopView]; - [self.view addSubview:self.bottomViewForGroupChat]; - [self.view addSubview:self.addMembersBottomView]; - [self.view addSubview:self.addContactContainerView]; - [self.view addSubview:self.broadcastBottomView]; - - - - - - self.searchTextField = [[TMSearchTextField alloc] initWithFrame:NSMakeRect(14, self.view.bounds.size.height-[_actionsOffset[@(self.currentAction)] intValue]+6, self.view.bounds.size.width-30, 30)]; - self.searchTextField.delegate = self; - [self.view addSubview:self.searchTextField]; - - - - - NSRect frame = NSMakeRect(0, 0, self.view.bounds.size.width, self.view.bounds.size.height-[_actionsOffset[@(self.currentAction)] intValue]); - - self.tableView = [[SelectUsersTableView alloc] initWithFrame:frame]; - [self.tableView setAutoresizesSubviews:YES]; - [self.tableView setAutoresizingMask:NSViewHeightSizable | NSViewWidthSizable]; - - - self.currentAction = self.currentAction; - self.tableView.exceptions = self.filter; - [self.tableView readyContacts]; - - weakify(); - [self.tableView setMultipleCallback:^(NSArray *contacts) { - - TLContact *contact = contacts[0]; - if(strongSelf.currentAction == NewConversationActionCreateSecretChat) { - [MessageSender startEncryptedChat:contact.user callback:^{ - - }]; - [strongSelf.popover close]; - } - - if(strongSelf.currentAction == NewConversationActionWrite) { - - [strongSelf.popover close]; - - TLDialog *dialog = contact.user.dialog; - if(!dialog) { - [[Storage manager] dialogByPeer:contact.user.n_id completeHandler:^(TLDialog *dialog, TLMessage *message) { - - if(dialog) - [[DialogsManager sharedManager] add:@[dialog]]; - else - dialog = [[DialogsManager sharedManager] createDialogForUser:contact.user]; - - if(message) - [[MessagesManager sharedManager] add:@[message]]; - - - [[Telegram sharedInstance] showMessagesFromDialog:dialog sender:strongSelf]; - - }]; - } else { - [[Telegram sharedInstance] showMessagesFromDialog:contact.user.dialog sender:strongSelf]; - } - } - }]; - - - [self.tableView setMultipleCallback:^(NSArray *contacts) { - if(strongSelf.currentAction == NewConversationActionCreateGroup) { - [strongSelf checkCreateButton]; - [strongSelf updateTopTitle]; - } - - if(strongSelf.currentAction == NewConversationActionCreateBroadcast) { - [strongSelf checkCreateBroadcastButton]; - [strongSelf updateTopTitle]; - } - }]; - - [self.view addSubview:self.tableView.containerView]; - - - - self.prevTopView = self.defaultTopView; - - if(self.currentAction != NewConversationActionWrite) - [self startAnimation:NewConversationActionWrite animated:NO]; - - -} - - --(void)setChooseButtonTitle:(NSString *)title { - self.chooseMembersTitle = title; -} - --(BOOL)isGroupRow:(NSUInteger)row item:(TMRowItem *)item { - return NO; -} - --(void)dealloc { - [Notification removeObserver:self]; -} - - - -- (TMButton *)backButton { - NSImage *backImage = image_boxBack(); - TMButton *back = [[TMButton alloc] initWithFrame:NSZeroRect]; - [back setAutoresizesSubviews:YES]; - [back setAutoresizingMask:NSViewMinXMargin]; - [back setTarget:self selector:@selector(actionGoBack)]; - [back setText:NSLocalizedString(@"Profile.Back", nil)]; - [back setTextFont:[NSFont fontWithName:@"HelveticaNeue" size:14]]; - NSSize size = NSMakeSize([back sizeOfText].width+24, [back sizeOfText].height); - [back setFrameSize:size]; - [back setFrameOrigin:NSMakePoint(self.view.bounds.size.width - size.width - 25, 24)]; - - [back setTextColor:LINK_COLOR forState:TMButtonNormalState]; - [back setTextColor:NSColorFromRGB(0x467fb0) forState:TMButtonNormalHoverState]; - [back setTextColor:NSColorFromRGB(0x2e618c) forState:TMButtonPressedState]; - - TMImageView *imgView = [[TMImageView alloc] initWithFrame:NSMakeRect(0, roundf(size.height/2-backImage.size.height/2-2), backImage.size.width, backImage.size.height)]; - imgView.image = backImage; - - [back addSubview:imgView]; - - return back; - -} - - -- (TMView *)createAddContactView:(int)topOffset { - static float rightOffet = 0.0; - float width = self.view.bounds.size.width - rightOffet; - - TMView *topView = [[TMView alloc] initWithFrame:NSMakeRect(0, self.addContactSize.height-topOffset, width, topOffset)]; - [topView setBackgroundColor:[NSColor whiteColor]]; - [topView setAutoresizesSubviews:YES]; - [topView setAutoresizingMask:NSViewMaxYMargin]; - - - - TMButton *back = [self backButton]; - - [back setFrame:NSMakeRect(15, topView.frame.size.height-back.frame.size.height-15, back.frame.size.width, back.frame.size.height)]; - - - TMTextField *topTextField = [[TMTextField alloc] initWithFrame:NSMakeRect(0, topView.frame.size.height-back.frame.size.height-15, topView.frame.size.width, 20)]; - - - - [topTextField setStringValue:NSLocalizedString(@"NewConversation.AddContact", nil)]; - [topTextField setEditable:NO]; - [topTextField setSelectable:NO]; - [topTextField setBordered:NO]; - [topTextField setFont:[NSFont fontWithName:@"HelveticaNeue" size:14]]; - [topTextField setTextColor:NSColorFromRGB(0x333333)]; - [topTextField setAlignment:NSCenterTextAlignment]; - - - - AddContactView *addContactView = [[AddContactView alloc] initWithFrame:NSMakeRect(0, 0, topView.frame.size.width, topOffset-40)]; - addContactView.controller = self; - - - - [topView addSubview:topTextField]; - - [topView addSubview:back]; - - - [topView addSubview:addContactView]; - - - return topView; - -} - --(TMView *)topViewForDefault:(int)topOffset { - - static float rightOffet = 0; - float width = self.view.bounds.size.width - rightOffet; - - TMView *topView = [[TMView alloc] initWithFrame:NSMakeRect(0, self.view.bounds.size.height - topOffset, width, topOffset)]; - [topView setBackgroundColor:[NSColor whiteColor]]; - [topView setAutoresizesSubviews:YES]; - [topView setAutoresizingMask:NSViewMinYMargin]; - - - - dispatch_block_t separatorDraw = ^ { - [NSColorFromRGB(0xf4f4f4) set]; - NSRectFill(NSMakeRect(15, 0, topView.frame.size.width-30, 1)); - }; - - int offsetY = topView.frame.size.height - 39; - - NSImage *gImage = image_group(); - TMButton *createChatButton = [[TMButton alloc] initWithFrame:NSMakeRect(0, offsetY, topView.frame.size.width, 40)]; - [createChatButton setAutoresizesSubviews:YES]; - [createChatButton setAutoresizingMask:NSViewMinXMargin]; - [createChatButton setTarget:self selector:@selector(actionCreateChat)]; - [createChatButton setText:NSLocalizedString(@"NewConversation.CreateGroupChat", nil)]; - [createChatButton setTextFont:[NSFont fontWithName:@"HelveticaNeue" size:14]]; - - [createChatButton setTextOffset:NSMakeSize(0, 3)]; - - // [createChatButton setDrawBlock:separatorDraw]; - - NSSize size = NSMakeSize([createChatButton sizeOfText].width+30, [createChatButton sizeOfText].height); - [createChatButton setTextColor:BLUE_UI_COLOR forState:TMButtonNormalState]; - [createChatButton setTextColor:NSColorFromRGB(0x467fb0) forState:TMButtonNormalHoverState]; - [createChatButton setTextColor:NSColorFromRGB(0x2e618c) forState:TMButtonPressedState]; - TMImageView *gImageView = [[TMImageView alloc] initWithFrame:NSMakeRect(roundf((topView.frame.size.width-size.width)/2) - 4, roundf(size.height/2-gImage.size.height/2+11), gImage.size.width, gImage.size.height)]; - gImageView.image = gImage; - - [createChatButton addSubview:gImageView]; - - - [topView addSubview:createChatButton]; - - offsetY-=(createChatButton.frame.size.height)+1; - - - - - - - - NSImage *bImage = [NSImage imageNamed:@"newConversationBroadcast"]; - TMButton *broadcastButton = [[TMButton alloc] initWithFrame:NSMakeRect(0, offsetY, topView.frame.size.width, 35)]; - [broadcastButton setAutoresizesSubviews:YES]; - [broadcastButton setAutoresizingMask:NSViewMinXMargin]; - [broadcastButton setTarget:self selector:@selector(actionCreateBroadcast)]; - [broadcastButton setText:NSLocalizedString(@"NewConversation.CreateBroadcast", nil)]; - [broadcastButton setTextFont:[NSFont fontWithName:@"HelveticaNeue" size:15]]; - size = NSMakeSize([broadcastButton sizeOfText].width+20, [broadcastButton sizeOfText].height); - - - [broadcastButton setTextOffset:NSMakeSize(0, 3)]; - [broadcastButton setTextColor:BLUE_UI_COLOR forState:TMButtonNormalState]; - [broadcastButton setTextColor:NSColorFromRGB(0x467fb0) forState:TMButtonNormalHoverState]; - [broadcastButton setTextColor:NSColorFromRGB(0x2e618c) forState:TMButtonPressedState]; - - TMImageView *bImageView = [[TMImageView alloc] initWithFrame:NSMakeRect(roundf((topView.frame.size.width-size.width)/2) - 8, roundf(size.height/2-bImage.size.height/2+9), bImage.size.width, bImage.size.height)]; - bImageView.image = bImage; - - [broadcastButton addSubview:bImageView]; - - // [broadcastButton setDrawBlock:separatorDraw]; - - - [topView addSubview:broadcastButton]; - - offsetY-=(broadcastButton.frame.size.height)+6; - - - NSImage *sImage = image_secret(); - TMButton *createSecretChatButton = [[TMButton alloc] initWithFrame:NSMakeRect(0, offsetY, topView.frame.size.width, 41)]; - [createSecretChatButton setAutoresizesSubviews:YES]; - [createSecretChatButton setAutoresizingMask:NSViewMinXMargin]; - [createSecretChatButton setTarget:self selector:@selector(actionCreateSecretChat)]; - [createSecretChatButton setText:NSLocalizedString(@"NewConversation.CreateSecretChat", nil)]; - [createSecretChatButton setTextFont:[NSFont fontWithName:@"HelveticaNeue" size:14]]; - - [createSecretChatButton setTextOffset:NSMakeSize(0, 2)]; - - // [createSecretChatButton setDrawBlock:separatorDraw]; - - size = NSMakeSize([createSecretChatButton sizeOfText].width+20, [createSecretChatButton sizeOfText].height); - - [createSecretChatButton setTextColor:NSColorFromRGB(0x40b158) forState:TMButtonNormalState]; - [createSecretChatButton setTextColor:NSColorFromRGB(0x458b80) forState:TMButtonNormalHoverState]; - [createSecretChatButton setTextColor:NSColorFromRGB(0x458b99) forState:TMButtonPressedState]; - - TMImageView *sImageView = [[TMImageView alloc] initWithFrame:NSMakeRect(roundf((topView.frame.size.width-size.width)/2) - 4, roundf(size.height/2-sImage.size.height/2+12), sImage.size.width, sImage.size.height)]; - sImageView.image = sImage; - - [createSecretChatButton addSubview:sImageView]; - - - - [topView addSubview:createSecretChatButton]; - - - - - - offsetY-=(createSecretChatButton.frame.size.height)-4; - - - - NSImage *cImage = image_addContact(); - TMButton *addContactButton = [[TMButton alloc] initWithFrame:NSMakeRect(0, offsetY, topView.frame.size.width, 35)]; - [addContactButton setAutoresizesSubviews:YES]; - [addContactButton setAutoresizingMask:NSViewMinXMargin]; - [addContactButton setTarget:self selector:@selector(actionAddContact)]; - [addContactButton setText:NSLocalizedString(@"NewConversation.AddContact", nil)]; - [addContactButton setTextFont:[NSFont fontWithName:@"HelveticaNeue" size:15]]; - size = NSMakeSize([addContactButton sizeOfText].width+20, [addContactButton sizeOfText].height); - [addContactButton setTextOffset:NSMakeSize(0, 2)]; - - [addContactButton setTextColor:BLUE_UI_COLOR forState:TMButtonNormalState]; - [addContactButton setTextColor:NSColorFromRGB(0x467fb0) forState:TMButtonNormalHoverState]; - [addContactButton setTextColor:NSColorFromRGB(0x2e618c) forState:TMButtonPressedState]; - - TMImageView *cImageView = [[TMImageView alloc] initWithFrame:NSMakeRect(roundf((topView.frame.size.width-size.width)/2) - 4, roundf(size.height/2-cImage.size.height/2+7), cImage.size.width, cImage.size.height)]; - cImageView.image = cImage; - - [addContactButton addSubview:cImageView]; - - - - [topView addSubview:addContactButton]; - - - return topView; -} - - -- (void) searchFieldTextChange:(NSString*)searchString { - [self.tableView search:searchString]; -} - --(TMView *)createBottomViewForAddMembers { - TMView *bottomView = [[TMView alloc] initWithFrame:NSMakeRect(0, 0, self.view.bounds.size.width, 40)]; - - [bottomView setBackgroundColor:NSColorFromRGB(0xfafafa)]; - [bottomView setAutoresizesSubviews:YES]; - [bottomView setAutoresizingMask:NSViewMinYMargin]; - - - self.addMembersButton = [[BTRButton alloc] initWithFrame:NSMakeRect(0, 2, self.view.bounds.size.width, 40)]; - - - weakify(); - [self.addMembersButton addBlock:^(BTRControlEvents events) { - - NSArray *selected = [strongSelf.tableView selectedItems]; - - if([strongSelf.chooseTarget respondsToSelector:strongSelf.chooseSelector]) { - - [strongSelf.chooseTarget performSelectorOnMainThread:strongSelf.chooseSelector withObject:selected waitUntilDone:YES]; - - } - - [strongSelf.popover close]; - - } forControlEvents:BTRControlEventMouseDownInside]; - - - - - [self.addMembersButton setTitleFont:[NSFont fontWithName:@"HelveticaNeue" size:13] forControlState:BTRControlStateNormal]; - [self.addMembersButton setCursor:[NSCursor pointingHandCursor] forControlState:BTRControlStateHover]; - - [self.addMembersButton setTitle:self.chooseMembersTitle forControlState:BTRControlStateNormal]; - - - [self.addMembersButton setTitleColor:DARK_BLUE forControlState:BTRControlStateNormal]; - - [self.addMembersButton setTitleColor:NSColorFromRGB(0xcccccc) forControlState:BTRControlStateDisabled]; - - [bottomView addSubview:self.addMembersButton]; - - - return bottomView; -} - - --(TMView *)createBottomViewForBroadcast { - - TMView *bottomView = [[TMView alloc] initWithFrame:NSMakeRect(0, -40, self.view.bounds.size.width, 40)]; - - [bottomView setBackgroundColor:NSColorFromRGB(0xfafafa)]; - [bottomView setAutoresizesSubviews:YES]; - [bottomView setAutoresizingMask:NSViewMinYMargin]; - - - weakify(); - - [bottomView setDrawBlock:^{ - [NSColorFromRGB(0xf1f1f1) setFill]; - NSRectFill(NSMakeRect(0, strongSelf.broadcastBottomView.frame.size.height-1, strongSelf.broadcastBottomView.frame.size.width, 1)); - }]; - - self.createBroadcastButton = [[BTRButton alloc] initWithFrame:NSMakeRect(0, 2, self.view.bounds.size.width, 40)]; - - - [self.createBroadcastButton addBlock:^(BTRControlEvents events) { - - - NSMutableArray *participants = [[NSMutableArray alloc] init]; - - [strongSelf.tableView.selectedItems enumerateObjectsUsingBlock:^( SelectUserItem * obj, NSUInteger idx, BOOL *stop) { - [participants addObject:@(obj.user.n_id)]; - }]; - - TL_broadcast *broadcast = [TL_broadcast createWithN_id:arc4random() participants:participants title:@"" date:[[MTNetwork instance] getTime]]; - - TL_conversation *conversation = [TL_conversation createWithPeer:[TL_peerBroadcast createWithChat_id:broadcast.n_id] top_message:0 unread_count:0 last_message_date:[[MTNetwork instance] getTime] notify_settings:[TL_peerNotifySettingsEmpty create] last_marked_message:0 top_message_fake:0 last_marked_date:[[MTNetwork instance] getTime] sync_message_id:0]; - - [[DialogsManager sharedManager] add:@[conversation]]; - [conversation save]; - - [[BroadcastManager sharedManager] add:@[broadcast]]; - - int fakeId = [MessageSender getFakeMessageId]; - - - TL_localMessageService *msg = [TL_localMessageService createWithN_id:fakeId flags:TGOUTMESSAGE from_id:[UsersManager currentUserId] to_id:conversation.peer date:[[MTNetwork instance] getTime] action:[TL_messageActionEncryptedChat createWithTitle:NSLocalizedString(@"MessageAction.ServiceMessage.CreatedBroadcast", nil)] fakeId:fakeId randomId:rand_long() dstate:DeliveryStateNormal]; - - [MessagesManager addAndUpdateMessage:msg]; - - - [[Telegram rightViewController] showByDialog:conversation sender:strongSelf]; - - [strongSelf.popover close]; - - } forControlEvents:BTRControlEventMouseDownInside]; - - - - - [self.createBroadcastButton setTitleFont:[NSFont fontWithName:@"HelveticaNeue" size:13] forControlState:BTRControlStateNormal]; - [self.createBroadcastButton setTitleFont:[NSFont fontWithName:@"HelveticaNeue" size:13] forControlState:BTRControlStateDisabled]; - [self.createBroadcastButton setCursor:[NSCursor pointingHandCursor] forControlState:BTRControlStateHover]; - - [self.createBroadcastButton setTitle:NSLocalizedString(@"Broadcast.Create", nil) forControlState:BTRControlStateNormal]; - - [self.createBroadcastButton setTitle:NSLocalizedString(@"Broadcast.Create", nil) forControlState:BTRControlStateDisabled]; - - [self.createBroadcastButton setTitleColor:DARK_BLUE forControlState:BTRControlStateNormal]; - - [self.createBroadcastButton setTitleColor:NSColorFromRGB(0xcccccc) forControlState:BTRControlStateDisabled]; - - [bottomView addSubview:self.createBroadcastButton]; - - - return bottomView; -} - - - --(TMView *)topViewForGroupChat:(int)topOffset { - static float rightOffet = 0.0; - float width = self.view.bounds.size.width - rightOffet; - - TMView *topView = [[TMView alloc] initWithFrame:NSMakeRect(0, self.view.frame.size.height-topOffset, width, topOffset)]; - [topView setBackgroundColor:[NSColor whiteColor]]; - [topView setAutoresizesSubviews:YES]; - [topView setAutoresizingMask:NSViewMaxYMargin]; - - - TMButton *back = [self backButton]; - - - [back setFrame:NSMakeRect(15, topView.frame.size.height-back.frame.size.height-15, back.frame.size.width, back.frame.size.height)]; - - - TMTextField *topTextField = [[TMTextField alloc] initWithFrame:NSMakeRect(0, topView.frame.size.height-back.frame.size.height-15, topView.frame.size.width, 20)]; - - - - [topTextField setStringValue:NSLocalizedString(@"NewConversation.CreatingGroupChat", nil)]; - [topTextField setEditable:NO]; - [topTextField setSelectable:NO]; - [topTextField setBordered:NO]; - [topTextField setFont:[NSFont fontWithName:@"HelveticaNeue" size:14]]; - [topTextField setTextColor:NSColorFromRGB(0x333333)]; - [topTextField setAlignment:NSCenterTextAlignment]; - - - - self.textField = topTextField; - - [self updateTopTitle]; - - [topView addSubview:topTextField]; - - [topView addSubview:back]; - return topView; -} - - - --(TMView *)topViewForSecretChat:(int)topOffset { - static float rightOffet = 0.0; - float width = self.view.bounds.size.width - rightOffet; - - TMView *topView = [[TMView alloc] initWithFrame:NSMakeRect(0, self.view.frame.size.height-topOffset, width, topOffset)]; - [topView setBackgroundColor:[NSColor whiteColor]]; - [topView setAutoresizesSubviews:YES]; - [topView setAutoresizingMask:NSViewMaxYMargin]; - - - TMButton *back = [self backButton]; - - - - [back setFrame:NSMakeRect(15, topView.frame.size.height-back.frame.size.height-15, back.frame.size.width, back.frame.size.height)]; - - - TMTextField *topTextField = [[TMTextField alloc] initWithFrame:NSMakeRect(0, topView.frame.size.height-back.frame.size.height-15, topView.frame.size.width, 20)]; - - - - [topTextField setStringValue:NSLocalizedString(@"NewConversation.CreatingSecretChat", nil)]; - [topTextField setEditable:NO]; - [topTextField setSelectable:NO]; - [topTextField setBordered:NO]; - [topTextField setFont:[NSFont fontWithName:@"HelveticaNeue" size:14]]; - [topTextField setTextColor:NSColorFromRGB(0x333333)]; - [topTextField setAlignment:NSCenterTextAlignment]; - - [topView addSubview:topTextField]; - - [topView addSubview:back]; - - [back setFrame:NSMakeRect(15, topView.frame.size.height-back.frame.size.height-15, back.frame.size.width, back.frame.size.height)]; - - return topView; -} - --(void)createGroupChat { - NSArray *selected = [self.tableView selectedItems]; - - if(selected.count == 0 || self.chatTitle.length == 0) - return; - - - - NSMutableArray *array = [[NSMutableArray alloc] init]; - for(SelectUserItem* item in selected) { - if(!item.user.type != TLUserTypeSelf) { - TL_inputUserContact *_contact = [TL_inputUserContact createWithUser_id:item.user.n_id]; - [array addObject:_contact]; - } - - } - - - [RPCRequest sendRequest:[TLAPI_messages_createChat createWithUsers:array title:self.chatTitle] successHandler:^(RPCRequest *request, TLUpdates *response) { - - TL_localMessage *msg = [TL_localMessage convertReceivedMessage:(TLMessage *) ( [response.updates[1] message])]; - - [[FullChatManager sharedManager] performLoad:msg.conversation.chat.n_id callback:^(TLChatFull *fullChat) { - [[Telegram sharedInstance] showMessagesFromDialog:((TL_localMessage *)response.message).conversation sender:self]; - }]; - - - } errorHandler:^(RPCRequest *request, RpcError *error) { - - }]; - - [self.popover close]; - -} - - --(TMView *)createBottomViewForGroupChat { - TMView *bottomView = [[TMView alloc] initWithFrame:NSMakeRect(0, -60, self.view.bounds.size.width, 60)]; - - [bottomView setBackgroundColor:NSColorFromRGB(0xfafafa)]; - [bottomView setAutoresizesSubviews:YES]; - [bottomView setAutoresizingMask:NSViewMinYMargin]; - - TMGrowingTextView *textView = [[TMGrowingTextView alloc] init]; - [textView setEditable:YES]; - [textView setRichText:NO]; - [textView setMode:TMGrowingModeSingleLine]; - [textView setLimit:34]; - textView.growingDelegate = self; - // [textView setBackgroundImage:msg_input()]; - [textView setPlaceholderString:NSLocalizedString(@"NewConversation.GroupNamePlaceholder", nil)]; - self.createButton = [[TMButton alloc] initWithFrame:NSZeroRect]; - - [self.createButton setTarget:self selector:@selector(createGroupChat)]; - [self.createButton setText:NSLocalizedString(@"NewConversation.CreateGroup", nil)]; - [self.createButton setTextFont:[NSFont fontWithName:@"HelveticaNeue-Medium" size:12]]; - NSSize size = [self.createButton sizeOfText]; - [self.createButton setFrameSize:size]; - [self.createButton setFrameOrigin:NSMakePoint(bottomView.bounds.size.width - size.width - 25, 24)]; - - - __block TMView *strong = bottomView; - - [bottomView setDrawBlock:^ { - [GRAY_BORDER_COLOR set]; - NSRectFill(NSMakeRect(0, strong.frame.size.height-1, strong.frame.size.width, 1)); - }]; - - [bottomView addSubview:self.createButton]; - - textView.containerView.frame = NSMakeRect(15, roundf(bottomView.frame.size.height/2-15), bottomView.frame.size.width-100, 30); - [textView textDidChange:nil]; - [bottomView addSubview:textView.containerView]; - - return bottomView; -} - --(void)TMGrowingTextViewHeightChanged:(id)textView height:(int)height cleared:(BOOL)isCleared { - -} - --(void)TMGrowingTextViewFirstResponder:(id)textView isFirstResponder:(BOOL)isFirstResponder { - -} - --(BOOL)TMGrowingTextViewCommandOrControlPressed:(id)textView isCommandPressed:(BOOL)isCommandPressed { - [self createGroupChat]; - return YES; -} - - -- (void) TMGrowingTextViewTextDidChange:(TMGrowingTextView *)textView { - self.chatTitle = [textView.stringValue trim]; - [self checkCreateButton]; -} - --(void)checkCreateBroadcastButton { - [self.createBroadcastButton setEnabled:[self.tableView selectedItems].count > 0]; - } - --(void)checkCreateButton -{ - [self.addMembersButton setEnabled:[self.tableView selectedItems].count > 0]; - - if(self.chatTitle.length > 0 && [self.tableView selectedItems].count > 0) { - [self.createButton setTextColor:LINK_COLOR forState:TMButtonNormalState]; - [self.createButton setTextColor:NSColorFromRGB(0x467fb0) forState:TMButtonNormalHoverState]; - [self.createButton setTextColor:NSColorFromRGB(0x2e618c) forState:TMButtonPressedState]; - [self.createButton setDisabled:NO]; - - } else { - [self.createButton setTextColor:NSColorFromRGB(0xaeaeae) forState:TMButtonNormalState]; - [self.createButton setDisabled:YES]; - } - - -} - - - --(void)actionGoBack { - [self reset]; - - self.prevTopView = self.currentTopView; - NewConversationAction prevAction = self.currentAction; - self.currentTopView = self.defaultTopView; - self.currentAction = NewConversationActionWrite; - - [self startAnimation:prevAction animated:YES]; -} - --(void)actionAddContact { -// [self.popover close]; -// alert(@":(", @"Not working, wait please :)"); - - [self reset]; - - self.prevTopView = self.currentTopView; - NewConversationAction prevAction = self.currentAction; - self.currentTopView = self.addContactContainerView; - self.currentAction = NewConversationActionAddContact; - - [self startAnimation:prevAction animated:YES]; - -} - - --(void)actionCreateChat { - [self reset]; - - self.prevTopView = self.currentTopView; - NewConversationAction prevAction = self.currentAction; - self.currentTopView = self.createChatTopView; - - - self.currentAction = NewConversationActionCreateGroup; - self.tableView.selectLimit = maxChatUsers(); - [self.textField setStringValue:NSLocalizedString(@"NewConversation.CreatingGroupChat", nil)]; - self.currentBottomView = self.bottomViewForGroupChat; - [self startAnimation:prevAction animated:YES]; -} - --(void)actionCreateBroadcast { - [self reset]; - [self checkCreateBroadcastButton]; - self.prevTopView = self.currentTopView; - NewConversationAction prevAction = self.currentAction; - self.currentTopView = self.createChatTopView; - self.currentAction = NewConversationActionCreateBroadcast; - self.tableView.selectLimit = maxBroadcastUsers(); - [self.textField setStringValue:NSLocalizedString(@"NewConversation.CreatingBroadcast", nil)]; - self.currentBottomView = self.broadcastBottomView; - [self startAnimation:prevAction animated:YES]; -} - --(void)actionCreateSecretChat { - [self reset]; - - self.prevTopView = self.currentTopView; - - self.currentTopView = self.createSecretChatTopView; - NewConversationAction prevAction = self.currentAction; - self.currentAction = NewConversationActionCreateSecretChat; - [self startAnimation:prevAction animated:YES]; - -} - --(void)startAnimation:(NewConversationAction)prevAction animated:(BOOL)animated { - - - [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context){ - [context setDuration:animated && self.currentAction != NewConversationActionAddContact && prevAction != NewConversationActionAddContact ? 0.2 : 0]; - - [self fadeView:self.prevTopView alpha:0.0f]; - - - [self.prevTopView setHidden:prevAction == NewConversationActionAddContact]; - - [self.currentBottomView setHidden:self.currentAction == NewConversationActionAddContact ? YES : NO]; - - - [self.currentTopView setHidden:NO]; - - [self fadeView:self.currentTopView alpha:1.0f]; - - - [self.tableView.containerView setHidden:self.currentAction == NewConversationActionAddContact]; - [self.searchTextField setHidden:self.currentAction == NewConversationActionAddContact]; - - - [self.currentTopView becomeFirstResponder]; - - self.popover.animates = NO; - [self.popover setContentSize:self.currentAction == NewConversationActionAddContact ? self.addContactSize : self.normalSize]; - - - - [[self.currentBottomView animator] setFrameOrigin:NSMakePoint(0, self.currentAction == NewConversationActionCreateBroadcast || self.currentAction == NewConversationActionCreateGroup || self.currentAction == NewConversationActionChoosePeople ? 0 : -self.currentBottomView.frame.size.height)]; - - NSPoint searchPos = self.currentAction == NewConversationActionWrite ? NSMakePoint(self.searchTextField.frame.origin.x, self.view.bounds.size.height-[_actionsOffset[@(self.currentAction)] intValue]+6) : NSMakePoint(self.searchTextField.frame.origin.x, self.view.bounds.size.height-self.currentTopView.frame.size.height+83); - - - if(self.currentAction == NewConversationActionChoosePeople) { - searchPos = NSMakePoint(self.searchTextField.frame.origin.x, self.view.bounds.size.height-self.currentTopView.frame.size.height-[_actionsOffset[@(self.currentAction)] intValue]); - } - - int marginY = self.currentAction == NewConversationActionWrite || self.currentAction == NewConversationActionCreateSecretChat ? 0 : self.currentBottomView.frame.size.height; - - - int f = self.currentAction == NewConversationActionWrite ? 190 : (self.currentAction == NewConversationActionChoosePeople ? 40 : 80); - - id search = prevAction == NewConversationActionAddContact ? self.searchTextField : [self.searchTextField animator]; - id table = prevAction == NewConversationActionAddContact ? self.tableView.containerView : [self.tableView.containerView animator]; - - [table setFrameSize:NSMakeSize(self.tableView.containerView.frame.size.width, self.view.frame.size.height-f-marginY)]; - - NSPoint tablePos = NSMakePoint(0, marginY ); - - - - - [search setFrameOrigin:searchPos]; - [table setFrameOrigin:tablePos]; - - - - } completionHandler:^{ - [self.prevTopView setHidden:YES]; - - }]; - - -} - - --(void)reset { - [self updateTopTitle]; -} - --(void)fadeView:(NSView *)superview alpha:(float)alpha { - [[superview animator] setAlphaValue:alpha]; - for (NSView *view in superview.subviews) { - [[view animator] setAlphaValue:alpha]; - } -} - - --(void)updateTopTitle { - NSArray *selected = [self.tableView selectedItems]; - - NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] init]; - - - [attr appendString:self.currentAction == NewConversationActionCreateBroadcast ? NSLocalizedString(@"NewConversation.CreatingBroadcast", nil) : NSLocalizedString(@"NewConversation.CreatingGroupChat", nil) withColor:NSColorFromRGB(0x333333)]; - NSRange range = [attr appendString:[NSString stringWithFormat:@" - %lu/%d",selected.count,self.tableView.selectLimit] withColor:DARK_GRAY]; - [attr setFont:[NSFont fontWithName:@"HelveticaNeue" size:12] forRange:range]; - [attr setAlignment:NSCenterTextAlignment range:NSMakeRange(0, attr.length-1)]; - [self.textField setAttributedStringValue:attr]; - [self.textField setAlignment:NSCenterTextAlignment]; -} - - --(void)setCurrentAction:(NewConversationAction)currentAction { - self->_currentAction = currentAction; - -// [self.bottomViewForGroupChat setHidden:currentAction != NewConversationActionCreateGroup]; - [self.addMembersBottomView setHidden:currentAction != NewConversationActionChoosePeople]; - - // self.tableView.selectType = (currentAction == NewConversationActionCreateBroadcast) || (currentAction == NewConversationActionCreateGroup) || (currentAction == NewConversationActionChoosePeople) ? SelectUsersTypeMultiple : SelectUsersTypeSingle; -} - -@end diff --git a/TelegramTest/NewLoginViewController.m b/TelegramTest/NewLoginViewController.m index dda5f90b..5f23b991 100644 --- a/TelegramTest/NewLoginViewController.m +++ b/TelegramTest/NewLoginViewController.m @@ -68,7 +68,7 @@ - (void)loadView { TMTextField *applicationNameTextField = [TMTextField defaultTextField]; applicationNameTextField.stringValue = NSLocalizedString(@"App.Name", nil); - applicationNameTextField.font = [NSFont fontWithName:@"HelveticaNeue-Light" size:28]; + applicationNameTextField.font = TGSystemLightFont(28); applicationNameTextField.textColor = NSColorFromRGB(0x333333); [applicationNameTextField sizeToFit]; applicationNameTextField.wantsLayer = IS_RETINA; @@ -88,7 +88,7 @@ - (void)loadView { // [applicationInfoAttributedString appendString:@".\n" withColor:NSColorFromRGB(0x9b9b9b)]; // [applicationInfoAttributedString appendString:NSLocalizedString(@"Login.Description", nil) withColor:NSColorFromRGB(0x9b9b9b)]; - [applicationInfoAttributedString setFont:[NSFont fontWithName:@"HelveticaNeue" size:13] forRange:applicationInfoAttributedString.range]; + [applicationInfoAttributedString setFont:TGSystemFont(13) forRange:applicationInfoAttributedString.range]; NSMutableParagraphStyle *applicationInfoParagraphStyle = [[NSMutableParagraphStyle alloc] init]; [applicationInfoParagraphStyle setLineSpacing:2]; @@ -223,7 +223,6 @@ - (void)signIn { if([error.error_msg isEqualToString:@"SESSION_PASSWORD_NEEDED"]) { - return; } @@ -256,7 +255,7 @@ - (void)signIn { r.phone_code_hash = self.phone_code_hash; r.phone_code = self.SMSCodeView.code; [self.navigationViewController pushViewController:r animated:YES]; - }]; + } alwayContinueWithErrorContext:YES]; } - (void)setIsPhoneRegistered:(BOOL)isPhoneRegistered { @@ -383,7 +382,7 @@ - (void)getSMSCodeSendRequest { self.isCodeExpired = NO; - + [TMViewController showModalProgress]; [RPCRequest sendRequest:[TLAPI_auth_sendCode createWithPhone_number:self.phoneNumber sms_type:5 api_id:API_ID api_hash:API_HASH lang_code:@"en"] successHandler:^(RPCRequest *request, TL_auth_sentCode *response) { @@ -404,6 +403,8 @@ - (void)getSMSCodeSendRequest { [self performSMSCodeTextFieldShowAnimation]; + [TMViewController hideModalProgressWithSuccess]; + } errorHandler:^(RPCRequest *request, RpcError *error) { if(error.error_code == PHONE_MIGRATE_X) { [self getSMSCodeSendRequest]; @@ -412,11 +413,13 @@ - (void)getSMSCodeSendRequest { error.error_msg = NSLocalizedString(@"Login.InvalidPhoneNumber", nil); } + [TMViewController hideModalProgress]; + [self.getSMSCodeView loadingSuccess]; [self.getSMSCodeView showErrorWithText:error.error_msg]; [self.countrySelectorView performBlocking:NO]; } - }]; + } alwayContinueWithErrorContext:YES]; } -(void)sendSmsCode { @@ -433,7 +436,7 @@ -(void)sendSmsCode { } } errorHandler:^(RPCRequest *request, RpcError *error) { - }]; + } alwayContinueWithErrorContext:YES]; } - (void)startTimer:(int)time { @@ -545,7 +548,7 @@ - (void)sendCallRequest { } errorHandler:^(RPCRequest *request, RpcError *error) { if([strongSelf.phone_code_hash isEqualToString:phone_code_hash]) [self.SMSCodeView changeCallTextFieldString:NSLocalizedString(@"Login.Error", nil)]; - }]; + } alwayContinueWithErrorContext:YES]; } - (void)textField:(id)textField handleURLClick:(NSString *)url { diff --git a/TelegramTest/NoMessagesView.m b/TelegramTest/NoMessagesView.m index 85f80398..8b643442 100644 --- a/TelegramTest/NoMessagesView.m +++ b/TelegramTest/NoMessagesView.m @@ -19,6 +19,8 @@ @interface NoMessagesView () @property (nonatomic,strong) NSAttributedString *defAttrString; +@property (nonatomic,strong) TMAvatarImageView *avatarImageView; + @end @implementation NoMessagesView @@ -27,6 +29,12 @@ - (id)initWithFrame:(NSRect)frame { self = [super initWithFrame:frame]; if (self) { + + _avatarImageView = [TMAvatarImageView standartUserInfoAvatar]; + + [self addSubview:_avatarImageView]; + + [self setBackgroundColor:NSColorFromRGB(0xffffff)]; [self setAutoresizesSubviews:YES]; [self setAutoresizingMask:NSViewHeightSizable | NSViewWidthSizable]; @@ -98,17 +106,17 @@ - (NSAttributedString *)buildSecretString { [string appendString:[NSString stringWithFormat:descFormat,chat.peerUser.first_name] withColor:NSColorFromRGB(0x9b9b9b)]; - [string setFont:[NSFont fontWithName:@"HelveticaNeue" size:13] forRange:NSMakeRange(0, string.length)]; + [string setFont:TGSystemFont(13) forRange:NSMakeRange(0, string.length)]; [string addAttribute:NSParagraphStyleAttributeName value:subParagraphStyle2 range:NSMakeRange(0, string.length)]; - [string setFont:[NSFont fontWithName:@"HelveticaNeue-Medium" size:13] forRange:NSMakeRange([descFormat rangeOfString:@"%1$@"].location, self.conversation.encryptedChat.peerUser.first_name.length)]; + [string setFont:TGSystemMediumFont(13) forRange:NSMakeRange([descFormat rangeOfString:@"%1$@"].location, self.conversation.encryptedChat.peerUser.first_name.length)]; NSRange range = [string appendString:NSLocalizedString(@"Secret.join.secret_chats",nil) withColor:NSColorFromRGB(0x9b9b9b)]; - [string setFont:[NSFont fontWithName:@"HelveticaNeue" size:13] forRange:range]; + [string setFont:TGSystemFont(13) forRange:range]; [string addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:range]; @@ -133,7 +141,7 @@ - (NSAttributedString *)buildSecretString { [subString appendString:NSLocalizedString(@"Secret.join.desc4", nil) withColor:NSColorFromRGB(0x9b9b9b)]; - [subString setFont:[NSFont fontWithName:@"HelveticaNeue" size:13] forRange:NSMakeRange(0, subString.length)]; + [subString setFont:TGSystemFont(13) forRange:NSMakeRange(0, subString.length)]; [subString addAttribute:NSParagraphStyleAttributeName value:subParagraphStyle range:NSMakeRange(0, subString.length)]; @@ -149,11 +157,22 @@ -(void)setConversation:(TL_conversation *)conversation { assert([NSThread isMainThread]); + [_avatarImageView updateWithConversation:conversation]; + _conversation = conversation; // && conversation.top_message == -1 [self.field removeFromSuperview]; + dispatch_block_t updateSize = ^{ + NSSize size = [self.field isKindOfClass:[TMTextField class]] ? [((TMTextField *)_field).attributedStringValue sizeForTextFieldForWidth:NSWidth(self.frame) - 100] : [self.field.attributedString coreTextSizeForTextFieldForWidth:NSWidth(self.frame) - 100]; + + [self.field setFrameSize:size]; + [self setFrameSize:self.frame.size]; + }; + + [_avatarImageView setHidden:conversation.type != DialogTypeUser || conversation.user.isBot]; + if(conversation.type == DialogTypeSecretChat) { self.field = [TMTextField defaultTextField]; @@ -171,8 +190,8 @@ -(void)setConversation:(TL_conversation *)conversation { [[FullUsersManager sharedManager] loadUserFull:conversation.user callback:^(TL_userFull *userFull) { if(userFull.bot_info.n_description.length > 0) { - TL_localMessageService *service = [TL_localMessageService createWithN_id:0 flags:0 from_id:0 to_id:_conversation.peer date:0 action:[TL_messageActionBotDescription createWithTitle:userFull.bot_info.n_description] fakeId:0 randomId:rand_long() dstate:DeliveryStateNormal]; - + TL_localMessageService *service = [TL_localMessageService createWithFlags:0 n_id:0 from_id:0 to_id:_conversation.peer date:0 action:[TL_messageActionBotDescription createWithTitle:userFull.bot_info.n_description] fakeId:0 randomId:rand_long() dstate:DeliveryStateNormal]; + NSMutableAttributedString *attr = [[MessagesUtils serviceAttributedMessage:service forAction:service.action] mutableCopy]; [attr detectAndAddLinks:URLFindTypeAll]; @@ -183,6 +202,7 @@ -(void)setConversation:(TL_conversation *)conversation { [self.field setAttributedString:_defAttrString]; } + updateSize(); }]; @@ -196,17 +216,30 @@ -(void)setConversation:(TL_conversation *)conversation { self.progress.usesThreadedAnimation = NO; + updateSize(); - NSSize size = [self.field isKindOfClass:[TMTextField class]] ? [((TMTextField *)_field).attributedStringValue sizeForTextFieldForWidth:NSWidth(self.frame) - 100] : [self.field.attributedString coreTextSizeForTextFieldForWidth:NSWidth(self.frame) - 100]; - - [self.field setFrameSize:size]; - [self.field setCenterByView:self]; } -(void)setFrameSize:(NSSize)newSize { [super setFrameSize:newSize]; - [self.field setCenterByView:self]; + + if(_avatarImageView.isHidden) { + [self.field setCenterByView:self]; + } else { + [_avatarImageView setCenterByView:self]; + + + [_avatarImageView setCenteredXByView:self]; + [_field setCenteredXByView:self]; + + int totalHeight = NSHeight(_avatarImageView.frame) + NSHeight(_field.frame) + 10; + + [_field setFrameOrigin:NSMakePoint(NSMinX(_field.frame), roundf((newSize.height - totalHeight)/2))]; + [_avatarImageView setFrameOrigin:NSMakePoint(NSMinX(_avatarImageView.frame) , roundf((newSize.height - totalHeight)/2 + NSHeight(_field.frame) + 10))]; + } + + } -(void)setHidden:(BOOL)flag { @@ -215,7 +248,7 @@ -(void)setHidden:(BOOL)flag { if(self.conversation) [self setConversation:self.conversation]; - + [super setHidden:flag]; } @@ -233,9 +266,12 @@ -(void)setLoading:(BOOL)isLoading { assert([NSThread isMainThread]); [self.progress setHidden:!isLoading || self.conversation.type == DialogTypeSecretChat]; - [self.field setHidden:isLoading]; + + + [self.field setHidden:!self.progress.isHidden]; + [_avatarImageView setHidden:_avatarImageView.isHidden || !self.progress.isHidden]; if(isLoading) { [self.progress startAnimation:self]; diff --git a/TelegramTest/NotSelectedDialogsViewController.m b/TelegramTest/NotSelectedDialogsViewController.m index 8e41b1c9..02a1a28c 100644 --- a/TelegramTest/NotSelectedDialogsViewController.m +++ b/TelegramTest/NotSelectedDialogsViewController.m @@ -7,7 +7,6 @@ // #import "NotSelectedDialogsViewController.h" -#import "TMGifImageView.h" #import #import "TGCTextView.h" @interface NotSelectedDialogsViewController() @@ -44,7 +43,7 @@ - (void) loadView { NSMutableParagraphStyle *mutParaStyle=[[NSMutableParagraphStyle alloc] init]; [mutParaStyle setAlignment:NSCenterTextAlignment]; [mutParaStyle setLineSpacing:3]; - [textField setAttributedStringValue:[[NSAttributedString alloc] initWithString:NSLocalizedString(@"Conversation.SelectConversation", nil) attributes:@{NSForegroundColorAttributeName: DARK_GRAY, NSFontAttributeName: [NSFont fontWithName:@"HelveticaNeue" size:14]}]]; + [textField setAttributedStringValue:[[NSAttributedString alloc] initWithString:NSLocalizedString(@"Conversation.SelectConversation", nil) attributes:@{NSForegroundColorAttributeName: DARK_GRAY, NSFontAttributeName: TGSystemFont(14)}]]; [textField sizeToFit]; [textField setDrawsBackground:NO]; diff --git a/TelegramTest/Notification.h b/TelegramTest/Notification.h index 2b1e8aa4..bbb06fbd 100644 --- a/TelegramTest/Notification.h +++ b/TelegramTest/Notification.h @@ -18,6 +18,7 @@ extern NSString *const AUTH_COMPLETE; extern NSString *const MESSAGE_SEND_EVENT; // событие проихсодит когда сообщение вроде как отправилось, просто поставлено в очередь на отправку extern NSString *const MESSAGE_SENT_EVENT; // событие проихсодит когда сообщение отправено extern NSString *const MESSAGE_RECEIVE_EVENT; // событие: пришло сообщение +extern NSString *const MESSAGE_UPDATE_MESSAGE_ID; extern NSString *const MESSAGE_READ_EVENT; // сообщение прочитенно сообщение extern NSString *const MESSAGE_CHANGED_DSTATE; // поменялось состояние отправления сообщения @@ -81,6 +82,11 @@ extern NSString *const UPDATE_WEB_PAGES; extern NSString *const UPDATE_READ_CONTENTS; extern NSString *const UPDATE_AUDIO_PLAYER_STATE; +extern NSString *const UPDATE_MESSAGE_ENTITIES; +extern NSString *const UPDATE_MESSAGE_GROUP_HOLE; +extern NSString *const UPDATE_MESSAGE_VIEWS; + +extern NSString *const CHAT_FLAGS_UPDATED; extern NSString *const KEY_PREVIEW_OBJECT; @@ -98,6 +104,7 @@ extern NSString *const KEY_BROADCAST; extern NSString *const KEY_PHOTO; extern NSString *const KEY_MESSAGE_ID_LIST; extern NSString *const KEY_MESSAGE_LIST; +extern NSString *const KEY_DATA; extern NSString *const KEY_DIALOG; extern NSString *const KEY_POSITION; extern NSString *const KEY_DIALOGS; @@ -105,9 +112,12 @@ extern NSString *const KEY_MEDIA; extern NSString *const KEY_PEER_ID; extern NSString *const KEY_IS_MUTE; extern NSString *const KEY_PARTICIPANTS; - +extern NSString *const KEY_GROUP_HOLE; extern NSString *const KEY_WEBPAGE; - +extern NSString *const KEY_MESSAGE_ID; +extern NSString *const KEY_RANDOM_ID; +extern NSString *const KEY_ORDER; +extern NSString *const KEY_STICKERSET; extern NSString *const KEY_PRIVACY; extern NSString *const PRIVACY_UPDATE; extern NSString *const LOGOUT_EVENT; @@ -116,6 +126,13 @@ extern NSString *const LOGOUT_EVENT; extern NSString *const LAYOUT_CHANGED; extern NSString *const UNREAD_COUNT_CHANGED; + +extern NSString *const STICKERS_REORDER; +extern NSString *const STICKERS_NEW_PACK; +extern NSString *const STICKERS_ALL_CHANGED; + + + + (void)addObserver:(id)target selector:(SEL)selector name:(NSString *)name; + (void)removeObserver:(id)target; @@ -130,6 +147,8 @@ extern NSString *const UNREAD_COUNT_CHANGED; + (void)perform:(NSString *)name object:(id)object; + (void)perform:(NSString *)name data:(NSDictionary *)data; ++(void)performOnStageQueue:(NSString *)name object:(id)object; ++(void)performOnStageQueue:(NSString *)name data:(NSDictionary *)data; extern NSString *const USER_ACTIVITY_CONVERSATION; diff --git a/TelegramTest/Notification.m b/TelegramTest/Notification.m index c60d7d35..eed738fc 100644 --- a/TelegramTest/Notification.m +++ b/TelegramTest/Notification.m @@ -19,6 +19,7 @@ @implementation Notification NSString *const MESSAGE_SEND_EVENT = @"MESSAGE_SEND_EVENT"; NSString *const MESSAGE_SENT_EVENT = @"MESSAGE_SENT_EVENT"; NSString *const MESSAGE_RECEIVE_EVENT = @"MESSAGE_RECEIVE_EVENT"; +NSString *const MESSAGE_UPDATE_MESSAGE_ID = @"MESSAGE_UPDATE_MESSAGE_ID"; NSString *const MESSAGE_READ_EVENT = @"MESSAGE_READ_EVENT"; NSString *const MESSAGE_DELETE_EVENT = @"MESSAGE_DELETE_EVENT"; @@ -82,11 +83,15 @@ @implementation Notification NSString *const UPDATE_WEB_PAGES = @"UPDATE_WEB_PAGES"; NSString *const UPDATE_READ_CONTENTS = @"UPDATE_READ_CONTENTS"; NSString *const UPDATE_AUDIO_PLAYER_STATE = @"UPDATE_AUDIO_PLAYER_STATE"; +NSString *const UPDATE_MESSAGE_ENTITIES = @"UPDATE_MESSAGE_ENTITIES"; +NSString *const UPDATE_MESSAGE_GROUP_HOLE = @"UPDATE_MESSAGE_GROUP"; +NSString *const UPDATE_MESSAGE_VIEWS = @"UPDATE_MESSAGE_VIEWS"; NSString *const UPDATE_NEW_AUTH = @"UPDATE_NEW_AUTH"; - NSString *const FULLCHAT_LOADED = @"FULLCHAT_LOADED"; +NSString *const CHAT_FLAGS_UPDATED = @"CHAT_FLAGS_UPDATED"; + NSString *const KEY_PREVIEW_OBJECT = @"preview_object"; NSString *const KEY_USER = @"user"; @@ -103,6 +108,7 @@ @implementation Notification NSString *const KEY_PHOTO = @"photo"; NSString *const KEY_MESSAGE_ID_LIST = @"message_id_list"; NSString *const KEY_MESSAGE_LIST = @"message_list"; +NSString *const KEY_DATA = @"randomdata"; NSString *const KEY_DIALOG = @"dialog"; NSString *const KEY_POSITION = @"position"; NSString *const KEY_DIALOGS = @"dialogs"; @@ -110,9 +116,12 @@ @implementation Notification NSString *const KEY_PEER_ID = @"peer_id"; NSString *const KEY_IS_MUTE = @"is_mute"; NSString *const KEY_PARTICIPANTS = @"participants"; - +NSString *const KEY_GROUP_HOLE = @"group_hole"; +NSString *const KEY_MESSAGE_ID = @"KEY_MESSAGE_ID"; +NSString *const KEY_RANDOM_ID = @"KEY_RANDOM_ID"; NSString *const KEY_WEBPAGE = @"WEBPAGE"; - +NSString *const KEY_ORDER = @"order"; +NSString *const KEY_STICKERSET = @"sticker_set"; NSString *const LOGOUT_EVENT = @"logout"; NSString *const KEY_PRIVACY = @"key_privacy"; @@ -121,6 +130,11 @@ @implementation Notification NSString *const LAYOUT_CHANGED = @"TGAPPLICATIONLAYOUTCHANGED"; NSString *const UNREAD_COUNT_CHANGED = @"TGUNREADCOUNTCHANGED"; +NSString *const STICKERS_REORDER = @"stickers_reoder"; +NSString *const STICKERS_NEW_PACK = @"stickers_new_pack";; +NSString *const STICKERS_ALL_CHANGED = @"stickers_all_changed"; + + +(NSNotificationCenter *)center { static NSNotificationCenter *center; static dispatch_once_t onceToken; @@ -146,14 +160,9 @@ +(void)removeObserver:(id)target { } -+(void)perform:(NSString *)name object:(id)object { - - [[self center] postNotificationNameOnMainThread:name object:object userInfo:object ? @{name:object} : nil]; -} - + (NSString *) notificationNameByDialog:(TL_conversation *)dialog action:(NSString *) action { - return [NSString stringWithFormat:@"%@_%d_%d_%d", action, dialog.type, dialog.peer.chat_id, dialog.peer.user_id]; + return [NSString stringWithFormat:@"%@_%d_%d", action, dialog.type, dialog.peer_id]; } + (NSString *)notificationForUser:(TLUser *)user action:(NSString *)action { @@ -174,6 +183,20 @@ +(void)perform:(NSString *)name data:(NSDictionary *)data { [[self center] postNotificationNameOnMainThread:name object:nil userInfo:data]; } ++(void)perform:(NSString *)name object:(id)object { + + [[self center] postNotificationNameOnMainThread:name object:object userInfo:object ? @{name:object} : nil]; +} + ++(void)performOnStageQueue:(NSString *)name object:(id)object { + + [[self center] postNotificationNameOnStageThread:name object:object userInfo:object ? @{name:object} : nil]; +} + ++(void)performOnStageQueue:(NSString *)name data:(NSDictionary *)data { + [[self center] postNotificationNameOnStageThread:name object:nil userInfo:data]; +} + NSString *const USER_ACTIVITY_CONVERSATION = @"org.telegram.conversation"; diff --git a/TelegramTest/NotificationConversationRowView.m b/TelegramTest/NotificationConversationRowView.m index 6e5cbb0a..6bc8e3c2 100644 --- a/TelegramTest/NotificationConversationRowView.m +++ b/TelegramTest/NotificationConversationRowView.m @@ -24,11 +24,11 @@ @implementation NotificationConversationRowView -(instancetype)initWithFrame:(NSRect)frameRect { if(self = [super initWithFrame:frameRect]) { - _avatarImageView = [[TMAvatarImageView alloc] initWithFrame:NSMakeRect(100, 5, 30, 30)]; + _avatarImageView = [[TMAvatarImageView alloc] initWithFrame:NSMakeRect(30, 5, 30, 30)]; [self addSubview:_avatarImageView]; - _nameTextField = [[TMNameTextField alloc] initWithFrame:NSMakeRect(140, 13, NSWidth(frameRect) - 100, 20)]; + _nameTextField = [[TMNameTextField alloc] initWithFrame:NSMakeRect(70, 13, NSWidth(frameRect) - 100, 20)]; [_nameTextField setSelector:@selector(dialogTitle)]; [self addSubview:_nameTextField]; @@ -72,14 +72,14 @@ - (void)drawRect:(NSRect)dirtyRect { [DIALOG_BORDER_COLOR set]; - NSRectFill(NSMakeRect(100, 0, NSWidth(dirtyRect) - 200, 1)); + NSRectFill(NSMakeRect(30, 0, NSWidth(dirtyRect) - 60, 1)); } -(void)setFrameSize:(NSSize)newSize { [super setFrameSize:newSize]; - [_nameTextField setFrameSize:NSMakeSize(newSize.width - 250 - NSWidth(_notificationSwitch.frame), 20)]; - [_notificationSwitch setFrameOrigin:NSMakePoint(newSize.width - 100 - NSWidth(_notificationSwitch.frame), 7)]; + [_nameTextField setFrameSize:NSMakeSize(newSize.width - 110 - NSWidth(_notificationSwitch.frame), 20)]; + [_notificationSwitch setFrameOrigin:NSMakePoint(newSize.width - 30 - NSWidth(_notificationSwitch.frame), 7)]; } @@ -87,6 +87,8 @@ -(void)redrawRow { [super redrawRow]; + [_notificationSwitch setEnabled:[SettingsArchiver checkMaskedSetting:PushNotifications]]; + NotificationConversationRowItem *item = (NotificationConversationRowItem *) [self rowItem]; [_avatarImageView updateWithConversation:item.conversation]; @@ -94,6 +96,8 @@ -(void)redrawRow { [_notificationSwitch setOn:!item.conversation.isMute animated:NO]; + + } @end diff --git a/TelegramTest/NotificationSettingsViewController.m b/TelegramTest/NotificationSettingsViewController.m index da5d7768..1414c468 100644 --- a/TelegramTest/NotificationSettingsViewController.m +++ b/TelegramTest/NotificationSettingsViewController.m @@ -48,7 +48,9 @@ -(void)loadView { self.searchView = [[TGSearchRowView alloc] initWithFrame:NSMakeRect(0, 0, NSWidth(self.view.frame), 50)]; - [self.searchView setXOffset:100]; + [self.searchView setXOffset:30]; + + self.searchItem.height = 40; [self.searchView setDelegate:self]; @@ -63,7 +65,7 @@ -(void)searchFieldTextChange:(NSString *)searchString { NSArray *sorted = self.items; - if(self.tableView.count <= 5) + if(self.tableView.count < 6) { return; } @@ -71,7 +73,7 @@ -(void)searchFieldTextChange:(NSString *)searchString { if(searchString.length > 0) { sorted = [self.items filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(NotificationConversationRowItem *evaluatedObject, NSDictionary *bindings) { - return evaluatedObject.conversation.type == DialogTypeChat ? [evaluatedObject.conversation.chat.title searchInStringByWordsSeparated:searchString] : [evaluatedObject.conversation.user.fullName searchInStringByWordsSeparated:searchString]; + return evaluatedObject.class == [NotificationConversationRowItem class] && (evaluatedObject.conversation.type == DialogTypeChat ? [evaluatedObject.conversation.chat.title searchInStringByWordsSeparated:searchString] : [evaluatedObject.conversation.user.fullName searchInStringByWordsSeparated:searchString]); }]]; } @@ -79,7 +81,7 @@ -(void)searchFieldTextChange:(NSString *)searchString { - NSRange range = NSMakeRange(5, self.tableView.list.count-5); + NSRange range = NSMakeRange(6, self.tableView.list.count-6); NSArray *list = [self.tableView.list subarrayWithRange:range]; @@ -90,7 +92,7 @@ -(void)searchFieldTextChange:(NSString *)searchString { [self.tableView removeRowsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:range] withAnimation:self.tableView.defaultAnimation]; - [self.tableView insert:sorted startIndex:5 tableRedraw:YES]; + [self.tableView insert:sorted startIndex:6 tableRedraw:YES]; } @@ -109,7 +111,7 @@ -(void)configure { [_tableView removeAllItems:YES]; - GeneralSettingsRowItem *resetAllNotifications = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(GeneralSettingsRowItem *item) { + GeneralSettingsRowItem *resetAllNotifications = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(TGGeneralRowItem *item) { confirm(appName(), NSLocalizedString(@"NotificationSettings.ResetAllNotificationsConfirm", nil), ^{ @@ -117,15 +119,19 @@ -(void)configure { [RPCRequest sendRequest:[TLAPI_account_resetNotifySettings create] successHandler:^(id request, id response) { - [self.tableView.list enumerateObjectsUsingBlock:^(NotificationConversationRowItem *obj, NSUInteger idx, BOOL *stop) { - - [obj.conversation updateNotifySettings:[TL_peerNotifySettings createWithMute_until:0 sound:obj.conversation.notify_settings.sound show_previews:obj.conversation.notify_settings.show_previews events_mask:obj.conversation.notify_settings.events_mask]]; - - TL_conversation *original = [[DialogsManager sharedManager] find:obj.conversation.peer_id]; - - - [original updateNotifySettings:[TL_peerNotifySettings createWithMute_until:0 sound:obj.conversation.notify_settings.sound show_previews:obj.conversation.notify_settings.show_previews events_mask:obj.conversation.notify_settings.events_mask]]; + [SettingsArchiver addSetting:PushNotifications]; + + [self.items enumerateObjectsUsingBlock:^(NotificationConversationRowItem *obj, NSUInteger idx, BOOL *stop) { + if([obj isKindOfClass:[NotificationConversationRowItem class]]) { + [obj.conversation updateNotifySettings:[TL_peerNotifySettings createWithMute_until:0 sound:obj.conversation.notify_settings.sound show_previews:obj.conversation.notify_settings.show_previews events_mask:obj.conversation.notify_settings.events_mask]]; + + TL_conversation *original = [[DialogsManager sharedManager] find:obj.conversation.peer_id]; + + + [original updateNotifySettings:[TL_peerNotifySettings createWithMute_until:0 sound:obj.conversation.notify_settings.sound show_previews:obj.conversation.notify_settings.show_previews events_mask:obj.conversation.notify_settings.events_mask]]; + } + }]; @@ -140,34 +146,47 @@ -(void)configure { }, nil); - } description:NSLocalizedString(@"NotificationSettings.ResetAllNotifications", nil) height:82 stateback:^id(GeneralSettingsRowItem *item) { + } description:NSLocalizedString(@"NotificationSettings.ResetAllNotifications", nil) height:42 stateback:^id(TGGeneralRowItem *item) { return @""; }]; - GeneralSettingsRowItem *messagePreview = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSwitch callback:^(GeneralSettingsRowItem *item) { + GeneralSettingsRowItem *messagePreview = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSwitch callback:^(TGGeneralRowItem *item) { [SettingsArchiver addOrRemoveSetting:MessagesNotificationPreview]; - } description:NSLocalizedString(@"NotificationSettings.MessagePreview", nil) height:42 stateback:^id(GeneralSettingsRowItem *item) { + } description:NSLocalizedString(@"NotificationSettings.MessagePreview", nil) height:42 stateback:^id(TGGeneralRowItem *item) { - return @([SettingsArchiver checkMaskedSetting:MessagesNotificationPreview]); + return @([SettingsArchiver checkMaskedSetting:MessagesNotificationPreview] && [SettingsArchiver checkMaskedSetting:PushNotifications]); }]; - GeneralSettingsRowItem *soundNotification = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeChoice callback:^(GeneralSettingsRowItem *item) { + [messagePreview setEnabled:[SettingsArchiver checkMaskedSetting:PushNotifications]]; + + + GeneralSettingsRowItem *soundEffects = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSwitch callback:^(TGGeneralRowItem *item) { - } description:NSLocalizedString(@"Settings.NotificationTone", nil) height:42 stateback:^id(GeneralSettingsRowItem *item) { - return NSLocalizedString([SettingsArchiver soundNotification], nil); + [SettingsArchiver addOrRemoveSetting:PushNotifications]; + + [messagePreview setEnabled:[SettingsArchiver checkMaskedSetting:PushNotifications]]; + + [self.tableView reloadData]; + + } description:NSLocalizedString(@"Notifications", nil) height:82 stateback:^id(TGGeneralRowItem *item) { + return @([SettingsArchiver checkMaskedSetting:PushNotifications]); }]; - + GeneralSettingsRowItem *soundNotification = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeChoice callback:^(TGGeneralRowItem *item) { + + } description:NSLocalizedString(@"Settings.NotificationTone", nil) height:42 stateback:^id(TGGeneralRowItem *item) { + return NSLocalizedString([SettingsArchiver soundNotification], nil); + }]; NSMenu *menu = [[NSMenu alloc] initWithTitle:@""]; @@ -194,19 +213,19 @@ -(void)configure { soundNotification.menu = menu; - GeneralSettingsBlockHeaderItem *description = [[GeneralSettingsBlockHeaderItem alloc] initWithObject:NSLocalizedString(@"NotificationSettings.Description", nil)]; - - description.height = 82; - description.isFlipped = YES; + GeneralSettingsBlockHeaderItem *description = [[GeneralSettingsBlockHeaderItem alloc] initWithString:NSLocalizedString(@"NotificationSettings.Description", nil) height:82 flipped:YES]; - [self.tableView addItem:resetAllNotifications tableRedraw:NO]; + [self.tableView addItem:soundEffects tableRedraw:NO]; + [self.tableView addItem:messagePreview tableRedraw:NO]; [self.tableView addItem:soundNotification tableRedraw:NO]; + + [self.tableView addItem:resetAllNotifications tableRedraw:NO]; [self.tableView addItem:description tableRedraw:NO]; [self.tableView addItem:self.searchItem tableRedraw:NO]; @@ -214,7 +233,7 @@ -(void)configure { [self.tableView reloadData]; - [[Storage manager] dialogsWithOffset:0 limit:1000 completeHandler:^(NSArray *d, NSArray *m) { + [[Storage manager] dialogsWithOffset:0 limit:1000 completeHandler:^(NSArray *d) { [ASQueue dispatchOnMainQueue:^{ @@ -235,14 +254,14 @@ -(void)insertAll:(NSArray *)all { all = [all filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.type != 2 && self.type != 3"]]; - [all enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - - [self.tableView addItem:[[NotificationConversationRowItem alloc] initWithObject:obj] tableRedraw:NO]; + [all enumerateObjectsUsingBlock:^(TL_conversation *obj, NSUInteger idx, BOOL *stop) { + if(!obj.isInvisibleChannel) + [self.tableView addItem:[[NotificationConversationRowItem alloc] initWithObject:obj] tableRedraw:NO]; }]; - if(all.count > 5) - _items = [self.tableView.list subarrayWithRange:NSMakeRange(5, self.tableView.list.count - 5)]; + if(all.count > 6) + _items = [self.tableView.list subarrayWithRange:NSMakeRange(5, self.tableView.list.count - 6)]; [self.tableView reloadData]; diff --git a/TelegramTest/OnlineNotificationManager.h b/TelegramTest/OnlineNotificationManager.h deleted file mode 100644 index 0134a3b2..00000000 --- a/TelegramTest/OnlineNotificationManager.h +++ /dev/null @@ -1,17 +0,0 @@ -// -// OnlineNotificationManager.h -// Messenger for Telegram -// -// Created by keepcoder on 28.04.14. -// Copyright (c) 2014 keepcoder. All rights reserved. -// - -#import - -@interface OnlineNotificationManager : NSObject - -+(void) addUser:(TLUser *)user; - -+(void)removeUser:(TLUser *)user; - -@end diff --git a/TelegramTest/OnlineNotificationManager.m b/TelegramTest/OnlineNotificationManager.m deleted file mode 100644 index 808cd5c7..00000000 --- a/TelegramTest/OnlineNotificationManager.m +++ /dev/null @@ -1,83 +0,0 @@ -// -// OnlineNotificationManager.m -// Messenger for Telegram -// -// Created by keepcoder on 28.04.14. -// Copyright (c) 2014 keepcoder. All rights reserved. -// - -#import "OnlineNotificationManager.h" -#import "TGTimer.h" - -@interface OnlineNotificationManager () -@property (nonatomic,strong) NSMutableArray *users; -@property (nonatomic,strong) TGTimer *timer; -@end - -@implementation OnlineNotificationManager - -- (void)addUser:(TLUser *)user { - if(user && [_users indexOfObject:user] == NSNotFound) { - [_users addObject:user]; - } - - [self checkAndStart]; -} - -- (void)removeUser:(TLUser *)user { - [_users removeObject:user]; - - [self checkAndStart]; -} - -- (void)checkAndStart { - - if(_users.count > 0) { - if(!_timer) { - _timer = [[TGTimer alloc] initWithTimeout:60.0 repeat:YES completion:^{ - [self notify]; - } queue:[ASQueue globalQueue].nativeQueue]; - - [_timer start]; - } - - } else { - [_timer invalidate]; - _timer = nil; - } - - -} - -- (void)notify { - for (TLUser *user in _users) { - [Notification perform:USER_STATUS data:@{KEY_USER_ID: @(user.n_id)}]; - } -} - -+ (void)addUser:(TLUser *)user { - [ASQueue dispatchOnStageQueue:^{ - [[self instance] addUser:user]; - }]; - -} - -+ (void)removeUser:(TLUser *)user { - [ASQueue dispatchOnStageQueue:^{ - [[self instance] removeUser:user]; - }]; - -} - -+ (id)instance { - static OnlineNotificationManager * instance; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - - instance = [[[self class] alloc] init]; - instance.users = [[NSMutableArray alloc] init]; - }); - return instance; -} - -@end diff --git a/TelegramTest/PhoneChangeAlertController.m b/TelegramTest/PhoneChangeAlertController.m index 21255488..0d2a5e19 100644 --- a/TelegramTest/PhoneChangeAlertController.m +++ b/TelegramTest/PhoneChangeAlertController.m @@ -40,7 +40,7 @@ -(void)loadView { [attr appendString:[NSString stringWithFormat:textFormat,@"",@"",@"",@""] withColor:GRAY_TEXT_COLOR]; - [attr setFont:[NSFont fontWithName:@"HelveticaNeue" size:13] forRange:attr.range]; + [attr setFont:TGSystemFont(13) forRange:attr.range]; NSRange startRange = [textFormat rangeOfString:@"%1$@"]; NSRange endRange = [textFormat rangeOfString:@"%2$@"]; @@ -49,7 +49,7 @@ -(void)loadView { - [attr addAttribute:NSFontAttributeName value:[NSFont fontWithName:@"HelveticaNeue-Medium" size:13] range:NSMakeRange(startRange.location, length-4)]; + [attr addAttribute:NSFontAttributeName value:TGSystemMediumFont(13) range:NSMakeRange(startRange.location, length-4)]; startRange = [textFormat rangeOfString:@"%3$@"]; @@ -57,7 +57,7 @@ -(void)loadView { length = endRange.location - startRange.location; - [attr addAttribute:NSFontAttributeName value:[NSFont fontWithName:@"HelveticaNeue-Medium" size:13] range:NSMakeRange(startRange.location - 8, length-4)]; + [attr addAttribute:NSFontAttributeName value:TGSystemMediumFont(13) range:NSMakeRange(startRange.location - 8, length-4)]; // // diff --git a/TelegramTest/PhoneChangeConfirmController.m b/TelegramTest/PhoneChangeConfirmController.m index de1ae5c4..117f4cc8 100644 --- a/TelegramTest/PhoneChangeConfirmController.m +++ b/TelegramTest/PhoneChangeConfirmController.m @@ -32,9 +32,9 @@ - (void)loadView { self.smsCodeView = [[UserInfoShortTextEditView alloc] initWithFrame:NSMakeRect(100, 30, self.view.frame.size.width-200, 35)]; - self.smsCodeView.textView.font = [NSFont fontWithName:@"HelveticaNeue" size:13]; + self.smsCodeView.textView.font = TGSystemFont(13); - NSAttributedString *smsCodePlaceholder = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"PhoneChangeController.SmsPlaceholder", nil) attributes:@{NSFontAttributeName:[NSFont fontWithName:@"HelveticaNeue" size:13], NSForegroundColorAttributeName:GRAY_TEXT_COLOR}]; + NSAttributedString *smsCodePlaceholder = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"PhoneChangeController.SmsPlaceholder", nil) attributes:@{NSFontAttributeName:TGSystemFont(13), NSForegroundColorAttributeName:GRAY_TEXT_COLOR}]; [self.smsCodeView.textView.cell setPlaceholderAttributedString:smsCodePlaceholder]; diff --git a/TelegramTest/PhotoCollectionImageView.h b/TelegramTest/PhotoCollectionImageView.h index 2acadffd..bf472660 100644 --- a/TelegramTest/PhotoCollectionImageView.h +++ b/TelegramTest/PhotoCollectionImageView.h @@ -8,9 +8,13 @@ #import "TGImageView.h" #import "PhotoCollectionImageObject.h" -@interface PhotoCollectionImageView : TGImageView +@class TMCollectionPageController; + +@interface PhotoCollectionImageView : TGImageView + +@property (nonatomic,weak) TMCollectionPageController *controller; @end diff --git a/TelegramTest/PhotoCollectionImageView.m b/TelegramTest/PhotoCollectionImageView.m index db6b3a30..de79b049 100644 --- a/TelegramTest/PhotoCollectionImageView.m +++ b/TelegramTest/PhotoCollectionImageView.m @@ -51,9 +51,9 @@ -(void)mouseUp:(NSEvent *)theEvent { PhotoCollectionImageObject *obj = (PhotoCollectionImageObject *) self.object; - if([[Telegram rightViewController].collectionViewController isEditable]) { + if([_controller isEditable]) { - [[Telegram rightViewController].collectionViewController setSelected:![[Telegram rightViewController].collectionViewController isSelectedItem:obj] forItem:obj]; + [_controller setSelected:![_controller isSelectedItem:obj] forItem:obj]; [self setObject:obj]; @@ -63,7 +63,7 @@ -(void)mouseUp:(NSEvent *)theEvent { if([[(TL_localMessage *)obj.previewObject.media media] isKindOfClass:[TL_messageMediaPhoto class]]) { obj.previewObject.reservedObject = imageFromFile(locationFilePath(self.object.location, @"jpg")); - [[TGPhotoViewer viewer] show:obj.previewObject conversation:[Telegram rightViewController].collectionViewController.conversation]; + [[TGPhotoViewer viewer] show:obj.previewObject conversation:self.controller.conversation]; } else if([[(TL_localMessage *)obj.previewObject.media media] isKindOfClass:[TL_messageMediaVideo class]]) { [self checkAction]; } @@ -142,9 +142,9 @@ -(void)setObject:(PhotoCollectionImageObject *)object { TL_localMessage *msg = object.previewObject.media; - [self.selectButton setHidden:![[Telegram rightViewController].collectionViewController isEditable]]; + [self.selectButton setHidden:![_controller isEditable]]; - [self.selectButton setSelected:[[Telegram rightViewController].collectionViewController isSelectedItem:object]]; + [self.selectButton setSelected:[_controller isSelectedItem:object]]; [self.loaderView setHidden:YES]; [self.playImage setHidden:YES]; diff --git a/TelegramTest/PhotoHistoryFilter.h b/TelegramTest/PhotoHistoryFilter.h index d48c353e..53f58a60 100644 --- a/TelegramTest/PhotoHistoryFilter.h +++ b/TelegramTest/PhotoHistoryFilter.h @@ -7,7 +7,7 @@ // #import "HistoryFilter.h" - -@interface PhotoHistoryFilter : HistoryFilter +#import "CommonMediaHistoryFilter.h" +@interface PhotoHistoryFilter : CommonMediaHistoryFilter @end diff --git a/TelegramTest/PhotoHistoryFilter.m b/TelegramTest/PhotoHistoryFilter.m index d6b89898..bd7a9b4b 100644 --- a/TelegramTest/PhotoHistoryFilter.m +++ b/TelegramTest/PhotoHistoryFilter.m @@ -11,16 +11,6 @@ @implementation PhotoHistoryFilter -static NSMutableDictionary * messageItems; -static NSMutableDictionary * messageKeys; - --(id)initWithController:(ChatHistoryController *)controller { - if(self = [super initWithController:controller]) { - } - - return self; -} - -(int)type { return HistoryFilterPhoto; } @@ -29,87 +19,8 @@ +(int)type { return HistoryFilterPhoto; } -- (NSMutableDictionary *)messageKeys:(int)peer_id { - return [[self class] messageKeys:peer_id]; -} - -- (NSMutableArray *)messageItems:(int)peer_id { - return [[self class] messageItems:peer_id]; -} - -+ (NSMutableDictionary *)messageKeys:(int)peer_id { - - __block NSMutableDictionary *keys; - [ASQueue dispatchOnStageQueue:^{ - - keys = messageKeys[@(peer_id)]; - - if(!keys) - { - keys = [[NSMutableDictionary alloc] init]; - messageKeys[@(peer_id)] = keys; - } - - } synchronous:YES]; - - return keys; -} - -+ (NSMutableArray *)messageItems:(int)peer_id { - __block NSMutableArray *items; - - [ASQueue dispatchOnStageQueue:^{ - - items = messageItems[@(peer_id)]; - - if(!items) - { - items = [[NSMutableArray alloc] init]; - messageItems[@(peer_id)] = items; - } - - } synchronous:YES]; - - - - return items; -} - - -+(void)drop { - [ASQueue dispatchOnStageQueue:^{ - [messageKeys removeAllObjects]; - [messageItems removeAllObjects]; - }]; -} - - -+(void)initialize { - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - messageItems = [[NSMutableDictionary alloc] init]; - messageKeys = [[NSMutableDictionary alloc] init]; - - }); -} - --(void)remoteRequest:(BOOL)next peer_id:(int)peer_id callback:(void (^)(id response))callback { - - self.request = [RPCRequest sendRequest:[TLAPI_messages_search createWithPeer:[self.controller.conversation inputPeer] q:@"" filter:[TL_inputMessagesFilterPhotos create] min_date:0 max_date:0 offset:0 max_id:self.controller.max_id limit:(int)self.controller.selectLimit] successHandler:^(RPCRequest *request, id response) { - - - if(callback && self != nil) { - callback(response); - } - - } errorHandler:^(RPCRequest *request, RpcError *error) { - - if(callback) { - callback(nil); - } - - } timeout:10 queue:[ASQueue globalQueue].nativeQueue]; - +-(TLMessagesFilter *)messagesFilter { + return [TL_inputMessagesFilterPhotos create]; } -(NSString *)description { diff --git a/TelegramTest/PhotoTableItemView.m b/TelegramTest/PhotoTableItemView.m index 4d547753..49b082dc 100644 --- a/TelegramTest/PhotoTableItemView.m +++ b/TelegramTest/PhotoTableItemView.m @@ -59,13 +59,14 @@ -(void)redrawRow { [item.previewObjects enumerateObjectsUsingBlock:^(PhotoCollectionImageObject *obj, NSUInteger idx, BOOL *stop) { - TGImageView *imageView; + PhotoCollectionImageView *imageView; if(self.images.count > idx) { imageView = self.images[idx]; } else { imageView = [[PhotoCollectionImageView alloc] initWithFrame:NSZeroRect]; + imageView.controller = (TMCollectionPageController *) self.rowItem.table.viewController; [self.images addObject:imageView]; [self addSubview:imageView]; } diff --git a/TelegramTest/PhotoVideoHistoryFilter.h b/TelegramTest/PhotoVideoHistoryFilter.h index b54f1cc2..1df2e48c 100644 --- a/TelegramTest/PhotoVideoHistoryFilter.h +++ b/TelegramTest/PhotoVideoHistoryFilter.h @@ -7,7 +7,7 @@ // #import "HistoryFilter.h" - -@interface PhotoVideoHistoryFilter : HistoryFilter +#import "CommonMediaHistoryFilter.h" +@interface PhotoVideoHistoryFilter : CommonMediaHistoryFilter @end diff --git a/TelegramTest/PhotoVideoHistoryFilter.m b/TelegramTest/PhotoVideoHistoryFilter.m index f5daf21e..edc51ed1 100644 --- a/TelegramTest/PhotoVideoHistoryFilter.m +++ b/TelegramTest/PhotoVideoHistoryFilter.m @@ -10,19 +10,6 @@ #import "ChatHistoryController.h" @implementation PhotoVideoHistoryFilter - - -static NSMutableDictionary * messageItems; -static NSMutableDictionary * messageKeys; - --(id)initWithController:(ChatHistoryController *)controller { - if(self = [super initWithController:controller]) { - - } - return self; -} - - -(int)type { return HistoryFilterPhoto | HistoryFilterVideo; } @@ -31,85 +18,8 @@ +(int)type { return HistoryFilterPhoto | HistoryFilterVideo; } - -- (NSMutableDictionary *)messageKeys:(int)peer_id { - return [[self class] messageKeys:peer_id]; -} - -- (NSMutableArray *)messageItems:(int)peer_id { - return [[self class] messageItems:peer_id]; -} - -+ (NSMutableDictionary *)messageKeys:(int)peer_id { - - __block NSMutableDictionary *keys; - [ASQueue dispatchOnStageQueue:^{ - - keys = messageKeys[@(peer_id)]; - - if(!keys) - { - keys = [[NSMutableDictionary alloc] init]; - messageKeys[@(peer_id)] = keys; - } - - } synchronous:YES]; - - return keys; -} - -+ (NSMutableArray *)messageItems:(int)peer_id { - __block NSMutableArray *items; - - [ASQueue dispatchOnStageQueue:^{ - - items = messageItems[@(peer_id)]; - - if(!items) - { - items = [[NSMutableArray alloc] init]; - messageItems[@(peer_id)] = items; - } - - } synchronous:YES]; - - - - return items; -} -+(void)initialize { - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - messageItems = [[NSMutableDictionary alloc] init]; - messageKeys = [[NSMutableDictionary alloc] init]; - - }); -} - - -+(void)drop { - [ASQueue dispatchOnStageQueue:^{ - [messageKeys removeAllObjects]; - [messageItems removeAllObjects]; - }]; -} --(void)remoteRequest:(BOOL)next peer_id:(int)peer_id callback:(void (^)(id response))callback { - - self.request = [RPCRequest sendRequest:[TLAPI_messages_search createWithPeer:[self.controller.conversation inputPeer] q:@"" filter:[TL_inputMessagesFilterPhotoVideo create] min_date:0 max_date:0 offset:0 max_id:self.controller.max_id limit:(int)self.controller.selectLimit] successHandler:^(RPCRequest *request, id response) { - - - if(callback) { - callback(response); - } - - } errorHandler:^(RPCRequest *request, RpcError *error) { - - if(callback) { - callback(nil); - } - - } timeout:10 queue:[ASQueue globalQueue].nativeQueue]; - +-(TLMessagesFilter *)messagesFilter { + return [TL_inputMessagesFilterPhotoVideo create]; } -(NSString *)description { diff --git a/TelegramTest/PreviewObject.h b/TelegramTest/PreviewObject.h index f9bd3583..bd2408fd 100644 --- a/TelegramTest/PreviewObject.h +++ b/TelegramTest/PreviewObject.h @@ -13,6 +13,9 @@ @property (nonatomic, assign, readonly) long msg_id; @property (nonatomic, assign, readonly) int peerId; + +@property (nonatomic,assign) int date; + @property (nonatomic,assign) long access_hash; @property (nonatomic,strong) id reservedObject; diff --git a/TelegramTest/PreviewObject.m b/TelegramTest/PreviewObject.m index 1869c7ed..ac2842f5 100644 --- a/TelegramTest/PreviewObject.m +++ b/TelegramTest/PreviewObject.m @@ -21,6 +21,10 @@ -(id)initWithMsdId:(long)msg_id media:(id)media peer_id:(int)peer_id { return self; } +-(int)date { + return [self.media isKindOfClass:[TLMessage class]] ? [(TLMessage *)self.media date] : _date; +} + -(BOOL)isEqual:(PreviewObject *)object { return self.msg_id == object.msg_id; } diff --git a/TelegramTest/PrivacySettingsViewController.m b/TelegramTest/PrivacySettingsViewController.m index 3649bd9b..e97bfaa3 100644 --- a/TelegramTest/PrivacySettingsViewController.m +++ b/TelegramTest/PrivacySettingsViewController.m @@ -45,8 +45,8 @@ -(void)loadView { NSMutableArray *added = [[NSMutableArray alloc] init]; - [strongSelf.allowUsersAction.result.multiObjects enumerateObjectsUsingBlock:^(SelectUserItem *obj, NSUInteger idx, BOOL *stop) { - [added addObject:@(obj.user.n_id)]; + [strongSelf.allowUsersAction.result.multiObjects enumerateObjectsUsingBlock:^(TLUser *obj, NSUInteger idx, BOOL *stop) { + [added addObject:@(obj.n_id)]; }]; strongSelf.changedPrivacy.allowUsers = [strongSelf.changedPrivacy.allowUsers arrayByAddingObjectsFromArray:added]; @@ -66,8 +66,8 @@ -(void)loadView { ((ComposeActionCustomBehavior *)self.disallowUsersAction.behavior).composeDone = ^ { NSMutableArray *added = [[NSMutableArray alloc] init]; - [strongSelf.disallowUsersAction.result.multiObjects enumerateObjectsUsingBlock:^(SelectUserItem *obj, NSUInteger idx, BOOL *stop) { - [added addObject:@(obj.user.n_id)]; + [strongSelf.disallowUsersAction.result.multiObjects enumerateObjectsUsingBlock:^(TLUser *obj, NSUInteger idx, BOOL *stop) { + [added addObject:@(obj.n_id)]; }]; strongSelf.changedPrivacy.disallowUsers = [strongSelf.changedPrivacy.disallowUsers arrayByAddingObjectsFromArray:added]; @@ -119,43 +119,43 @@ -(void)loadView { [self.view addSubview:self.tableView.containerView]; - GeneralSettingsRowItem *everbody = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSelected callback:^(GeneralSettingsRowItem *item) { + GeneralSettingsRowItem *everbody = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSelected callback:^(TGGeneralRowItem *item) { self.changedPrivacy.allowType = PrivacyAllowTypeEverbody; self.changedPrivacy = self.changedPrivacy; - } description:NSLocalizedString(@"PrivacySettingsController.Everbody", nil) height:70 stateback:^id(GeneralSettingsRowItem *item) { + } description:NSLocalizedString(@"PrivacySettingsController.Everbody", nil) height:70 stateback:^id(TGGeneralRowItem *item) { return @(self.changedPrivacy.allowType == PrivacyAllowTypeEverbody); }]; [self.tableView insert:everbody atIndex:self.tableView.list.count tableRedraw:NO]; - GeneralSettingsRowItem *myContacts = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSelected callback:^(GeneralSettingsRowItem *item) { + GeneralSettingsRowItem *myContacts = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSelected callback:^(TGGeneralRowItem *item) { self.changedPrivacy.allowType = PrivacyAllowTypeContacts; self.changedPrivacy = self.changedPrivacy; - } description:NSLocalizedString(@"PrivacySettingsController.MyContacts", nil) height:42 stateback:^id(GeneralSettingsRowItem *item) { + } description:NSLocalizedString(@"PrivacySettingsController.MyContacts", nil) height:42 stateback:^id(TGGeneralRowItem *item) { return @(self.changedPrivacy.allowType == PrivacyAllowTypeContacts); }]; [self.tableView insert:myContacts atIndex:self.tableView.list.count tableRedraw:NO]; - GeneralSettingsRowItem *nobody = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSelected callback:^(GeneralSettingsRowItem *item) { + GeneralSettingsRowItem *nobody = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSelected callback:^(TGGeneralRowItem *item) { self.changedPrivacy.allowType = PrivacyAllowTypeNobody; self.changedPrivacy = self.changedPrivacy; - } description:NSLocalizedString(@"PrivacySettingsController.Nobody", nil) height:42 stateback:^id(GeneralSettingsRowItem *item) { + } description:NSLocalizedString(@"PrivacySettingsController.Nobody", nil) height:42 stateback:^id(TGGeneralRowItem *item) { return @(self.changedPrivacy.allowType == PrivacyAllowTypeNobody); }]; [self.tableView insert:nobody atIndex:self.tableView.list.count tableRedraw:NO]; - self.allowSelector = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(GeneralSettingsRowItem *item) { + self.allowSelector = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(TGGeneralRowItem *item) { if(self.changedPrivacy.allowUsers.count == 0) { [[Telegram rightViewController] showComposeWithAction:self.allowUsersAction]; @@ -170,7 +170,7 @@ -(void)loadView { } description:NSLocalizedString(@"PrivacySettingsController.AlwaysShareWith", nil) subdesc:@"5 users" height:42 stateback:nil]; - self.disallowSelector = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(GeneralSettingsRowItem *item) { + self.disallowSelector = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(TGGeneralRowItem *item) { if(self.changedPrivacy.disallowUsers.count == 0) { [[Telegram rightViewController] showComposeWithAction:self.disallowUsersAction]; diff --git a/TelegramTest/PrivacyUserListItemView.m b/TelegramTest/PrivacyUserListItemView.m index a909cfe6..4f424f67 100644 --- a/TelegramTest/PrivacyUserListItemView.m +++ b/TelegramTest/PrivacyUserListItemView.m @@ -31,7 +31,7 @@ - (id)initWithFrame:(NSRect)frame self.avatarImageView = [TMAvatarImageView standartNewConversationTableAvatar]; [self addSubview:self.avatarImageView]; - [self.avatarImageView setFont:[NSFont fontWithName:@"HelveticaNeue-Light" size:15]]; + [self.avatarImageView setFont:TGSystemLightFont(15)]; [self.avatarImageView setFrameSize:NSMakeSize(36, 36)]; @@ -39,7 +39,7 @@ - (id)initWithFrame:(NSRect)frame [self.titleTextField setEditable:NO]; [self.titleTextField setBordered:NO]; [self.titleTextField setBackgroundColor:[NSColor clearColor]]; - [self.titleTextField setFont:[NSFont fontWithName:@"HelveticaNeue" size:13]]; + [self.titleTextField setFont:TGSystemFont(13)]; [[self.titleTextField cell] setLineBreakMode:NSLineBreakByTruncatingTail]; [[self.titleTextField cell] setTruncatesLastVisibleLine:YES]; [self addSubview:self.titleTextField]; @@ -51,7 +51,7 @@ - (id)initWithFrame:(NSRect)frame [self.numberTextField setEditable:NO]; [self.numberTextField setBordered:NO]; [self.numberTextField setBackgroundColor:[NSColor clearColor]]; - [self.numberTextField setFont:[NSFont fontWithName:@"HelveticaNeue" size:12]]; + [self.numberTextField setFont:TGSystemFont(12)]; [self.numberTextField setTextColor:GRAY_TEXT_COLOR]; [[self.numberTextField cell] setLineBreakMode:NSLineBreakByTruncatingTail]; [[self.numberTextField cell] setTruncatesLastVisibleLine:YES]; @@ -65,7 +65,7 @@ - (id)initWithFrame:(NSRect)frame self.removeButton = [TMTextButton standartUserProfileButtonWithTitle:NSLocalizedString(@"Remove", nil)]; - [self.removeButton setFont:[NSFont fontWithName:@"HelveticaNeue" size:14]]; + [self.removeButton setFont:TGSystemFont(14)]; [self.removeButton setTextColor:BLUE_UI_COLOR]; [self.removeButton sizeToFit]; diff --git a/TelegramTest/PrivacyViewController.m b/TelegramTest/PrivacyViewController.m index 39f5d890..29b45c10 100644 --- a/TelegramTest/PrivacyViewController.m +++ b/TelegramTest/PrivacyViewController.m @@ -37,14 +37,12 @@ -(void)loadView { [self.view addSubview:self.tableView.containerView]; - GeneralSettingsBlockHeaderItem *privacyHeader = [[GeneralSettingsBlockHeaderItem alloc] initWithObject:NSLocalizedString(@"PrivacyAndSecurity.PrivacyHeader", nil)]; - - privacyHeader.height = 61; + GeneralSettingsBlockHeaderItem *privacyHeader = [[GeneralSettingsBlockHeaderItem alloc] initWithString:NSLocalizedString(@"PrivacyAndSecurity.PrivacyHeader", nil) height:51 flipped:NO]; [self.tableView insert:privacyHeader atIndex:self.tableView.list.count tableRedraw:NO]; - self.blockedUsersRowIten = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(GeneralSettingsRowItem *item) { + self.blockedUsersRowIten = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(TGGeneralRowItem *item) { [[Telegram rightViewController] showBlockedUsers]; @@ -53,7 +51,7 @@ -(void)loadView { [self.tableView insert:self.blockedUsersRowIten atIndex:self.tableView.list.count tableRedraw:NO]; - self.lastSeenRowItem = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(GeneralSettingsRowItem *item) { + self.lastSeenRowItem = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(TGGeneralRowItem *item) { if(!self.lastSeenRowItem.locked) [[Telegram rightViewController] showLastSeenController]; @@ -64,18 +62,16 @@ -(void)loadView { - GeneralSettingsBlockHeaderItem *security = [[GeneralSettingsBlockHeaderItem alloc] initWithObject:NSLocalizedString(@"PrivacyAndSecurity.SecurityHeader", nil)]; - - security.height = 51; + GeneralSettingsBlockHeaderItem *security = [[GeneralSettingsBlockHeaderItem alloc] initWithString:NSLocalizedString(@"PrivacyAndSecurity.SecurityHeader", nil) height:51 flipped:NO]; [self.tableView insert:security atIndex:self.tableView.list.count tableRedraw:NO]; - GeneralSettingsRowItem *passcode = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(GeneralSettingsRowItem *item) { + GeneralSettingsRowItem *passcode = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(TGGeneralRowItem *item) { [[Telegram rightViewController] showPasscodeController]; - } description:NSLocalizedString(@"PrivacyAndSecurity.PassCode", nil) height:42 stateback:^id(GeneralSettingsRowItem *item) { + } description:NSLocalizedString(@"PrivacyAndSecurity.PassCode", nil) height:42 stateback:^id(TGGeneralRowItem *item) { return @(YES); }]; @@ -94,23 +90,23 @@ -(void)loadView { if(accept) { - GeneralSettingsRowItem *terminateSessions = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(GeneralSettingsRowItem *item) { + GeneralSettingsRowItem *terminateSessions = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(TGGeneralRowItem *item) { [[Telegram rightViewController] showSessionsController]; // [self terminateSessions]; - } description:NSLocalizedString(@"PrivacyAndSecurity.TerminateSessions", nil) height:42 stateback:^id(GeneralSettingsRowItem *item) { + } description:NSLocalizedString(@"PrivacyAndSecurity.TerminateSessions", nil) height:42 stateback:^id(TGGeneralRowItem *item) { return @(YES); }]; [self.tableView insert:terminateSessions atIndex:self.tableView.list.count tableRedraw:NO]; - GeneralSettingsRowItem *twoStepVerification = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(GeneralSettingsRowItem *item) { + GeneralSettingsRowItem *twoStepVerification = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(TGGeneralRowItem *item) { [[Telegram rightViewController] showPasswordMainController]; - } description:NSLocalizedString(@"PrivacyAndSecurity.TwoStepVerification", nil) height:42 stateback:^id(GeneralSettingsRowItem *item) { + } description:NSLocalizedString(@"PrivacyAndSecurity.TwoStepVerification", nil) height:42 stateback:^id(TGGeneralRowItem *item) { return @(YES); }]; @@ -121,26 +117,24 @@ -(void)loadView { // -// GeneralSettingsRowItem *logout = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(GeneralSettingsRowItem *item) { +// GeneralSettingsRowItem *logout = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(TGGeneralRowItem *item) { // N // [self logOut]; // // -// } description:NSLocalizedString(@"PrivacyAndSecurity.Logout", nil) height:42 stateback:^id(GeneralSettingsRowItem *item) { +// } description:NSLocalizedString(@"PrivacyAndSecurity.Logout", nil) height:42 stateback:^id(TGGeneralRowItem *item) { // return @([SettingsArchiver checkMaskedSetting:AutoGroupAudio]); // }]; // // [self.tableView insert:logout atIndex:self.tableView.list.count tableRedraw:NO]; - GeneralSettingsBlockHeaderItem *deleteAccountHeader = [[GeneralSettingsBlockHeaderItem alloc] initWithObject:NSLocalizedString(@"PrivacyAndSecurity.DeleteAccountHeader", nil)]; - - deleteAccountHeader.height = 51; + GeneralSettingsBlockHeaderItem *deleteAccountHeader = [[GeneralSettingsBlockHeaderItem alloc] initWithString:NSLocalizedString(@"PrivacyAndSecurity.DeleteAccountHeader", nil) height:51 flipped:NO]; [self.tableView insert:deleteAccountHeader atIndex:self.tableView.list.count tableRedraw:NO]; - self.accountDaysItem = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(GeneralSettingsRowItem *item) { + self.accountDaysItem = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(TGGeneralRowItem *item) { /// [self logOut]; @@ -170,7 +164,7 @@ -(void)loadView { [menu popUpForView:view.subdescField]; } - } description:NSLocalizedString(@"PrivacyAndSecurity.DeleteAccount", nil) height:42 stateback:^id(GeneralSettingsRowItem *item) { + } description:NSLocalizedString(@"PrivacyAndSecurity.DeleteAccount", nil) height:42 stateback:^id(TGGeneralRowItem *item) { return @([SettingsArchiver checkMaskedSetting:AutoGroupAudio]); }]; @@ -190,9 +184,9 @@ -(void)loadView { // [self.tableView insert:deleteAccountHeader atIndex:self.tableView.list.count tableRedraw:NO]; // // -// GeneralSettingsRowItem *deleteAccount = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(GeneralSettingsRowItem *item) { +// GeneralSettingsRowItem *deleteAccount = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(TGGeneralRowItem *item) { // -// } description:NSLocalizedString(@"PrivacyAndSecurity.DeleteAccount", nil) height:42 stateback:^id(GeneralSettingsRowItem *item) { +// } description:NSLocalizedString(@"PrivacyAndSecurity.DeleteAccount", nil) height:42 stateback:^id(TGGeneralRowItem *item) { // return @([SettingsArchiver checkMaskedSetting:EmojiReplaces]); // }]; // diff --git a/TelegramTest/ProfileSharedMediaView.m b/TelegramTest/ProfileSharedMediaView.m index 1ccbcf22..ef0a6dbc 100644 --- a/TelegramTest/ProfileSharedMediaView.m +++ b/TelegramTest/ProfileSharedMediaView.m @@ -52,7 +52,7 @@ - (id)initWithFrame:(NSRect)frame //} -(void)mouseUp:(NSEvent *)theEvent { - [[Telegram rightViewController] showCollectionPage:_conversation]; + [appWindow().navigationController showInfoPage:_conversation]; } diff --git a/TelegramTest/QueueManager.m b/TelegramTest/QueueManager.m index 10a2264c..5fe8466a 100644 --- a/TelegramTest/QueueManager.m +++ b/TelegramTest/QueueManager.m @@ -26,6 +26,8 @@ - (id)init { - (void)add:(NSOperation *)operation { [self.queue addOperation:operation]; + NSLog(@"operation count:%d",self.queue.operationCount); + } +(QueueManager *)sharedManager { diff --git a/TelegramTest/RPC.h b/TelegramTest/RPC.h index b7cad045..b243761b 100644 --- a/TelegramTest/RPC.h +++ b/TelegramTest/RPC.h @@ -20,6 +20,8 @@ @property (nonatomic, strong) MTRequest *mtrequest; @property (nonatomic, assign) dispatch_queue_t queue; +@property (nonatomic, assign) BOOL alwayContinueWithErrorContext; + typedef void (^RPCSuccessHandler)(id request, id response); typedef void (^RPCErrorHandler)(id request, RpcError *error); @@ -30,7 +32,7 @@ typedef void (^RPCErrorHandler)(id request, RpcError *error); - (void)cancelRequest; + (id)sendRequest:(id)object successHandler:(RPCSuccessHandler)successHandler errorHandler:(RPCErrorHandler)errorHandler; - ++ (id)sendRequest:(id)object successHandler:(RPCSuccessHandler)successHandler errorHandler:(RPCErrorHandler)errorHandler alwayContinueWithErrorContext:(BOOL)alwayContinueWithErrorContext; + (id)sendRequest:(id)object successHandler:(RPCSuccessHandler)successHandler errorHandler:(RPCErrorHandler)errorHandler timeout:(int)timeout; + (id)sendRequest:(id)object successHandler:(RPCSuccessHandler)successHandler errorHandler:(RPCErrorHandler)errorHandler timeout:(int)timeout queue:(dispatch_queue_t)queue; diff --git a/TelegramTest/RPCRequest.m b/TelegramTest/RPCRequest.m index 86daca3c..1e9595f0 100644 --- a/TelegramTest/RPCRequest.m +++ b/TelegramTest/RPCRequest.m @@ -71,6 +71,18 @@ + (id)sendRequest:(id)object successHandler:(RPCSuccessHandler)successHandler er } ++ (id)sendRequest:(id)object successHandler:(RPCSuccessHandler)successHandler errorHandler:(RPCErrorHandler)errorHandler alwayContinueWithErrorContext:(BOOL)alwayContinueWithErrorContext { + RPCRequest *message = [[RPCRequest alloc] init]; + message.object = object; + message.alwayContinueWithErrorContext = alwayContinueWithErrorContext; + message.successHandler = successHandler; + message.errorHandler = errorHandler; + + [[MTNetwork instance] sendRequest:message]; + + return message; +} + +(id)sendRequest:(id)object forDc:(int)dc_id successHandler:(RPCSuccessHandler)successHandler errorHandler:(RPCErrorHandler)errorHandler { diff --git a/TelegramTest/ReadHistroryTask.m b/TelegramTest/ReadHistroryTask.m index 3f099821..a4de3581 100644 --- a/TelegramTest/ReadHistroryTask.m +++ b/TelegramTest/ReadHistroryTask.m @@ -9,7 +9,6 @@ #import "ReadHistroryTask.h" #import "TMTaskRequest.h" @interface ReadHistroryTask () -@property (nonatomic,strong) TLPeer *peer; @property (nonatomic,strong) TL_conversation *conversation; @end @@ -30,7 +29,7 @@ -(id)initWithParams:(NSDictionary *)params taskId:(NSUInteger)taskId { -(id)initWithParams:(NSDictionary *)params { if(self = [super init]) { _params = params; - _peer = [_params objectForKey:@"peer"]; + _conversation = [_params objectForKey:@"conversation"]; _taskId = [TMTaskRequest futureTaskId]; } @@ -39,9 +38,6 @@ -(id)initWithParams:(NSDictionary *)params { -(void)execute { - if(!_conversation) { - _conversation = [[Storage manager] selectConversation:_peer]; - } if(_conversation) { @@ -66,28 +62,33 @@ -(void)loop:(int)offset { if(_conversation.type == DialogTypeSecretChat) { request = [TLAPI_messages_readEncryptedHistory createWithPeer:[_conversation.encryptedChat inputPeer] max_date:[[MTNetwork instance] getTime]]; + } else if(_conversation.type != DialogTypeChannel) { + request = [TLAPI_messages_readHistory createWithPeer:[_conversation inputPeer] max_id:_conversation.read_inbox_max_id]; } else { - request = [TLAPI_messages_readHistory createWithPeer:[_conversation inputPeer] max_id:_conversation.top_message offset:offset]; + request = [TLAPI_channels_readHistory createWithChannel:[_conversation inputPeer] max_id:_conversation.read_inbox_max_id]; //TODO } [RPCRequest sendRequest:request successHandler:^(RPCRequest *request, id response) { if(![response isKindOfClass:[TL_boolTrue class]] && ![response isKindOfClass:[TL_boolFalse class]]) { - TL_messages_affectedHistory *history = response; - if(history.offset > 0) { - [self loop:history.offset]; - } else { + TL_messages_affectedMessages *history = response; + + [ASQueue dispatchOnMainQueue:^{ if([_delegate respondsToSelector:@selector(didCompleteTaskRequest:)]) { [_delegate didCompleteTaskRequest:self]; } - } + }]; + } else { - if([_delegate respondsToSelector:@selector(didCompleteTaskRequest:)]) { - [_delegate didCompleteTaskRequest:self]; - } + + [ASQueue dispatchOnMainQueue:^{ + if([_delegate respondsToSelector:@selector(didCompleteTaskRequest:)]) { + [_delegate didCompleteTaskRequest:self]; + } + }]; } - } errorHandler:nil]; + } errorHandler:nil timeout:0 queue:taskQueue().nativeQueue]; } diff --git a/TelegramTest/Rebel/RBLPopover.m b/TelegramTest/Rebel/RBLPopover.m index 82584a42..c06d7417 100755 --- a/TelegramTest/Rebel/RBLPopover.m +++ b/TelegramTest/Rebel/RBLPopover.m @@ -323,7 +323,7 @@ - (void)showRelativeToRect:(CGRect)positioningRect ofView:(NSView *)positioningV if (shouldClose) { - id mouseDownView = [((AppDelegate *)[NSApp delegate]).window.contentView hitTest:event.locationInWindow]; + id mouseDownView = [self.popoverWindow.parentWindow.contentView hitTest:event.locationInWindow]; if(mouseDownView != self.positioningView) { [strongSelf close]; } diff --git a/TelegramTest/RegistrationAvatarView.m b/TelegramTest/RegistrationAvatarView.m index dced5e29..dd6bdb3e 100644 --- a/TelegramTest/RegistrationAvatarView.m +++ b/TelegramTest/RegistrationAvatarView.m @@ -25,7 +25,7 @@ - (id)initWithFrame:(NSRect)frame self.placeholderTextField = [[TMTextField alloc] init]; [self.placeholderTextField setEditable:NO]; [self.placeholderTextField setBordered:NO]; - [self.placeholderTextField setFont:[NSFont fontWithName:@"HelveticaNeue" size:15]]; + [self.placeholderTextField setFont:TGSystemFont(15)]; [self.placeholderTextField setTextColor:NSColorFromRGB(0xc8c8c8)]; [self.placeholderTextField setStringValue:NSLocalizedString(@"Registration.AddPhoto", nil)]; [self.placeholderTextField setAlignment:NSCenterTextAlignment]; diff --git a/TelegramTest/RegistrationViewController.m b/TelegramTest/RegistrationViewController.m index c25eb800..78848957 100644 --- a/TelegramTest/RegistrationViewController.m +++ b/TelegramTest/RegistrationViewController.m @@ -63,7 +63,7 @@ - (void)loadView { TMBackButton *backButton = [[TMBackButton alloc] initWithFrame:NSZeroRect string:[NSString stringWithFormat:@" %@",NSLocalizedString(@"Profile.Back", nil)]]; - [backButton.field setFont:[NSFont fontWithName:@"Helvetica-Light" size:15]]; + [backButton.field setFont:TGSystemLightFont(15)]; [backButton.imageView setFrameOrigin:NSMakePoint(0, 4)]; [backButton sizeToFit]; [backButton setFrameOrigin:NSMakePoint(4, 260)]; @@ -81,7 +81,7 @@ - (void)loadView { self.titleTextField.stringValue = NSLocalizedString(@"Registration", nil); [self.titleTextField setEditable:NO]; [self.titleTextField setBordered:NO]; - self.titleTextField.font = [NSFont fontWithName:@"Helvetica-Light" size:28]; + self.titleTextField.font = TGSystemLightFont(28); // self.titleTextField.wantsLayer = IS_RETINA; [self.titleTextField sizeToFit]; @@ -93,7 +93,7 @@ - (void)loadView { self.firstNameTextField.drawsBackground = NO; self.firstNameTextField.delegate = self; - NSAttributedString *placeHolder = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"Registartion.FirstName", nil) attributes:@{NSFontAttributeName: [NSFont fontWithName:@"Helvetica-Light" size:15], NSForegroundColorAttributeName: NSColorFromRGB(0xc8c8c8)}]; + NSAttributedString *placeHolder = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"Registartion.FirstName", nil) attributes:@{NSFontAttributeName: TGSystemLightFont(15), NSForegroundColorAttributeName: NSColorFromRGB(0xc8c8c8)}]; [self.firstNameTextField.cell setPlaceholderAttributedString:placeHolder]; // [self.firstNameTextField setPlaceholderAttributedString:placeHolder]; [self.firstNameTextField setPlaceholderPoint:NSMakePoint(2, 1)]; @@ -101,7 +101,7 @@ - (void)loadView { [[self.firstNameTextField cell] setTruncatesLastVisibleLine:YES]; [[self.firstNameTextField cell] setLineBreakMode:NSLineBreakByTruncatingTail]; - self.firstNameTextField.font = [NSFont fontWithName:@"Helvetica-Light" size:15]; + self.firstNameTextField.font = TGSystemLightFont(15); self.firstNameTextField.focusRingType = NSFocusRingTypeNone; [self.firstNameTextField setBordered:NO]; [self.containerView addSubview:self.firstNameTextField]; @@ -111,14 +111,14 @@ - (void)loadView { self.lastNameTextField.drawsBackground = NO; self.lastNameTextField.delegate = self; - placeHolder = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"Registration.LastName", nil) attributes:@{NSFontAttributeName: [NSFont fontWithName:@"Helvetica-Light" size:15], NSForegroundColorAttributeName: NSColorFromRGB(0xc8c8c8)}]; + placeHolder = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"Registration.LastName", nil) attributes:@{NSFontAttributeName: TGSystemLightFont(15), NSForegroundColorAttributeName: NSColorFromRGB(0xc8c8c8)}]; [self.lastNameTextField.cell setPlaceholderAttributedString:placeHolder]; // [self.lastNameTextField setPlaceholderAttributedString:placeHolder]; [self.lastNameTextField setPlaceholderPoint:NSMakePoint(2, 1)]; [[self.lastNameTextField cell] setTruncatesLastVisibleLine:YES]; [[self.lastNameTextField cell] setLineBreakMode:NSLineBreakByTruncatingTail]; - self.lastNameTextField.font = [NSFont fontWithName:@"Helvetica-Light" size:15]; + self.lastNameTextField.font = TGSystemLightFont(15); self.lastNameTextField.focusRingType = NSFocusRingTypeNone; [self.lastNameTextField setBordered:NO]; [self.containerView addSubview:self.lastNameTextField]; diff --git a/TelegramTest/RightViewController.h b/TelegramTest/RightViewController.h index 7443e3e3..e704f513 100644 --- a/TelegramTest/RightViewController.h +++ b/TelegramTest/RightViewController.h @@ -42,6 +42,13 @@ #import "TGSplitViewController.h" #import "CacheSettingsViewController.h" #import "NotificationSettingsViewController.h" +#import "ComposeCreateChannelViewController.h" +#import "ChannelInfoViewController.h" +#import "ComposeCreateChannelUserNameStepViewController.h" +#import "ComposeConfirmModeratorViewController.h" +#import "ComposeManagmentViewController.h" +#import "ComposeChannelParticipantsViewController.h" +#import "ComposeSettingupNewChannelViewController.h" @class MainViewController; @class LeftViewController; @@ -75,19 +82,21 @@ @property (nonatomic, strong) PhoneChangeConfirmController *phoneChangeConfirmController; @property (nonatomic, strong) TGOpacityViewController *opacityViewController; @property (nonatomic, strong) TGPasscodeSettingsViewController *passcodeViewController; - @property (nonatomic, strong) TGSessionsViewController *sessionsViewContoller; @property (nonatomic, strong) TGPasswosdMainViewController *passwordMainViewController; @property (nonatomic, strong) TGPasswordSetViewController *passwordSetViewController; - - @property (nonatomic, strong) ChatExportLinkViewController *chatExportLinkViewController; @property (nonatomic, strong) TGStickersSettingsViewController *stickersSettingsViewController; - @property (nonatomic, strong) ComposeChooseGroupViewController *composeChooseGroupViewController; - @property (nonatomic, strong) CacheSettingsViewController *cacheSettingsViewController; @property (nonatomic, strong) NotificationSettingsViewController *notificationSettingsViewController; +@property (nonatomic, strong) ComposeCreateChannelViewController *composeCreateChannelViewController; +@property (nonatomic, strong) ChannelInfoViewController *channelInfoViewController; +@property (nonatomic, strong) ComposeCreateChannelUserNameStepViewController *composeCreateChannelUserNameStepViewController; +@property (nonatomic, strong) ComposeConfirmModeratorViewController *composeConfirmModeratorViewController; +@property (nonatomic,strong) ComposeManagmentViewController *composeManagmentViewController; +@property (nonatomic,strong) ComposeChannelParticipantsViewController *composeChannelParticipantsViewController; +@property (nonatomic,strong) ComposeSettingupNewChannelViewController *composeSettingupNewChannelViewController; - (void)modalViewSendAction:(id)object; - (BOOL)isModalViewActive; @@ -97,20 +106,13 @@ - (void)showShareContactModalView:(TLUser *)user; - (void)showForwardMessagesModalView:(TL_conversation *)dialog messagesCount:(NSUInteger)messagesCount; +- (void)showShareLinkModalView:(NSString *)url text:(NSString *)text; -- (void)showByDialog:(TL_conversation *)dialog sender:(id)sender; - -- (BOOL)showByDialog:(TL_conversation *)dialog withJump:(int)messageId historyFilter:(Class)filter sender:(id)sender; - (void)showComposeWithAction:(ComposeAction *)composeAction; - (void)showComposeCreateChat:(ComposeAction *)composeAction; - (void)showComposeBroadcastList:(ComposeAction *)composeAction; - (void)showComposeAddUserToGroup:(ComposeAction *)composeAction; -- (void)showUserInfoPage:(TLUser *)user conversation:(TL_conversation *)conversation; -- (void)showUserInfoPage:(TLUser *)user; -- (void)showCollectionPage:(TL_conversation *)conversation; -- (void)showChatInfoPage:(TLChat *)chat; -- (void)showBroadcastInfoPage:(TL_broadcast *)broadcast; - (void)showNotSelectedDialog; -(void)showEncryptedKeyWindow:(TL_encryptedChat *)chat; @@ -120,6 +122,8 @@ - (void)showSecuritySettings; - (void)showAbout; - (void)showUserNameController; +- (void)showUserNameControllerWithChannel:(TL_channel *)channel completionHandler:(dispatch_block_t)completionHandler; + - (void)showAddContactController; - (void)showPrivacyController; @@ -150,4 +154,18 @@ -(void)showCacheSettingsViewController; -(void)showNotificationSettingsViewController; + +-(void)showComposeCreateChannel:(ComposeAction *)action; + +-(void)showChannelInfoPage:(TLChat *)chat; + +-(void)showComposeChangeUserName:(ComposeAction *)action; + +-(void)showComposeAddModerator:(ComposeAction *)action; +-(void)showComposeManagment:(ComposeAction *)action; + + +-(void)showComposeChannelParticipants:(ComposeAction *)action; + +-(void)showComposeSettingsupNewChannel:(ComposeAction *)action; @end diff --git a/TelegramTest/RightViewController.m b/TelegramTest/RightViewController.m index 06c8c39d..7fe6d302 100644 --- a/TelegramTest/RightViewController.m +++ b/TelegramTest/RightViewController.m @@ -106,6 +106,7 @@ - (void) loadView { self.navigationViewController = [[TMNavigationController alloc] initWithFrame:self.view.bounds]; [self.view addSubview:self.navigationViewController.view]; + [self.view setBackgroundColor:[NSColor whiteColor]]; [self.view setAutoresizesSubviews:YES]; @@ -121,6 +122,8 @@ - (void) loadView { self.collectionViewController = [[TMCollectionPageController alloc] initWithFrame:rect]; self.noDialogsSelectedViewController = [[NotSelectedDialogsViewController alloc] initWithFrame:rect]; self.broadcastInfoViewController = [[BroadcastInfoViewController alloc] initWithFrame:rect]; + self.channelInfoViewController = [[ChannelInfoViewController alloc] initWithFrame:rect]; + self.composePickerViewController = [[ComposePickerViewController alloc] initWithFrame:rect]; self.composeChatCreateViewController = [[ComposeChatCreateViewController alloc] initWithFrame:rect]; @@ -163,13 +166,16 @@ - (void) loadView { self.passwordSetViewController = [[TGPasswordSetViewController alloc] initWithFrame:rect]; - [self.navigationViewController pushViewController:self.messagesViewController animated:NO]; - - - [self.navigationViewController.viewControllerStack removeAllObjects]; +// [self.navigationViewController pushViewController:self.messagesViewController animated:NO]; +// +// +// [self.navigationViewController.viewControllerStack removeAllObjects]; +// + self.navigationViewController.messagesViewController = self.messagesViewController; + [self.navigationViewController.view.window makeFirstResponder:nil]; } @@ -211,7 +217,6 @@ -(void)didChangedLayout { [self.navigationViewController.viewControllerStack removeObject:[self oldEmptyController]]; - [self.navigationViewController.viewControllerStack insertObject:[self currentEmptyController] atIndex:0]; if([self isModalViewActive]) { @@ -348,8 +353,14 @@ - (void)modalViewSendAction:(id)object { return; } - - + if(!dialog.canSendMessage && self.modalView == [self forwardModalView]) { + NSAlert *alert = [[NSAlert alloc] init]; + [alert setAlertStyle:NSInformationalAlertStyle]; + [alert setMessageText:NSLocalizedString(@"Alert.Error", nil)]; + [alert setInformativeText: NSLocalizedString(@"Conversation.CantForwardMessagesToThisConversation", nil)]; + [alert show]; + return; + } if(self.modalView == [self shareContactModalView]) { @@ -360,7 +371,7 @@ - (void)modalViewSendAction:(id)object { if(modalObject && modalObject.phone) { - [[Telegram sharedInstance] showMessagesFromDialog:dialog sender:self]; + [self.navigationViewController showMessagesViewController:dialog]; [self.messagesViewController shareContact:modalObject forConversation:dialog callback:^{ @@ -375,51 +386,54 @@ - (void)modalViewSendAction:(id)object { - } else { + } else if(self.modalView == [self shareModalView]) { + + + NSDictionary *obj = self.modalObject; + + [appWindow().navigationController showMessagesViewController:dialog]; + + [appWindow().navigationController.messagesViewController setStringValueToTextField:[NSString stringWithFormat:@"%@\n%@",obj[@"url"],obj[@"text"]]]; + + [appWindow().navigationController.messagesViewController selectInputTextByText:obj[@"text"]]; + + } else { // confirm(NSLocalizedString(@"Alert.Forward", nil), [NSString stringWithFormat:NSLocalizedString(@"Alert.ForwardTo", nil),(dialog.type == DialogTypeChat) ? dialog.chat.title : (dialog.type == DialogTypeBroadcast) ? dialog.broadcast.title : dialog.user.fullName], ^{ - NSMutableArray *messages = [self.messagesViewController selectedMessages]; - NSMutableArray *ids = [[NSMutableArray alloc] init]; - for(MessageTableItem *item in messages) - [ids addObject:item.message]; - - [ids sortUsingComparator:^NSComparisonResult(TLMessage * a, TLMessage * b) { - return a.n_id > b.n_id ? NSOrderedDescending : NSOrderedAscending; - }]; - - [self.messagesViewController cancelSelectionAndScrollToBottom]; - weakify(); - - - dialog.last_marked_date = [[MTNetwork instance] getTime]+1; - dialog.last_marked_message = dialog.top_message; - - [dialog save]; - - // self.messagesViewController.didUpdatedTable = ^ { - - // strongSelf.messagesViewController.didUpdatedTable = nil; - - [strongSelf.messagesViewController setFwdMessages:ids forConversation:dialog]; - - // }; - - // if(self.messagesViewController.conversation == dialog) { - // self.messagesViewController.didUpdatedTable(); - // } - [self hideModalView:YES animation:YES]; - - [[Telegram sharedInstance] showMessagesFromDialog:dialog sender:self]; - - - TMViewController *controller = [_leftViewController currentTabController]; - - if([controller isKindOfClass:[StandartViewController class]]) { - [(StandartViewController *)controller searchByString:@""]; - } - - + NSMutableArray *messages = [self.messagesViewController selectedMessages]; + NSMutableArray *ids = [[NSMutableArray alloc] init]; + for(MessageTableItem *item in messages) + [ids addObject:item.message]; + + [ids sortUsingComparator:^NSComparisonResult(TLMessage * a, TLMessage * b) { + return a.n_id > b.n_id ? NSOrderedDescending : NSOrderedAscending; + }]; + + [self.messagesViewController cancelSelectionAndScrollToBottom]; + + + dialog.last_marked_date = [[MTNetwork instance] getTime]+1; + dialog.last_marked_message = dialog.top_message; + + [dialog save]; + + [self.messagesViewController setFwdMessages:ids forConversation:dialog]; + + + [self hideModalView:YES animation:YES]; + + [appWindow().navigationController showMessagesViewController:dialog]; + + + + TMViewController *controller = [_leftViewController currentTabController]; + + if([controller isKindOfClass:[StandartViewController class]]) { + [(StandartViewController *)controller searchByString:@""]; + } + + // },nil); } @@ -450,14 +464,32 @@ - (void)showShareContactModalView:(TLUser *)user { } -- (void)showForwardMessagesModalView:(TL_conversation *)dialog messagesCount:(NSUInteger)messagesCount { +- (void)showShareLinkModalView:(NSString *)url text:(NSString *)text { [self hideModalView:YES animation:NO]; + if([Telegram isSingleLayout]) { + [self.navigationViewController pushViewController:[self currentEmptyController] animated:YES]; + } + + TMModalView *view = [self shareModalView]; + + self.modalView = view; + self.modalObject = @{@"url":url, @"text":text}; + [view removeFromSuperview]; + [view setFrameSize:view.bounds.size]; + [view setHeaderTitle:NSLocalizedString(@"Messages.SharingLink", nil) text:url]; + + [self hideModalView:NO animation:YES]; +} + +- (void)showForwardMessagesModalView:(TL_conversation *)dialog messagesCount:(NSUInteger)messagesCount { + [self hideModalView:YES animation:NO]; + TMModalView *view = [self forwardModalView]; self.modalView = view; @@ -481,7 +513,7 @@ - (void)showForwardMessagesModalView:(TL_conversation *)dialog messagesCount:(NS } NSString *name; - if(dialog.type == DialogTypeChat) { + if(dialog.type == DialogTypeChat || dialog.type == DialogTypeChannel) { name = dialog.chat.title; } else if(dialog.type == DialogTypeSecretChat) { name = dialog.encryptedChat.peerUser.fullName; @@ -506,6 +538,15 @@ - (TMModalView *)forwardModalView { return view; } +- (TMModalView *)shareModalView { + static TMModalView *view; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + view = [[TMModalView alloc] initWithFrame:self.view.bounds]; + }); + return view; +} + - (TMModalView *)shareContactModalView { static TMModalView *view; @@ -540,43 +581,6 @@ - (void)logout:(NSNotification *)notify { [self.messagesViewController drop]; } -- (void)showByDialog:(TL_conversation *)dialog sender:(id)sender { - [self showByDialog:dialog withJump:0 historyFilter:[HistoryFilter class] sender:sender]; -} - - -- (BOOL)showByDialog:(TL_conversation *)dialog withJump:(int)messageId historyFilter:(Class )filter sender:(id)sender { - - - [self hideModalView:YES animation:NO]; - - if(self.messagesViewController.conversation == dialog && self.navigationViewController.currentController != self.messagesViewController && ![_mainViewController isSingleLayout]) { - - [self.messagesViewController setCurrentConversation:dialog withJump:messageId historyFilter:filter]; - - [self.navigationViewController.viewControllerStack removeAllObjects]; - [self.navigationViewController.viewControllerStack addObject:[self currentEmptyController]]; - [self.navigationViewController.viewControllerStack addObject:self.messagesViewController]; - [self.navigationViewController.viewControllerStack addObject:self.navigationViewController.currentController]; - [self.navigationViewController goBackWithAnimation:YES]; - } else { - - [self.messagesViewController setCurrentConversation:dialog withJump:messageId historyFilter:filter force:[Telegram isSingleLayout]]; - - if(![_mainViewController isSingleLayout]) { - - - - [self.navigationViewController.viewControllerStack removeAllObjects]; - [self.navigationViewController.viewControllerStack addObject:[self currentEmptyController]]; - - } - - [self.navigationViewController pushViewController:self.messagesViewController animated:((self.navigationViewController.currentController != self.noDialogsSelectedViewController && ![sender isKindOfClass:[NotSelectedDialogsViewController class]] && ![sender isKindOfClass:[SearchViewController class]] && ![sender isKindOfClass:[ContactsViewController class]] && ![sender isKindOfClass:[RightViewController class]]) || [Telegram isSingleLayout]) && ![sender isKindOfClass:[AppDelegate class]] && ![sender isKindOfClass:[TGPhotoViewer class]]]; - } - - return YES; -} -(TMViewController *)currentEmptyController { return [_mainViewController isSingleLayout] ? [self conversationsController] : self.noDialogsSelectedViewController; @@ -654,6 +658,23 @@ - (void)showComposeCreateChat:(ComposeAction *)composeAction { [self.navigationViewController pushViewController:self.composeChatCreateViewController animated:self.navigationViewController.currentController != [self noDialogsSelectedViewController]]; } +-(void)showComposeCreateChannel:(ComposeAction *)composeAction { + if(self.navigationViewController.currentController == self.composeCreateChannelViewController && self.composeCreateChannelViewController.action == composeAction) + return; + + if(!self.composeCreateChannelViewController) + { + self.composeCreateChannelViewController = [[ComposeCreateChannelViewController alloc] initWithFrame:self.view.bounds]; + } + + + [self hideModalView:YES animation:NO]; + + [self.composeCreateChannelViewController setAction:composeAction]; + [self.navigationViewController pushViewController:self.composeCreateChannelViewController animated:self.navigationViewController.currentController != [self noDialogsSelectedViewController]]; + +} + -(void)showComposeBroadcastList:(ComposeAction *)composeAction { if(self.navigationViewController.currentController == self.composeBroadcastListViewController && self.composeBroadcastListViewController.action == composeAction) @@ -684,12 +705,19 @@ - (void)showComposeAddUserToGroup:(ComposeAction *)composeAction { } - (void)showChatInfoPage:(TLChat *)chat { - if(self.navigationViewController.currentController == self.chatInfoViewController && self.chatInfoViewController.chat.n_id == chat.n_id) + + + if([chat isKindOfClass:[TL_channel class]]) { + [self showChannelInfoPage:chat]; return; + } - if(chat.type != TLChatTypeNormal) + if(self.navigationViewController.currentController == self.chatInfoViewController && self.chatInfoViewController.chat.n_id == chat.n_id) return; + //if(chat.type != TLChatTypeNormal) + // return; + [self hideModalView:YES animation:NO]; @@ -763,8 +791,23 @@ - (void)showUserNameController { [self hideModalView:YES animation:NO]; + self.userNameViewController.channel = nil; + self.userNameViewController.completionHandler = nil; + + [self.navigationViewController pushViewController:self.userNameViewController animated:self.navigationViewController.currentController != [self noDialogsSelectedViewController]]; +} + +- (void)showUserNameControllerWithChannel:(TL_channel *)channel completionHandler:(dispatch_block_t)completionHandler { + if(self.navigationViewController.currentController == self.userNameViewController) + return; + + [self hideModalView:YES animation:NO]; + + self.userNameViewController.channel = channel; + self.userNameViewController.completionHandler = completionHandler; [self.navigationViewController pushViewController:self.userNameViewController animated:self.navigationViewController.currentController != [self noDialogsSelectedViewController]]; + } -(void)showAddContactController { @@ -990,4 +1033,95 @@ -(void)showNotificationSettingsViewController { [self.navigationViewController pushViewController:_notificationSettingsViewController animated:self.navigationViewController.currentController != [self noDialogsSelectedViewController]]; } + +-(void)showChannelInfoPage:(TLChat *)chat { + if((self.navigationViewController.currentController == self.channelInfoViewController && self.channelInfoViewController.chat.n_id == chat.n_id) || chat.type == TLChatTypeForbidden ) + return; + + + [self hideModalView:YES animation:NO]; + + [self.channelInfoViewController setChat:chat]; + + [self.navigationViewController pushViewController:self.channelInfoViewController animated:self.navigationViewController.currentController != self.noDialogsSelectedViewController]; +} + +-(void)showComposeChangeUserName:(ComposeAction *)action { + if(self.navigationViewController.currentController == self.composeCreateChannelUserNameStepViewController && self.composeCreateChannelUserNameStepViewController.action == action) + return; + + if(_composeCreateChannelUserNameStepViewController == nil) { + _composeCreateChannelUserNameStepViewController = [[ComposeCreateChannelUserNameStepViewController alloc] initWithFrame:self.view.bounds]; + } + + + [self hideModalView:YES animation:NO]; + + [self.composeCreateChannelUserNameStepViewController setAction:action]; + [self.navigationViewController pushViewController:self.composeCreateChannelUserNameStepViewController animated:self.navigationViewController.currentController != [self noDialogsSelectedViewController]]; + +} + +-(void)showComposeAddModerator:(ComposeAction *)action { + if(self.navigationViewController.currentController == self.composeConfirmModeratorViewController && self.composeConfirmModeratorViewController.action == action) + return; + + if(_composeConfirmModeratorViewController == nil) { + _composeConfirmModeratorViewController = [[ComposeConfirmModeratorViewController alloc] initWithFrame:self.view.bounds]; + } + + + [self hideModalView:YES animation:NO]; + + [_composeConfirmModeratorViewController setAction:action]; + [self.navigationViewController pushViewController:_composeConfirmModeratorViewController animated:self.navigationViewController.currentController != [self noDialogsSelectedViewController]]; + +} + +-(void)showComposeManagment:(ComposeAction *)action { + if(self.navigationViewController.currentController == self.composeManagmentViewController && self.composeManagmentViewController.action == action) + return; + + if(_composeManagmentViewController == nil) { + _composeManagmentViewController = [[ComposeManagmentViewController alloc] initWithFrame:self.view.bounds]; + } + + + [self hideModalView:YES animation:NO]; + + [_composeManagmentViewController setAction:action]; + [self.navigationViewController pushViewController:_composeManagmentViewController animated:self.navigationViewController.currentController != [self noDialogsSelectedViewController]]; +} + +-(void)showComposeChannelParticipants:(ComposeAction *)action { + if(self.navigationViewController.currentController == _composeChannelParticipantsViewController && _composeChannelParticipantsViewController.action == action) + return; + + if(_composeChannelParticipantsViewController == nil) { + _composeChannelParticipantsViewController = [[ComposeChannelParticipantsViewController alloc] initWithFrame:self.view.bounds]; + } + + + [self hideModalView:YES animation:NO]; + + [_composeChannelParticipantsViewController setAction:action]; + [self.navigationViewController pushViewController:_composeChannelParticipantsViewController animated:self.navigationViewController.currentController != [self noDialogsSelectedViewController]]; +} + +-(void)showComposeSettingsupNewChannel:(ComposeAction *)action { + if(self.navigationViewController.currentController == _composeSettingupNewChannelViewController && _composeSettingupNewChannelViewController.action == action) + return; + + if(_composeSettingupNewChannelViewController == nil) { + _composeSettingupNewChannelViewController = [[ComposeSettingupNewChannelViewController alloc] initWithFrame:self.view.bounds]; + } + + [self hideModalView:YES animation:NO]; + + [_composeSettingupNewChannelViewController setAction:action]; + [self.navigationViewController pushViewController:_composeSettingupNewChannelViewController animated:self.navigationViewController.currentController != [self noDialogsSelectedViewController]]; + +} + + @end diff --git a/TelegramTest/SearchHashtagCellView.m b/TelegramTest/SearchHashtagCellView.m index 363cbe3e..8c88302d 100644 --- a/TelegramTest/SearchHashtagCellView.m +++ b/TelegramTest/SearchHashtagCellView.m @@ -19,7 +19,7 @@ @implementation SearchHashtagCellView -(instancetype)initWithFrame:(NSRect)frameRect { if(self = [super initWithFrame:frameRect]) { _textField = [TMTextField defaultTextField]; - [_textField setFont:[NSFont fontWithName:@"HelveticaNeue" size:13]]; + [_textField setFont:TGSystemFont(13)]; [self addSubview:_textField]; } diff --git a/TelegramTest/SearchHistoryFilter.m b/TelegramTest/SearchHistoryFilter.m index 78646d42..9cd25840 100644 --- a/TelegramTest/SearchHistoryFilter.m +++ b/TelegramTest/SearchHistoryFilter.m @@ -10,81 +10,6 @@ @implementation SearchHistoryFilter - -static NSMutableDictionary * messageItems; -static NSMutableDictionary * messageKeys; - --(id)initWithController:(ChatHistoryController *)controller { - if(self = [super initWithController:controller]) { - - } - - return self; -} - - -+(void)initialize { - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - messageItems = [[NSMutableDictionary alloc] init]; - messageKeys = [[NSMutableDictionary alloc] init]; - - }); -} - -- (NSMutableDictionary *)messageKeys:(int)peer_id { - return [[self class] messageKeys:peer_id]; -} - -- (NSMutableArray *)messageItems:(int)peer_id { - return [[self class] messageItems:peer_id]; -} - -+ (NSMutableDictionary *)messageKeys:(int)peer_id { - - __block NSMutableDictionary *keys; - [ASQueue dispatchOnStageQueue:^{ - - keys = messageKeys[@(peer_id)]; - - if(!keys) - { - keys = [[NSMutableDictionary alloc] init]; - messageKeys[@(peer_id)] = keys; - } - - } synchronous:YES]; - - return keys; -} - -+ (NSMutableArray *)messageItems:(int)peer_id { - __block NSMutableArray *items; - - [ASQueue dispatchOnStageQueue:^{ - - items = messageItems[@(peer_id)]; - - if(!items) - { - items = [[NSMutableArray alloc] init]; - messageItems[@(peer_id)] = items; - } - - } synchronous:YES]; - - - - return items; -} - -+(void)drop { - [ASQueue dispatchOnStageQueue:^{ - [messageKeys removeAllObjects]; - [messageItems removeAllObjects]; - }]; -} - -(int)type { return HistoryFilterSearch; } diff --git a/TelegramTest/SearchItem.m b/TelegramTest/SearchItem.m index c5753060..4f85fa5a 100644 --- a/TelegramTest/SearchItem.m +++ b/TelegramTest/SearchItem.m @@ -51,28 +51,47 @@ - (id)initWithUserItem:(TLUser*)user searchString:(NSString*)searchString { } -- (id)initWithGlobalItem:(TLUser*)user searchString:(NSString *)searchString { +- (id)initWithGlobalItem:(id)object searchString:(NSString *)searchString { self = [super init]; if(self) { [self initialize]; self.type = SearchItemGlobalUser; - self.conversation = [[DialogsManager sharedManager] findByUserId:user.n_id]; - if(!self.conversation) { - self.conversation = [[DialogsManager sharedManager] createDialogForUser:user]; - } - - self.user = user; - - [self.title appendString:user.fullName withColor:DARK_BLACK]; - - - [self.status appendString:[NSString stringWithFormat:@"@%@",user.username] withColor:GRAY_TEXT_COLOR]; - - [self.status setSelectionColor:NSColorFromRGB(0xfffffe) forColor:GRAY_TEXT_COLOR]; + if([object isKindOfClass:[TLUser class]]) { + + TLUser *user = object; - [NSMutableAttributedString selectText:[NSString stringWithFormat:@"@%@",searchString] fromAttributedString:(NSMutableAttributedString *)self.status selectionColor:BLUE_UI_COLOR]; + self.conversation = user.dialog; + + self.user = user; + + [self.title appendString:user.fullName withColor:DARK_BLACK]; + + + + [self.status appendString:[NSString stringWithFormat:@"@%@",user.username] withColor:GRAY_TEXT_COLOR]; + + [self.status setSelectionColor:NSColorFromRGB(0xfffffe) forColor:GRAY_TEXT_COLOR]; + + [NSMutableAttributedString selectText:[NSString stringWithFormat:@"@%@",searchString] fromAttributedString:(NSMutableAttributedString *)self.status selectionColor:BLUE_UI_COLOR]; + + } else if([object isKindOfClass:[TLChat class]]) { + TLChat *chat = object; + + self.conversation = chat.dialog; + + self.chat = chat; + + [self.title appendString:chat.title withColor:DARK_BLACK]; + + + [self.status appendString:[NSString stringWithFormat:@"@%@",chat.username] withColor:GRAY_TEXT_COLOR]; + + [self.status setSelectionColor:NSColorFromRGB(0xfffffe) forColor:GRAY_TEXT_COLOR]; + + [NSMutableAttributedString selectText:[NSString stringWithFormat:@"@%@",searchString] fromAttributedString:(NSMutableAttributedString *)self.status selectionColor:BLUE_UI_COLOR]; + } } return self; @@ -85,11 +104,7 @@ - (id)initWithChatItem:(TLChat *)chat searchString:(NSString *)searchString { self.type = SearchItemChat; self.chat = [[ChatsManager sharedManager] find:chat.n_id]; - self.conversation = [[DialogsManager sharedManager] findByChatId:chat.n_id]; - - if(!self.conversation) { - self.conversation = [[DialogsManager sharedManager] createDialogForChat:chat]; - } + self.conversation = chat.dialog; [self.title appendString:chat.title withColor:DARK_BLACK]; [NSMutableAttributedString selectText:searchString fromAttributedString:(NSMutableAttributedString *)self.title selectionColor:BLUE_UI_COLOR]; @@ -108,7 +123,7 @@ - (id)initWithDialogItem:(TL_conversation *)dialog searchString:(NSString*)searc self.conversation = dialog; - if(self.conversation.type == DialogTypeChat) { + if(self.conversation.type == DialogTypeChat || self.conversation.type == DialogTypeChannel) { self.chat = self.conversation.chat; } else if(self.conversation.type == DialogTypeSecretChat) { self.user = self.conversation.encryptedChat.peerUser; @@ -118,9 +133,7 @@ - (id)initWithDialogItem:(TL_conversation *)dialog searchString:(NSString*)searc - - - [self.title appendString:self.conversation.type == DialogTypeChat ? dialog.chat.title : dialog.user.fullName withColor:DARK_BLACK]; + [self.title appendString:self.conversation.type == DialogTypeChat || self.conversation.type == DialogTypeChannel ? self.chat.title : dialog.user.fullName withColor:DARK_BLACK]; [NSMutableAttributedString selectText:searchString fromAttributedString:(NSMutableAttributedString*)self.title selectionColor:BLUE_UI_COLOR]; @@ -147,7 +160,7 @@ - (id)initWithMessageItem:(TL_localMessage *)message searchString:(NSString *)se self.user = self.conversation.encryptedChat.peerUser; } - if(self.conversation.type == DialogTypeChat) { + if(self.conversation.type == DialogTypeChat || self.conversation.type == DialogTypeChannel) { self.chat = self.conversation.chat; [self.title appendString:self.chat.title withColor:DARK_BLACK]; } else { @@ -172,7 +185,7 @@ - (id)initWithMessageItem:(TL_localMessage *)message searchString:(NSString *)se [[self.status mutableString] replaceCharactersInRange:NSMakeRange(0, range.location - 8 + offset) withString:@"..."]; } - if(self.conversation.type == DialogTypeChat || self.user.n_id != self.message.from_id) { + if(self.conversation.type == DialogTypeChannel || self.conversation.type == DialogTypeChat || self.user.n_id != self.message.from_id) { TLUser *user = [[UsersManager sharedManager] find:self.message.from_id]; @@ -190,11 +203,11 @@ - (id)initWithMessageItem:(TL_localMessage *)message searchString:(NSString *)se [self.date setSelectionColor:NSColorFromRGB(0xcbe1f1) forColor:NSColorFromRGB(0x333333)]; [self.date setSelectionColor:NSColorFromRGB(0xcbe1f2) forColor:DARK_BLUE]; - - NSString *dateStr = [TGDateUtils stringForMessageListDate:message.date]; - [self.date appendString:dateStr withColor:NSColorFromRGB(0xaeaeae)]; - + NSString *dateStr = [TGDateUtils stringForMessageListDate:message.date]; + [self.date appendString:dateStr withColor:NSColorFromRGB(0xaeaeae)]; + + self.dateSize = [self.date size]; } return self; diff --git a/TelegramTest/SearchLoadMoreCell.m b/TelegramTest/SearchLoadMoreCell.m index d16fa6c0..04348cce 100644 --- a/TelegramTest/SearchLoadMoreCell.m +++ b/TelegramTest/SearchLoadMoreCell.m @@ -23,7 +23,7 @@ - (id)initWithFrame:(NSRect)frameRect { self.loadMore = [[TMTextButton alloc] init]; [self.loadMore setTextColor:BLUE_UI_COLOR]; [self.loadMore setAutoresizingMask:NSViewMinXMargin | NSViewMaxXMargin]; - [self.loadMore setFont:[NSFont fontWithName:@"HelveticaNeue" size:13]]; + [self.loadMore setFont:TGSystemFont(13)]; [self.loadMore setTapBlock:^{ SearchLoadMoreItem *item = (SearchLoadMoreItem *)[strongSelf rowItem]; if(item.clickBlock) diff --git a/TelegramTest/SearchMessageTableItem.m b/TelegramTest/SearchMessageTableItem.m index 574339a3..62b7359c 100644 --- a/TelegramTest/SearchMessageTableItem.m +++ b/TelegramTest/SearchMessageTableItem.m @@ -28,6 +28,19 @@ -(id)initWithMessage:(TL_localMessage *)message selectedText:(NSString *)selecte if(self = [super init]) { _conversation = message.conversation; + + if(message.chat.migrated_to.channel_id != 0) { + + TLChat *chat = [[ChatsManager sharedManager] find:message.chat.migrated_to.channel_id]; + + _conversation = [chat dialog]; + + /* + 27.04.15, 18:47:02: Dmitry Moskovsky: Оро + + */ + } + _message = message; _selectText = selectedText; @@ -65,6 +78,15 @@ -(void)update { [_dateText appendString:@"" withColor:NSColorFromRGB(0xaeaeae)]; } + if(self.conversation.type != DialogTypeSecretChat && self.conversation.chat) + self.nameTextSize = [self.conversation.chat dialogTitleSize]; + else if(self.conversation.type == DialogTypeSecretChat) + self.nameTextSize = [self.conversation.user dialogEncryptedTitleSize]; + else + self.nameTextSize = [self.conversation.user dialogTitleSize]; + + self.nameTextSize = NSMakeSize(self.nameTextSize.width + (self.conversation.isMute ? 20 : 0), self.nameTextSize.height); + _dateSize = [_dateText size]; _dateSize.width+=5; _dateSize.width = ceil(_dateSize.width); diff --git a/TelegramTest/SearchMessagesView.h b/TelegramTest/SearchMessagesView.h index 2ec00210..e0178761 100644 --- a/TelegramTest/SearchMessagesView.h +++ b/TelegramTest/SearchMessagesView.h @@ -10,9 +10,9 @@ @interface SearchMessagesView : TMView -@property (nonatomic,strong) MessagesViewController *controller; +@property (nonatomic,weak) MessagesViewController *controller; --(void)showSearchBox:( void (^)(int msg_id, NSString *searchString))callback closeCallback:(dispatch_block_t) closeCallback; +-(void)showSearchBox:( void (^)(TL_localMessage *msg, NSString *searchString))callback closeCallback:(dispatch_block_t) closeCallback; -(NSString *)currentString; diff --git a/TelegramTest/SearchMessagesView.m b/TelegramTest/SearchMessagesView.m index 995afe6b..7ff08e57 100644 --- a/TelegramTest/SearchMessagesView.m +++ b/TelegramTest/SearchMessagesView.m @@ -16,7 +16,7 @@ @interface SearchMessagesView () @property (nonatomic,strong) NSProgressIndicator *progressIndicator; -@property (nonatomic,copy) void (^goToMessage)(int msg_id, NSString *searchString); +@property (nonatomic,copy) void (^goToMessage)(TL_localMessage *msg, NSString *searchString); @property (nonatomic,copy) dispatch_block_t closeCallback; @@ -57,7 +57,7 @@ -(id)initWithFrame:(NSRect)frameRect { [self.cancelButton setTapBlock:^ { strongSelf.closeCallback(); - [strongSelf.controller jumpToLastMessages]; + [strongSelf.controller jumpToLastMessages:YES]; [strongSelf.request cancelRequest]; strongSelf.request = nil; }]; @@ -159,9 +159,11 @@ -(void)searchFieldTextChange:(NSString *)searchString { -(void)load:(BOOL)first { - [RPCRequest sendRequest:[TLAPI_messages_search createWithPeer:[Telegram conversation].inputPeer q:self.searchField.stringValue filter:[TL_inputMessagesFilterEmpty create] min_date:0 max_date:0 offset:(int)self.messages.count max_id:0 limit:100] successHandler:^(id request, TL_messages_messages *response) { + [RPCRequest sendRequest:[TLAPI_messages_search createWithFlags:0 peer:self.controller.conversation.inputPeer q:self.searchField.stringValue filter:[TL_inputMessagesFilterEmpty create] min_date:0 max_date:0 offset:(int)self.messages.count max_id:0 limit:100] successHandler:^(id request, TL_messages_messages *response) { + [TL_localMessage convertReceivedMessages:response.messages]; + if(response.messages.count > 0) { [self.messages addObjectsFromArray:response.messages]; } @@ -201,7 +203,7 @@ -(void)next { _currentIdx = 0; } - _goToMessage([(TLMessage *)_messages[_currentIdx] n_id],_searchField.stringValue); + _goToMessage(_messages[_currentIdx],_searchField.stringValue); } -(void)prev { @@ -214,7 +216,7 @@ -(void)prev { _currentIdx = (int)_messages.count - 1; } - _goToMessage([(TLMessage *)_messages[_currentIdx] n_id],_searchField.stringValue); + _goToMessage(_messages[_currentIdx],_searchField.stringValue); } -(void)setLocked:(BOOL)locked { @@ -253,16 +255,18 @@ -(void)mouseUp:(NSEvent *)theEvent { --(void)showSearchBox:( void (^)(int msg_id, NSString *searchString))callback closeCallback:(dispatch_block_t) closeCallback { +-(void)showSearchBox:( void (^)(TL_localMessage *msg, NSString *searchString))callback closeCallback:(dispatch_block_t) closeCallback { self.messages = nil; self.currentIdx = -1; [self.searchField setStringValue:@""]; + [self.searchField becomeFirstResponder]; + self.goToMessage = callback; self.closeCallback = closeCallback; - [self setFrameSize:NSMakeSize([Telegram rightViewController].view.frame.size.width, NSHeight(self.frame))]; + [self setFrameSize:NSMakeSize(self.controller.view.frame.size.width, NSHeight(self.frame))]; [self updateSearchArrows]; diff --git a/TelegramTest/SearchSeparatorTableCell.m b/TelegramTest/SearchSeparatorTableCell.m index 43e4d49b..1bfb6fe2 100644 --- a/TelegramTest/SearchSeparatorTableCell.m +++ b/TelegramTest/SearchSeparatorTableCell.m @@ -47,7 +47,7 @@ - (id)initWithFrame:(NSRect)frameRect { [self.textField setBordered:NO]; [self.textField setDrawsBackground:NO]; [self.textField setAutoresizingMask:NSViewMinXMargin | NSViewMaxXMargin]; - [self.textField setFont:[NSFont fontWithName:@"HelveticaNeue" size:13]]; + [self.textField setFont:TGSystemFont(13)]; [self addSubview:self.textField]; } return self; @@ -57,6 +57,8 @@ -(void)setFrame:(NSRect)frame { [super setFrame:frame]; [self.textField setCenterByView:self]; + + [self.textField setFrameOrigin:NSMakePoint(NSMinX(_textField.frame), 6)]; } @@ -69,7 +71,9 @@ - (void)redrawRow { self.textField.stringValue = item.itemCount == -1 ? NSLocalizedString(@"Search.LoadingMessages", nil) : (item.itemCount == 0 ? item.oneName : [NSString stringWithFormat:@"%d %@", item.itemCount, item.itemCount == 1 ? item.oneName : item.pluralName]); [self.textField sizeToFit]; - [self.textField setCenterByView:self]; + [self.textField setCenteredXByView:self]; + + [self.textField setFrameOrigin:NSMakePoint(NSMinX(_textField.frame), 6)]; } diff --git a/TelegramTest/SearchTableCell.m b/TelegramTest/SearchTableCell.m index 214d8f1a..e2ef93e3 100644 --- a/TelegramTest/SearchTableCell.m +++ b/TelegramTest/SearchTableCell.m @@ -36,7 +36,7 @@ - (id) initWithFrame:(NSRect)frameRect { [self.titleTextField setAutoresizingMask:NSViewWidthSizable]; [[self.titleTextField cell] setTruncatesLastVisibleLine:YES]; [[self.titleTextField cell] setLineBreakMode:NSLineBreakByTruncatingTail]; - [self.titleTextField setFont:[NSFont fontWithName:@"HelveticaNeue" size:14]]; + [self.titleTextField setFont:TGSystemFont(14)]; [self.titleTextField setDrawsBackground:NO]; // [self.titleTextField setBackgroundColor:[NSColor redColor]]; @@ -46,7 +46,7 @@ - (id) initWithFrame:(NSRect)frameRect { [self.statusTextField setEditable:NO]; [self.statusTextField setBordered:NO]; [self.statusTextField setDrawsBackground:NO]; - [self.statusTextField setFont:[NSFont fontWithName:@"HelveticaNeue" size:13]]; + [self.statusTextField setFont:TGSystemFont(13)]; [self.statusTextField setSelector:@selector(statusForSearchTableView)]; [self.statusTextField setAutoresizingMask:NSViewWidthSizable]; [[self.statusTextField cell] setLineBreakMode:NSLineBreakByCharWrapping]; @@ -59,7 +59,7 @@ - (id) initWithFrame:(NSRect)frameRect { [self.dateTextField setBordered:NO]; [self.dateTextField setAutoresizingMask:NSViewMinXMargin]; [self.dateTextField setBackgroundColor:[NSColor clearColor]]; - [self.dateTextField setFont:[NSFont fontWithName:@"Helvetica-Light" size:12]]; + [self.dateTextField setFont:TGSystemLightFont(12)]; [self addSubview:self.dateTextField]; self.avatarImageView = [TMAvatarImageView standartTableAvatar]; @@ -95,7 +95,7 @@ - (void)redrawRow { SearchItem *item = [self rowItem]; - if(item.conversation.type == DialogTypeChat) { + if(item.conversation.type == DialogTypeChat || item.conversation.type == DialogTypeChannel) { [self.titleTextField setChat:item.chat]; } @@ -129,19 +129,26 @@ - (void)redrawRow { [self.avatarImageView setUser:item.user]; [self.statusTextField setUser:item.user]; - if(item.type == SearchItemGlobalUser) { - [self.statusTextField setUser:nil]; - [self.statusTextField setAttributedStringValue:item.status]; - } + } - [self.titleTextField setFrameSize:NSMakeSize(self.bounds.size.width - 75, self.titleTextField.bounds.size.height)]; + if(item.type == SearchItemGlobalUser) { + [self.statusTextField setUser:nil]; + [self.statusTextField setChat:nil]; + [self.statusTextField setAttributedStringValue:item.status]; + } + + [self.titleTextField sizeToFit]; + + [self.titleTextField setFrameSize:NSMakeSize(MIN(self.bounds.size.width - 75,NSWidth(self.titleTextField.frame)), self.titleTextField.bounds.size.height)]; [self.dateTextField setHidden:YES]; } else { - if(item.conversation.type == DialogTypeChat) { + + + if(item.conversation.type == DialogTypeChat || item.conversation.type == DialogTypeChannel) { [self.avatarImageView setChat:item.chat]; } @@ -195,9 +202,10 @@ - (void)drawRect:(NSRect)dirtyRect { [DIALOG_BORDER_COLOR set]; NSRectFill(NSMakeRect(68, 0, self.bounds.size.width - DIALOG_BORDER_WIDTH - 68, 1)); -// [NSColorFromRGB(0xcccccc) set]; -// -// NSRectFill(NSMakeRect(66, 0, self.bounds.size.width - DIALOG_BORDER_WIDTH - 66, 1)); + } + + if([self rowItem].conversation.isVerified) { + [self.isSelected ? image_VerifyWhite() : image_Verify() drawInRect:NSMakeRect(NSMaxX(self.titleTextField.frame),NSMinY(self.titleTextField.frame) , image_Verify().size.width, image_Verify().size.height) fromRect:NSZeroRect operation:NSCompositeHighlight fraction:1]; } } diff --git a/TelegramTest/SearchViewController.h b/TelegramTest/SearchViewController.h index 2f504ff5..e0462202 100644 --- a/TelegramTest/SearchViewController.h +++ b/TelegramTest/SearchViewController.h @@ -27,6 +27,8 @@ typedef enum { - (void) searchByString:(NSString*)searchString; +-(int)selectedPeerId; + -(void)dontLoadHashTagsForOneRequest; @end diff --git a/TelegramTest/SearchViewController.m b/TelegramTest/SearchViewController.m index 8d615819..918d5f3e 100644 --- a/TelegramTest/SearchViewController.m +++ b/TelegramTest/SearchViewController.m @@ -27,7 +27,8 @@ SearchSectionContacts, SearchSectionUsers, SearchSectionMessages, - SearchSectionGlobalUsers + SearchSectionGlobalUsers, + SearchSectionChannels } SearchSection; @interface SearchParams : NSObject @@ -101,6 +102,7 @@ @interface SearchViewController() @property (nonatomic, strong) SearchLoadMoreItem *usersLoadMoreItem; @property (nonatomic, strong) SearchLoadMoreItem *messagesLoadMoreItem; @property (nonatomic, strong) SearchLoadMoreItem *globalUsersLoadMoreItem; +@property (nonatomic, strong) SearchLoadMoreItem *globalChannelsLoadMoreItem; @property (nonatomic, strong) SearchLoaderItem *messagesLoaderItem; @@ -114,10 +116,8 @@ - (void)loadView { [super loadView]; weakify(); - [self.view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; - self.contactsSeparator = [[SearchSeparatorItem alloc] initWithOneName:NSLocalizedString(@"Search.Separator.Contacts", nil) pluralName:NSLocalizedString(@"Search.Separator.Contacts", nil)]; self.usersSeparator = [[SearchSeparatorItem alloc] initWithOneName:NSLocalizedString(@"Search.Separator.User", nil) pluralName:NSLocalizedString(@"Search.Separator.Users", nil)]; self.messagesSeparator = [[SearchSeparatorItem alloc] initWithOneName:NSLocalizedString(@"Search.Separator.Messages", nil) pluralName:NSLocalizedString(@"Search.Separator.Messages", nil)]; @@ -146,6 +146,12 @@ - (void)loadView { }]; + self.globalChannelsLoadMoreItem = [[SearchLoadMoreItem alloc] init]; + [self.globalChannelsLoadMoreItem setClickBlock:^{ + [strongSelf showMore:SearchSectionChannels animation:YES]; + }]; + + self.messagesLoadMoreItem = [[SearchLoadMoreItem alloc] init]; [self.messagesLoadMoreItem setClickBlock:^{ [strongSelf showMore:SearchSectionMessages animation:YES]; @@ -167,8 +173,6 @@ - (void)loadView { [self.noResultsImageView setImage:image_noResults()]; [self.noResultsImageView setAutoresizingMask:NSViewMaxXMargin | NSViewMaxYMargin | NSViewMinXMargin | NSViewMinYMargin | NSViewWidthSizable | NSViewHeightSizable]; - - [self.noResultsView setCenterByView:self.view]; [self.noResultsView addSubview:self.noResultsImageView]; [self.noResultsView setAutoresizingMask:NSViewMaxXMargin | NSViewMaxYMargin | NSViewMinXMargin | NSViewMinYMargin | NSViewWidthSizable | NSViewHeightSizable]; @@ -182,8 +186,6 @@ - (void)loadView { [self.tableView reloadData]; [self.view addSubview:self.tableView.containerView]; - - [Notification addObserver:self selector:@selector(notificationDialogSelectionChanged:) name:@"ChangeDialogSelection"]; [self addScrollEvent]; @@ -209,13 +211,9 @@ - (void)scrollViewDocumentOffsetChangingNotificationHandler:(NSNotification *)aN if(self.searchParams.isStorageLoaded) { [self remoteSearch:self.searchParams]; - } else { - [self localSearch:self.searchParams]; } } - - // ; } @@ -227,7 +225,7 @@ - (void)notificationDialogSelectionChanged:(NSNotification *)notify { TL_conversation *dialog = [notify.userInfo objectForKey:KEY_DIALOG]; [self.tableView cancelSelection]; - if(![dialog isKindOfClass:NSNull.class] && dialog) { + if(![dialog isKindOfClass:NSNull.class] && dialog && self.searchParams.searchString.length > 0) { NSUInteger hash = [SearchItem hash:[[SearchItem alloc] initWithDialogItem:dialog searchString:self.searchParams.searchString]]; [self.tableView setSelectedByHash:hash]; } @@ -282,16 +280,12 @@ - (BOOL)selectionWillChange:(NSInteger)row item:(TMRowItem *) item { return res; } - - if(item && (![item isKindOfClass:[SearchSeparatorItem class]])) { TGConversationTableItem *searchItem = (TGConversationTableItem *)item; if(searchItem.conversation) { [[Telegram rightViewController] modalViewSendAction:searchItem.conversation]; - } //else if(searchItem.user) { - // [[Telegram rightViewController] modalViewSendAction:[[DialogsManager sharedManager] findByUserId:searchItem.user.n_id]]; - // } + } } return NO; @@ -314,19 +308,28 @@ - (void)selectionDidChange:(NSInteger)row item:(TMRowItem *)item { if([item isKindOfClass:[SearchMessageTableItem class]]) { msg_id = [[(SearchMessageTableItem *)searchItem message] n_id]; } else { - TMViewController *controller = [[Telegram leftViewController] currentTabController]; + StandartViewController *controller = (StandartViewController *) [[Telegram leftViewController] currentTabController]; - if([controller isKindOfClass:[StandartViewController class]]) { - // [(StandartViewController *)controller searchByString:@""]; + if([controller isKindOfClass:[StandartViewController class]] && dialog) { + [controller hideSearchViewControllerWithConversationUsed:dialog]; } + } if(dialog){ - BOOL success = [[Telegram rightViewController] showByDialog:dialog withJump:msg_id historyFilter:[HistoryFilter class] sender:self]; - if(!success) { - [[Telegram rightViewController].messagesViewController setCurrentConversation:dialog withJump:msg_id historyFilter:[HistoryFilter class]]; - } + + + [appWindow().navigationController showMessagesViewController:dialog withMessage:searchItem.message]; + + + + // [self searchByString:@""]; + +// BOOL success = [[Telegram rightViewController] showByDialog:dialog withJump:msg_id historyFilter:[HistoryFilter class] sender:self]; +// if(!success) { +// [[Telegram rightViewController].messagesViewController setCurrentConversation:dialog withJump:msg_id historyFilter:[HistoryFilter class]]; +// } [self.tableView setSelectedByHash:item.hash]; } } else if(item && [item isKindOfClass:[SearchHashtagItem class]]) { @@ -484,7 +487,8 @@ - (void)showSearchResults:(SearchParams *)params { } if(params.globalUsers.count > insertCount) { - [self.tableView insert:[params.globalUsers subarrayWithRange:NSMakeRange(0, insertCount-1)] startIndex:[self.tableView count] tableRedraw:NO]; + for(int i = 0; i < insertCount; i++) + [self.tableView addItem:[params.globalUsers objectAtIndex:i] tableRedraw:NO]; self.globalUsersLoadMoreItem.num = (int)params.globalUsers.count - insertCount; [self.tableView addItem:self.globalUsersLoadMoreItem tableRedraw:NO]; @@ -552,7 +556,13 @@ - (void)remoteSearch:(SearchParams *)params { self.searchParams.isLoading = YES; - [RPCRequest sendRequest:[TLAPI_messages_search createWithPeer:[TL_inputPeerEmpty create] q:params.searchString filter:[TL_inputMessagesFilterEmpty create] min_date:0 max_date:0 offset:params.remote_offset max_id:0 limit:50] successHandler:^(RPCRequest *request, TL_messages_messagesSlice *response) { + + int offset_id = [[(SearchMessageTableItem *)[params.messages lastObject] message] n_id]; + int offset_date = [[(SearchMessageTableItem *)[params.messages lastObject] message] date]; + + id request = ACCEPT_FEATURE ? [TLAPI_messages_searchGlobal createWithQ:params.searchString offset_date:offset_date offset_peer:[TL_inputPeerEmpty create] offset_id:offset_id limit:50] : [TLAPI_messages_search createWithFlags:0 peer:[TL_inputPeerEmpty create] q:params.searchString filter:[TL_inputMessagesFilterEmpty create] min_date:0 max_date:0 offset:params.remote_offset max_id:0 limit:50]; + + [RPCRequest sendRequest:request successHandler:^(RPCRequest *request, TL_messages_messagesSlice *response) { if(params != self.searchParams) @@ -598,9 +608,7 @@ - (void)remoteSearch:(SearchParams *)params { params.isRemoteLoaded = YES; - if(params.isStorageLoaded) { - [self showMessagesResults:params]; - } + [self showMessagesResults:params]; } errorHandler:^(RPCRequest *request, RpcError *error) { if(params != self.searchParams) @@ -614,9 +622,14 @@ - (void)showMessagesResults:(SearchParams *)params { if(params != self.searchParams) return; + + [self.tableView setDefaultAnimation:NSTableViewAnimationEffectNone]; [self.tableView removeItem:self.messagesLoaderItem]; + + self.messagesSeparator.itemCount = params.isLoading ? -1 : (int)params.messages.count; + if(!params.messages.count) { [self.tableView removeItem:self.messagesSeparator]; [self.tableView removeItem:self.messagesLoadMoreItem]; @@ -626,6 +639,8 @@ - (void)showMessagesResults:(SearchParams *)params { [self.tableView.containerView setHidden:self.tableView.count == 0]; [CATransaction commit]; return; + } else if(self.searchParams.dialogs.count > 0) { + [self.tableView addItem:self.messagesSeparator tableRedraw:YES]; } [CATransaction begin]; @@ -635,7 +650,7 @@ - (void)showMessagesResults:(SearchParams *)params { if(params.messages_offset <= 50) { if([self.tableView isItemInList:self.messagesSeparator]) { - [self.messagesSeparator setItemCount:params.messages_count]; + // [self.messagesSeparator setItemCount:params.messages_count]; [self.tableView reloadDataForRowIndexes:[NSIndexSet indexSetWithIndex:self.tableView.count - 1] columnIndexes:[NSIndexSet indexSetWithIndex:0]]; } } @@ -654,8 +669,13 @@ - (void)showMessagesResults:(SearchParams *)params { } +-(int)selectedPeerId { + return ((SearchItem *)self.tableView.selectedItem).conversation.peer_id; +} + - (void)searchByString:(NSString *)searchString { + [self.tableView.containerView setHidden:NO]; if(searchString.length == 0) { @@ -693,9 +713,9 @@ - (void)searchByString:(NSString *)searchString { for(TLChat *chat in searchChats) { TL_conversation *dialog = chat.dialog; - if(dialog && !dialog.fake) + if(dialog && !dialog.fake && ([chat isKindOfClass:[TLChat class]] && !chat.isDeactivated)) [dialogs addObject:dialog]; - else + else if ([chat isKindOfClass:[TLChat class]] && !chat.isDeactivated) [dialogsNeedCheck addObject:@(-chat.n_id)]; } @@ -774,15 +794,9 @@ - (void)searchByString:(NSString *)searchString { _dontLoadHashtagsForOneRequest = NO; - - - - [[Storage manager] searchDialogsByPeers:dialogsNeedCheck needMessages:NO searchString:nil completeHandler:^(NSArray *dialogsDB, NSArray *messagesDB, NSArray *searchMessagesDB) { - + [[Storage manager] searchDialogsByPeers:dialogsNeedCheck needMessages:NO searchString:nil completeHandler:^(NSArray *dialogsDB) { [[DialogsManager sharedManager] add:dialogsDB]; - [[MessagesManager sharedManager] add:messagesDB]; - [dialogs addObjectsFromArray:dialogsDB]; NSArray *insertedDialogs = [dialogs sortedArrayWithOptions:NSSortStable usingComparator:^NSComparisonResult(TL_conversation *dialog1, TL_conversation *dialog2) { @@ -831,7 +845,7 @@ - (void)searchByString:(NSString *)searchString { } - if((self.type & SearchTypeGlobalUsers) == SearchTypeGlobalUsers && searchParams.searchString.length >= 5) { + if((self.type & SearchTypeGlobalUsers) == SearchTypeGlobalUsers) { searchParams.globalUsers = [[NSMutableArray alloc] init]; @@ -839,10 +853,11 @@ - (void)searchByString:(NSString *)searchString { [filtred enumerateObjectsUsingBlock:^(TLUser *obj, NSUInteger idx, BOOL *stop) { - SearchItem *item = [[SearchItem alloc] initWithGlobalItem:obj searchString:searchString]; - - [searchParams.globalUsers addObject:item]; - + if(searchParams.searchString.length >= 5 || obj.isContact) { + SearchItem *item = [[SearchItem alloc] initWithGlobalItem:obj searchString:searchString]; + + [searchParams.globalUsers addObject:item]; + } }]; @@ -874,8 +889,7 @@ - (void)searchByString:(NSString *)searchString { self.searchParams.isFinishLoading = YES; } else { dispatch_after_seconds(0.1, ^{ - // [self remoteSearch:searchParams]; - [self localSearch:searchParams]; + [self remoteSearch:searchParams]; }); } @@ -916,23 +930,30 @@ -(void)remoteGlobalSearch:(SearchParams *)params { params.isLoading = NO; params.isRemoteGlobalUsersLoaded = YES; - if(response.users.count > 0) { + if(response.users.count > 0 || response.chats > 0) { + NSMutableArray *chatIds = [[NSMutableArray alloc] init]; NSMutableArray *ids = [[NSMutableArray alloc] init]; [params.globalUsers enumerateObjectsUsingBlock:^(SearchItem *obj, NSUInteger idx, BOOL *stop) { - [ids addObject:@([obj.user n_id])]; + if(obj.user) + [ids addObject:@([obj.user n_id])]; + else + [chatIds addObject:@([obj.chat n_id])]; }]; + + NSArray *acceptUsers = [response.users filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"NOT(self.n_id IN %@)",ids]]; + NSArray *acceptChats = [response.chats filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"NOT(self.n_id IN %@)",ids]]; - NSArray *filtred = [response.users filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"NOT(self.n_id IN %@)",ids]]; + [[UsersManager sharedManager] add:acceptUsers withCustomKey:@"n_id" update:YES]; - [[UsersManager sharedManager] add:filtred withCustomKey:@"n_id" update:YES]; + [[ChatsManager sharedManager] add:acceptChats]; - [filtred enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + [[acceptChats arrayByAddingObjectsFromArray:acceptUsers] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { [params.globalUsers addObject:[[SearchItem alloc] initWithGlobalItem:obj searchString:params.searchString]]; }]; @@ -951,68 +972,6 @@ -(void)remoteGlobalSearch:(SearchParams *)params { } --(void)localSearch:(SearchParams *)params { - - - - //self.searchParams.isLoading = YES; - - params.isStorageLoaded = YES; - params.messages_count = 0; - [self remoteSearch:params]; - - return; - - - [[Storage manager] searchMessagesBySearchString:params.searchString offset:params.local_offset completeHandler:^(NSInteger count, NSArray *messages) { - - - [ASQueue dispatchOnStageQueue:^{ - if(self.searchParams != params) - return; - - [[MessagesManager sharedManager] add:messages]; - - - self.searchParams.isLoading = NO; - - params.local_offset += (int) count; - - - params.messages_offset+= (int)count; - - params.messages_count+=(int)count; - - - if(!params.messages) - params.messages = [NSMutableArray array]; - - for(TL_localMessage *message in messages) - [params.messages addObject:[[SearchMessageTableItem alloc] initWithMessage:message selectedText:params.searchString]]; - - if(params.messages.count > 0) { - [[ASQueue mainQueue] dispatchOnQueue:^{ - [self showMessagesResults:params]; - }]; - } - - - - if(count < 50) { - params.isStorageLoaded = YES; - params.messages_count = 0; - [self remoteSearch:params]; - } - - }]; - - - }]; - - - - -} -(void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; diff --git a/TelegramTest/SecretChatAccepter.m b/TelegramTest/SecretChatAccepter.m index 52556fa5..b92de91a 100644 --- a/TelegramTest/SecretChatAccepter.m +++ b/TelegramTest/SecretChatAccepter.m @@ -58,7 +58,7 @@ -(void)proccess:(NSNotification *)notify { [RPCRequest sendRequest:[TLAPI_messages_acceptEncryption createWithPeer:[TL_inputEncryptedChat createWithChat_id:chat_id access_hash:params.access_hash] g_b:params.g_a_or_b key_fingerprint:params.key_fingerprint] successHandler:^(RPCRequest *request3, TL_encryptedChat * acceptResponse) { - TL_conversation *dialog = [TL_conversation createWithPeer:[TL_peerSecret createWithChat_id:acceptResponse.n_id] top_message:-1 unread_count:0 last_message_date:[[MTNetwork instance] getTime] notify_settings:[TL_peerNotifySettingsEmpty create] last_marked_message:0 top_message_fake:-1 last_marked_date:[[MTNetwork instance] getTime] sync_message_id:0]; + TL_conversation *dialog = [TL_conversation createWithPeer:[TL_peerSecret createWithChat_id:acceptResponse.n_id] top_message:-1 unread_count:0 last_message_date:[[MTNetwork instance] getTime] notify_settings:[TL_peerNotifySettingsEmpty create] last_marked_message:0 top_message_fake:-1 last_marked_date:[[MTNetwork instance] getTime] sync_message_id:0 read_inbox_max_id:0 unread_important_count:0 lastMessage:nil]; [[ChatsManager sharedManager] add:@[acceptResponse]]; [[DialogsManager sharedManager] insertDialog:dialog]; diff --git a/TelegramTest/SelectChatItem.h b/TelegramTest/SelectChatItem.h index 6f780b82..b7ba2491 100644 --- a/TelegramTest/SelectChatItem.h +++ b/TelegramTest/SelectChatItem.h @@ -10,4 +10,7 @@ @interface SelectChatItem : TMRowItem @property (nonatomic,strong,readonly) TLChat *chat; + +@property (nonatomic) BOOL isSelected; + @end diff --git a/TelegramTest/SelectChatRowView.m b/TelegramTest/SelectChatRowView.m index 8138b4ba..328b45c8 100644 --- a/TelegramTest/SelectChatRowView.m +++ b/TelegramTest/SelectChatRowView.m @@ -19,6 +19,9 @@ @interface SelectChatRowView () @property (nonatomic, strong) TMNameTextField *titleTextField; @property (nonatomic, strong) TMStatusTextField *statusTextField; + +@property (nonatomic, strong) BTRButton *selectButton; + -(SelectChatItem *)rowItem; @@ -33,17 +36,16 @@ - (id)initWithFrame:(NSRect)frame if (self) { [self setSelectedBackgroundColor: NSColorFromRGB(0xfafafa)]; [self setNormalBackgroundColor:NSColorFromRGB(0xffffff)]; - _avatarImageView = [TMAvatarImageView standartNewConversationTableAvatar]; + _avatarImageView = [TMAvatarImageView standartMessageTableAvatar]; [self addSubview:_avatarImageView]; - [_avatarImageView setFont:[NSFont fontWithName:@"HelveticaNeue-Light" size:15]]; - [_avatarImageView setFrameSize:NSMakeSize(36, 36)]; + _titleTextField = [[TMNameTextField alloc] init]; [_titleTextField setEditable:NO]; [_titleTextField setBordered:NO]; [_titleTextField setBackgroundColor:[NSColor clearColor]]; - [_titleTextField setFont:[NSFont fontWithName:@"HelveticaNeue-Medium" size:12]]; + [_titleTextField setFont:TGSystemMediumFont(12)]; [[_titleTextField cell] setLineBreakMode:NSLineBreakByTruncatingTail]; [[_titleTextField cell] setTruncatesLastVisibleLine:YES]; @@ -56,7 +58,7 @@ - (id)initWithFrame:(NSRect)frame [_statusTextField setEditable:NO]; [_statusTextField setBordered:NO]; [_statusTextField setBackgroundColor:[NSColor clearColor]]; - [_statusTextField setFont:[NSFont fontWithName:@"HelveticaNeue" size:12]]; + [_statusTextField setFont:TGSystemFont(12)]; [[_statusTextField cell] setLineBreakMode:NSLineBreakByTruncatingTail]; [[_statusTextField cell] setTruncatesLastVisibleLine:YES]; [_statusTextField setSelector:@selector(statusForSearchTableView)]; @@ -64,6 +66,24 @@ - (id)initWithFrame:(NSRect)frame [self addSubview:_statusTextField]; + + self.selectButton = [[BTRButton alloc] initWithFrame:NSMakeRect(20, roundf((50 - image_ComposeCheckActive().size.height )/ 2), image_ComposeCheckActive().size.width, image_ComposeCheckActive().size.height)]; + // [self.selectButton setAutoresizingMask:NSViewMinXMargin]; + + weakify(); + + [self.selectButton setBackgroundImage:image_ComposeCheck() forControlState:BTRControlStateNormal]; + [self.selectButton setBackgroundImage:image_ComposeCheck() forControlState:BTRControlStateHover]; + [self.selectButton setBackgroundImage:image_ComposeCheck() forControlState:BTRControlStateHighlighted]; + [self.selectButton setBackgroundImage:image_ComposeCheckActive() forControlState:BTRControlStateSelected]; + [self.selectButton addBlock:^(BTRControlEvents events) { + [strongSelf mouseDown:[NSApp currentEvent]]; + } forControlEvents:BTRControlEventLeftClick]; + + + [self addSubview:self.selectButton]; + + } return self; } @@ -77,17 +97,22 @@ - (void) redrawRow { [_statusTextField setChat:[self rowItem].chat]; - [self setSelected:NO]; + [self setSelected:[[self rowItem] isSelected]]; + [self.selectButton setHidden:![self isEditable]]; [_titleTextField sizeToFit]; [_statusTextField sizeToFit]; - - [_titleTextField setFrameOrigin:NSMakePoint(77, 25)]; - [_statusTextField setFrameOrigin:NSMakePoint(77, 8)]; - [_avatarImageView setFrameOrigin:NSMakePoint(30, (50 - 36) / 2)]; + const int editableOffset = 20; + + [self.titleTextField setFrameOrigin:NSMakePoint(self.isEditable ? 77 + editableOffset : 56,25)]; + [self.statusTextField setFrameOrigin:NSMakePoint(self.isEditable ? 77 + editableOffset : 56, 8)]; + + [self.avatarImageView setFrameOrigin:NSMakePoint(self.isEditable ? 30 + 20 : 10, (50 - 36) / 2)]; + + [_avatarImageView setChat:[self rowItem].chat]; @@ -105,24 +130,87 @@ -(void)setFrameSize:(NSSize)newSize { } + +- (void)needUpdateSelectType { + [self setEditable:[self isEditable] animation:NO]; + [self setSelected:[self rowItem].isSelected animation:NO]; +} + - (void)mouseDown:(NSEvent *)theEvent { + if(((SelectUsersTableView *)[self rowItem].table).canSelectItem || [self rowItem].isSelected) { + [self rowItem].isSelected = ![self rowItem].isSelected; + if(!self.isEditable) { + [super mouseDown:theEvent]; + return; + } + + [self setSelected:[self rowItem].isSelected animation:YES]; + + [((SelectUsersTableView *)[self rowItem].table).selectDelegate selectTableDidChangedItem:[self rowItem]]; + + } - [((SelectUsersTableView *)[self rowItem].table).selectDelegate selectTableDidChangedItem:[self rowItem]]; - } - (BOOL)isEditable { - return NO; + return [(SelectUsersTableView *)[self rowItem].table selectLimit] > 0; } - (void)setEditable:(BOOL)editable animation:(BOOL)animation { + // animation = NO; + static float duration = 0.1f; + + + if((!self.visibleRect.size.width && !self.visibleRect.size.height) || !animation) { + + if(editable) { + [self.selectButton.layer setOpacity:1]; + [self.selectButton setHidden:NO]; + } else { + [self.selectButton setHidden:YES]; + } + + return; + } + + + int oldOpacity = self.selectButton.layer.opacity; + + [self.selectButton.layer setOpacity:editable ? 0 : 1]; + + [self.selectButton setHidden:oldOpacity == 0 && !editable]; + + + + POPBasicAnimation *position = [POPBasicAnimation animationWithPropertyNamed:kPOPLayerPositionX]; + position.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]; + position.toValue = @(editable ? 20 : 0); + position.duration = duration; + [position setCompletionBlock:^(POPAnimation *anim, BOOL result) { + [self.selectButton setFrameOrigin:[self selectOrigin]]; + }]; + + + [self.selectButton.layer pop_addAnimation:position forKey:@"slide"]; + + POPBasicAnimation *opacityAnim = [POPBasicAnimation animationWithPropertyNamed:kPOPLayerOpacity]; + opacityAnim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]; + opacityAnim.fromValue = @(editable ? 0 : 1); + opacityAnim.toValue = @(editable ? 1 : 0); + opacityAnim.duration = duration; + [opacityAnim setCompletionBlock:^(POPAnimation *anim, BOOL result) { + if(result) { + [self.selectButton setHidden:!editable]; + } + }]; + [self.selectButton.layer pop_addAnimation:opacityAnim forKey:@"opacity"]; } -- (void)needUpdateSelectType { - [self setEditable:[self isEditable] animation:NO]; +-(NSPoint)selectOrigin { + return NSMakePoint([self isEditable] ? 20 : 0, NSMinY(self.selectButton.frame)); } - (void)setSelected:(BOOL)isSelected { @@ -131,14 +219,60 @@ - (void)setSelected:(BOOL)isSelected { -(void)checkSelected:(BOOL)isSelected { // [self.lastSeenTextField setSelected:isSelected]; - // [_titleTextField setSelected:isSelected]; + // [self.titleTextField setSelected:isSelected]; } - (void)setSelected:(BOOL)isSelected animation:(BOOL)animation { + + [self.selectButton setSelected:isSelected]; + + if(self.selectButton.layer.anchorPoint.x != 0.5) { + CGPoint point = self.selectButton.layer.position; + + point.x += roundf(image_ComposeCheckActive().size.width / 2); + point.y += roundf(image_ComposeCheckActive().size.height / 2); + + self.selectButton.layer.position = point; + self.selectButton.layer.anchorPoint = CGPointMake(0.5, 0.5); + } + + if(self.selectButton.isSelected) { + [self.selectButton setBackgroundImage:image_ComposeCheckActive() forControlState:BTRControlStateNormal]; + [self.selectButton setBackgroundImage:image_ComposeCheckActive() forControlState:BTRControlStateHover]; + [self.selectButton setBackgroundImage:image_ComposeCheckActive() forControlState:BTRControlStateHighlighted]; + } else { + [self.selectButton setBackgroundImage:image_ComposeCheck() forControlState:BTRControlStateNormal]; + [self.selectButton setBackgroundImage:image_ComposeCheck() forControlState:BTRControlStateHover]; + [self.selectButton setBackgroundImage:image_ComposeCheck() forControlState:BTRControlStateHighlighted]; + } + + if(animation) { + float duration = 1 / 18.f; + float to = 0.9; + + POPBasicAnimation *scaleAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPLayerScaleXY]; + scaleAnimation.fromValue = [NSValue valueWithCGSize:CGSizeMake(1.0f, 1.0f)]; + scaleAnimation.toValue = [NSValue valueWithCGSize:CGSizeMake(to, to)]; + scaleAnimation.duration = duration / 2; + [scaleAnimation setCompletionBlock:^(POPAnimation *anim, BOOL result) { + if(result) { + POPBasicAnimation *scaleAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPLayerScaleXY]; + scaleAnimation.fromValue = [NSValue valueWithCGSize:CGSizeMake(to, to)]; + scaleAnimation.toValue = [NSValue valueWithCGSize:CGSizeMake(1.0f, 1.0f)]; + scaleAnimation.duration = duration / 2; + [self.selectButton.layer pop_addAnimation:scaleAnimation forKey:@"scale"]; + } + }]; + + [self.selectButton.layer pop_addAnimation:scaleAnimation forKey:@"scale"]; + + + } } + -(SelectChatItem *)rowItem { return (SelectChatItem *) [super rowItem]; } @@ -150,7 +284,7 @@ - (void)drawRect:(NSRect)dirtyRect [LIGHT_GRAY_BORDER_COLOR setFill]; - NSRectFill(NSMakeRect(30, 0, NSWidth(self.frame) - 60 , 1)); + NSRectFill(NSMakeRect(NSMinX(self.titleTextField.frame), 0, NSWidth(self.frame) - 60 , 1)); } diff --git a/TelegramTest/SelectTextManager.m b/TelegramTest/SelectTextManager.m index e29cefe5..978fa024 100644 --- a/TelegramTest/SelectTextManager.m +++ b/TelegramTest/SelectTextManager.m @@ -27,18 +27,19 @@ +(void)removeSelectManagerDelegate:(id)delegate { } +(void)addRange:(NSRange)range forItem:(id)item { - - [[[self instance] list] removeObject:item]; - - [[[self instance] keys] removeObjectForKey:[item identifier]]; - if(range.location != NSNotFound) { - [[[self instance] list] addObject:item]; + if(item != nil) { + [[[self instance] list] removeObject:item]; - [[self instance] keys][[item identifier]] = [NSValue valueWithRange:range]; + [[[self instance] keys] removeObjectForKey:[item identifier]]; + + if(range.location != NSNotFound) { + [[[self instance] list] addObject:item]; + + [[self instance] keys][[item identifier]] = [NSValue valueWithRange:range]; + } } - } +(void)removeRangeForItem:(id)item { diff --git a/TelegramTest/SelectUserRowView.m b/TelegramTest/SelectUserRowView.m index 0440d0f9..a0cea065 100644 --- a/TelegramTest/SelectUserRowView.m +++ b/TelegramTest/SelectUserRowView.m @@ -31,17 +31,16 @@ - (id)initWithFrame:(NSRect)frame if (self) { [self setSelectedBackgroundColor: NSColorFromRGB(0xfafafa)]; [self setNormalBackgroundColor:NSColorFromRGB(0xffffff)]; - self.avatarImageView = [TMAvatarImageView standartNewConversationTableAvatar]; - [self addSubview:self.avatarImageView]; - [self.avatarImageView setFont:[NSFont fontWithName:@"HelveticaNeue-Light" size:15]]; - [self.avatarImageView setFrameSize:NSMakeSize(36, 36)]; + self.avatarImageView = [TMAvatarImageView standartMessageTableAvatar]; + [self addSubview:self.avatarImageView]; + _titleTextField = [[TMNameTextField alloc] init]; [self.titleTextField setEditable:NO]; [self.titleTextField setBordered:NO]; [self.titleTextField setBackgroundColor:[NSColor clearColor]]; - [self.titleTextField setFont:[NSFont fontWithName:@"HelveticaNeue-Medium" size:12]]; + [self.titleTextField setFont:TGSystemMediumFont(12)]; [[self.titleTextField cell] setLineBreakMode:NSLineBreakByTruncatingTail]; [[self.titleTextField cell] setTruncatesLastVisibleLine:YES]; @@ -54,7 +53,7 @@ - (id)initWithFrame:(NSRect)frame [self.lastSeenTextField setEditable:NO]; [self.lastSeenTextField setBordered:NO]; [self.lastSeenTextField setBackgroundColor:[NSColor clearColor]]; - [self.lastSeenTextField setFont:[NSFont fontWithName:@"HelveticaNeue" size:12]]; + [self.lastSeenTextField setFont:TGSystemFont(12)]; [[self.lastSeenTextField cell] setLineBreakMode:NSLineBreakByTruncatingTail]; [[self.lastSeenTextField cell] setTruncatesLastVisibleLine:YES]; [self.lastSeenTextField setSelector:@selector(statusForGroupInfo)]; @@ -102,12 +101,13 @@ - (void) redrawRow { [self setSelected:[[self rowItem] isSelected]]; + [self.selectButton setHidden:![self isEditable]]; [self.titleTextField sizeToFit]; [self.lastSeenTextField sizeToFit]; - [self.selectButton setHidden:![self isEditable]]; + // [self.titleTextField setFrameSize:[self rowItem].titleSize]; //[self.lastSeenTextField setFrameSize:[self rowItem].lastSeenSize]; @@ -147,9 +147,11 @@ - (void)mouseDown:(NSEvent *)theEvent { return; } - [self setSelected:[self rowItem].isSelected animation:YES]; - - [((SelectUsersTableView *)[self rowItem].table).selectDelegate selectTableDidChangedItem:[self rowItem]]; + if([self rowItem].user.n_id != [UsersManager currentUserId]) { + [self setSelected:[self rowItem].isSelected animation:YES]; + + [((SelectUsersTableView *)[self rowItem].table).selectDelegate selectTableDidChangedItem:[self rowItem]]; + } } @@ -157,7 +159,7 @@ - (void)mouseDown:(NSEvent *)theEvent { - (BOOL)isEditable { - return [[self rowItem].table selectLimit] > 0; + return [(SelectUsersTableView *)[self rowItem].table selectLimit] > 0; } - (void)setEditable:(BOOL)editable animation:(BOOL)animation { @@ -288,7 +290,7 @@ - (void)drawRect:(NSRect)dirtyRect [LIGHT_GRAY_BORDER_COLOR setFill]; - NSRectFill(NSMakeRect(point.x+2, 0, NSWidth(self.frame) - point.x - [self rowItem].rightBorderMargin, 1)); + NSRectFill(NSMakeRect(point.x+2, 0, NSWidth(self.frame) - point.x - 10, 1)); // // [NSColorFromRGB(arc4random() % 16000000) setFill]; // diff --git a/TelegramTest/SelectUsersTableView.h b/TelegramTest/SelectUsersTableView.h index 7e1873d3..38a81d49 100644 --- a/TelegramTest/SelectUsersTableView.h +++ b/TelegramTest/SelectUsersTableView.h @@ -13,7 +13,9 @@ typedef enum { SelectTableTypeUser, - SelectTableTypeChats + SelectTableTypeChats, + SelectTableTypeCommon, + SelectTableConversations } SelectTableType ; @protocol SelectTableDelegate @@ -35,6 +37,9 @@ typedef enum { @property (nonatomic,strong) NSArray *selectedItems; +-(void)addItems:(NSArray *)items; +-(void)removeSelectedItems; + @property (nonatomic,assign) NSUInteger selectLimit; @property (nonatomic,assign,readonly) SelectTableType type; @@ -44,6 +49,11 @@ typedef enum { - (void)readyContacts; - (void)readyChats; +- (void)readyConversations; + +//SelectUserItems; +- (void)readyCommon:(NSArray *)items; + - (void)search:(NSString *)searchString; @end diff --git a/TelegramTest/SelectUsersTableView.m b/TelegramTest/SelectUsersTableView.m index 8e294db8..1b5cd4a1 100644 --- a/TelegramTest/SelectUsersTableView.m +++ b/TelegramTest/SelectUsersTableView.m @@ -18,6 +18,7 @@ @interface SelectUsersTableView () @property (nonatomic,strong) TGSearchRowView *searchView; @property (nonatomic,strong) TGSearchRowItem *searchItem; @property (nonatomic,strong) RPCRequest *request; + @end @implementation SelectUsersTableView @@ -51,7 +52,7 @@ -(void)readyContacts { NSMutableArray *items = [[NSMutableArray alloc] init]; - contacts = [contacts filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"NOT(self.user_id IN %@ AND (self.user.flags & 1 << 16) == 0)",self.exceptions]]; + contacts = [contacts filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"NOT(self.user_id IN (%@)) || (self.user.flags & 1 << 16) == 0",self.exceptions]]; @@ -70,29 +71,36 @@ -(void)readyContacts { [items filterUsingPredicate:[NSPredicate predicateWithFormat:@"self.user.n_id != %d",[UsersManager currentUserId]]]; + [self readyItems:items]; - self.tm_delegate = self; - - [self removeAllItems:NO]; - - self.items = items; - - self.searchItem = [[TGSearchRowItem alloc] init]; - - self.searchView = [[TGSearchRowView alloc] initWithFrame:NSMakeRect(0, 0, NSWidth(self.bounds), 50)]; + if(contacts.count > 30) + dispatch_after_seconds(0.3, ^{ + [self insertOther:[contacts subarrayWithRange:NSMakeRange(30, contacts.count - 30)]]; + }); - [self insert:self.searchItem atIndex:0 tableRedraw:NO]; +} + +- (void)readyCommon:(NSArray *)items { - [self insert:self.items startIndex:1 tableRedraw:NO]; + _type = SelectTableTypeCommon; + [self readyItems:items]; +} + +-(void)removeSelectedItems { + self.defaultAnimation = NSTableViewAnimationEffectFade; - [self reloadData]; + NSArray *copy = [self.selectedItems copy]; - if(contacts.count > 30) - dispatch_after_seconds(0.3, ^{ - [self insertOther:[contacts subarrayWithRange:NSMakeRange(30, contacts.count - 30)]]; - }); + [copy enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + + [self.items removeObject:obj]; + + [self removeItem:obj tableRedraw:YES]; + + }]; + self.defaultAnimation = NSTableViewAnimationEffectNone; } @@ -101,7 +109,11 @@ -(void)readyChats { _type = SelectTableTypeChats; - NSArray *chats = [[[DialogsManager sharedManager] all] filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.type == %d",DialogTypeChat]]; + NSArray *chats = [[[DialogsManager sharedManager] all] filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(TL_conversation *evaluatedObject, NSDictionary * _Nullable bindings) { + + return (evaluatedObject.type == DialogTypeChat && evaluatedObject.chat.type == TLChatTypeNormal && !evaluatedObject.chat.isDeactivated && (!evaluatedObject.chat.isAdmins_enabled || evaluatedObject.chat.isAdmin)) || (evaluatedObject.type == DialogTypeChannel && evaluatedObject.chat.isManager); + + }]]; NSMutableArray *items = [[NSMutableArray alloc] init]; @@ -112,12 +124,49 @@ -(void)readyChats { }]; + [self readyItems:items]; + +} + +-(void)readyConversations { + _type = SelectTableConversations; + + NSArray *chats = [[DialogsManager sharedManager] all]; + + NSMutableArray *accepted = [[NSMutableArray alloc] init]; + + [chats enumerateObjectsUsingBlock:^(TL_conversation *obj, NSUInteger idx, BOOL * _Nonnull stop) { + + if(obj.type == DialogTypeUser || (obj.type == DialogTypeChat && obj.chat.type == TLChatTypeNormal && !obj.chat.isDeactivated && (!obj.chat.isAdmins_enabled || obj.chat.isAdmin)) || (obj.type == DialogTypeChannel && obj.chat.isManager)) { + [accepted addObject:obj]; + } + + }]; + + + NSMutableArray *items = [[NSMutableArray alloc] init]; + + [accepted enumerateObjectsUsingBlock:^(TL_conversation * obj, NSUInteger idx, BOOL *stop) { + + if(obj.chat) { + [items addObject:[[SelectChatItem alloc] initWithObject:obj.chat]]; + } else { + [items addObject:[[SelectUserItem alloc] initWithObject:obj.user]]; + } + + + }]; + [self readyItems:items]; +} + + +-(void)readyItems:(NSArray *)items { self.tm_delegate = self; [self removeAllItems:NO]; - self.items = items; + self.items = [items mutableCopy]; self.searchItem = [[TGSearchRowItem alloc] init]; @@ -129,7 +178,15 @@ -(void)readyChats { [self reloadData]; + +} + +-(void)addItems:(NSArray *)items { + [self.items addObjectsFromArray:items]; + [self insert:items startIndex:self.count tableRedraw:NO]; + + [self reloadData]; } -(void)insertOther:(NSArray *)other { @@ -220,12 +277,13 @@ - (BOOL) selectionWillChange:(NSInteger)row item:(SelectUserItem *) item { - (void)selectionDidChange:(NSInteger)row item:(SelectUserItem *)item { - [self.selectDelegate selectTableDidChangedItem:item]; - - if(self.multipleCallback != nil) { - self.multipleCallback(@[item.user]); + if(![item isKindOfClass:[TGSearchRowItem class]]) { + [self.selectDelegate selectTableDidChangedItem:item]; + + if(self.multipleCallback != nil) { + self.multipleCallback(@[item.user]); + } } - } @@ -278,9 +336,45 @@ -(void)searchFieldTextChange:(NSString *)searchString { else if(_type == SelectTableTypeChats) [self searchChats:searchString]; + else + if(_type == SelectTableTypeCommon) + [self searchUsers:searchString]; + else + if(_type == SelectTableConversations) + [self searchAll:searchString]; } +-(void)searchAll:(NSString *)searchString { + NSArray *sorted = self.items; + + + if(searchString.length > 0) { + sorted = [self.items filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(SelectUserItem *evaluatedObject, NSDictionary *bindings) { + if([evaluatedObject isKindOfClass:[SelectChatItem class]]) { + return [((SelectChatItem *)evaluatedObject).chat.title searchInStringByWordsSeparated:searchString]; + } else { + return [[evaluatedObject.user fullName] searchInStringByWordsSeparated:searchString]; + } + }]]; + } + + + NSRange range = NSMakeRange(1, self.list.count-1); + + NSArray *list = [self.list subarrayWithRange:range]; + + [list enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + [self removeItem:obj tableRedraw:NO]; + }]; + + [self removeRowsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:range] withAnimation:self.defaultAnimation]; + + + [self insert:sorted startIndex:1 tableRedraw:YES]; + +} + -(void)searchChats:(NSString *)searchString { NSArray *sorted = self.items; @@ -314,10 +408,8 @@ - (void)searchUsers:(NSString *)searchString { __block NSArray *sorted = [self.items filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.user.n_id != %d",[UsersManager currentUserId]]]; - if(searchString.length > 0) { - if([searchString hasPrefix:@"@"]) searchString = [searchString substringFromIndex:1]; @@ -328,9 +420,6 @@ - (void)searchUsers:(NSString *)searchString { }]]; } - - - NSRange range = NSMakeRange(1, self.list.count-1); NSArray *list = [self.list subarrayWithRange:range]; @@ -341,55 +430,83 @@ - (void)searchUsers:(NSString *)searchString { [self removeRowsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:range] withAnimation:self.defaultAnimation]; - [self insert:sorted startIndex:1 tableRedraw:YES]; - [_request cancelRequest]; - - dispatch_after_seconds(0.2, ^{ - [self remoteSearchByUserName:searchString]; - }); + if(_type == SelectTableTypeUser) { + [_request cancelRequest]; + + NSArray *users = [UsersManager findUsersByName:searchString]; + + [self filterAndAddGlobalUsers:users checkContact:YES]; + + dispatch_after_seconds(0.2, ^{ + [self remoteSearchByUserName:searchString]; + }); + } } +-(void)filterAndAddGlobalUsers:(NSArray *)users checkContact:(BOOL)checkContact { + + + NSMutableArray *rmrf = [NSMutableArray array]; + + [self.list enumerateObjectsUsingBlock:^(SelectUserItem *obj, NSUInteger idx, BOOL * _Nonnull stop) { + + if([obj isKindOfClass:[SelectUserItem class]]) { + if(obj.isSearchUser && !obj.isSelected) { + [rmrf addObject:obj]; + } + } + }]; + + [rmrf enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + [self removeItem:obj]; + [self.items removeObject:obj]; + }]; + + NSMutableArray *converted = [NSMutableArray array]; + + NSMutableArray *ids = [[NSMutableArray alloc] init]; + + [self.list enumerateObjectsUsingBlock:^(SelectUserItem *obj, NSUInteger idx, BOOL *stop) { + if([obj isKindOfClass:[SelectUserItem class]]) + [ids addObject:@(obj.user.n_id)]; + }]; + + + NSArray *filtred = [users filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"NOT(self.n_id IN %@)",ids]]; + + + [filtred enumerateObjectsUsingBlock:^(TLUser *obj, NSUInteger idx, BOOL *stop) { + + if(checkContact && !obj.isContact) + return; + + SelectUserItem *item = [[SelectUserItem alloc] initWithObject:obj]; + item.isSearchUser = YES; + [converted addObject:item]; + + }]; + + if(converted.count > 0) { + [self.items insertObjects:converted atIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, converted.count)]]; + + [self insert:converted startIndex:self.count tableRedraw:YES]; + } + +} + -(void)remoteSearchByUserName:(NSString *)userName { if(userName.length > 4) { + _request = [RPCRequest sendRequest:[TLAPI_contacts_search createWithQ:userName limit:100] successHandler:^(RPCRequest *request, TL_contacts_found *response) { - - NSMutableArray *converted = [[NSMutableArray alloc] init]; - - - NSMutableArray *ids = [[NSMutableArray alloc] init]; - - [_items enumerateObjectsUsingBlock:^(SelectUserItem *obj, NSUInteger idx, BOOL *stop) { - [ids addObject:@(obj.user.n_id)]; - }]; - - NSArray *filtred = [response.users filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"NOT(self.n_id IN %@)",ids]]; - - [filtred enumerateObjectsUsingBlock:^(TLUser *obj, NSUInteger idx, BOOL *stop) { - - [obj rebuildNames]; - - // if([obj isKindOfClass:[TL_userContact class]]) { - - SelectUserItem *item = [[SelectUserItem alloc] initWithObject:obj]; - item.isSearchUser = YES; - [converted addObject:item]; - // } - - }]; - - if(converted.count > 0) { - [self.items insertObjects:converted atIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, converted.count)]]; - - [self insert:converted startIndex:self.count tableRedraw:YES]; - } - + [self filterAndAddGlobalUsers:response.users checkContact:NO]; + } errorHandler:^(RPCRequest *request, RpcError *error) { diff --git a/TelegramTest/SelfDestructionController.m b/TelegramTest/SelfDestructionController.m index 9c47e5bf..3a21cf58 100644 --- a/TelegramTest/SelfDestructionController.m +++ b/TelegramTest/SelfDestructionController.m @@ -83,8 +83,8 @@ -(void)loopAndCheckMessages { } } if(todelete.count) { - [[Storage manager] deleteMessages:todelete completeHandler:nil]; - [Notification perform:MESSAGE_DELETE_EVENT data:@{KEY_MESSAGE_ID_LIST:todelete}]; + + [[DialogsManager sharedManager] deleteMessagesWithMessageIds:todelete]; [remoteDelete enumerateKeysAndObjectsUsingBlock:^(NSNumber *chat_id, NSMutableArray *obj, BOOL *stop) { @@ -129,7 +129,7 @@ -(void)didReadMessages:(NSNotification *)notification { } if(tosave.count) - [[Storage manager] insertMessages:tosave completeHandler:nil]; + [[Storage manager] insertMessages:tosave]; }]; } @@ -159,7 +159,7 @@ -(void)addMessage:(TL_destructMessage *)message force:(BOOL)force { if(message.ttl_seconds != 0) { message.destruction_time = [[NSDate date] timeIntervalSince1970]+message.ttl_seconds; [self.targets addObject:message]; - [[Storage manager] updateMessages:@[message]]; + [message save:NO]; } }]; diff --git a/TelegramTest/SenderItem.h b/TelegramTest/SenderItem.h index 27e44bb8..ca09a8fc 100644 --- a/TelegramTest/SenderItem.h +++ b/TelegramTest/SenderItem.h @@ -43,12 +43,10 @@ typedef enum { @property (nonatomic, strong) NSString *filePath; -- (id)initWithMessage:(NSString *)message forConversation:(TL_conversation *)conversation; +- (id)initWithMessage:(NSString *)message forConversation:(TL_conversation *)conversation additionFlags:(int)additionFlags; -- (id)initWithPath:(NSString *)filePath forConversation:(TL_conversation *)conversation; - -- (id)initWithPath:(NSString *)filePath forConversation:(TL_conversation *)conversation; +- (id)initWithPath:(NSString *)filePath forConversation:(TL_conversation *)conversation additionFlags:(int)additionFlags; -(id)initWithConversation:(TL_conversation *)conversation; @@ -71,4 +69,11 @@ typedef enum { -(void)resend; +-(BOOL)canRelease; + +-(int)senderFlags; + +-(void)updateMessageId:(TLUpdates *)updates; +-(TL_updateNewMessage *)updateNewMessageWithUpdates:(TLUpdates *)updates; + @end diff --git a/TelegramTest/SenderItem.m b/TelegramTest/SenderItem.m index db5eb537..3116d903 100644 --- a/TelegramTest/SenderItem.m +++ b/TelegramTest/SenderItem.m @@ -10,6 +10,8 @@ #import "SenderItem.h" #import "MessageTableItem.h" #import "StickerSenderItem.h" +#import "WeakReference.h" +#import "MessageTableCell.h" @interface SenderItem () @property (nonatomic,strong) NSMutableArray *listeners; @end @@ -25,14 +27,14 @@ - (id)initWithTempPath:(NSData *)temp_path_to_file path_to_file:(NSString *)path return self; } -- (id)initWithPath:(NSString *)path_for_file forConversation:(TL_conversation *)conversation { +- (id)initWithPath:(NSString *)path_for_file forConversation:(TL_conversation *)conversation additionFlags:(int)additionFlags { if(self = [super init]) { [NSException raise:@"Fatal sending error" format:@"Can't use (%@) this class class for send message with file path",NSStringFromClass([self class])]; } return self; } -- (id)initWithMessage:(NSString *)message forConversation:(TL_conversation *)conversation { +- (id)initWithMessage:(NSString *)message forConversation:(TL_conversation *)conversation additionFlags:(int)additionFlags { if(self = [super init]) { [NSException raise:@"Fatal sending error" format:@"Can't use (%@) this class class for send message with file path",NSStringFromClass([self class])]; } @@ -82,7 +84,7 @@ + (id)senderForMessage:(TL_localMessage *)msg { if(!item) { if(![msg isKindOfClass:[TL_destructMessage class]]) { - if([msg.media isKindOfClass:[TL_messageMediaEmpty class]]) { + if([msg.media isKindOfClass:[TL_messageMediaEmpty class]] || msg.media == nil) { item = [[MessageSenderItem alloc] init]; } else if([msg.media isKindOfClass:[TL_messageMediaPhoto class]]) { item = [[ImageSenderItem alloc] init]; @@ -113,7 +115,7 @@ + (id)senderForMessage:(TL_localMessage *)msg { } else { if(msg.class == [TL_destructMessage class]) { - if([msg.media isKindOfClass:[TL_messageMediaEmpty class]]) + if([msg.media isKindOfClass:[TL_messageMediaEmpty class]] || msg.media == nil) item = [[MessageSenderSecretItem alloc] init]; else { @@ -164,42 +166,45 @@ -(void)setState:(MessageState)state { self->_state = state; - [ASQueue dispatchOnStageQueue:^{ + [ASQueue dispatchOnMainQueue:^{ [self notifyAllListeners:@selector(onStateChanged:)]; if(state == MessageSendingStateSent || state == MessageSendingStateError || state == MessageSendingStateCancelled) { [self removeAllListeners]; - self.rpc_request = nil; - - if(state == MessageSendingStateError) { - if(self.message.dstate != DeliveryStateError) { - self.message.dstate = DeliveryStateError; - [self.message save:YES]; - } + [ASQueue dispatchOnStageQueue:^{ + self.rpc_request = nil; - if([self isKindOfClass:[ForwardSenterItem class]]) { - ForwardSenterItem *sender = (ForwardSenterItem *) self; - [sender.fakes enumerateObjectsUsingBlock:^(TL_localMessage *obj, NSUInteger idx, BOOL *stop) { - if(obj.dstate != DeliveryStateError) { - obj.dstate = DeliveryStateError; - [obj save:idx == sender.fakes.count-1]; - } - }]; - } - } - - - if(state == MessageSendingStateError && self.conversation.type == DialogTypeSecretChat) { - if(self.rpc_request.error.error_code == 400) { - EncryptedParams *params = [EncryptedParams findAndCreate:self.conversation.peer.peer_id]; + if(state == MessageSendingStateError) { + if(self.message.dstate != DeliveryStateError) { + self.message.dstate = DeliveryStateError; + [self.message save:YES]; + } - [params setState:EncryptedDiscarted]; - [params save]; + if([self isKindOfClass:[ForwardSenterItem class]]) { + ForwardSenterItem *sender = (ForwardSenterItem *) self; + [sender.fakes enumerateObjectsUsingBlock:^(TL_localMessage *obj, NSUInteger idx, BOOL *stop) { + if(obj.dstate != DeliveryStateError) { + obj.dstate = DeliveryStateError; + [obj save:idx == sender.fakes.count-1]; + } + }]; + } } - } + + + if(state == MessageSendingStateError && self.conversation.type == DialogTypeSecretChat) { + if(self.rpc_request.error.error_code == 400) { + EncryptedParams *params = [EncryptedParams findAndCreate:self.conversation.peer.peer_id]; + + [params setState:EncryptedDiscarted]; + + [params save]; + } + } + }]; } @@ -210,6 +215,7 @@ -(void)setState:(MessageState)state { if(state == MessageSendingStateSent || state == MessageSendingStateCancelled) { [waiting removeObject:self]; + [senders removeObjectForKey:@(_message.randomId)]; } }]; @@ -261,18 +267,23 @@ +(BOOL)allSendersSaved { -(void)setProgress:(float)progress { self->_progress = progress; - [ASQueue dispatchOnStageQueue:^{ + [ASQueue dispatchOnMainQueue:^{ [self notifyAllListeners:@selector(onProgressChanged:)]; }]; } -(void)notifyAllListeners:(SEL)selector { - NSArray *copy = [self.listeners copy]; - for (id current in copy) { - if([current respondsToSelector:selector]) - [current performSelector:selector withObject:self]; - } + + assert([NSThread isMainThread]); + + [_listeners enumerateObjectsUsingBlock:^(WeakReference *current, NSUInteger idx, BOOL * _Nonnull stop) { + idlistener = current.nonretainedObjectValue; + + if([listener respondsToSelector:selector]) + [listener performSelector:selector withObject:self]; + }]; + } -(void)setTableItem:(MessageTableItem *)tableItem { @@ -280,37 +291,70 @@ -(void)setTableItem:(MessageTableItem *)tableItem { tableItem.messageSender = self; } +-(NSUInteger)indexOfListener:(id)listener { + + + assert([NSThread isMainThread]); + __block NSUInteger index = NSNotFound; + + [_listeners enumerateObjectsUsingBlock:^(WeakReference *obj, NSUInteger idx, BOOL *stop) { + + if(obj.nonretainedObjectValue == (__bridge void *)(listener)) { + index = idx; + *stop = YES; + } + + }]; + + return index; +} + -(void)addEventListener:(id)listener { - [ASQueue dispatchOnStageQueue:^{ + [ASQueue dispatchOnMainQueue:^{ if(!self.listeners) self.listeners = [[NSMutableArray alloc] init]; - if([self.listeners indexOfObject:listener] == NSNotFound) - [self.listeners addObject:listener]; + if([self indexOfListener:listener] == NSNotFound) + [self.listeners addObject:[WeakReference weakReferenceWithObject:listener]]; [self notifyAllListeners:@selector(onAddedListener:)]; }]; } -(void)enumerateEventListeners:(void (^)(id listener, NSUInteger idx, BOOL *stop))enumerator { - [ASQueue dispatchOnStageQueue:^{ + [ASQueue dispatchOnMainQueue:^{ NSArray *copy = [self.listeners copy]; - [copy enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - enumerator(obj,idx,stop); + [copy enumerateObjectsUsingBlock:^(WeakReference *obj, NSUInteger idx, BOOL *stop) { + enumerator(obj.nonretainedObjectValue,idx,stop); }]; }]; } -(void)removeAllListeners { - [self notifyAllListeners:@selector(onRemovedListener:)]; - [self.listeners removeAllObjects]; + assert([NSThread isMainThread]); + + NSArray *copy = [_listeners copy]; + + [_listeners removeAllObjects]; + + [copy enumerateObjectsUsingBlock:^(WeakReference *current, NSUInteger idx, BOOL * _Nonnull stop) { + idlistener = current.nonretainedObjectValue; + + if([listener respondsToSelector:@selector(onRemovedListener:)]) + [listener performSelector:@selector(onRemovedListener:) withObject:self]; + }]; + } -(void)removeEventListener:(id)listener { - [ASQueue dispatchOnStageQueue:^{ - [self.listeners removeObject:listener]; + [ASQueue dispatchOnMainQueue:^{ + + NSUInteger idx = [self indexOfListener:listener]; + + if(idx != NSNotFound) + [self.listeners removeObjectAtIndex:idx]; [self notifyAllListeners:@selector(onRemovedListener:)]; @@ -334,14 +378,7 @@ -(BOOL)checkErrorAndReUploadFile:(RpcError *)error path:(NSString *)path { } --(void)dealloc { - [self removeAllListeners]; - - [ASQueue dispatchOnStageQueue:^{ - [senders removeObjectForKey:@(_message.randomId)]; - } synchronous:YES]; - -} + -(void)perform { @@ -376,4 +413,68 @@ -(void)cancel { -(void)resend { } + +-(void)updateMessageId:(TLUpdates *)updates { + + if([updates isKindOfClass:[TL_updates class]]) { + NSArray *updateMessageIdUpdate = [[updates updates] filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.className == %@",NSStringFromClass([TL_updateMessageID class])]]; + + if(updateMessageIdUpdate.count > 0) { + self.message.n_id = [(TL_updateMessageID *)updateMessageIdUpdate[0] n_id]; + } + } + +} + +-(int)senderFlags { + int flags = 0; + + flags|= self.message.reply_to_msg_id != 0 ? 1 : 0; + + flags|=[self.message.media.webpage isKindOfClass:[TL_webPageEmpty class]] ? 2 : 0; + + flags|=self.message.from_id == 0 ? 1 << 4 : 0; + + if(self.message.entities.count > 0) + flags|= 1 << 3; + + return flags; +} + +-(TL_updateNewMessage *)updateNewMessageWithUpdates:(TLUpdates *)updates { + + __block id update; + + [updates.updates enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + + if([obj isKindOfClass:[TL_updateNewMessage class]] || [obj isKindOfClass:[TL_updateNewChannelMessage class]]) { + update = obj; + *stop = YES; + } + + }]; + + return update; + +} + +-(BOOL)canRelease { + + __block BOOL c = YES; + + [ASQueue dispatchOnMainQueue:^{ + + [_listeners enumerateObjectsUsingBlock:^(WeakReference *obj, NSUInteger idx, BOOL * _Nonnull stop) { + if([obj.nonretainedObjectValue isKindOfClass:[MessageTableCell class]]) { + c = NO; + *stop = YES; + } + }]; + + c = _listeners.count == 0; + } synchronous:YES]; + + return c; +} + @end diff --git a/TelegramTest/SettingsArchiver.h b/TelegramTest/SettingsArchiver.h index 93703791..aa5f51c8 100644 --- a/TelegramTest/SettingsArchiver.h +++ b/TelegramTest/SettingsArchiver.h @@ -38,7 +38,8 @@ typedef enum { StatusBarIcon = 1 << 21, SmartNotifications = 1 << 22, MarkedInputText = 1 << 23, - MessagesNotificationPreview = 1 << 24 + MessagesNotificationPreview = 1 << 24, + IncludeMutedUnreadCount = 1 << 25 } SettingsMask; diff --git a/TelegramTest/SettingsArchiver.m b/TelegramTest/SettingsArchiver.m index 115a6143..9d2c55de 100644 --- a/TelegramTest/SettingsArchiver.m +++ b/TelegramTest/SettingsArchiver.m @@ -52,7 +52,7 @@ -(id)init { - (void)initialize { self.auto_download_limit_size = DownloadLimitSize10; - self.mask = SendEnter | OnlineFocused | SoundEffects | AutoGroupAudio | AutoPrivateAudio | AutoPrivatePhoto | AutoGroupPhoto | PushNotifications | iCloudSynch | StatusBarIcon; + self.mask = SendEnter | OnlineFocused | SoundEffects | AutoGroupAudio | AutoPrivateAudio | AutoPrivatePhoto | AutoGroupPhoto | PushNotifications | iCloudSynch | StatusBarIcon | MessagesNotificationPreview | MarkedInputText | IncludeMutedUnreadCount; self.documents_folder = dp(); self.defaultSoundNotification = @"DefaultSoundName"; @@ -343,6 +343,18 @@ + (instancetype)instance { [SettingsArchiver addSetting:MarkedInputText]; } + if(![defaults objectForKey:@"MessagesPreview"]) { + [defaults setObject:@"once" forKey:@"MessagesPreview"]; + + [SettingsArchiver addSetting:MessagesNotificationPreview]; + } + + if(![defaults objectForKey:@"IncludeMutedUnreadCount"]) { + [defaults setObject:@"once" forKey:@"IncludeMutedUnreadCount"]; + + [SettingsArchiver addSetting:IncludeMutedUnreadCount]; + } + }); }); diff --git a/TelegramTest/SettingsSecurityViewController.m b/TelegramTest/SettingsSecurityViewController.m index 4f52b897..78146bc7 100644 --- a/TelegramTest/SettingsSecurityViewController.m +++ b/TelegramTest/SettingsSecurityViewController.m @@ -66,7 +66,7 @@ -(void)loadView { TMTextField *cacheDesc = [TMTextField defaultTextField]; - [cacheDesc setFont:[NSFont fontWithName:@"HelveticaNeue" size:12]]; + [cacheDesc setFont:TGSystemFont(12)]; [cacheDesc setStringValue:NSLocalizedString(@"Settings.ClearCacheDescription",nil)]; @@ -98,7 +98,7 @@ -(void)loadView { TMTextField *terminateDesc = [TMTextField defaultTextField]; - [terminateDesc setFont:[NSFont fontWithName:@"HelveticaNeue" size:12]]; + [terminateDesc setFont:TGSystemFont(12)]; [terminateDesc setStringValue:NSLocalizedString(@"Settings.TerminateOtherSessionsDescription",nil)]; diff --git a/TelegramTest/SettingsWindowController.m b/TelegramTest/SettingsWindowController.m index 4e8c71d2..0866acb6 100644 --- a/TelegramTest/SettingsWindowController.m +++ b/TelegramTest/SettingsWindowController.m @@ -20,6 +20,7 @@ @interface SettingsWindowController () @property (weak) IBOutlet NSButton *open_links_in_background; +@property (weak) IBOutlet NSButton *convertEmoji; @property (weak) IBOutlet NSButton *auto_downlod_video_group; @property (weak) IBOutlet NSButton *auto_downlod_video_private; @@ -104,6 +105,8 @@ - (void)awakeFromNib [self.open_links_in_background setTitle:NSLocalizedString(@"Settings.OpenLinksBackground", nil)]; + [self.convertEmoji setTitle:NSLocalizedString(@"Settings.EmojiReplaces", nil)]; + [self.auto_downlod_video_private setTitle:NSLocalizedString(@"Settings.PrivateChats", nil)]; [self.auto_downlod_video_group setTitle:NSLocalizedString(@"Settings.Groups", nil)]; @@ -175,7 +178,7 @@ - (void)awakeFromNib self.blocked_table_view.removeButton = self.remove_from_block_button; - [self.chat_settings_view setFrameOrigin:NSMakePoint(0, 60)]; + [self.chat_settings_view setFrameOrigin:NSMakePoint(0, 30)]; [self.security_settings_view setFrameOrigin:NSMakePoint(-5, self.security_settings_view.frame.size.height-70)]; @@ -229,6 +232,8 @@ -(void)updateUI { [self.open_links_in_background setState:[SettingsArchiver checkMaskedSetting:OpenLinksInBackground]]; + [self.convertEmoji setState:[SettingsArchiver checkMaskedSetting:EmojiReplaces]]; + [self.auto_downlod_video_group setState:[SettingsArchiver checkMaskedSetting:AutoGroupVideo]]; [self.auto_downlod_video_private setState:[SettingsArchiver checkMaskedSetting:AutoPrivateVideo]]; @@ -386,6 +391,9 @@ - (IBAction)checkMarkedInputtext:(id)sender { - (IBAction)soundEffectCheckbox:(id)sender { [SettingsArchiver addOrRemoveSetting:SoundEffects]; } +- (IBAction)convertEmoji:(id)sender { + [SettingsArchiver addOrRemoveSetting:EmojiReplaces]; +} - (IBAction)openLinksInBackground:(id)sender { [SettingsArchiver addOrRemoveSetting:OpenLinksInBackground]; diff --git a/TelegramTest/SettingsWindowController.xib b/TelegramTest/SettingsWindowController.xib index bc672d58..a4c64da1 100644 --- a/TelegramTest/SettingsWindowController.xib +++ b/TelegramTest/SettingsWindowController.xib @@ -1,5 +1,5 @@ - + @@ -23,6 +23,7 @@ + @@ -254,11 +255,11 @@ - + - + @@ -267,7 +268,7 @@ - + @@ -276,7 +277,7 @@ - + @@ -307,7 +308,7 @@ - + @@ -338,7 +339,7 @@ - + @@ -347,7 +348,7 @@ - + @@ -395,7 +396,7 @@ - + @@ -404,7 +405,7 @@ - + @@ -422,7 +423,7 @@ - + @@ -431,7 +432,7 @@ - + @@ -440,7 +441,7 @@ - + @@ -452,7 +453,7 @@ - + @@ -471,21 +472,21 @@ - + - + - + @@ -494,7 +495,7 @@ + - + diff --git a/TelegramTest/ShareContactSenterItem.h b/TelegramTest/ShareContactSenterItem.h index 6ff1c9dc..5aadd5f0 100644 --- a/TelegramTest/ShareContactSenterItem.h +++ b/TelegramTest/ShareContactSenterItem.h @@ -9,5 +9,5 @@ #import "SenderItem.h" @interface ShareContactSenterItem : SenderItem --(id)initWithContact:(TLUser *)contact forConversation:(TL_conversation *)conversation; +-(id)initWithContact:(TLUser *)contact forConversation:(TL_conversation *)conversation additionFlags:(int)additionFlags; @end diff --git a/TelegramTest/ShareContactSenterItem.m b/TelegramTest/ShareContactSenterItem.m index 9676fb4d..6d635c2d 100644 --- a/TelegramTest/ShareContactSenterItem.m +++ b/TelegramTest/ShareContactSenterItem.m @@ -18,13 +18,17 @@ -(void)setState:(MessageState)state { } --(id)initWithContact:(TLUser *)contact forConversation:(TL_conversation *)conversation { +-(id)initWithContact:(TLUser *)contact forConversation:(TL_conversation *)conversation additionFlags:(int)additionFlags { if(self = [super init]) { self.conversation = conversation; TL_messageMediaContact *media = [TL_messageMediaContact createWithPhone_number:contact.phone first_name:contact.first_name last_name:contact.last_name user_id:contact.n_id]; self.message = [MessageSender createOutMessage:@"" media:media conversation:conversation]; + if(additionFlags & (1 << 4)) + self.message.from_id = 0; + + [self.message save:YES]; } @@ -40,21 +44,23 @@ -(void)performRequest { TLInputMedia *media = [TL_inputMediaContact createWithPhone_number:self.message.media.phone_number first_name:self.message.media.first_name last_name:self.message.media.last_name]; if(self.conversation.type != DialogTypeBroadcast) { - request = [TLAPI_messages_sendMedia createWithFlags:self.message.reply_to_msg_id != 0 ? 1 : 0 peer:self.conversation.inputPeer reply_to_msg_id:self.message.reply_to_msg_id media:media random_id:self.message.randomId reply_markup:[TL_replyKeyboardMarkup createWithFlags:0 rows:[@[]mutableCopy]]]; + request = [TLAPI_messages_sendMedia createWithFlags:[self senderFlags] peer:self.conversation.inputPeer reply_to_msg_id:self.message.reply_to_msg_id media:media random_id:self.message.randomId reply_markup:[TL_replyKeyboardMarkup createWithFlags:0 rows:[@[]mutableCopy]]]; } else { request = [TLAPI_messages_sendBroadcast createWithContacts:[self.conversation.broadcast inputContacts] random_id:[self.conversation.broadcast generateRandomIds] message:self.message.message media:media]; } self.rpc_request = [RPCRequest sendRequest:request successHandler:^(RPCRequest *request, TLUpdates * response) { - if(response.updates.count < 2) + [self updateMessageId:response]; + + TL_localMessage *msg = [TL_localMessage convertReceivedMessage:[[self updateNewMessageWithUpdates:response] message]]; + + if(msg == nil) { [self cancel]; return; } - TLMessage *msg = [TL_localMessage convertReceivedMessage:(TLMessage *) ( [response.updates[1] message])]; - if(self.conversation.type != DialogTypeBroadcast) { self.message.n_id = msg.n_id; self.message.date = msg.date; diff --git a/TelegramTest/SharedLinksHistoryFilter.h b/TelegramTest/SharedLinksHistoryFilter.h index b946af27..f3fc9b4c 100644 --- a/TelegramTest/SharedLinksHistoryFilter.h +++ b/TelegramTest/SharedLinksHistoryFilter.h @@ -7,7 +7,7 @@ // #import "HistoryFilter.h" - -@interface SharedLinksHistoryFilter : HistoryFilter +#import "CommonMediaHistoryFilter.h" +@interface SharedLinksHistoryFilter : CommonMediaHistoryFilter @end diff --git a/TelegramTest/SharedLinksHistoryFilter.m b/TelegramTest/SharedLinksHistoryFilter.m index b3263cc7..115c6980 100644 --- a/TelegramTest/SharedLinksHistoryFilter.m +++ b/TelegramTest/SharedLinksHistoryFilter.m @@ -8,27 +8,8 @@ #import "SharedLinksHistoryFilter.h" #import "ChatHistoryController.h" -@implementation SharedLinksHistoryFilter -static NSMutableDictionary * messageItems; -static NSMutableDictionary * messageKeys; - --(id)initWithController:(ChatHistoryController *)controller { - if(self = [super initWithController:controller]) { - - } - - return self; -} - -+(void)initialize { - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - messageItems = [[NSMutableDictionary alloc] init]; - messageKeys = [[NSMutableDictionary alloc] init]; - - }); -} +@implementation SharedLinksHistoryFilter -(int)type { @@ -39,79 +20,8 @@ +(int)type { return HistoryFilterSharedLink; } -- (NSMutableDictionary *)messageKeys:(int)peer_id { - return [[self class] messageKeys:peer_id]; -} - -- (NSMutableArray *)messageItems:(int)peer_id { - return [[self class] messageItems:peer_id]; -} - -+ (NSMutableDictionary *)messageKeys:(int)peer_id { - - __block NSMutableDictionary *keys; - [ASQueue dispatchOnStageQueue:^{ - - keys = messageKeys[@(peer_id)]; - - if(!keys) - { - keys = [[NSMutableDictionary alloc] init]; - messageKeys[@(peer_id)] = keys; - } - - } synchronous:YES]; - - return keys; -} - -+ (NSMutableArray *)messageItems:(int)peer_id { - __block NSMutableArray *items; - - [ASQueue dispatchOnStageQueue:^{ - - items = messageItems[@(peer_id)]; - - if(!items) - { - items = [[NSMutableArray alloc] init]; - messageItems[@(peer_id)] = items; - } - - } synchronous:YES]; - - - - return items; -} - - -+(void)drop { - [ASQueue dispatchOnStageQueue:^{ - [messageKeys removeAllObjects]; - [messageItems removeAllObjects]; - }]; -} - - - --(void)remoteRequest:(BOOL)next peer_id:(int)peer_id callback:(void (^)(id response))callback { - - self.request = [RPCRequest sendRequest:[TLAPI_messages_search createWithPeer:[self.controller.conversation inputPeer] q:@"" filter:[TL_inputMessagesFilterUrl create] min_date:0 max_date:0 offset:0 max_id:self.controller.max_id limit:(int)self.controller.selectLimit] successHandler:^(RPCRequest *request, id response) { - - - if(callback && self != nil) { - callback(response); - } - - } errorHandler:^(RPCRequest *request, RpcError *error) { - - if(callback) { - callback(nil); - } - - } timeout:10 queue:[ASQueue globalQueue].nativeQueue]; - +-(TLMessagesFilter *)messagesFilter { + return [TL_inputMessagesFilterUrl create]; } -(NSString *)description { diff --git a/TelegramTest/SharedManager.m b/TelegramTest/SharedManager.m index 191d20ae..6acef849 100644 --- a/TelegramTest/SharedManager.m +++ b/TelegramTest/SharedManager.m @@ -156,17 +156,14 @@ +(void)proccessGlobalResponse:(id)response { [TL_localMessage convertReceivedMessages:[response messages]]; - - [[MessagesManager sharedManager] add:[response messages]]; - [[Storage manager] insertMessages:[response messages] completeHandler:nil]; + [[Storage manager] insertMessages:[response messages]]; } if([response respondsToSelector:@selector(n_messages)] && [response n_messages].count > 0) { [TL_localMessage convertReceivedMessages:[response n_messages]]; - [[MessagesManager sharedManager] add:[response n_messages]]; - [[Storage manager] insertMessages:[response n_messages] completeHandler:nil]; + [[Storage manager] insertMessages:[response n_messages]]; } if([response respondsToSelector:@selector(users)] && [response users].count > 0) { diff --git a/TelegramTest/StandartViewController.h b/TelegramTest/StandartViewController.h index 54b81fc6..3a666286 100644 --- a/TelegramTest/StandartViewController.h +++ b/TelegramTest/StandartViewController.h @@ -16,5 +16,6 @@ -(BOOL)isSearchActive; +(NSMenu *)attachMenu; +-(void)hideSearchViewControllerWithConversationUsed:(TL_conversation*)conversation; -(void)searchByString:(NSString *)searchString; @end diff --git a/TelegramTest/StandartViewController.m b/TelegramTest/StandartViewController.m index 5bbc9091..16e71e2b 100644 --- a/TelegramTest/StandartViewController.m +++ b/TelegramTest/StandartViewController.m @@ -10,11 +10,14 @@ #import "ComposeActionGroupBehavior.h" #import "ComposeActionSecretChatBehavior.h" #import "ComposeActionBroadcastBehavior.h" - +#import "TGRecentSearchTableView.h" +#import "ComposeActionCreateChannelBehavior.h" +#import "ComposeActionCreateMegaGroupBehavior.h" @interface StandartViewController () @property (nonatomic, strong) BTRButton *topButton; @property (nonatomic, strong) TMSearchTextField *searchTextField; @property (nonatomic,strong) TMMenuPopover *menuPopover; +@property (nonatomic,strong) TGRecentSearchTableView *recentTableView; @end @interface ExtendView : TMView @@ -30,6 +33,10 @@ -(void)removeFromSuperview { } +-(BOOL)becomeFirstResponder { + return [super becomeFirstResponder]; +} + -(void)setFrameSize:(NSSize)newSize { @@ -142,11 +149,12 @@ -(void)loadView { self.searchView = _searchViewController.view; + + _recentTableView = [[TGRecentSearchTableView alloc] initWithFrame:self.view.bounds]; + + } --(BOOL)becomeFirstResponder { - return [self.searchTextField becomeFirstResponder]; -} -(void)showComposeMenu { @@ -168,6 +176,10 @@ -(void)showComposeMenu { +(NSMenu *)attachMenu { NSMenu *theMenu = [[NSMenu alloc] init]; + + + + NSMenuItem *createGropup = [NSMenuItem menuItemWithTitle:NSLocalizedString(@"ComposeMenu.CreateGroup", nil) withBlock:^(id sender) { @@ -186,25 +198,6 @@ +(NSMenu *)attachMenu { - NSMenuItem *broadcast = [NSMenuItem menuItemWithTitle:NSLocalizedString(@"ComposeMenu.Broadcast", nil) withBlock:^(id sender) { - ComposeAction *action = [[ComposeAction alloc] initWithBehaviorClass:[ComposeActionBroadcastBehavior class]]; - - if([[BroadcastManager sharedManager] all].count == 0) { - [[Telegram rightViewController] showComposeWithAction:action]; - } else { - [[Telegram rightViewController] showComposeBroadcastList:action]; - } - - [[NSApplication sharedApplication] activateIgnoringOtherApps:YES]; - - }]; - - [broadcast setImage:[NSImage imageNamed:@"ComposeMenuNewBroadcast"]]; - [broadcast setHighlightedImage:[NSImage imageNamed:@"ComposeMenuNewBroadcastActive"]]; - [theMenu addItem:broadcast]; - - - NSMenuItem *secretChat = [NSMenuItem menuItemWithTitle:NSLocalizedString(@"ComposeMenu.SecretChat", nil) withBlock:^(id sender) { ComposeAction *action = [[ComposeAction alloc] initWithBehaviorClass:[ComposeActionSecretChatBehavior class]]; @@ -221,13 +214,53 @@ +(NSMenu *)attachMenu { [theMenu addItem:secretChat]; + + // if(ACCEPT_FEATURE) { + NSMenuItem *createChannel = [NSMenuItem menuItemWithTitle:NSLocalizedString(@"ComposeMenu.CreateChannel", nil) withBlock:^(id sender) { + + + ComposeAction *action = [[ComposeAction alloc] initWithBehaviorClass:[ComposeActionCreateChannelBehavior class]]; + + [[Telegram rightViewController] showComposeCreateChannel:action]; + + [[NSApplication sharedApplication] activateIgnoringOtherApps:YES]; + + }]; + + [createChannel setImage:[NSImage imageNamed:@"ComposeMenuNewBroadcast"]]; + [createChannel setHighlightedImage:[NSImage imageNamed:@"ComposeMenuNewBroadcastActive"]]; + [theMenu addItem:createChannel]; + // } + + + + +// NSMenuItem *createMegagroup = [NSMenuItem menuItemWithTitle:NSLocalizedString(@"ComposeMenu.CreateMegaGroup", nil) withBlock:^(id sender) { +// +// +// ComposeAction *action = [[ComposeAction alloc] initWithBehaviorClass:[ComposeActionCreateMegaGroupBehavior class]]; +// +// ComposeCreateChannelViewController *viewController = [[ComposeCreateChannelViewController alloc] initWithFrame:[Telegram rightViewController].view.bounds]; +// +// [viewController setAction:action]; +// +// +// [[Telegram rightViewController].navigationViewController pushViewController:viewController animated:YES]; +// +// +// +// [[NSApplication sharedApplication] activateIgnoringOtherApps:YES]; +// +// }]; +// +// [createMegagroup setImage:[NSImage imageNamed:@"ComposeMenuNewBroadcast"]]; +// [createMegagroup setHighlightedImage:[NSImage imageNamed:@"ComposeMenuNewBroadcastActive"]]; +// [theMenu addItem:createMegagroup]; + + return theMenu; } -- (void) searchFieldBlur {} -- (void) searchFieldFocus {} - - -(BOOL)isSearchActive { return self.searchView.superview != nil; } @@ -244,11 +277,103 @@ - (void) searchFieldTextChange:(NSString *)searchString { } -(void)searchByString:(NSString *)searchString { + [self.searchTextField setStringValue:searchString]; + + if(searchString.length > 0) { + [self.searchTextField becomeFirstResponder]; + } else { + [self.searchTextField resignFirstResponder]; + } } +-(BOOL)becomeFirstResponder { + return [super becomeFirstResponder]; +} + +-(void)hideSearchViewControllerWithConversationUsed:(TL_conversation*)conversation { + + + + if(self.searchViewController.selectedPeerId != conversation.peer_id) + return; + + [self searchByString:@""]; + + // add to recent + + + + [[Storage yap] asyncReadWriteWithBlock:^(YapDatabaseReadWriteTransaction * __nonnull transaction) { + + NSMutableArray *peerIds = [transaction objectForKey:@"peerIds" inCollection:RECENT_SEARCH]; + + if(!peerIds) + { + peerIds = [[NSMutableArray alloc] init]; + } + + [peerIds removeObject:@(conversation.peer_id)]; + + [peerIds insertObject:@(conversation.peer_id) atIndex:0]; + + [transaction setObject:peerIds forKey:@"peerIds" inCollection:RECENT_SEARCH]; + + }]; + + +} + +-(BOOL)showRecentSearchItems { + + + BOOL canShow = [self.recentTableView loadRecentSearchItems]; + + if(canShow) { + [self.mainView removeFromSuperview]; + [self.searchView removeFromSuperview]; + + NSRect tableRect = NSMakeRect(0, 0, NSWidth(self.view.frame), NSHeight(self.view.frame) - 48); + + [self.recentTableView.containerView setFrame:tableRect]; + + [self.view addSubview:self.recentTableView.containerView]; + + } + + return canShow; +} + +-(void)hideRecentSearchItems { + [self hideSearch:self.searchTextField.stringValue.length == 0]; +} + +-(void)searchFieldFocus { + if(self.searchTextField.stringValue.length == 0 && [self.searchTextField isFirstResponder]) + [self showRecentSearchItems]; +} + +-(void)searchFieldBlur { + [self hideRecentSearchItems]; +} + +-(void)searchFieldDidResign { + [self hideRecentSearchItems]; +} + +-(BOOL)resignFirstResponder { + + [self.searchTextField endEditing]; + + return YES; +} -(void)hideSearch:(BOOL)hide { + + if(hide && [self.searchTextField isFirstResponder]) { + if([self showRecentSearchItems]) + return; + } NSRect tableRect = NSMakeRect(0, 0, NSWidth(self.view.frame), NSHeight(self.view.frame) - 48); @@ -256,6 +381,8 @@ -(void)hideSearch:(BOOL)hide { [self.searchView setFrame:tableRect]; [self.mainView setFrame:tableRect]; + [self.recentTableView.containerView removeFromSuperview]; + if(hide) { [self.searchView removeFromSuperview]; [self.view addSubview:self.mainView]; diff --git a/TelegramTest/StartBotSenderItem.m b/TelegramTest/StartBotSenderItem.m index c4e3a0d6..62c85ce2 100644 --- a/TelegramTest/StartBotSenderItem.m +++ b/TelegramTest/StartBotSenderItem.m @@ -41,18 +41,20 @@ -(SendingQueueType)sendingQueue { -(void)performRequest { - id request = [TLAPI_messages_startBot createWithBot:_bot.inputUser chat_id:self.conversation.peer.chat_id random_id:self.message.randomId start_param:_startParam]; + id request = [TLAPI_messages_startBot createWithBot:_bot.inputUser peer:self.conversation.inputPeer random_id:self.message.randomId start_param:_startParam]; self.rpc_request = [RPCRequest sendRequest:request successHandler:^(RPCRequest *request, TLUpdates * response) { - if(response.updates.count < 2) + [self updateMessageId:response]; + + TL_localMessage *msg = [TL_localMessage convertReceivedMessage:[[self updateNewMessageWithUpdates:response] message]]; + + if(msg == nil) { [self cancel]; return; } - TL_localMessage *msg = [TL_localMessage convertReceivedMessage:(TLMessage *) ( [response.updates[1] message])]; - self.message.n_id = msg.n_id; self.message.date = msg.date; self.message.media = msg.media; diff --git a/TelegramTest/StickerSenderItem.h b/TelegramTest/StickerSenderItem.h index 13739e64..0f81c3a0 100644 --- a/TelegramTest/StickerSenderItem.h +++ b/TelegramTest/StickerSenderItem.h @@ -11,6 +11,6 @@ @interface StickerSenderItem : SenderItem --(id)initWithDocument:(TLDocument *)document forConversation:(TL_conversation*)conversation; +-(id)initWithDocument:(TLDocument *)document forConversation:(TL_conversation*)conversation additionFlags:(int)additionFlags; @end diff --git a/TelegramTest/StickerSenderItem.m b/TelegramTest/StickerSenderItem.m index eab32c82..984112a0 100644 --- a/TelegramTest/StickerSenderItem.m +++ b/TelegramTest/StickerSenderItem.m @@ -11,11 +11,15 @@ @implementation StickerSenderItem --(id)initWithDocument:(TLDocument *)document forConversation:(TL_conversation*)conversation { +-(id)initWithDocument:(TLDocument *)document forConversation:(TL_conversation*)conversation additionFlags:(int)additionFlags { if(self = [super initWithConversation:conversation]) { self.message = [MessageSender createOutMessage:@"" media:[TL_messageMediaDocument createWithDocument:document] conversation:conversation]; + if(additionFlags & (1 << 4)) + self.message.from_id = 0; + + [self.message save:YES]; } @@ -29,7 +33,7 @@ -(void)performRequest { id media = [TL_inputMediaDocument createWithN_id:[TL_inputDocument createWithN_id:self.message.media.document.n_id access_hash:self.message.media.document.access_hash]]; if(self.conversation.type != DialogTypeBroadcast) { - request = [TLAPI_messages_sendMedia createWithFlags:self.message.reply_to_msg_id != 0 ? 1 : 0 peer:self.conversation.inputPeer reply_to_msg_id:self.message.reply_to_msg_id media:media random_id:self.message.randomId reply_markup:[TL_replyKeyboardMarkup createWithFlags:0 rows:[@[]mutableCopy]]]; + request = [TLAPI_messages_sendMedia createWithFlags:[self senderFlags] peer:self.conversation.inputPeer reply_to_msg_id:self.message.reply_to_msg_id media:media random_id:self.message.randomId reply_markup:[TL_replyKeyboardMarkup createWithFlags:0 rows:[@[]mutableCopy]]]; } else { TL_broadcast *broadcast = self.conversation.broadcast; @@ -38,16 +42,18 @@ -(void)performRequest { } [RPCRequest sendRequest:request successHandler:^(RPCRequest *request, TLUpdates * response) { - - if(response.updates.count < 2) + + [self updateMessageId:response]; + + TL_localMessage *msg = [TL_localMessage convertReceivedMessage:[[self updateNewMessageWithUpdates:response] message]]; + + if(msg == nil) { [self cancel]; return; } - TL_localMessage *msg = [TL_localMessage convertReceivedMessage:(TLMessage *) ( [response.updates[1] message])]; - if(self.conversation.type != DialogTypeBroadcast) { self.message.n_id = msg.n_id; diff --git a/TelegramTest/StickersPanelView.h b/TelegramTest/StickersPanelView.h index 3abd0d84..0dc9fa15 100644 --- a/TelegramTest/StickersPanelView.h +++ b/TelegramTest/StickersPanelView.h @@ -11,6 +11,8 @@ @interface StickersPanelView : TMView +@property (nonatomic,weak) MessagesViewController *messagesViewController; + -(void)showAndSearch:(NSString *)emotion animated:(BOOL)animated; -(void)hide:(BOOL)animated; diff --git a/TelegramTest/StickersPanelView.m b/TelegramTest/StickersPanelView.m index cfd93197..ef28a2e7 100644 --- a/TelegramTest/StickersPanelView.m +++ b/TelegramTest/StickersPanelView.m @@ -106,16 +106,16 @@ -(void)rebuild:(NSArray *)stickers { TGMessagesStickerImageObject *imgObj = [[TGMessagesStickerImageObject alloc] initWithLocation:obj.thumb.location placeHolder:placeholder]; - imgObj.imageSize = strongsize(NSMakeSize(obj.thumb.w, obj.thumb.h), NSHeight(self.frame) - 6); + imgObj.imageSize = strongsize(NSMakeSize(obj.thumb.w, obj.thumb.h), NSHeight(self.frame) - 10); TGStickerImageView *imgView = [[TGStickerImageView alloc] initWithFrame:NSMakeRect(0, 0, imgObj.imageSize.width, imgObj.imageSize.height)]; [imgView setTapBlock:^{ - [[Telegram rightViewController].messagesViewController sendSticker:obj forConversation:[Telegram conversation] addCompletionHandler:nil]; + [_messagesViewController sendSticker:obj forConversation:[Telegram conversation] addCompletionHandler:nil]; - [[Telegram rightViewController].messagesViewController setStringValueToTextField:@""]; + [_messagesViewController setStringValueToTextField:@""]; }]; imgView.object = imgObj; diff --git a/TelegramTest/Storage.h b/TelegramTest/Storage.h index 9a31b63a..c4684bc0 100644 --- a/TelegramTest/Storage.h +++ b/TelegramTest/Storage.h @@ -19,7 +19,9 @@ #import "TGSecretAction.h" #import "ASQueue.h" - +#import "SSignalKit.h" +#import "TGMessageHole.h" +#import "TGHistoryResponse.h" @interface Storage : NSObject { // FMDatabase *db; @@ -35,39 +37,38 @@ extern NSString *const REPLAY_COLLECTION; extern NSString *const FILE_NAMES; extern NSString *const ATTACHMENTS; extern NSString *const BOT_COMMANDS; +extern NSString *const RECENT_SEARCH; -(void)drop:(void (^)())completeHandler; - - -+(void)dbSetKey:(NSString *)key; -+(void)dbRekey:(NSString *)rekey; ++(void)drop; ++(void)open:(void (^)())completeHandler; +(Storage *)manager; ++(void)initManagerWithCallback:(dispatch_block_t)callback; +(YapDatabaseConnection *)yap; +(NSString *)path; -// START MESSAGE AND DIALOGS PROCEDURES!!! ++(BOOL)isInitialized; +// START MESSAGE AND DIALOGS PROCEDURES!!! -- (void)searchMessagesBySearchString:(NSString *)searchString offset:(int)offset completeHandler:(void (^)(NSInteger count, NSArray *messages))completeHandler; -(TGUpdateState *)updateState; -(void)saveUpdateState:(TGUpdateState *)state; -(void)messages:(void (^)(NSArray *))completeHandler forIds:(NSArray *)ids random:(BOOL)random queue:(ASQueue *)q; -(void)messages:(void (^)(NSArray *))completeHandler forIds:(NSArray *)ids random:(BOOL)random sync:(BOOL)sync queue:(ASQueue *)q; -(NSArray *)issetMessages:(NSArray *)ids; --(void)insertMessage:(TLMessage *)message completeHandler:(dispatch_block_t)completeHandler; +-(void)insertMessages:(NSArray *)messages; -(void)insertMessages:(NSArray *)messages completeHandler:(dispatch_block_t)completeHandler; +-(void)updateChannelMessageViews:(long)channelMsgId views:(int)views; --(void)deleteMessages:(NSArray *)messages completeHandler:(void (^)(BOOL result))completeHandler; --(void)deleteMessagesWithRandomIds:(NSArray *)messages completeHandler:(void (^)(BOOL result))completeHandler; - +-(void)deleteMessages:(NSArray *)messages completeHandler:(void (^)(NSArray *peer_update_data))completeHandler; +-(void)deleteMessagesWithRandomIds:(NSArray *)messages isChannelMessages:(BOOL)isChannelMessages completeHandler:(void (^)(NSArray *peer_update_data))completeHandler; +-(void)deleteChannelMessages:(NSArray *)messages completeHandler:(void (^)(NSArray *peer_update_data, NSDictionary *readCount))completeHandler; -(void)markMessagesAsRead:(NSArray *)messages useRandomIds:(NSArray *)randomIds; --(void)lastMessageForPeer:(TLPeer *)peer completeHandler:(void (^)(TL_localMessage *message))completeHandler; - --(TL_localMessage *)lastMessage:(int)peer_id from_id:(int)from_id; +-(void)lastMessageWithConversation:(TL_conversation *)conversation completeHandler:(void (^)(TL_localMessage *message, int importantMessage))completeHandler; // end messages -(void)deleteMessagesInDialog:(TL_conversation *)dialog completeHandler:(dispatch_block_t)completeHandler; @@ -80,15 +81,12 @@ extern NSString *const BOT_COMMANDS; + (NSMutableArray *)emoji; + (void)saveEmoji:(NSMutableArray *)emoji; - -- (void)updateDialog:(TL_conversation *)dialog; - --(void)insertDialogs:(NSArray *)dialogs completeHandler:(void (^)(BOOL result))completeHandler; +-(void)insertDialogs:(NSArray *)dialogs; -(void)insertBroadcast:(TL_broadcast *)broadcast; -(void)deleteBroadcast:(TL_broadcast *)broadcast; --(NSArray *)broadcastList; +-(void)broadcastList:(void (^)(NSArray *list))completeHandler; -(void)deleteDialog:(TL_conversation *)dialog completeHandler:(void (^)(void))completeHandler; @@ -96,12 +94,10 @@ extern NSString *const BOT_COMMANDS; -(void)loadChats:(void (^)(NSArray *chats))completeHandler; -- (void)dialogByPeer:(int)peer completeHandler:(void (^)(TLDialog *dialog, TLMessage *message))completeHandler; - -- (void)searchDialogsByPeers:(NSArray *)peers needMessages:(BOOL)needMessages searchString:(NSString *)searchString completeHandler:(void (^)(NSArray *dialogs, NSArray *messages, NSArray *searchMessages))completeHandler; +- (void)searchDialogsByPeers:(NSArray *)peers needMessages:(BOOL)needMessages searchString:(NSString *)searchString completeHandler:(void (^)(NSArray *dialogs))completeHandler; --(void)dialogsWithOffset:(int)offset limit:(int)limit completeHandler:(void (^)(NSArray *d, NSArray *m))completeHandler; +-(void)dialogsWithOffset:(int)offset limit:(int)limit completeHandler:(void (^)(NSArray *d))completeHandler; ; -(void)updateTopMessage:(TL_conversation *)dialog completeHandler:(void (^)(BOOL result))completeHandler; @@ -116,7 +112,6 @@ extern NSString *const BOT_COMMANDS; - (void)insertUser:(TLUser *)user completeHandler:(void (^)(BOOL result))completeHandler; - (void)insertUsers:(NSArray *)users completeHandler:(void (^)(BOOL result))completeHandler; - (void)users:(void (^)(NSArray *result))completeHandler; -- (void)updateLastSeen:(TLUser *)user; -(void)insertContacst:(NSArray *)contacts; @@ -142,26 +137,43 @@ extern NSString *const BOT_COMMANDS; -(void)deleteImportedContacts:(NSSet *)result; --(void)unreadCount:(void (^)(int count))completeHandler; +-(void)unreadCount:(void (^)(int count))completeHandler includeMuted:(BOOL)includeMuted; --(void)markAllInDialog:(TL_conversation *)dialog; +-(void)markAllInConversation:(int)peer_id; --(void)markAllInConversation:(TL_conversation *)conversation max_id:(int)max_id completeHandler:(void (^)(NSArray * ids))completeHandler; +-(void)markAllInConversation:(int)peer_id max_id:(int)max_id out:(BOOL)n_out completeHandler:(void (^)(NSArray * ids))completeHandler; -(void)insertEncryptedChat:(TLEncryptedChat *)chat; --(void)loadMessages:(int)conversationId localMaxId:(int)localMaxId limit:(int)limit next:(BOOL)next maxDate:(int)maxDate filterMask:(int)mask completeHandler:(void (^)(NSArray *))completeHandler; +-(TGHistoryResponse *)loadMessages:(int)conversationId min_id:(int)min_id max_id:(int)max_id minDate:(int)minDate maxDate:(int)maxDate limit:(int)limit next:(BOOL)next filterMask:(int)mask isChannel:(BOOL)isChannel; + +-(TGHistoryResponse *)loadChannelMessages:(int)conversationId min_id:(int)min_id max_id:(int)max_id minDate:(int)minDate maxDate:(int)maxDate limit:(int)limit filterMask:(int)mask important:(BOOL)important next:(BOOL)next; + +-(void)invalidateChannelMessagesWithPts:(int)pts; +-(void)validateChannelMessages:(NSArray *)messages; + +-(void)updateMessageViews:(int)views channelMsgId:(long)channelMsgId; + +-(void)markChannelMessagesAsRead:(int)channel_id max_id:(int)max_id callback:(void (^)(int unread_count))callback; +-(void)updateTopMessagesWithMessages:(NSDictionary *)topMessages topImportantMessages:(NSDictionary *)topImportantMessages; + +-(TL_localMessage *)lastImportantMessageAroundMinId:(long)channelMsgId; +-(TL_localMessage *)lastMessageAroundMinId:(long)channelMsgId important:(BOOL)important isTop:(BOOL)isTop; +-(TL_localMessage *)messageById:(int)msgId inChannel:(int)channel_id; + + -(TL_localMessage *)messageById:(int)msgId; --(void)insertMedia:(TL_localMessage *)message; +-(void)updateUsersStatus:(NSArray *)users; + -(void)addUserPhoto:(int)user_id media:(TLUserProfilePhoto *)photo; -(void)deleteUserPhoto:(int)user_id; -(void)countOfUserPhotos:(int)user_id; --(void)media:(void (^)(NSArray *))completeHandler max_id:(long)max_id peer_id:(int)peer_id next:(BOOL)next limit:(int)limit; +-(void)media:(void (^)(NSArray *))completeHandler max_id:(int)max_id filterMask:(int)filterMask peer:(TLPeer *)peer next:(BOOL)next limit:(int)limit; -(int)countOfMedia:(int)peer_id; @@ -170,17 +182,6 @@ extern NSString *const BOT_COMMANDS; - (void) removeContact:(TLContact *) contact ; - (void) insertContact:(TLContact *) contact; -//-(void)notifySettings:(void (^)(NSDictionary *))completeHandler; -//-(void)addNotifySetting:(int)peer_id mute_until:(int)mute_until; - -//-(void)selfDestructorFor:(int)chat_id max_id:(int)max_id completeHandler:(void (^)(Destructor *destructor))completeHandler; -// -//-(void)selfDestructors:(int)chat_id completeHandler:(void (^)(NSArray *destructors))completeHandler; -//-(void)selfDestructors:(void (^)(NSArray *destructors))completeHandler; -// -//-(void)insertDestructor:(Destructor *)destructor; -//-(void)updateDestructTime:(int)time forMessages:(NSArray *)msgIds; - -(void)insertBlockedUsers:(NSArray *)users; -(void)deleteBlockedUsers:(NSArray *)users; -(void)blockedList:(void (^)(NSArray *users))completeHandler; @@ -193,11 +194,16 @@ extern NSString *const BOT_COMMANDS; -(void)selectTasks:(void (^)(NSArray *tasks))completeHandler; -(TL_conversation *)selectConversation:(TLPeer *)peer; + + +-(void)conversationsWithPeerIds:(NSArray *)peer_ids completeHandler:(void (^)(NSArray * result))completeHandler; + - (id)fileInfoByPathHash:(NSString *)pathHash; - (void)findFileInfoByPathHash:(NSString *)pathHash completeHandler:(void (^)(BOOL result, id file))completeHandler; - (void)setFileInfo:(id)file forPathHash:(NSString *)pathHash; - (void)deleteFileHash:(NSString *)pathHash; --(void)updateMessages:(NSArray *)messages; + +-(void)messagesWithWebpage:(TLMessageMedia *)mediaWebpage callback:(void (^)(NSDictionary *))callback; -(void)insertSecretAction:(TGSecretAction *)action; @@ -224,4 +230,17 @@ extern NSString *const BOT_COMMANDS; -(void)readMessagesContent:(NSArray *)messages; +-(NSArray *)conversationsWithIds:(NSArray *)ids; + ++(void)updateEncryptionKey:(NSString *)key; + ++(void)updateOldEncryptionKey:(NSString *)key; + + + +-(void)insertMessagesHole:(TGMessageHole *)hole; +-(void)removeHole:(TGMessageHole *)hole; +-(NSArray *)groupHoles:(int)peer_id min:(int)min max:(int)max; +-(void)addHolesAroundMessage:(TL_localMessage *)message; +-(int)syncedMessageIdWithPeerId:(int)peer_id important:(BOOL)important latest:(BOOL)latest isChannel:(BOOL)isChannel; @end \ No newline at end of file diff --git a/TelegramTest/Storage.m b/TelegramTest/Storage.m index 0980066d..4fdace46 100644 --- a/TelegramTest/Storage.m +++ b/TelegramTest/Storage.m @@ -32,24 +32,64 @@ @implementation Storage NSString *const FILE_NAMES = @"file_names"; NSString *const ATTACHMENTS = @"attachments"; NSString *const BOT_COMMANDS = @"bot_commands_v2"; +NSString *const RECENT_SEARCH = @"recent_search"; -(id)init { if(self = [super init]) { - [self open:nil]; + [self open:nil queue:nil]; } return self; } +static ASQueue *keyQueue; +static Storage *instance; + + ++(void)initialize { + keyQueue = [[ASQueue alloc] initWithName:"dbKeyQueue"]; +} + +(Storage *)manager { - static Storage *instance; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - instance = [[[self class] alloc] init]; - }); + + [keyQueue dispatchOnQueue:^{ + + if(!instance) + instance = [[[self class] alloc] init]; + + } synchronous:YES]; + return instance; } ++(BOOL)isInitialized { + + __block BOOL inited = NO; + + [keyQueue dispatchOnQueue:^{ + + inited = instance != nil; + + } synchronous:YES]; + + return inited; +} + ++(void)initManagerWithCallback:(dispatch_block_t)callback { + [keyQueue dispatchOnQueue:^{ + if(!instance) + instance = [[self alloc] initWithCallback:callback]; + }]; +} + +-(id)initWithCallback:(dispatch_block_t)callback { + if(self = [super init]) { + [self open:callback queue:dispatch_get_current_queue()]; + } + + return self; +} + static YapDatabaseConnection *y_connection; static YapDatabase *y_db; static NSString *yap_path; @@ -59,7 +99,7 @@ +(YapDatabaseConnection *)yap { dispatch_once(&yapToken, ^{ - yap_path = [NSString stringWithFormat:@"%@/yap_store-%@",[self path], [[NSUserDefaults standardUserDefaults] objectForKey:@"db_name"]]; + yap_path = [NSString stringWithFormat:@"%@/yap_store-%@",[self path], @"t143.sqlite"]; y_db = [[YapDatabase alloc] initWithPath:yap_path]; y_connection = [y_db newConnection]; @@ -67,18 +107,6 @@ +(YapDatabaseConnection *)yap { return y_connection; } - -+(void)reyap { - - YapDatabaseOptions *options = [[YapDatabaseOptions alloc] init]; - - options.corruptAction = YapDatabaseCorruptAction_Delete; - - y_db = [[YapDatabase alloc] initWithPath:yap_path serializer:NULL deserializer:NULL preSanitizer:NULL postSanitizer:NULL options:options]; - y_connection = [y_db newConnection]; - -} - +(NSString *)path { NSFileManager *fm = [NSFileManager defaultManager]; NSString *applicationSupportPath = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES)[0]; @@ -92,30 +120,6 @@ +(NSString *)path { } -static NSString *encryptionKey = @""; - - -+(void)dbSetKey:(NSString *)key { - - [Storage manager]; - - encryptionKey = key; -} - -+(void)dbRekey:(NSString *)rekey { - - [[Storage manager] dbRekey:encryptionKey]; - -} - --(void)dbRekey:(NSString *)rekey { - - [queue inDatabase:^(FMDatabase *db) { - - [db rekey:rekey]; - - }]; -} static NSString *kEmoji = @"kEmojiNew"; @@ -152,148 +156,205 @@ + (void)saveInputTextForPeers:(NSMutableDictionary *)dictionary { } +NSString *const tableMessages = @"messages"; +NSString *const tableChannelMessages = @"channel_messages_v1"; +NSString *const tableChats = @"chats"; +NSString *const tableUpdateState = @"update_state2"; +NSString *const tableUsers = @"users"; +NSString *const tableContacts = @"contacts"; +NSString *const tableChatsFull = @"chats_full_new"; +NSString *const tableImportedContacts = @"imported_contacts"; +NSString *const tableEncryptedChats = @"encrypted_chats"; +NSString *const tableSelfDestruction = @"self_destruction"; +NSString *const tableUserPhotos = @"user_photos"; +NSString *const tableBlockedUsers = @"blocked_users"; +NSString *const tableTasks = @"tasks"; +NSString *const tableFiles = @"files"; +NSString *const tableBroadcasts = @"broadcasts"; +NSString *const tableOutSecretActions = @"out_secret_actions"; +NSString *const tableInSecretActions = @"in_secret_actions"; +NSString *const tableSupportMessages = @"support_messages2"; +NSString *const tableMessageHoles = @"message_holes_v1"; +NSString *const tableMessagesMedia = @"messages_media_v1"; +NSString *const tableModernDialogs = @"modern_dialogs"; + + + --(void)open:(void (^)())completeHandler { + +-(void)open:(void (^)())completeHandler queue:(dispatch_queue_t)dqueue { + + if(!dqueue) + dqueue = dispatch_get_current_queue(); - NSString *dbName = @"t143.sqlite"; // 61 + NSString *dbPath = [[Storage path] stringByAppendingPathComponent:@"encrypted.sqlite"]; + + if(!encryptionKey) { + return; + } - self->queue = [FMDatabaseQueue databaseQueueWithPath:[NSString stringWithFormat:@"%@/%@",[Storage path],dbName]]; + self->queue = [FMDatabaseQueue databaseQueueWithPath:dbPath]; + __block BOOL res = NO; + [[Storage yap] flushMemoryWithFlags:YapDatabaseConnectionFlushMemoryFlags_All]; - [queue inDatabaseWithDealocing:^(FMDatabase *db) { + + [queue inDatabase:^(FMDatabase *db) { + + [db close]; + + [self createAndCheckDatabase:@"t143.sqlite"]; + + [db open]; + res = [db setKey:encryptionKey]; - }]; - - - NSString *oldName = [[NSUserDefaults standardUserDefaults] objectForKey:@"db_name"]; - - if(![oldName isEqualToString:dbName]) { - [SettingsArchiver setSupportUserId:0]; - [SettingsArchiver removeSetting:BlockedContactsSynchronized]; + char* errorMessage; + + + sqlite3_exec(db.sqliteHandle, "PRAGMA synchronous=OFF", NULL, NULL, &errorMessage); + sqlite3_exec(db.sqliteHandle, "PRAGMA count_changes=OFF", NULL, NULL, &errorMessage); + sqlite3_exec(db.sqliteHandle, "PRAGMA journal_mode=MEMORY", NULL, NULL, &errorMessage); + sqlite3_exec(db.sqliteHandle, "PRAGMA temp_store=MEMORY", NULL, NULL, &errorMessage); - [[NSUserDefaults standardUserDefaults] setObject:dbName forKey:@"db_name"]; - [[NSUserDefaults standardUserDefaults] synchronize]; - } - - [queue inDatabase:^(FMDatabase *db) { - [db executeUpdate:@"create table if not exists messages (n_id INTEGER PRIMARY KEY,message_text TEXT, flags integer, from_id integer, peer_id integer, date integer, serialized blob, random_id, destruct_time, filter_mask integer, fake_id integer, dstate integer)"]; + [db executeUpdate:[NSString stringWithFormat:@"create table if not exists %@ (n_id INTEGER PRIMARY KEY,message_text TEXT, flags integer, from_id integer, peer_id integer, date integer, serialized blob, random_id, destruct_time, filter_mask integer, fake_id integer, dstate integer, webpage_id blob)",tableMessages]]; + //messages indexes { - [db executeUpdate:@"CREATE INDEX if not exists select_messages_idx ON messages(peer_id,date)"]; - [db executeUpdate:@"CREATE INDEX if not exists peer_idx ON messages(peer_id)"]; - [db executeUpdate:@"CREATE INDEX if not exists date_idx ON messages(date)"]; - [db executeUpdate:@"CREATE INDEX if not exists random_idx ON messages(random_id)"]; - [db executeUpdate:@"CREATE INDEX if not exists peer_flags_idx ON messages(peer_id,flags)"]; + [db executeUpdate:[NSString stringWithFormat:@"CREATE INDEX if not exists select_messages_idx ON %@(peer_id,date)",tableMessages]]; + [db executeUpdate:[NSString stringWithFormat:@"CREATE INDEX if not exists peer_idx ON %@(peer_id)",tableMessages]]; + [db executeUpdate:[NSString stringWithFormat:@"CREATE INDEX if not exists date_idx ON %@(date)",tableMessages]]; + [db executeUpdate:[NSString stringWithFormat:@"CREATE INDEX if not exists random_idx ON %@(random_id)",tableMessages]]; + [db executeUpdate:[NSString stringWithFormat:@"CREATE INDEX if not exists peer_flags_idx ON %@(peer_id,flags)",tableMessages]]; + [db executeUpdate:[NSString stringWithFormat:@"CREATE INDEX if not exists fake_id_idx ON %@(fake_id)",tableMessages]]; + [db executeUpdate:[NSString stringWithFormat:@"CREATE INDEX if not exists webpage_idx ON %@(webpage_id)",tableMessages]]; } - [db executeUpdate:@"create table if not exists dialogs (peer_id INTEGER PRIMARY KEY, top_message integer, unread_count unsigned integer,last_message_date integer, type integer, notify_settings blob, last_marked_message integer, top_message_fake integer, dstate integer,sync_message_id integer,last_marked_date integer,last_real_message_date integer)"]; + [db executeUpdate:[NSString stringWithFormat:@"create table if not exists %@ (n_id blob, flags integer, from_id integer, peer_id integer, date integer, serialized blob, random_id, filter_mask integer, fake_id integer, dstate integer, pts integer, invalidate integer, views integer, is_viewed integer, webpage_id blob)",tableChannelMessages]]; + + if (![db columnExists:@"webpage_id" inTableWithName:tableChannelMessages]) + [db executeUpdate:[NSString stringWithFormat:@"ALTER TABLE %@ ADD COLUMN webpage_id integer",tableChannelMessages]]; - //dialogs indexes + + // channel messages indexes { - [db executeUpdate:@"CREATE INDEX if not exists select_conv_idx ON dialogs(top_message,last_real_message_date)"]; - + [db executeUpdate:[NSString stringWithFormat:@"CREATE INDEX if not exists cm_n_id_idx ON %@(n_id)",tableChannelMessages]]; + [db executeUpdate:[NSString stringWithFormat:@"CREATE INDEX if not exists cm_select_messages_idx ON %@(peer_id,date)",tableChannelMessages]]; + [db executeUpdate:[NSString stringWithFormat:@"CREATE INDEX if not exists cm_peer_idx ON %@(peer_id)",tableChannelMessages]]; + [db executeUpdate:[NSString stringWithFormat:@"CREATE INDEX if not exists cm_date_idx ON %@(date)",tableChannelMessages]]; + [db executeUpdate:[NSString stringWithFormat:@"CREATE INDEX if not exists cm_random_idx ON %@(random_id)",tableChannelMessages]]; + [db executeUpdate:[NSString stringWithFormat:@"CREATE INDEX if not exists cm_peer_flags_idx ON %@(peer_id,flags)",tableChannelMessages]]; + [db executeUpdate:[NSString stringWithFormat:@"CREATE INDEX if not exists cm_fake_idx ON %@(fake_id)",tableChannelMessages]]; + [db executeUpdate:[NSString stringWithFormat:@"CREATE INDEX if not exists cm_pts_idx ON %@(pts)",tableChannelMessages]]; + [db executeUpdate:[NSString stringWithFormat:@"CREATE INDEX if not exists web_page_idx ON %@(webpage_id)",tableChannelMessages]]; } - [db executeUpdate:@"create table if not exists chats (n_id INTEGER PRIMARY KEY, serialized blob)"]; + + + [db executeUpdate:[NSString stringWithFormat:@"create table if not exists %@ (n_id INTEGER PRIMARY KEY, serialized blob)",tableChats]]; - [db executeUpdate:@"create table if not exists update_state (seq integer, pts integer, date integer, qts integer, pts_count integer)"]; + [db executeUpdate:[NSString stringWithFormat:@"create table if not exists %@ (n_id INTEGER PRIMARY KEY, seq integer, pts integer, date integer, qts integer, pts_count integer)",tableUpdateState]]; - [db executeUpdate:@"CREATE TABLE IF NOT EXISTS users (n_id INTEGER PRIMARY KEY, serialized blob, lastseen_update integer)"]; + [db executeUpdate:[NSString stringWithFormat:@"CREATE TABLE IF NOT EXISTS %@ (n_id INTEGER PRIMARY KEY, serialized blob, lastseen_update integer,last_seen integer)",tableUsers]]; + + if (![db columnExists:@"last_seen" inTableWithName:tableUsers]) + { + [db executeUpdate:[NSString stringWithFormat:@"ALTER TABLE %@ ADD COLUMN last_seen integer",tableUsers]]; + } + + + [db executeUpdate:[NSString stringWithFormat:@"create table if not exists %@ (user_id INTEGER PRIMARY KEY,mutual integer)",tableContacts]]; + + + [db executeUpdate:[NSString stringWithFormat:@"create table if not exists %@ (n_id INTEGER PRIMARY KEY, last_update_time integer, serialized blob)",tableChatsFull]]; + + [db executeUpdate:[NSString stringWithFormat:@"create table if not exists %@ (hash blob primary key, hashObject string, user_id integer)",tableImportedContacts]]; - [db executeUpdate:@"create table if not exists contacts (user_id INTEGER PRIMARY KEY,mutual integer)"]; + [db executeUpdate:[NSString stringWithFormat:@"create table if not exists %@ (chat_id integer primary key,serialized blob)",tableEncryptedChats]]; - [db executeUpdate:@"CREATE INDEX if not exists user_id_index ON contacts(user_id)"]; + - [db executeUpdate:@"create table if not exists chats_full_new (n_id INTEGER PRIMARY KEY, last_update_time integer, serialized blob)"]; - [db executeUpdate:@"create table if not exists imported_contacts (hash blob primary key, hashObject string, user_id integer)"]; + [db executeUpdate:[NSString stringWithFormat:@"create table if not exists %@ (id integer primary key autoincrement, chat_id integer, max_id integer, ttl integer)",tableSelfDestruction]]; - [db executeUpdate:@"create table if not exists encrypted_chats (chat_id integer primary key,serialized blob)"]; + [db executeUpdate:[NSString stringWithFormat:@"create table if not exists %@ (id blob primary key, user_id integer, serialized blob,date integer)",tableUserPhotos]]; - [db executeUpdate:@"create table if not exists sharedmedia (message_id integer primary key, peer_id integer, serialized blob,date integer, filter_mask integer)"]; - [db executeUpdate:@"CREATE INDEX if not exists sm_peer_idx ON sharedmedia(peer_id)"]; + [db executeUpdate:[NSString stringWithFormat:@"create table if not exists %@ (user_id integer primary key, date integer)",tableBlockedUsers]]; + [db executeUpdate:[NSString stringWithFormat:@"create table if not exists %@ (task_id integer primary key, params blob, extender blob)",tableTasks]]; + [db executeUpdate:[NSString stringWithFormat:@"create table if not exists %@ (hash string PRIMARY KEY, serialized blob)",tableFiles]]; - [db executeUpdate:@"create table if not exists self_destruction (id integer primary key autoincrement, chat_id integer, max_id integer, ttl integer)"]; + [db executeUpdate:[NSString stringWithFormat:@"create table if not exists %@ (n_id integer PRIMARY KEY, serialized blob, title string, date integer)",tableBroadcasts]]; - [db executeUpdate:@"create table if not exists user_photos (id blob primary key, user_id integer, serialized blob,date integer)"]; + [db executeUpdate:[NSString stringWithFormat:@"create table if not exists %@ (action_id integer primary key, message_data blob, chat_id integer, senderClass string, out_seq_no integer, layer integer)",tableOutSecretActions]]; + [db executeUpdate:[NSString stringWithFormat:@"create table if not exists %@ (action_id integer primary key, message_data blob, file_data blob, chat_id integer, date integer, in_seq_no integer, layer integer)",tableInSecretActions]]; - [db executeUpdate:@"create table if not exists blocked_users (user_id integer primary key, date integer)"]; - [db executeUpdate:@"create table if not exists tasks (task_id integer primary key, params blob, extender blob)"]; + [db executeUpdate:[NSString stringWithFormat:@"create table if not exists %@ (n_id blob, serialized blob)",tableSupportMessages]]; + [db executeUpdate:[NSString stringWithFormat:@"CREATE INDEX if not exists sp_n_id_idx ON %@(n_id)",tableSupportMessages]]; - [db executeUpdate:@"create table if not exists files (hash string PRIMARY KEY, serialized blob)"]; - [db executeUpdate:@"create table if not exists broadcasts (n_id integer PRIMARY KEY, serialized blob, title string, date integer)"]; + [db executeUpdate:[NSString stringWithFormat:@"create table if not exists %@ (unique_id integer primary key, peer_id integer, min_id integer, max_id integer, date integer,count integer, type integer, imploded integer)",tableMessageHoles]]; + [db executeUpdate:[NSString stringWithFormat:@"CREATE INDEX if not exists mh_min_id_idx ON %@(min_id)",tableMessageHoles]]; + [db executeUpdate:[NSString stringWithFormat:@"CREATE INDEX if not exists mh_min_id_idx ON %@(max_id)",tableMessageHoles]]; + [db executeUpdate:[NSString stringWithFormat:@"CREATE INDEX if not exists mh_peer_min_idx ON %@(peer_id,min_id)",tableMessageHoles]]; + [db executeUpdate:[NSString stringWithFormat:@"CREATE INDEX if not exists mh_peer_type_idx ON %@(peer_id,type)",tableMessageHoles]]; - [db executeUpdate:@"create table if not exists out_secret_actions (action_id integer primary key, message_data blob, chat_id integer, senderClass string, out_seq_no integer, layer integer)"]; - [db executeUpdate:@"create table if not exists in_secret_actions (action_id integer primary key, message_data blob, file_data blob, chat_id integer, date integer, in_seq_no integer, layer integer)"]; + // modern dialogs + { + [db executeUpdate:[NSString stringWithFormat:@"create table if not exists %@ (peer_id INTEGER PRIMARY KEY, top_message blob, unread_count integer,last_message_date integer, type integer, last_marked_message integer,last_marked_date integer,last_real_message_date integer, read_inbox_max_id integer, mute_until integer,unread_important_count integer, pts integer, is_invisible integer, top_important_message blob)",tableModernDialogs]]; + + [db executeUpdate:[NSString stringWithFormat:@"CREATE INDEX if not exists c_l_idx ON %@(last_real_message_date)",tableModernDialogs]]; + [db executeUpdate:[NSString stringWithFormat:@"CREATE INDEX if not exists c_t_idx ON %@(top_message)",tableModernDialogs]]; + [db executeUpdate:[NSString stringWithFormat:@"CREATE INDEX if not exists c_ti_idx ON %@(top_important_message)",tableModernDialogs]]; + + } + + [self upgradeDialogsTo42Layer:db]; - [db executeUpdate:@"create table if not exists support_messages (n_id INTEGER PRIMARY KEY, serialized blob)"]; + if([db hadError]) { [self drop:^{ - [self open:completeHandler]; + dispatch_async(dqueue, ^{ + [self open:completeHandler queue:dqueue]; + }); + }]; return; } - [db makeFunctionNamed:@"searchText" maximumArguments:2 withBlock:^(sqlite3_context *context, int argc, sqlite3_value **aargv) { - - if (sqlite3_value_type(aargv[0]) == SQLITE_TEXT) { - - @autoreleasepool { - - const char *c = (const char *)sqlite3_value_text(aargv[0]); - - NSString *s = [NSString stringWithUTF8String:c]; - - - const char *cSearch = (const char *)sqlite3_value_text(aargv[1]); - - NSString *search = [NSString stringWithUTF8String:cSearch]; - - BOOL result = [s rangeOfString:search options:NSCaseInsensitiveSearch].location != NSNotFound; - - - sqlite3_result_int(context, result); - } - } else { - sqlite3_result_null(context); - } - }]; - dispatch_async(dispatch_get_main_queue(), ^{ + dispatch_async(dqueue, ^{ if(completeHandler) completeHandler(); }); @@ -304,64 +365,174 @@ -(void)open:(void (^)())completeHandler { } +-(BOOL)upgradeDialogsTo42Layer:(FMDatabase *)db { + + NSString *oTable = @"dialogs"; + NSString *ocTable = @"channel_dialogs"; + + BOOL exist = [db tableExists:oTable]; + + if(exist) { + + FMResultSet *result = [db executeQuery:[NSString stringWithFormat:@"select * from %@ where type = %d",oTable,DialogTypeSecretChat]]; + + NSMutableArray *secretChats = [NSMutableArray array]; + + while ([result next]) { + + TL_conversation *conversation = [[TL_conversation alloc] init]; + conversation.peer = [self peerWithType:[result intForColumn:@"type"] peer_id:[result intForColumn:@"peer_id"]]; + conversation.unread_count = [result intForColumn:@"unread_count"]; + conversation.top_message = [result intForColumn:@"top_message"]; + conversation.last_message_date = [result intForColumn:@"last_message_date"]; + conversation.last_marked_message = [result intForColumn:@"last_marked_message"]; + conversation.last_marked_date = [result intForColumn:@"last_marked_date"]; + conversation.read_inbox_max_id = [result intForColumn:@"read_inbox_max_id"]; + conversation.notify_settings = [TLClassStore deserialize:[result dataForColumn:@"notify_settings"]]; + + [secretChats addObject:conversation]; + } + + [self insertDialogs:secretChats]; + + [db executeUpdate:[NSString stringWithFormat:@"drop table if exists %@",oTable]]; + [db executeUpdate:[NSString stringWithFormat:@"drop table if exists %@",ocTable]]; + [db executeUpdate:[NSString stringWithFormat:@"delete from %@ where 1=1",tableChats]]; + [db executeUpdate:[NSString stringWithFormat:@"delete from %@ where 1=1",tableChatsFull]]; + [db executeUpdate:[NSString stringWithFormat:@"delete from %@ where 1=1",tableSupportMessages]]; + [db executeUpdate:[NSString stringWithFormat:@"delete from %@ where n_id < ?",tableMessages],@(TGMINSECRETID)]; + + TGUpdateState *state = [self updateState]; + state.checkMinimum = NO; + state.pts = 0; + state.date = 0; + state.seq = 0; + state.checkMinimum = YES; + [self saveUpdateState:state]; + + [result close]; + + } + + return exist; + +} + + +static NSString *oldEncryptionKey; +static NSString *encryptionKey; + ++(void)updateEncryptionKey:(NSString *)key { + encryptionKey = key; +} + ++(void)updateOldEncryptionKey:(NSString *)key { + oldEncryptionKey = key; +} + // -//-(void) createAndCheckDatabase -//{ -// BOOL success; -// -// NSFileManager *fileManager = [NSFileManager defaultManager]; -// -// NSString *dbPath = [NSString stringWithFormat:@"%@/%@",[Storage path],@"encrypted.sqlite"]; -// -// success = [fileManager fileExistsAtPath:dbPath]; -// -// if (success) return; -// -// NSString *databasePathFromApp = dbPath; -// -// [fileManager copyItemAtPath:databasePathFromApp toPath:dbPath error:nil]; // Make a copy of the file in the Documents folder -// -// // Set the new encrypted database path to be in the Documents Folder -// NSString *encryptedDatabasePath = [[Storage path] stringByAppendingPathComponent:@"encrypted.sqlite"]; -// -// // SQL Query. NOTE THAT DATABASE IS THE FULL PATH NOT ONLY THE NAME -// const char* sqlQ = [[NSString stringWithFormat:@"ATTACH DATABASE '%@' AS encrypted KEY '%@';", encryptedDatabasePath, encryptionKey] UTF8String]; -// -// sqlite3 *unencrypted_DB; -// if (sqlite3_open([dbPath UTF8String], &unencrypted_DB) == SQLITE_OK) { -// -// // Attach empty encrypted database to unencrypted database -// sqlite3_exec(unencrypted_DB, sqlQ, NULL, NULL, NULL); -// -// // export database -// sqlite3_exec(unencrypted_DB, "SELECT sqlcipher_export('encrypted');", NULL, NULL, NULL); -// -// // Detach encrypted database -// sqlite3_exec(unencrypted_DB, "DETACH DATABASE encrypted;", NULL, NULL, NULL); -// -// sqlite3_close(unencrypted_DB); -// } -// else { -// sqlite3_close(unencrypted_DB); -// NSAssert1(NO, @"Failed to open database with message '%s'.", sqlite3_errmsg(unencrypted_DB)); -// } -// -//} -// +-(void) createAndCheckDatabase:(NSString *)dbName +{ + NSString *encryptedDatabasePath = [[Storage path] stringByAppendingPathComponent:@"encrypted.sqlite"]; --(void)drop:(void (^)())completeHandler { - [self->queue inDatabase:^(FMDatabase *db) { - [[NSFileManager defaultManager] removeItemAtPath:self->queue.path error:nil]; + + NSFileManager *fileManager = [NSFileManager defaultManager]; + + NSString *dbPath = [NSString stringWithFormat:@"%@/%@",[Storage path],dbName]; + NSString *copyDbPath = [NSString stringWithFormat:@"%@/%@",[Storage path],@"cp_db_p"]; + + BOOL success = [fileManager fileExistsAtPath:encryptedDatabasePath] && fileSize(encryptedDatabasePath) > 0 && ![fileManager fileExistsAtPath:copyDbPath]; + + if (success) { + [fileManager removeItemAtPath:dbPath error:nil]; + return; + } else { + [fileManager removeItemAtPath:encryptedDatabasePath error:nil]; + } + + if([fileManager fileExistsAtPath:dbPath]) + [fileManager copyItemAtPath:dbPath toPath:copyDbPath error:nil]; + + + const char* sqlQ = [[NSString stringWithFormat:@"ATTACH DATABASE '%@' AS encrypted KEY '%@';", encryptedDatabasePath, encryptionKey] UTF8String]; + + sqlite3 *unencrypted_DB; + + int rc = sqlite3_open([copyDbPath UTF8String], &unencrypted_DB); + + + if (rc == SQLITE_OK) { + + if(fileSize(dbPath) > 0) { + [ASQueue dispatchOnMainQueue:^{ + [TMViewController showModalProgressWithDescription:NSLocalizedString(@"DatabaseOptimizing",nil)]; + }]; + } - [[Storage yap] readWriteWithBlock:^(YapDatabaseReadWriteTransaction * __nonnull transaction) { - [transaction removeAllObjectsInAllCollections]; - }]; + int res = sqlite3_exec(unencrypted_DB, sqlQ, NULL, NULL, NULL); + + // export database + res = sqlite3_exec(unencrypted_DB, "SELECT sqlcipher_export('encrypted');", NULL, NULL, NULL); + + + // Detach encrypted database + res = sqlite3_exec(unencrypted_DB, "DETACH DATABASE encrypted;", NULL, NULL, NULL); - encryptionKey = @""; - [self open:completeHandler]; + + res = sqlite3_close(unencrypted_DB); + + + if(fileSize(dbPath) > 0) { + [ASQueue dispatchOnMainQueue:^{ + [TMViewController hideModalProgress]; + }]; + } + + } + else { + sqlite3_close(unencrypted_DB); + NSAssert1(NO, @"Failed to open database with message '%s'.", sqlite3_errmsg(unencrypted_DB)); + } + + [fileManager removeItemAtPath:copyDbPath error:nil]; + [fileManager removeItemAtPath:dbPath error:nil]; + +} +// + ++(void)open:(void (^)())completeHandler { + [[self manager] open:completeHandler queue:dispatch_get_current_queue()]; +} + +-(void)drop:(void (^)())completeHandler { + [self drop:completeHandler queue:dispatch_get_current_queue()]; +} + + ++(void)drop { + [[NSFileManager defaultManager] removeItemAtPath:[[Storage path] stringByAppendingPathComponent:@"encrypted.sqlite"] error:nil]; + + [[Storage yap] readWriteWithBlock:^(YapDatabaseReadWriteTransaction * __nonnull transaction) { + [transaction removeAllObjectsInAllCollections]; }]; +} + +-(void)drop:(void (^)())completeHandler queue:(dispatch_queue_t)dqueue { + dispatch_async(dqueue, ^{ + [self->queue inDatabase:^(FMDatabase *db) { + [[NSFileManager defaultManager] removeItemAtPath:self->queue.path error:nil]; + + + [[Storage yap] readWriteWithBlock:^(YapDatabaseReadWriteTransaction * __nonnull transaction) { + [transaction removeAllObjectsInAllCollections]; + }]; + + [self open:completeHandler queue:dqueue]; + }]; + }); + } @@ -371,14 +542,30 @@ -(TGUpdateState *)updateState { [queue inDatabaseWithDealocing:^(FMDatabase *db) { - [db beginTransaction]; - FMResultSet *result = [db executeQuery:@"select * from update_state limit 1"]; + + FMResultSet *result = [db executeQuery:[NSString stringWithFormat:@"select * from %@ where n_id = 1",tableUpdateState]]; + + dispatch_block_t proccessResult = ^{ + state = [[TGUpdateState alloc] initWithPts:[result intForColumn:@"pts"] qts:[result intForColumn:@"qts"] date:[result intForColumn:@"date"] seq:[result intForColumn:@"seq"] pts_count:[result intForColumn:@"pts_count"]]; + }; if([result next]) { - state = [[TGUpdateState alloc] initWithPts:[result intForColumn:@"pts"] qts:[result intForColumn:@"qts"] date:[result intForColumn:@"date"] seq:[result intForColumn:@"seq"] pts_count:[result intForColumn:@"pts_count"]]; + proccessResult(); + } else { + [result close]; + + result = [db executeQuery:[NSString stringWithFormat:@"select * from %@ limit 1",@"update_state"]]; + + if([result next]) { + proccessResult(); + + [db executeUpdate:@"delete from update_state where 1=1"]; + + [self saveUpdateState:state]; + } } - [db commit]; + [result close]; @@ -389,39 +576,12 @@ -(TGUpdateState *)updateState { -(void)saveUpdateState:(TGUpdateState *)state { [queue inDatabase:^(FMDatabase *db) { - [db executeUpdate:@"delete from update_state where 1=1"]; - - [db executeUpdate:@"insert into update_state (pts, qts, date, seq,pts_count) values (?,?,?,?,?)",@(state.pts),@(state.qts),@(state.date),@(state.seq),@(state.pts_count)]; + [db executeUpdate:[NSString stringWithFormat:@"insert or replace into %@ (n_id, pts, qts, date, seq,pts_count) values (?,?,?,?,?,?)",tableUpdateState],@(1),@(state.pts),@(state.qts),@(state.date),@(state.seq),@(state.pts_count)]; }]; } -- (void)searchMessagesBySearchString:(NSString *)searchString offset:(int)offset completeHandler:(void (^)(NSInteger count, NSArray *messages))completeHandler { - - [queue inDatabase:^(FMDatabase *db) { - NSString *searchSql = [NSString stringWithFormat:@"SELECT serialized, message_text,flags FROM messages WHERE instr(message_text,'%@') > 0 order by date desc LIMIT 50 OFFSET %d",[searchString lowercaseString],offset]; - FMResultSet *results = [db executeQueryWithFormat:searchSql, nil]; - NSMutableArray *messages = [[NSMutableArray alloc] init]; - while ([results next]) { - TL_localMessage *msg = [TLClassStore deserialize:[[results resultDictionary] objectForKey:@"serialized"]]; - - if(msg.dstate == DeliveryStateNormal) { - msg.flags = -1; - msg.message = [results stringForColumn:@"message_text"]; - msg.flags = [results intForColumn:@"flags"]; - [messages addObject:msg]; - } - } - [results close]; - - if(completeHandler) { - dispatch_async(dispatch_get_main_queue(), ^{ - completeHandler(messages.count, messages); - }); - } - }]; -} - (void)findFileInfoByPathHash:(NSString *)pathHash completeHandler:(void (^)(BOOL result, id file))completeHandler { [queue inDatabase:^(FMDatabase *db) { @@ -472,69 +632,101 @@ - (void)deleteFileHash:(NSString *)pathHash { } --(void)loadMessages:(int)conversationId localMaxId:(int)localMaxId limit:(int)limit next:(BOOL)next maxDate:(int)maxDate filterMask:(int)mask completeHandler:(void (^)(NSArray *))completeHandler { +TL_localMessage *parseMessage(FMResultSet *result) { + @try { + + TL_localMessage *msg = [TLClassStore deserialize:[result dataForColumn:@"serialized"]]; + + if([msg isChannelMessage]) { + msg.flags = [result intForColumn:@"flags"]; + msg.invalidate = [result intForColumn:@"invalidate"]; + msg.pts = [result intForColumn:@"pts"]; + msg.views = [result intForColumn:@"views"]; + msg.viewed = [result intForColumn:@"is_viewed"]; + } else { + + msg.flags = [result intForColumn:@"flags"]; + msg.message = [result stringForColumn:@"message_text"]; + + + } + + if(![msg isKindOfClass:[TL_messageEmpty class]]) + return msg; + + } + @catch (NSException *exception) { + + } + + return nil; +} + + +-(TGHistoryResponse *)loadMessages:(int)conversationId min_id:(int)min_id max_id:(int)max_id minDate:(int)minDate maxDate:(int)maxDate limit:(int)limit next:(BOOL)next filterMask:(int)mask isChannel:(BOOL)isChannel { - __block NSMutableArray *messages = [[NSMutableArray alloc] init]; + __block NSMutableArray *messages = [[NSMutableArray alloc] init]; + __block TGMessageHole *hole; + NSMutableArray *groupHoles = [[NSMutableArray alloc] init]; [queue inDatabaseWithDealocing:^(FMDatabase *db) { - //718606 - int currentDate = maxDate; - - - if(localMaxId != 0 && currentDate == 0) { - currentDate = [db intForQuery:@"SELECT date FROM messages WHERE n_id=?",@(localMaxId)]; - + int localMaxDate = maxDate; + int localMinDate = minDate; + + + if(max_id != 0 && localMaxDate == 0) { + localMaxDate = [db intForQuery:[NSString stringWithFormat:@"SELECT date FROM %@ WHERE n_id=?",tableMessages],@(max_id)]; } + if(min_id != 0 && localMinDate == 0) { + localMinDate = [db intForQuery:[NSString stringWithFormat:@"SELECT date FROM %@ WHERE n_id=?",tableMessages],@(min_id)]; + } + + if(localMaxDate == 0) + localMaxDate = INT32_MAX; - if(currentDate == 0) - currentDate = [[MTNetwork instance] getTime]; - NSString *sql = [NSString stringWithFormat:@"select serialized,flags,message_text from messages where peer_id = %d and date %@ %d and destruct_time > %d and (filter_mask & %d > 0) order by date %@, n_id %@ limit %d",conversationId,next ? @"<=" : @">",currentDate,[[MTNetwork instance] getTime],mask, next ? @"DESC" : @"ASC",next ? @"DESC" : @"ASC",limit]; + NSString *sql = [NSString stringWithFormat:@"SELECT * FROM %@ WHERE peer_id = %d AND date >= %d AND date < %d %@ AND (filter_mask & %d > 0) ORDER BY date %@, n_id %@ LIMIT %d",isChannel ? tableChannelMessages : tableMessages,conversationId,localMinDate,localMaxDate,isChannel ? @"" : [NSString stringWithFormat: @"and destruct_time > %d",[[MTNetwork instance] getTime]],mask, next ? @"DESC" : @"ASC",next ? @"DESC" : @"ASC",limit]; + - [self explainQuery:sql]; FMResultSet *result = [db executeQueryWithFormat:sql,nil]; + NSMutableArray *ids = [[NSMutableArray alloc] init]; + while ([result next]) { + TL_localMessage *msg = parseMessage(result); + if(msg) { + [messages addObject:msg]; + [ids addObject:@(msg.n_id)]; + } - TL_localMessage *msg = [TLClassStore deserialize:[result dataForColumn:@"serialized"]]; - msg.flags = -1; - msg.message = [result stringForColumn:@"message_text"]; - msg.flags = [result intForColumn:@"flags"]; - [messages addObject:msg]; } [result close]; - //select serialized,flags,message_text from messages where destruct_time > 1432213513 and peer_id = 699140 and date <= 1432213513 and (filter_mask & 2 > 0) order by date DESC, n_id DESC limit 18; - - // (@"history"); - TL_localMessage *lastMessage = [messages lastObject]; if(lastMessage) { NSArray *selectedCount = [messages filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.date == %d",lastMessage.date]]; - int localCount = [db intForQuery:@"SELECT count(*) from messages where peer_id = ? and date = ?",@(lastMessage.peer_id),@(lastMessage.date)]; + int localCount = [db intForQuery:[NSString stringWithFormat:@"SELECT count(*) from %@ where peer_id = ? and date = ?",isChannel ? tableChannelMessages : tableMessages],@(lastMessage.peer_id),@(lastMessage.date)]; if(selectedCount.count < localCount) { - NSString *sql = [NSString stringWithFormat:@"select serialized,flags,message_text from messages where date = %d and n_id != %d and peer_id = %d order by n_id desc",lastMessage.date,lastMessage.n_id,lastMessage.peer_id]; + NSString *sql = [NSString stringWithFormat:@"select * from %@ where date = %d and n_id NOT IN (%@) and peer_id = %d order by n_id desc",isChannel ? tableChannelMessages : tableMessages,lastMessage.date,[ids componentsJoinedByString:@","],lastMessage.peer_id]; FMResultSet *result = [db executeQueryWithFormat:sql,nil]; while ([result next]) { - TL_localMessage *msg = [TLClassStore deserialize:[result dataForColumn:@"serialized"]]; - msg.flags = -1; - msg.message = [result stringForColumn:@"message_text"]; - msg.flags = [result intForColumn:@"flags"]; - [messages addObject:msg]; + TL_localMessage *msg = parseMessage(result); + if(msg) + [messages addObject:msg]; } [result close]; @@ -542,49 +734,224 @@ -(void)loadMessages:(int)conversationId localMaxId:(int)localMaxId limit:(int)li } + int max = max_id; + int min = min_id; + + if(messages.count > 0) + { + TL_localMessage *first = next ? [messages firstObject] : [messages lastObject]; + TL_localMessage *last = !next ? [messages firstObject] : [messages lastObject]; + + max = first.n_id; + min = last.n_id; + } + + NSMutableArray *holes = [NSMutableArray array]; + + NSString *holeSql = [NSString stringWithFormat:@"select * from %@ where peer_id = %@ and max_id > %@ and min_id < %@ and (type & 2 = 2) order by date asc",tableMessageHoles,@(conversationId),@(next ? min : min_id),@(next ? max_id : max)]; + + + result = [db executeQuery:holeSql]; + + while ([result next]) { + TGMessageHole *hole = [[TGMessageHole alloc] initWithUniqueId:[result intForColumn:@"unique_id"] peer_id:[result intForColumn:@"peer_id"] min_id:[result intForColumn:@"min_id"] max_id:[result intForColumn:@"max_id"] date:[result intForColumn:@"date"] count:[result intForColumn:@"count"]]; + + [holes addObject:hole]; + } + + [result close]; + + + + if(!next) + hole = [holes firstObject]; + else + hole = [holes lastObject]; + + + + + if(mask & HistoryFilterImportantChannelMessage) { + + result = [db executeQuery:[NSString stringWithFormat:@"select * from %@ where peer_id = ? and ((min_id <= ?) and (max_id > ?)) and (type & 4 = 4) order by date asc",tableMessageHoles],@(conversationId),@(max),@(min)]; + + while ([result next]) { + TGMessageHole *gh = [[TGMessageGroupHole alloc] initWithUniqueId:[result intForColumn:@"unique_id"] peer_id:[result intForColumn:@"peer_id"] min_id:[result intForColumn:@"min_id"] max_id:[result intForColumn:@"max_id"] date:[result intForColumn:@"date"] count:[result intForColumn:@"count"]]; + + if(hole && (hole.max_id <= gh.max_id && hole.min_id >= gh.min_id)) { + hole = nil; + } + [groupHoles addObject:gh]; + + + } + + [result close]; + } + + + + if(hole) { + + NSPredicate *predicate; + + if(next) + predicate = [NSPredicate predicateWithFormat:@"self.n_id >= %d",hole.max_id]; + else + predicate = [NSPredicate predicateWithFormat:@"self.n_id <= %d",hole.min_id]; + + messages = [[messages filteredArrayUsingPredicate:predicate] mutableCopy]; + + } + + + [groupHoles enumerateObjectsUsingBlock:^(TGMessageGroupHole *hole, NSUInteger idx, BOOL *stop) { + + TL_localMessageService *msg = [TL_localMessageService createWithHole:hole]; + + [messages addObject:msg]; + }]; + + }]; + NSArray *supportList = [messages filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.reply_to_msg_id != 0"]]; NSMutableArray *supportIds = [[NSMutableArray alloc] init]; [supportList enumerateObjectsUsingBlock:^(TL_localMessage *obj, NSUInteger idx, BOOL *stop) { - [supportIds addObject:@([obj reply_to_msg_id])]; + [supportIds addObject:@(isChannel ? channelMsgId([obj reply_to_msg_id], obj.peer_id) :obj.reply_to_msg_id)]; }]; NSArray *support = [self selectSupportMessages:supportIds]; - [[MessagesManager sharedManager] addSupportMessages:support]; + [MessagesManager addSupportMessages:support]; - if(completeHandler) - completeHandler(messages); + return [[TGHistoryResponse alloc] initWithResult:[messages copy] hole:hole groupHoles:nil]; } + +-(void)invalidateChannelMessagesWithPts:(int)pts { + [queue inDatabase:^(FMDatabase *db) { + + [db executeUpdate:[NSString stringWithFormat:@"update %@ set invalidate = 1 where pts <= ?",tableChannelMessages],@(pts)]; + + }]; +} + + +-(void)validateChannelMessages:(NSArray *)messages { + [queue inDatabase:^(FMDatabase *db) { + + NSString *sql = [NSString stringWithFormat:@"update %@ set invalidate = 0 where n_id IN (%@)",tableChannelMessages,[messages componentsJoinedByString:@","]]; + + [db executeUpdateWithFormat:sql,nil]; + + }]; +} + +-(void)updateMessageViews:(int)views channelMsgId:(long)channelMsgId { + [queue inDatabase:^(FMDatabase *db){ + [db executeUpdate:[NSString stringWithFormat:@"update %@ set views = ? where n_id = ?",tableChannelMessages],@(views),@(channelMsgId)]; + }]; +} + + +-(void)markChannelMessagesAsRead:(int)channel_id max_id:(int)max_id callback:(void (^)(int unread_count))callback { + + dispatch_queue_t dqueue = dispatch_get_current_queue(); + + [queue inDatabase:^(FMDatabase *db) { + + int unread_count = [db intForQuery:[NSString stringWithFormat:@"select unread_count from %@ where peer_id = %d",tableModernDialogs,-channel_id]]; + + int current_max_read = [db intForQuery:[NSString stringWithFormat:@"select read_inbox_max_id from %@ where peer_id = %d",tableModernDialogs,-channel_id]]; + + unread_count = MAX(0, unread_count - (max_id - current_max_read)); + + + [db executeUpdate:[NSString stringWithFormat:@"update %@ set read_inbox_max_id = %d, unread_count = %d where peer_id = %d",tableModernDialogs,max_id,unread_count,-channel_id]]; + + if(callback != nil) { + dispatch_async(dqueue, ^{ + callback(unread_count); + }); + } + + }]; +} + +-(TL_localMessage *)lastImportantMessageAroundMinId:(long)channelMsgId; +{ + return [self lastMessageAroundMinId:channelMsgId important:YES isTop:NO]; +} + +-(TL_localMessage *)lastMessageAroundMinId:(long)msgId important:(BOOL)important isTop:(BOOL)isTop { + + __block TL_localMessage *msg; + + [queue inDatabaseWithDealocing:^(FMDatabase *db) { + + int peer_id = 0; + + NSData *data = [[NSData alloc] initWithBytes:&msgId length:8]; + + [data getBytes:&peer_id range:NSMakeRange(4, 4)]; + + + + FMResultSet *result = [db executeQuery:[NSString stringWithFormat:@"select flags,serialized,views,pts from %@ where n_id %@ ? and n_id < ? and peer_id = ? and (filter_mask & ?) = ? order by n_id %@ limit 1",tableChannelMessages,!isTop ? @"<=" : @">=",isTop ? @"asc" : @"desc"],@(msgId),@(channelMsgId(TGMINFAKEID,peer_id)),@(peer_id),@(important ? HistoryFilterImportantChannelMessage : HistoryFilterChannelMessage),@(important ? HistoryFilterImportantChannelMessage : HistoryFilterChannelMessage)]; + + if([result next]) { + msg = [TLClassStore deserialize:[result dataForColumn:@"serialized"]]; + msg.flags = [result intForColumn:@"flags"]; + msg.views = [result intForColumn:@"views"]; + msg.pts = [result intForColumn:@"pts"]; + } + + [result close]; + + }]; + + return msg; +} + + -(TL_localMessage *)messageById:(int)msgId { + return [self messageById:msgId inChannel:0]; +} + +-(TL_localMessage *)messageById:(int)msgId inChannel:(int)channel_id { + __block TL_localMessage *message; [queue inDatabaseWithDealocing:^(FMDatabase *db) { - NSString *sql = [NSString stringWithFormat:@"select serialized,flags,message_text from messages where n_id = %d",msgId]; + NSString *sql = [NSString stringWithFormat:@"select * from %@ where n_id = %d",tableMessages,msgId]; + + if(channel_id != 0) + { + sql = [NSString stringWithFormat:@"select * from %@ where n_id = %ld",tableChannelMessages,channelMsgId(msgId, channel_id)]; + } + FMResultSet *result = [db executeQueryWithFormat:sql,nil]; + while ([result next]) { - message = [TLClassStore deserialize:[result dataForColumn:@"serialized"]]; - message.flags = -1; - message.message = [result stringForColumn:@"message_text"]; - message.flags = [result intForColumn:@"flags"]; + message = parseMessage(result); } [result close]; - + }]; return message; - + } -(void)messages:(void (^)(NSArray *))completeHandler forIds:(NSArray *)ids random:(BOOL)random queue:(ASQueue *)q { @@ -598,15 +965,15 @@ -(void)messages:(void (^)(NSArray *))completeHandler forIds:(NSArray *)ids rando void (^block)(FMDatabase *db) = ^(FMDatabase *db) { NSString *strIds = [ids componentsJoinedByString:@","]; - NSString *sql = [NSString stringWithFormat:@"select serialized,flags,message_text from messages where %@ in (%@) order by date DESC",random ? @"random_id" : @"n_id",strIds]; + NSString *sql = [NSString stringWithFormat:@"select serialized,flags,message_text from %@ where %@ in (%@) order by date DESC",tableMessages,random ? @"random_id" : @"n_id",strIds]; FMResultSet *result = [db executeQueryWithFormat:sql,nil]; __block NSMutableArray *messages = [[NSMutableArray alloc] init]; while ([result next]) { TLMessage *msg = [TLClassStore deserialize:[result dataForColumn:@"serialized"]]; msg.flags = -1; - msg.message = [result stringForColumn:@"message_text"]; msg.flags = [result intForColumn:@"flags"]; + msg.message = [result stringForColumn:@"message_text"]; [messages addObject:msg]; } [result close]; @@ -665,54 +1032,69 @@ -(NSArray *)issetMessages:(NSArray *)ids { return isset; } --(void)lastMessageForPeer:(TLPeer *)peer completeHandler:(void (^)(TL_localMessage *message))completeHandler { +-(void)lastMessageWithConversation:(TL_conversation *)conversation completeHandler:(void (^)(TL_localMessage *message, int importantMessage))completeHandler { - int peer_id = [peer peer_id]; [queue inDatabase:^(FMDatabase *db) { TL_localMessage *message; - FMResultSet *result = [db executeQuery:@"select message_text,serialized,flags from messages where peer_id = ? ORDER BY date DESC LIMIT 1",@(peer_id)]; + int importantMessage = 0; - if([result next]) { - message = [TLClassStore deserialize:[result dataForColumn:@"serialized"]]; - message.flags = -1; - message.message = [result stringForColumn:@"message_text"]; - message.flags = [result intForColumn:@"flags"]; + + if([conversation.peer isKindOfClass:[TL_peerChannel class]]) { + NSString *topMessage = [NSString stringWithFormat:@"select serialized,flags,pts,views,invalidate from %@ where peer_id = %d and (filter_mask & %d) > 0 ORDER BY date DESC, n_id desc LIMIT 1",tableChannelMessages,conversation.peer_id,conversation.chat.isMegagroup ? HistoryFilterChannelMessage : HistoryFilterImportantChannelMessage]; + + FMResultSet *result; + + void (^fillMessage)(TL_localMessage *msg) = ^(TL_localMessage *msg) { + + msg.flags = [result intForColumn:@"flags"]; + msg.pts = [result intForColumn:@"pts"]; + msg.views = [result intForColumn:@"views"]; + msg.invalidate = [result intForColumn:@"invalidate"]; + }; + + result = [db executeQueryWithFormat:topMessage,nil]; + + if([result next]) { + message = [TLClassStore deserialize:[result dataForColumn:@"serialized"]]; + fillMessage(message); + } + + [result close]; + + importantMessage = message.n_id; + + + } else { + + NSString *sql = [NSString stringWithFormat:@"select serialized,flags,message_text from %@ where peer_id = %d ORDER BY n_id DESC LIMIT 1",tableMessages,conversation.peer_id]; + + FMResultSet *result = [db executeQueryWithFormat:sql,nil]; + + + if([result next]) { + message = [TLClassStore deserialize:[result dataForColumn:@"serialized"]]; + message.flags = [result intForColumn:@"flags"]; + message.message = [result stringForColumn:@"message_text"]; + } + + + [result close]; } - [result close]; + + dispatch_async(dispatch_get_main_queue(), ^{ - if(completeHandler != nil) completeHandler(message); + if(completeHandler != nil) completeHandler(message,importantMessage); }); }]; } --(TL_localMessage *)lastMessage:(int)peer_id from_id:(int)from_id { - - __block TL_localMessage *msg; - - [queue inDatabaseWithDealocing:^(FMDatabase *db) { - - FMResultSet *result = [db executeQuery:@"select message_text,serialized,flags from messages where peer_id = ? and from_id = ? ORDER BY date DESC LIMIT 1",@(peer_id),@(from_id)]; - - - if([result next]) { - msg = [TLClassStore deserialize:[result dataForColumn:@"serialized"]]; - msg.flags = -1; - msg.message = [result stringForColumn:@"message_text"]; - msg.flags = [result intForColumn:@"flags"]; - } - - [result close]; - - }]; - - return msg; -} + -(void)updateTopMessage:(TL_conversation *)dialog completeHandler:(void (^)(BOOL result))completeHandler { @@ -732,27 +1114,69 @@ -(void)updateTopMessage:(TL_conversation *)dialog completeHandler:(void (^)(BOOL --(void)updateMessages:(NSArray *)messages { + + +-(void)messagesWithWebpage:(TLMessageMedia *)mediaWebpage callback:(void (^)(NSDictionary *))callback { + + dispatch_queue_t dqueue = dispatch_get_current_queue(); + [queue inDatabase:^(FMDatabase *db) { - [messages enumerateObjectsUsingBlock:^(TL_localMessage *obj, NSUInteger idx, BOOL *stop) { + NSMutableDictionary *peers = [NSMutableDictionary dictionary]; + + + + + void (^proccessResult)(NSString *tableName, FMResultSet *result) = ^(NSString *tableName, FMResultSet *result){ - int destructTime = INT32_MAX; + TL_localMessage *msg = [TLClassStore deserialize:[result dataForColumn:@"serialized"]]; - if([obj isKindOfClass:[TL_destructMessage class]]) - destructTime = [(TL_destructMessage *)obj destruction_time]; + msg.media = mediaWebpage; - [db executeUpdate:@"update messages set message_text = ?, flags = ?, from_id = ?, peer_id = ?, date = ?, serialized = ?, random_id = ?, destruct_time = ?, filter_mask = ?, fake_id = ?, dstate = ? WHERE n_id = ?",obj.message,@(obj.flags),@(obj.from_id),@(obj.peer_id),@(obj.date),[TLClassStore serialize:obj],@(obj.randomId), @(destructTime), @(obj.filterType),@(obj.fakeId),@(obj.dstate),@(obj.n_id),nil]; + long random_id = [result longForColumn:@"random_id"]; - }]; - + [db executeUpdate:[NSString stringWithFormat:@"update %@ set serialized = ? where random_id = ?",tableName],[TLClassStore serialize:msg],@(random_id)]; + + int peer_id = msg.peer_id; + int n_id = msg.n_id; + + NSMutableArray *msgs = peers[@(peer_id)]; + + if(!msgs) { + msgs = peers[@(peer_id)] = [NSMutableArray array]; + } + + [msgs addObject:@(n_id)]; + }; + + + FMResultSet *result = [db executeQuery:[NSString stringWithFormat:@"select serialized,random_id from %@ where webpage_id = ?",tableMessages],@(mediaWebpage.webpage.n_id)]; + + while ([result next]) + proccessResult(tableMessages,result); + + [result close]; + + result = [db executeQuery:[NSString stringWithFormat:@"select serialized,random_id from %@ where webpage_id = ?",tableChannelMessages],@(mediaWebpage.webpage.n_id)]; + + while ([result next]) + proccessResult(tableChannelMessages,result); + + + + [result close]; + + if(callback != nil) + { + dispatch_async(dqueue, ^{ + callback([peers copy]); + }); + } + }]; } --(void)insertMessage:(TLMessage *)message completeHandler:(dispatch_block_t)completeHandler { - [self insertMessages:@[message] completeHandler:completeHandler]; -} -(void)markMessagesAsRead:(NSArray *)messages useRandomIds:(NSArray *)randomIds { @@ -776,16 +1200,17 @@ -(void)markMessagesAsRead:(NSArray *)messages useRandomIds:(NSArray *)randomIds }]; } --(void)markAllInDialog:(TL_conversation *)dialog { +-(void)markAllInConversation:(int)peer_id { [queue inDatabase:^(FMDatabase *db) { - //[db beginTransaction]; - [db executeUpdate:@"update messages set flags= flags & ~1 where peer_id = ?",[NSNumber numberWithInt:dialog.peer.peer_id]]; - //[db commit]; + [db beginTransaction]; + [db executeUpdate:@"update messages set flags= flags & ~1 where peer_id = ?",@(peer_id)]; + [db executeUpdate:[NSString stringWithFormat:@"update %@ set read_inbox_max_id = (select top_message from %@ where peer_id = ?) where peer_id = ?",tableModernDialogs,tableModernDialogs],@(peer_id),@(peer_id)]; + [db commit]; }]; } --(void)markAllInConversation:(TL_conversation *)conversation max_id:(int)max_id completeHandler:(void (^)(NSArray * ids))completeHandler { +-(void)markAllInConversation:(int)peer_id max_id:(int)max_id out:(BOOL)n_out completeHandler:(void (^)(NSArray * ids))completeHandler { NSMutableArray *ids = [[NSMutableArray alloc] init]; @@ -793,8 +1218,25 @@ -(void)markAllInConversation:(TL_conversation *)conversation max_id:(int)max_id [queue inDatabase:^(FMDatabase *db) { + [db beginTransaction]; + + int flags = n_out ? TGOUTMESSAGE | TGUNREADMESSAGE : TGUNREADMESSAGE; + + FMResultSet *result; + + if(!n_out) { + int read_inbox_max_id = [db intForQuery:[NSString stringWithFormat:@"select read_inbox_max_id from %@ where peer_id = ?",tableModernDialogs],@(peer_id)]; + + result = [db executeQuery:@"select n_id from messages where ((n_id <= ? and n_id >= ?) OR dstate=?) and peer_id = ? and (flags & ?) = ? and (flags & ?) = 0",@(max_id),@(read_inbox_max_id),@(DeliveryStatePending),@(peer_id),@(flags),@(flags),@(TGOUTMESSAGE)]; + + + [db executeUpdate:[NSString stringWithFormat:@"update %@ set read_inbox_max_id = ? where peer_id = ?",tableModernDialogs],@(max_id),@(peer_id)]; + } else { + result = [db executeQuery:[NSString stringWithFormat:@"select n_id from %@ where (n_id <= ? OR dstate= ?) and peer_id = ? and (flags & ?) = ?",tableMessages],@(max_id),@(DeliveryStatePending),@(peer_id),@(flags),@(flags)]; + } + + - FMResultSet *result = [db executeQuery:@"select n_id from messages where n_id <= ? and peer_id = ? and flags & 1 = 1",@(max_id),@(conversation.peer.peer_id)]; while ([result next]) { @@ -811,7 +1253,8 @@ -(void)markAllInConversation:(TL_conversation *)conversation max_id:(int)max_id [db executeUpdateWithFormat:sql,nil]; } - + + [db commit]; dispatch_async(q,^{ completeHandler(ids); @@ -830,69 +1273,166 @@ -(void)readMessagesContent:(NSArray *)messages { } --(void)deleteMessagesWithRandomIds:(NSArray *)messages completeHandler:(void (^)(BOOL result))completeHandler; { +-(void)deleteMessagesWithRandomIds:(NSArray *)messages isChannelMessages:(BOOL)isChannelMessages completeHandler:(void (^)(NSArray *peer_update_data))completeHandler { [queue inDatabase:^(FMDatabase *db) { + NSString *mark = [messages componentsJoinedByString:@","]; + NSMutableArray *peer_update_data = [[NSMutableArray alloc] init]; - NSString *sql = [NSString stringWithFormat:@"select n_id from messages where random_id IN (%@)",mark]; - FMResultSet *result = [db executeQueryWithFormat:sql,nil]; + NSString *sql = [NSString stringWithFormat:@"select n_id,peer_id from %@ where random_id IN (%@)",isChannelMessages ? tableChannelMessages: tableMessages,mark]; - NSMutableArray *ids = [[NSMutableArray alloc] init]; + FMResultSet *result = [db executeQueryWithFormat:sql,nil]; + + while ([result next]) { - [ids addObject:@([result intForColumn:@"n_id"])]; + [peer_update_data addObject:@{KEY_PEER_ID:@([result intForColumn:@"peer_id"]),KEY_MESSAGE_ID:@([result intForColumn:@"n_id"])}]; } [result close]; - - NSString *sids = [ids componentsJoinedByString:@","]; - - - sql = [NSString stringWithFormat:@"delete from messages WHERE n_id IN (%@)",sids]; + + + sql = [NSString stringWithFormat:@"delete from %@ WHERE random_id IN (%@)",tableMessages,mark]; [db executeUpdateWithFormat:sql,nil]; - sql = [NSString stringWithFormat:@"delete from sharedmedia WHERE message_id IN (%@)",sids]; + + sql = [NSString stringWithFormat:@"delete from %@ WHERE random_id IN (%@)",tableChannelMessages,mark]; [db executeUpdateWithFormat:sql,nil]; dispatch_async(dispatch_get_main_queue(), ^{ - if(completeHandler) completeHandler(YES); + if(completeHandler) completeHandler(peer_update_data); }); }]; } --(void)deleteMessages:(NSArray *)messages completeHandler:(void (^)(BOOL result))completeHandler { + +-(void)deleteMessages:(NSArray *)messages completeHandler:(void (^)(NSArray *peer_updates))completeHandler { + + dispatch_queue_t dqueue = dispatch_get_current_queue(); + + [queue inDatabase:^(FMDatabase *db) { //[db beginTransaction]; NSString *mark = [messages componentsJoinedByString:@","]; - NSString *sql = [NSString stringWithFormat:@"delete from messages WHERE n_id IN (%@)",mark]; - [db executeUpdateWithFormat:sql,nil]; + NSMutableArray *peer_updates = [[NSMutableArray alloc] init]; + + + NSString *sql = [NSString stringWithFormat:@"SELECT n_id,peer_id FROM messages WHERE n_id IN (%@)",mark]; - sql = [NSString stringWithFormat:@"delete from sharedmedia WHERE message_id IN (%@)",mark]; + FMResultSet *result = [db executeQueryWithFormat:sql,nil]; + + while ([result next]) { + + [peer_updates addObject:@{KEY_PEER_ID:@([result intForColumn:@"peer_id"]),KEY_MESSAGE_ID:@([result intForColumn:@"n_id"])}]; + } + + [result close]; + + sql = [NSString stringWithFormat:@"delete from messages WHERE n_id IN (%@)",mark]; [db executeUpdateWithFormat:sql,nil]; + //[db commit]; - dispatch_async(dispatch_get_main_queue(), ^{ - if(completeHandler) completeHandler(YES); + dispatch_async(dqueue, ^{ + if(completeHandler) completeHandler(peer_updates); }); }]; } +-(void)deleteChannelMessages:(NSArray *)messages completeHandler:(void (^)(NSArray *peer_updates, NSDictionary *readCount))completeHandler { + + dispatch_queue_t dqueue = dispatch_get_current_queue(); + + + [queue inDatabase:^(FMDatabase *db) { + NSString *mark = [messages componentsJoinedByString:@","]; + + NSMutableArray *peer_updates = [[NSMutableArray alloc] init]; + + if(messages.count > 0) { + NSString *sql = [NSString stringWithFormat:@"SELECT n_id,random_id FROM %@ WHERE n_id IN (%@)",tableChannelMessages,mark]; + + + FMResultSet *result = [db executeQueryWithFormat:sql,nil]; + + NSMutableDictionary *unreadCount = [NSMutableDictionary dictionary]; + + NSMutableArray *randomIds = [NSMutableArray array]; + + while ([result next]) { + + [randomIds addObject:@([result longForColumn:@"random_id"])]; + + long n_id = [result longForColumn:@"n_id"]; + + NSData *nData = [[NSData alloc] initWithBytes:&n_id length:8]; + + int msgId; + int peerId; + + + [nData getBytes:&msgId range:NSMakeRange(0, 4)]; + [nData getBytes:&peerId range:NSMakeRange(4, 4)]; + + int read_max_id = [db intForQuery:[NSString stringWithFormat:@"select read_inbox_max_id from %@ where peer_id = ?",tableModernDialogs],@(peerId)]; + + if(msgId > read_max_id) { + unreadCount[@(peerId)] = @([unreadCount[@(peerId)] intValue] + 1); + } + + + [peer_updates addObject:@{KEY_MESSAGE_ID:@(msgId),KEY_PEER_ID:@(peerId)}]; + } + + + [result close]; + + + [unreadCount enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { + + [db executeUpdate:[NSString stringWithFormat:@"update %@ set unread_count = unread_count - ? where peer_id = ?",tableModernDialogs],key,obj]; + }]; + + + sql = [NSString stringWithFormat:@"delete from %@ WHERE n_id IN (%@)",tableChannelMessages,mark]; + + [db executeUpdateWithFormat:sql,nil]; + + + dispatch_async(dqueue, ^{ + if(completeHandler) completeHandler(peer_updates,unreadCount); + }); + + } + + }]; +} + -(void)deleteMessagesInDialog:(TL_conversation *)dialog completeHandler:(dispatch_block_t)completeHandler { [queue inDatabase:^(FMDatabase *db) { [db beginTransaction]; - NSString *sql = [NSString stringWithFormat:@"delete from messages WHERE peer_id = %d",dialog.peer.peer_id]; - [db executeUpdateWithFormat:sql,nil]; - sql = [NSString stringWithFormat:@"delete from sharedmedia WHERE peer_id =%d",dialog.peer.peer_id]; + + NSString *sql = [NSString stringWithFormat:@"delete from %@ WHERE peer_id = %d",tableMessages,dialog.peer.peer_id]; [db executeUpdateWithFormat:sql,nil]; + if(dialog.type == DialogTypeChannel) { + sql = [NSString stringWithFormat:@"delete from %@ WHERE peer_id = %d",tableChannelMessages,dialog.peer.peer_id]; + [db executeUpdateWithFormat:sql,nil]; + + [db executeUpdate:[NSString stringWithFormat:@"delete from %@ where peer_id = ?",tableMessageHoles],@(dialog.peer_id)]; + } + + + + if(dialog.type == DialogTypeSecretChat) [db executeUpdate:@"delete from self_destruction where chat_id = ?",[NSNumber numberWithInt:dialog.peer.chat_id]]; @@ -905,16 +1445,30 @@ -(void)deleteMessagesInDialog:(TL_conversation *)dialog completeHandler:(dispatc }]; } +-(void)updateChannelMessageViews:(long)channelMsgId views:(int)views { + [queue inDatabase:^(FMDatabase *db) { + + [db executeUpdate:[NSString stringWithFormat:@"update %@ set views = ? where n_id = ?",tableChannelMessages],@(views),@(channelMsgId)]; + + }]; +} + + -(void)insertMessages:(NSArray *)messages completeHandler:(dispatch_block_t)completeHandler { + dispatch_queue_t dqueue = dispatch_get_current_queue(); + + + [queue inDatabase:^(FMDatabase *db) { - //[db beginTransaction]; NSArray *msgs = [messages copy]; + test_start_group(@"insert_test"); + for (TL_localMessage *message in msgs) { TL_localMessage *m = [message copy]; - m.message = @""; + m.message = nil; int destruct_time = INT32_MAX; if([message isKindOfClass:[TL_destructMessage class]]) { @@ -926,10 +1480,24 @@ -(void)insertMessages:(NSArray *)messages completeHandler:(dispatch_block_t)comp int mask = message.filterType; - void (^insertBlock)(NSString *tableName) = ^(NSString *tableName) { + dispatch_block_t clearWithFakeId = ^{ + if(message.n_id < TGMINFAKEID) { + + NSString *sql = [NSString stringWithFormat:@"delete from %@ WHERE fake_id = %d",tableMessages,message.fakeId]; + [db executeUpdateWithFormat:sql,nil]; + + + sql = [NSString stringWithFormat:@"delete from %@ WHERE fake_id = %d",tableChannelMessages,message.fakeId]; + [db executeUpdateWithFormat:sql,nil]; + + } + }; + + void (^insertBlock)(NSString *tableName) = ^(NSString *tableName) { + - [db executeUpdate:[NSString stringWithFormat:@"insert or replace into %@ (n_id,date,from_id,flags,peer_id,serialized, destruct_time, message_text, filter_mask,fake_id,dstate,random_id) values (?,?,?,?,?,?,?,?,?,?,?,?)",tableName], + [db executeUpdate:[NSString stringWithFormat:@"insert or replace into %@ (n_id,date,from_id,flags,peer_id,serialized, destruct_time, filter_mask,fake_id,dstate,random_id,webpage_id,message_text) values (?,?,?,?,?,?,?,?,?,?,?,?,?)",tableName], @(message.n_id), @(message.date), @(message.from_id), @@ -937,73 +1505,82 @@ -(void)insertMessages:(NSArray *)messages completeHandler:(dispatch_block_t)comp @(peer_id), [TLClassStore serialize:m], @(destruct_time), - message.message, @(mask), @(message.fakeId), @(message.dstate), - @(message.randomId) + @(message.randomId), + @(message.media.webpage.n_id), + message.message ]; - + }; + int globalPts = [db intForQuery:[NSString stringWithFormat:@"select pts from %@ where peer_id = ?",tableModernDialogs],@(message.peer_id)]; + - if(message.n_id < TGMINFAKEID) { + dispatch_block_t insertChannelMessageBlock = ^ { - NSString *sql = [NSString stringWithFormat:@"delete from messages WHERE n_id = %d",message.fakeId]; - [db executeUpdateWithFormat:sql,nil]; + int isset = [db intForQuery:[NSString stringWithFormat:@"select count(*) from %@ where n_id = ?",tableChannelMessages],@(message.channelMsgId)]; - } - - insertBlock(@"messages"); - - if([message.media isKindOfClass:[TL_messageMediaEmpty class]]) { - // [Telegram saveHashTags:message.message peer_id:message.peer_id]; + int pts = MAX(message.n_id,globalPts); - } + + message.pts = pts; + + if(isset == 0) { + [db executeUpdate:[NSString stringWithFormat:@"insert into %@ (n_id,date,from_id,flags,peer_id,serialized, filter_mask,fake_id,dstate,random_id,pts,views,webpage_id) values (?,?,?,?,?,?,?,?,?,?,?,?,?)",tableChannelMessages], + @(message.channelMsgId), + @(message.date), + @(message.from_id), + @(message.flags), + @(peer_id), + [TLClassStore serialize:message], + @(mask), + @(message.fakeId), + @(message.dstate), + @(message.randomId), + @(pts), + @(message.views), + @(message.media.webpage.n_id) + ]; + + + } else { + [db executeUpdate:[NSString stringWithFormat:@"update %@ set flags = ?, from_id = ?, peer_id = ?, date = ?, serialized = ?, random_id = ?, filter_mask = ?, fake_id = ?, dstate = ?, pts = ?, views = ?, webpage_id = ? WHERE n_id = ?",tableChannelMessages],@(message.flags),@(message.from_id),@(message.peer_id),@(message.date),[TLClassStore serialize:message],@(message.randomId), @(message.filterType),@(message.fakeId),@(message.dstate),@(pts), + @(message.views),@(message.media.webpage.n_id),@(message.channelMsgId),nil]; + + } + + + + }; + clearWithFakeId(); + if(![message isKindOfClass:[TL_messageEmpty class]]) { + if(![message.to_id isKindOfClass:[TL_peerChannel class]]) + insertBlock(@"messages"); + else + insertChannelMessageBlock(); + } } - if(completeHandler) - dispatch_async(dispatch_get_main_queue(), ^{ - completeHandler(); - }); + test_step_group(@"insert_test"); + test_release_group(@"insert_test"); + + if(completeHandler != nil) { + dispatch_async(dqueue, completeHandler); + } }]; -} - +} --(void)executeSaveConversation:(TL_conversation *)dialog db:(FMDatabase *)db { - - if(!dialog.isAddToList) { - return; - } - - - - [db executeUpdate:@"insert or replace into dialogs (peer_id,top_message,last_message_date,unread_count,type,notify_settings,last_marked_message,sync_message_id,last_marked_date,last_real_message_date) values (?,?,?,?,?,?,?,?,?,?)", - @([dialog.peer peer_id]), - @(dialog.top_message), - @(dialog.last_message_date), - @(dialog.unread_count), - @(dialog.type), - [TLClassStore serialize:dialog.notify_settings], - @(dialog.last_marked_message), - @(dialog.sync_message_id), - @(dialog.last_marked_date), - @(dialog.last_real_message_date) - ]; +-(void)insertMessages:(NSArray *)messages { + [self insertMessages:messages completeHandler:nil]; } -- (void)updateDialog:(TL_conversation *)dialog { - - - [queue inDatabase:^(FMDatabase *db) { - [self executeSaveConversation:dialog db:db]; - }]; -} -(void)loadChats:(void (^)(NSArray *chats))completeHandler { @@ -1011,14 +1588,19 @@ -(void)loadChats:(void (^)(NSArray *chats))completeHandler { NSMutableArray *chats = [[NSMutableArray alloc] init]; FMResultSet *secretResult = [db executeQuery:@"select * from encrypted_chats"]; while ([secretResult next]) { - [chats addObject:[TLClassStore deserialize:[secretResult dataForColumn:@"serialized"]]]; + + id chat = [TLClassStore deserialize:[secretResult dataForColumn:@"serialized"]]; + if(chat) + [chats addObject:chat]; } [secretResult close]; FMResultSet *chatResult = [db executeQuery:@"select * from chats"]; while ([chatResult next]) { - [chats addObject:[TLClassStore deserialize:[chatResult dataForColumn:@"serialized"]]]; + id obj = [TLClassStore deserialize:[chatResult dataForColumn:@"serialized"]]; + if(obj) + [chats addObject:obj]; } [chatResult close]; @@ -1028,126 +1610,172 @@ -(void)loadChats:(void (^)(NSArray *chats))completeHandler { }]; } -- (void)parseDialogs:(FMResultSet *)result dialogs:(NSMutableArray *)dialogs messages:(NSMutableArray *)messages { +-(TLPeer *)peerWithType:(DialogType)type peer_id:(int)peer_id { + + TLPeer *peer; + + if(type == DialogTypeSecretChat) { + peer = [TL_peerSecret createWithChat_id:peer_id]; + } else if(type == DialogTypeUser) { + peer = [TL_peerUser createWithUser_id:peer_id]; + } else if(type == DialogTypeChat) { + peer = [TL_peerChat createWithChat_id:-peer_id]; + } else if(type == DialogTypeBroadcast) { + peer = [TL_peerBroadcast createWithChat_id:peer_id]; + } else if(type == DialogTypeChannel) { + peer = [TL_peerChannel createWithChannel_id:-peer_id]; + } + + return peer; +} + + +- (NSArray *)parseDialogs:(FMResultSet *)result { + + NSMutableArray *dialogs = [NSMutableArray array]; + while ([result next]) { + TLPeer *peer = [self peerWithType:[result intForColumn:@"type"] peer_id:[result intForColumn:@"peer_id"]]; - TL_conversation *dialog = [[TL_conversation alloc] init]; - int type = [result intForColumn:@"type"]; - - if(type == DialogTypeSecretChat) { - dialog.peer = [TL_peerSecret createWithChat_id:[result intForColumn:@"peer_id"]]; - } else if(type == DialogTypeUser) { - dialog.peer = [TL_peerUser createWithUser_id:[result intForColumn:@"peer_id"]]; - } else if(type == DialogTypeChat) { - dialog.peer = [TL_peerChat createWithChat_id:-[result intForColumn:@"peer_id"]]; - } else if(type == DialogTypeBroadcast) { - dialog.peer = [TL_peerBroadcast createWithChat_id:[result intForColumn:@"peer_id"]]; - } - - - id notifyObject = [result dataForColumn:@"notify_settings"]; + TL_conversation *dialog = [TL_conversation createWithPeer:peer top_message:[result intForColumn:@"top_message"] unread_count:[result intForColumn:@"unread_count"] last_message_date:[result intForColumn:@"last_message_date"] notify_settings:[TL_peerNotifySettings createWithMute_until:[result intForColumn:@"mute_until"] sound:@"" show_previews:YES events_mask:0] last_marked_message:[result intForColumn:@"last_marked_message"] top_message_fake:0 last_marked_date:[result intForColumn:@"last_marked_date"] sync_message_id:0 read_inbox_max_id:[result intForColumn:@"read_inbox_max_id"] unread_important_count:[result intForColumn:@"unread_important_count"] lastMessage:nil pts:[result intForColumn:@"pts"] isInvisibleChannel:[result boolForColumn:@"is_invisible"] top_important_message:[result intForColumn:@"top_important_message"]]; - if(notifyObject != nil && ![notifyObject isKindOfClass:[NSNull class]]) { - dialog.notify_settings = [TLClassStore deserialize:notifyObject]; - } + [dialogs addObject:dialog]; + + } + + return dialogs; +} + +-(void)updateTopMessagesWithMessages:(NSDictionary *)topMessages topImportantMessages:(NSDictionary *)topImportantMessages { + + [queue inDatabase:^(FMDatabase *db) { - dialog.unread_count = [result intForColumn:@"unread_count"]; - dialog.top_message = [result intForColumn:@"top_message"]; - dialog.last_message_date = [result intForColumn:@"last_message_date"]; - dialog.last_marked_message = [result intForColumn:@"last_marked_message"]; - dialog.last_marked_date = [result intForColumn:@"last_marked_date"]; - dialog.sync_message_id = [result intForColumn:@"sync_message_id"]; - dialog.last_real_message_date = [result intForColumn:@"last_real_message_date"]; + [db beginTransaction]; - id serializedMessage =[[result resultDictionary] objectForKey:@"serialized_message"]; - TL_localMessage *message; - if(![serializedMessage isKindOfClass:[NSNull class]]) { - message = [TLClassStore deserialize:serializedMessage]; - message.flags = -1; - message.message = [result stringForColumn:@"message_text"]; - message.flags = [result intForColumn:@"flags"]; - if(message) - [messages addObject:message]; - } + [topMessages enumerateKeysAndObjectsUsingBlock:^(id key, TL_localMessage *obj, BOOL *stop) { + + [db executeUpdate:[NSString stringWithFormat:@"update %@ set top_message = ? where peer_id = ?",tableModernDialogs],@(obj.channelMsgId)]; + + }]; - dialog.lastMessage = message; + [topImportantMessages enumerateKeysAndObjectsUsingBlock:^(id key, TL_localMessage *obj, BOOL *stop) { + + [db executeUpdate:[NSString stringWithFormat:@"update %@ set top_important_message = ? where peer_id = ?",tableModernDialogs],@(obj.channelMsgId)]; + + }]; - [dialogs addObject:dialog]; - } -} - -- (void)dialogByPeer:(int)peer completeHandler:(void (^)(TLDialog *dialog, TLMessage *message))completeHandler { - [self searchDialogsByPeers:[NSArray arrayWithObject:@(peer)] needMessages:NO searchString:nil completeHandler:^(NSArray *dialogs, NSArray *messages, NSArray *searchMessages) { + [db commit]; - if(completeHandler) { - completeHandler(dialogs.count ? dialogs[0] : nil, messages.count ? messages[0] : nil); - } }]; + } -- (void)searchDialogsByPeers:(NSArray *)peers needMessages:(BOOL)needMessages searchString:(NSString *)searchString completeHandler:(void (^)(NSArray *dialogs, NSArray *messages, NSArray *searchMessages))completeHandler { + + +- (void)searchDialogsByPeers:(NSArray *)peers needMessages:(BOOL)needMessages searchString:(NSString *)searchString completeHandler:(void (^)(NSArray *dialogs))completeHandler { - NSMutableArray *dialogs = [[NSMutableArray alloc] init]; - NSMutableArray *messages = [[NSMutableArray alloc] init]; + __block NSArray *conversations; [queue inDatabaseWithDealocing:^(FMDatabase *db) { if(peers.count) { - FMResultSet *result = [db executeQuery:[NSString stringWithFormat:@"select messages.message_text,messages.from_id, dialogs.peer_id, dialogs.type,dialogs.last_message_date, messages.serialized serialized_message, dialogs.top_message,dialogs.sync_message_id,dialogs.last_marked_date,dialogs.unread_count unread_count, dialogs.notify_settings notify_settings, dialogs.last_marked_message last_marked_message,dialogs.last_real_message_date last_real_message_date, messages.flags from dialogs left join messages on dialogs.top_message = messages.n_id where dialogs.peer_id in (%@) ORDER BY dialogs.last_message_date DESC", [peers componentsJoinedByString:@","]]]; - - - [self parseDialogs:result dialogs:dialogs messages:messages]; + FMResultSet *result = [db executeQuery:[NSString stringWithFormat:@"select * from %@ where peer_id IN(%@) order by last_message_date DESC",tableModernDialogs, [peers componentsJoinedByString:@","]]]; + conversations = [self parseDialogs:result]; + [self fillLastMessagesWithConversations:conversations]; [result close]; } }]; if(completeHandler) { - // [[ASQueue mainQueue] dispatchOnQueue:^{ - completeHandler(dialogs, messages, nil); - // }]; + completeHandler(conversations); } } --(void)dialogsWithOffset:(int)offset limit:(int)limit completeHandler:(void (^)(NSArray *d, NSArray *m))completeHandler { +-(void)fillLastMessagesWithConversations:(NSArray *)list { [queue inDatabase:^(FMDatabase *db) { - NSMutableArray *dialogs = [[NSMutableArray alloc] init]; - NSMutableArray *messages = [[NSMutableArray alloc] init]; - + [list enumerateObjectsUsingBlock:^(TL_conversation *obj, NSUInteger idx, BOOL * _Nonnull stop) { + + NSString *sql = [NSString stringWithFormat:@"select * from %@ where peer_id = ? ORDER BY date DESC, n_id DESC LIMIT 1",obj.type == DialogTypeChannel ? tableChannelMessages : tableMessages]; + + FMResultSet *result = [db executeQuery:sql, @(obj.peer_id)]; + + if([result next]) { + obj.lastMessage = parseMessage(result); + obj.last_message_date = obj.lastMessage.date; + } + + + + [result close]; + + }]; - FMResultSet *result = [db executeQuery:@"select messages.message_text,messages.from_id, dialogs.peer_id, dialogs.type,dialogs.last_message_date, messages.serialized serialized_message, dialogs.top_message,dialogs.sync_message_id,dialogs.last_marked_date,dialogs.unread_count unread_count, dialogs.notify_settings notify_settings, dialogs.last_marked_message last_marked_message,dialogs.last_real_message_date last_real_message_date, messages.flags from dialogs left join messages on dialogs.top_message = messages.n_id ORDER BY dialogs.last_real_message_date DESC LIMIT ? OFFSET ?",@(limit),@(offset)]; - + }]; + + +} + +-(void)dialogsWithOffset:(int)offset limit:(int)limit completeHandler:(void (^)(NSArray *d))completeHandler { + + dispatch_queue_t dq = dispatch_get_current_queue(); + + [queue inDatabase:^(FMDatabase *db) { + FMResultSet *result = [db executeQuery:[NSString stringWithFormat:@"select * from %@ ORDER BY last_real_message_date DESC LIMIT ? OFFSET ?",tableModernDialogs],@(limit),@(offset)]; - [self parseDialogs:result dialogs:dialogs messages:messages]; + NSArray *dialogs = [self parseDialogs:result]; + [self fillLastMessagesWithConversations:dialogs]; [result close]; - if(completeHandler) completeHandler(dialogs,messages); + if(completeHandler){ + dispatch_async(dq, ^{ + completeHandler(dialogs); + }); + } }]; } --(void)insertDialogs:(NSArray *)dialogs completeHandler:(void (^)(BOOL))completeHandler { +-(void)insertDialogs:(NSArray *)dialogs { [queue inDatabase:^(FMDatabase *db) { - [db beginTransaction]; - for (TL_conversation *dialog in dialogs) { - [self executeSaveConversation:dialog db:db]; - } - [db commit]; - dispatch_async(dispatch_get_main_queue(), ^{ - if(completeHandler) completeHandler(YES); - }); + + [dialogs enumerateObjectsUsingBlock:^(TL_conversation *dialog, NSUInteger idx, BOOL * _Nonnull stop) { + + if(dialog.fake) + return; + + + [db executeUpdate:[NSString stringWithFormat:@"insert or replace into %@ (peer_id,top_message,type,last_message_date,unread_count,last_marked_message,last_marked_date,last_real_message_date,read_inbox_max_id, unread_important_count, pts,is_invisible,top_important_message,mute_until) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)",tableModernDialogs], + @(dialog.peer_id), + @(dialog.channel_top_message_id), + @(dialog.type), + @(dialog.last_message_date), + @(dialog.unread_count), + @(dialog.last_marked_message), + @(dialog.last_marked_date), + @(dialog.last_real_message_date), + @(dialog.read_inbox_max_id), + @(dialog.unread_important_count), + @(dialog.pts), + @(dialog.isInvisibleChannel), + @(dialog.channel_top_important_message_id), + @(dialog.notify_settings.mute_until) + ]; + + }]; + }]; } @@ -1170,21 +1798,26 @@ -(void)insertChat:(TLChat *)chat completeHandler:(void (^)(BOOL))completeHandler -(void)deleteDialog:(TL_conversation *)dialog completeHandler:(void (^)(void))completeHandler { [queue inDatabase:^(FMDatabase *db) { [db beginTransaction]; - [db executeUpdate:@"delete from dialogs where peer_id = ?",@(dialog.peer_id)]; - [db executeUpdate:@"delete from messages where peer_id = ?",@(dialog.peer_id)]; - [db executeUpdate:@"delete from sharedmedia where peer_id = ?",@(dialog.peer_id)]; - if([dialog.peer isChat]) { - [db executeUpdate:@"delete from encrypted_chats where chat_id = ?",[NSNumber numberWithInt:dialog.peer.chat_id]]; - [db executeUpdate:@"delete from chats where n_id = ?",[NSNumber numberWithInt:dialog.peer.chat_id]]; - if(dialog.type == DialogTypeSecretChat) - [db executeUpdate:@"delete from self_destruction where chat_id = ?",[NSNumber numberWithInt:dialog.peer.chat_id]]; - - if(dialog.type == DialogTypeBroadcast) { - [db executeUpdate:@"delete from broadcasts where n_id = ?",@(dialog.peer.chat_id)]; - } - } + [db executeUpdate:[NSString stringWithFormat:@"delete from %@ where peer_id = ?",tableModernDialogs],@(dialog.peer_id)]; + [db executeUpdate:[NSString stringWithFormat:@"delete from %@ where peer_id = ?",tableMessages],@(dialog.peer_id)]; + [db executeUpdate:[NSString stringWithFormat:@"delete from %@ where peer_id = ?",tableChannelMessages],@(dialog.peer_id)]; + [db executeUpdate:[NSString stringWithFormat:@"delete from %@ where peer_id = ?",tableMessageHoles],@(dialog.peer_id)]; + + TLChat *chat = dialog.chat; + + if([dialog.peer isKindOfClass:[TL_peerSecret class]]) + chat = (TLChat *) dialog.encryptedChat; + + if(chat) { + [db executeUpdate:[NSString stringWithFormat:@"delete from %@ where chat_id = ?",tableEncryptedChats],@(chat.n_id)]; + [db executeUpdate:[NSString stringWithFormat:@"delete from %@ where n_id = ?",tableChats],@(chat.n_id)]; + [db executeUpdate:[NSString stringWithFormat:@"delete from %@ where n_id = ?",tableChatsFull], @(chat.n_id)]; + [db executeUpdate:[NSString stringWithFormat:@"delete from %@ where chat_id = ?",tableSelfDestruction],@(dialog.peer.chat_id)]; + + } + [db commit]; dispatch_async(dispatch_get_main_queue(), ^{ @@ -1237,12 +1870,21 @@ -(void)users:(void (^)(NSArray *))completeHandler { NSMutableArray *users = [[NSMutableArray alloc] init]; + FMResultSet *result = [db executeQuery:@"select * from users"]; + while ([result next]) { TLUser *user = [TLClassStore deserialize:[result dataForColumn:@"serialized"]]; if([user isKindOfClass:[TLUser class]]) { user.lastSeenUpdate = [result intForColumn:@"lastseen_update"]; + + int last_seen = [result intForColumn:@"last_seen"]; + + if(last_seen != 0) { + user.status = last_seen < [[MTNetwork instance] getTime] ? [TL_userStatusOffline createWithWas_online:last_seen] : [TL_userStatusOnline createWithExpires:last_seen]; + } + [users addObject:user]; } @@ -1250,12 +1892,24 @@ -(void)users:(void (^)(NSArray *))completeHandler { [result close]; + if(completeHandler) { completeHandler(users); } }]; } +-(void)updateUsersStatus:(NSArray *)users { + [queue inDatabase:^(FMDatabase *db) { + + [users enumerateObjectsUsingBlock:^(TLUser *user, NSUInteger idx, BOOL * _Nonnull stop) { + + [db executeUpdate:[NSString stringWithFormat:@"update %@ set last_seen = ? where n_id = ?",tableUsers],@(user.lastSeenTime),@(user.n_id)]; + + }]; + + }]; +} - (void)insertUser:(TLUser *)user completeHandler:(void (^)(BOOL result))completeHandler { @@ -1273,7 +1927,7 @@ - (void)insertUsers:(NSArray *)users completeHandler:(void (^)(BOOL result))comp [[MTNetwork instance] setUserId:user.n_id]; } - [db executeUpdate:@"insert or replace into users (n_id, serialized,lastseen_update) values (?,?,?)", @(user.n_id), [TLClassStore serialize:user],@(user.lastSeenUpdate)]; + [db executeUpdate:@"insert or replace into users (n_id, serialized,lastseen_update,last_seen) values (?,?,?,?)", @(user.n_id), [TLClassStore serialize:user],@(user.lastSeenUpdate),@(user.status.lastSeenTime)]; } @@ -1365,31 +2019,6 @@ -(void)insertSession:(NSData *)session completeHandler:(void (^)(void))completeH }]; } --(void)sessions:(void (^)(NSArray *))completeHandler { - [queue inDatabase:^(FMDatabase *db) { - NSMutableArray *sessions = [[NSMutableArray alloc] init]; - //[db beginTransaction]; - FMResultSet *result = [db executeQuery:@"select * from sessions"]; - while ([result next]) { - [sessions addObject:[[result resultDictionary] objectForKey:@"session"]]; - } - [result close]; - //[db commit]; - dispatch_async(dispatch_get_main_queue(), ^{ - if(completeHandler) completeHandler(sessions); - }); - }]; -} - --(void)destroySessions { - [queue inDatabase:^(FMDatabase *db) { - [db executeUpdate:@"delete from sessions where 1 = 1"]; - }]; -} - - - - -(void)fullChats:(void (^)(NSArray *chats))completeHandler { [queue inDatabase:^(FMDatabase *db) { @@ -1398,9 +2027,12 @@ -(void)fullChats:(void (^)(NSArray *chats))completeHandler { while ([result next]) { TLChatFull *fullChat = [TLClassStore deserialize:[result dataForColumn:@"serialized"]]; - fullChat.lastUpdateTime = [result intForColumn:@"last_update_time"]; + if(fullChat) { + fullChat.lastUpdateTime = [result intForColumn:@"last_update_time"]; + + [chats addObject:fullChat]; + } - [chats addObject:fullChat]; } [result close]; dispatch_async(dispatch_get_main_queue(), ^{ @@ -1479,23 +2111,21 @@ -(void)importedContacts:(void (^)(NSSet *imported))completeHandler { } --(void)unreadCount:(void (^)(int count))completeHandler { +-(void)unreadCount:(void (^)(int count))completeHandler includeMuted:(BOOL)includeMuted { [queue inDatabase:^(FMDatabase *db) { - FMResultSet *result = [db executeQuery:@"select sum(unread_count) AS unread_count from dialogs"]; - + int unread_count = 0; - int unread_count = -1; - while ([result next]) { - unread_count = [result intForColumn:@"unread_count"]; + if(includeMuted) { + unread_count =[db intForQuery:[NSString stringWithFormat:@"select sum(unread_count) from %@ where is_invisible = 0 and unread_count > 0 and unread_count < 100000",tableModernDialogs]]; + } else { + unread_count = [db intForQuery:[NSString stringWithFormat:@"select sum(unread_count) from %@ where is_invisible = 0 and unread_count > 0 and unread_count < 100000 and (mute_until == 0 OR mute_until < ?)",tableModernDialogs],@([[MTNetwork instance] getTime])]; } - dispatch_async(dispatch_get_main_queue(), ^{ if(completeHandler) completeHandler(unread_count); }); - [result close]; }]; } @@ -1510,11 +2140,6 @@ -(void)insertEncryptedChat:(TL_encryptedChat *)chat { } --(void)insertMedia:(TL_localMessage *)message { - [queue inDatabase:^(FMDatabase *db) { - [db executeUpdate:@"insert or replace into sharedmedia (message_id,peer_id,serialized,date,filter_mask) values (?,?,?,?,?)",@(message.n_id),@(message.peer_id),[TLClassStore serialize:message],@([[MTNetwork instance] getTime]),@(message.filterType)]; - }]; -} -(void)countOfUserPhotos:(int)user_id { @@ -1540,18 +2165,23 @@ -(void)deleteUserPhoto:(int)n_id { } --(void)media:(void (^)(NSArray *))completeHandler max_id:(long)max_id peer_id:(int)peer_id next:(BOOL)next limit:(int)limit { +-(void)media:(void (^)(NSArray *))completeHandler max_id:(int)max_id filterMask:(int)filterMask peer:(TLPeer *)peer next:(BOOL)next limit:(int)limit { [queue inDatabase:^(FMDatabase *db) { - NSString *sql = [NSString stringWithFormat:@"select serialized,message_id from sharedmedia where peer_id = %d and message_id %@ %ld order by message_id DESC LIMIT %d",peer_id,next ? @"<" : @">",max_id,limit]; - - FMResultSet *result = [db executeQueryWithFormat:sql,nil]; + FMResultSet *result; + NSString *sql = [NSString stringWithFormat:@"select serialized from %@ where peer_id = %d and n_id %@ %@ and (filter_mask & %d) > 0 order by date DESC, n_id DESC LIMIT %d",[peer isKindOfClass:[TL_peerChannel class]] ? tableChannelMessages : tableMessages,peer.peer_id,next ? @"<" : @">",@([peer isKindOfClass:[TL_peerChannel class]] ? channelMsgId(max_id, peer.peer_id) : max_id),filterMask,limit]; + + + result = [db executeQueryWithFormat:sql,nil]; + + __block NSMutableArray *list = [[NSMutableArray alloc] init]; while ([result next]) { TL_localMessage *message = [TLClassStore deserialize:[[result resultDictionary] objectForKey:@"serialized"]]; - - [list addObject:[[PreviewObject alloc] initWithMsdId:[result intForColumn:@"message_id"] media:message peer_id:peer_id]]; + if(![message isKindOfClass:[TL_messageEmpty class]]) { + [list addObject:[[PreviewObject alloc] initWithMsdId:message.n_id media:message peer_id:peer.peer_id]]; + } } [LoopingUtils runOnMainQueueAsync:^{ @@ -1565,11 +2195,7 @@ -(int)countOfMedia:(int)peer_id { __block int count = 0; - [queue inDatabaseWithDealocing:^(FMDatabase *db) { - - count = [db intForQuery:@"select count(*) from sharedmedia where (filter_mask & 8 = 8) and peer_id = ?",@(peer_id)]; - - }]; + return count; } @@ -1740,6 +2366,10 @@ -(void)removeTask:(id)task { } -(void)selectTasks:(void (^)(NSArray *tasks))completeHandler { + + dispatch_queue_t dqueue = dispatch_get_current_queue(); + + [queue inDatabase:^(FMDatabase *db) { NSMutableArray *tasks = [[NSMutableArray alloc] init]; FMResultSet *result = [db executeQuery:@"select * from tasks"]; @@ -1767,7 +2397,7 @@ -(void)selectTasks:(void (^)(NSArray *tasks))completeHandler { [tasks addObject:task]; } [result close]; - dispatch_async(dispatch_get_main_queue(), ^{ + dispatch_async(dqueue, ^{ if(completeHandler) completeHandler(tasks); }); @@ -1781,37 +2411,15 @@ -(TL_conversation *)selectConversation:(TLPeer *)peer { [queue inDatabaseWithDealocing:^(FMDatabase *db) { - FMResultSet *result = [db executeQuery:@"select * from dialogs where peer_id = ?",@(peer.peer_id)]; - while ([result next]) { - - - conversation = [[TL_conversation alloc] init]; - int type = [result intForColumn:@"type"]; - - if(type == DialogTypeSecretChat) { - conversation.peer = [TL_peerSecret createWithChat_id:[result intForColumn:@"peer_id"]]; - } else if(type == DialogTypeUser) { - conversation.peer = [TL_peerUser createWithUser_id:[result intForColumn:@"peer_id"]]; - } else if(type == DialogTypeChat) { - conversation.peer = [TL_peerChat createWithChat_id:-[result intForColumn:@"peer_id"]]; - } else if(type == DialogTypeBroadcast) { - conversation.peer = [TL_peerBroadcast createWithChat_id:[result intForColumn:@"peer_id"]]; - } - - id notifyObject = [result dataForColumn:@"notify_settings"]; - - if(notifyObject != nil && ![notifyObject isKindOfClass:[NSNull class]]) { - conversation.notify_settings = [TLClassStore deserialize:notifyObject]; - } - - - conversation.unread_count = [result intForColumn:@"unread_count"]; - conversation.top_message = [result intForColumn:@"top_message"]; - conversation.last_message_date = [result intForColumn:@"last_message_date"]; - conversation.last_marked_message = [result intForColumn:@"last_marked_message"]; - conversation.last_marked_date = [result intForColumn:@"last_marked_date"]; - - } + NSString *sql = [NSString stringWithFormat:@"select * from %@ where peer_id = %d", tableModernDialogs,peer.peer_id]; + + FMResultSet *result = [db executeQueryWithFormat:sql,nil]; + + conversation = [[self parseDialogs:result] firstObject]; + + if(conversation != nil) + [self fillLastMessagesWithConversations:@[conversation]]; + [result close]; }]; @@ -1822,6 +2430,34 @@ -(TL_conversation *)selectConversation:(TLPeer *)peer { } +-(void)conversationsWithPeerIds:(NSArray *)peer_ids completeHandler:(void (^)(NSArray * result))completeHandler { + + dispatch_queue_t dqueue = dispatch_get_current_queue(); + + + if(peer_ids.count == 0) { + completeHandler(@[]); + return; + } + + [queue inDatabase:^(FMDatabase *db) { + + NSString *sql = [NSString stringWithFormat:@"select * from %@ where peer_id IN (%@)",tableModernDialogs,[peer_ids componentsJoinedByString:@","]]; + + FMResultSet *result = [db executeQueryWithFormat:sql,nil]; + + NSArray *list = [self parseDialogs:result]; + + [result close]; + + dispatch_async(dqueue, ^{ + completeHandler(list); + }); + + }]; + +} + -(void)insertBroadcast:(TL_broadcast *)broadcast { @@ -1836,26 +2472,28 @@ -(void)deleteBroadcast:(TL_broadcast *)broadcast { }]; } --(NSArray *)broadcastList { +-(void)broadcastList:(void (^)(NSArray *list))completeHandler { NSMutableArray *list = [[NSMutableArray alloc] init]; - [queue inDatabaseWithDealocing:^(FMDatabase *db) { + [queue inDatabase:^(FMDatabase *db) { FMResultSet *result = [db executeQuery:@"select * from broadcasts where 1=1 order by date"]; while ([result next]) { TL_broadcast *broadcast = [TLClassStore deserialize:[result dataForColumn:@"serialized"]]; - - [list addObject:broadcast]; + if(broadcast) { + [list addObject:broadcast]; + } } [result close]; + if(completeHandler) + completeHandler(list); + }]; - return list; - } -(void)insertSecretAction:(TGSecretAction *)action { @@ -1932,14 +2570,14 @@ -(NSArray *)selectSupportMessages:(NSArray *)ids { NSString *join = [ids componentsJoinedByString:@","]; - NSString *sql = [NSString stringWithFormat:@"select * from support_messages where n_id IN (%@)",join]; + NSString *sql = [NSString stringWithFormat:@"select * from %@ where n_id IN (%@)",tableSupportMessages,join]; FMResultSet *result = [db executeQueryWithFormat:sql,nil]; while ([result next]) { - - [messages addObject:[TLClassStore deserialize:[result dataForColumn:@"serialized"]]]; + id msg = [TLClassStore deserialize:[result dataForColumn:@"serialized"]]; + [messages addObject:msg]; } @@ -1955,7 +2593,15 @@ -(NSArray *)selectSupportMessages:(NSArray *)ids { -(void)addSupportMessages:(NSArray *)messages { [queue inDatabase:^(FMDatabase *db) { [messages enumerateObjectsUsingBlock:^(TL_localMessage *obj, NSUInteger idx, BOOL *stop) { - [db executeUpdate:@"insert into support_messages (n_id,serialized) values (?,?)",@(obj.n_id),[TLClassStore serialize:obj]]; + + BOOL isset = [db boolForQuery:[NSString stringWithFormat:@"select count(*) from %@ where n_id = ?",tableSupportMessages],@(obj.channelMsgId)]; + + if(isset) { + [db executeUpdate:[NSString stringWithFormat:@"update %@ set serialized = ? where n_id = ?",tableSupportMessages],@(obj.channelMsgId),[TLClassStore serialize:obj],@(obj.channelMsgId)]; + } else { + [db executeUpdate:[NSString stringWithFormat:@"insert or replace into %@ (n_id,serialized) values (?,?)",tableSupportMessages],@(obj.channelMsgId),[TLClassStore serialize:obj]]; + } + }]; }]; } @@ -1963,11 +2609,15 @@ -(void)addSupportMessages:(NSArray *)messages { -(void)updateMessageId:(long)random_id msg_id:(int)n_id { + [queue inDatabase:^(FMDatabase *db) { - [db executeUpdate:@"update sharedmedia set message_id = ? where message_id = (select n_id from messages where random_id = ?)",@(n_id),@(random_id)]; + [db executeUpdate:@"update messages set n_id = (?), dstate = (?) where random_id = ?",@(n_id),@(DeliveryStateNormal),@(random_id)]; + + int peer_id = [db intForQuery:[NSString stringWithFormat:@"select peer_id from %@ where random_id = ?",tableChannelMessages],@(random_id)]; + + [db executeUpdate:[NSString stringWithFormat:@"update %@ set n_id = (?), dstate = (?) where random_id = ?",tableChannelMessages],@(channelMsgId(n_id,peer_id)),@(DeliveryStateNormal),@(random_id)]; - [db executeUpdate:@"update messages set n_id = (?), dstate = (?) where random_id = ?",@(n_id),@(random_id),@(DeliveryStateNormal)]; }]; } @@ -1983,10 +2633,32 @@ +(void)addWebpage:(TLWebPage *)webpage forLink:(NSString *)link { } +-(NSArray *)conversationsWithIds:(NSArray *)ids { + + __block NSArray *dialogs; + + [queue inDatabaseWithDealocing:^(FMDatabase *db) { + + NSString *sql = [NSString stringWithFormat:@"select * from %@ where peer_id IN (%@)",tableModernDialogs,[ids componentsJoinedByString:@","]]; + + FMResultSet *result = [db executeQueryWithFormat:sql,nil]; + + dialogs = [self parseDialogs:result]; + + [result close]; + + }]; + + return dialogs; +} + +(TLWebPage *)findWebpage:(NSString *)link { __block TLWebPage *webpage; + if(link.length == 0) + return webpage; + [[Storage yap] readWithBlock:^(YapDatabaseReadTransaction *transaction) { @@ -2000,4 +2672,109 @@ +(TLWebPage *)findWebpage:(NSString *)link { } + +/* + + channel storage procedures + + */ + + + + +-(void)insertMessagesHole:(TGMessageHole *)hole { + + [queue inDatabase:^(FMDatabase *db) { + + + int unique_id = [db intForQuery:[NSString stringWithFormat:@"SELECT unique_id FROM %@ where peer_id = ? and (type & ?) = ? and ((min_id = 0 OR min_id < ?) and max_id = ?) order by date asc limit 1",tableMessageHoles],@(hole.type),@(hole.type),@(hole.peer_id),@(hole.min_id), @(hole.max_id)]; + + + [db executeUpdate:[NSString stringWithFormat:@"insert or replace into %@ (unique_id, peer_id, min_id, max_id, date, type, count, imploded) values (?,?,?,?,?,?,?,?)",tableMessageHoles],@(unique_id < 0 ? unique_id : hole.uniqueId),@(hole.peer_id),@(hole.min_id),@(hole.max_id),@(hole.date),@(hole.type),@(hole.messagesCount),@(hole.isImploded)]; + + + }]; + +} + +-(void)removeHole:(TGMessageHole *)hole { + [queue inDatabase:^(FMDatabase *db) { + + [db executeUpdate:[NSString stringWithFormat:@"delete from %@ where unique_id = ?",tableMessageHoles],@(hole.uniqueId)]; + + }]; +} + +-(NSArray *)groupHoles:(int)peer_id min:(int)min max:(int)max { + + + NSMutableArray *holes = [[NSMutableArray alloc] init]; + + [queue inDatabaseWithDealocing:^(FMDatabase *db) { + + FMResultSet *result; + + result = [db executeQuery:[NSString stringWithFormat:@"select * from %@ where peer_id = ? and (type & 4 = 4) and NOT(? >= max_id OR ? <= min_id) order by date asc",tableMessageHoles],@(peer_id),@(min),@(max)]; + + while ([result next]) { + [holes addObject:[[TGMessageGroupHole alloc] initWithUniqueId:[result intForColumn:@"unique_id"] peer_id:[result intForColumn:@"peer_id"] min_id:[result intForColumn:@"min_id"] max_id:[result intForColumn:@"max_id"] date:[result intForColumn:@"date"] count:[result intForColumn:@"count"] isImploded:[result boolForColumn:@"imploded"]]]; + } + + + + [result close]; + + }]; + + + return [holes copy]; +} + +-(void)addHolesAroundMessage:(TL_localMessage *)message { + [queue inDatabase:^(FMDatabase *db) { + + + BOOL messageIsset = [db boolForQuery:[NSString stringWithFormat:@"select count(*) from %@ where n_id = ?",message.isChannelMessage ? tableChannelMessages : tableMessages],@(message.channelMsgId)]; + + if(!messageIsset) + { + int minSynchedId = [self syncedMessageIdWithPeerId:message.peer_id important:message.isImportantMessage latest:NO isChannel:message.isChannelMessage]; + + if(minSynchedId == 0) { + minSynchedId = INT32_MAX; + } + + if(minSynchedId > message.n_id) { + TGMessageHole *hole = [[TGMessageHole alloc] initWithUniqueId:-rand_int() peer_id:message.peer_id min_id:message.n_id+1 max_id:minSynchedId-1 date:message.date count:0]; + + [self insertMessagesHole:hole]; + } + } + + }]; +} + +-(int)syncedMessageIdWithPeerId:(int)peer_id important:(BOOL)important latest:(BOOL)latest isChannel:(BOOL)isChannel { + + __block int max_id = 0; + + [queue inDatabaseWithDealocing:^(FMDatabase *db) { + + int maxMsgId = [db intForQuery:[NSString stringWithFormat:@"select n_id from %@ where peer_id = ? and n_id < ? and (filter_mask & ?) > 0 and dstate = ? order by date %@, n_id %@ limit 1",isChannel ? tableChannelMessages : tableMessages,latest ? @"desc" : @"asc",latest ? @"desc" : @"asc"],@(peer_id),@(isChannel ? channelMsgId(TGMINFAKEID, peer_id) : TGMINFAKEID),@(isChannel ? (important ?HistoryFilterImportantChannelMessage : HistoryFilterChannelMessage) : HistoryFilterNone),@(DeliveryStateNormal)]; + + + int holeMaxId = [db intForQuery:[NSString stringWithFormat:@"select max_id from %@ where peer_id = ? and (type & ?) = ? and max_id > ? and min_id <= ?",tableMessageHoles],@(important ? 4 : 2),@(important ? 4 : 2),@(peer_id),@(maxMsgId),@(maxMsgId)]; + + + if(holeMaxId != 0) + max_id = holeMaxId; + else + max_id = maxMsgId; + + }]; + + + return max_id; +} + @end diff --git a/TelegramTest/TGAllStickersTableView.h b/TelegramTest/TGAllStickersTableView.h index a2c960d8..493adb55 100644 --- a/TelegramTest/TGAllStickersTableView.h +++ b/TelegramTest/TGAllStickersTableView.h @@ -16,11 +16,15 @@ -(void)removeSticker:(TL_outDocument *)document; -(void)load:(BOOL)force; +@property (nonatomic,strong) dispatch_block_t didNeedReload; + -(void)showWithStickerPack:(TL_messages_stickerSet *)stickerPack; -(NSArray *)allStickers; -(NSArray *)sets; +-(void)updateSets:(NSArray *)sets; + -(void)scrollToStickerPack:(long)packId; @end diff --git a/TelegramTest/TGAllStickersTableView.m b/TelegramTest/TGAllStickersTableView.m index b39b8d9c..14c97fd5 100644 --- a/TelegramTest/TGAllStickersTableView.m +++ b/TelegramTest/TGAllStickersTableView.m @@ -21,7 +21,6 @@ @interface TGAllStickersTableView () @property (nonatomic,strong) NSMutableArray *stickers; @property (nonatomic,strong) NSMutableArray *sets; @property (nonatomic,assign) BOOL isCustomStickerPack; -@property (nonatomic,strong) NSDictionary *topSets; @end @@ -97,6 +96,7 @@ -(id)initWithObject:(NSArray *)object packId:(long)packId { return self; } + -(NSUInteger)hash { @@ -187,7 +187,7 @@ -(void)redrawRow { [imageView setTapBlock:^ { if(!_tableView.isCustomStickerPack) - [[Telegram rightViewController].messagesViewController sendSticker:item.stickers[idx] forConversation:[Telegram conversation] addCompletionHandler:nil]; + [[EmojiViewController instance].messagesViewController sendSticker:item.stickers[idx] forConversation:[Telegram conversation] addCompletionHandler:nil]; }]; @@ -218,9 +218,6 @@ -(void)redrawRow { } - - - [self addSubview:button]; xOffset+=width; @@ -243,12 +240,47 @@ -(instancetype)initWithFrame:(NSRect)frameRect { if(self = [super initWithFrame:frameRect]) { _stickers = [[NSMutableArray alloc] init]; self.tm_delegate = self; + + [Notification addObserver:self selector:@selector(stickersNeedFullReload:) name:STICKERS_ALL_CHANGED]; + [Notification addObserver:self selector:@selector(stickersNeedReorder:) name:STICKERS_REORDER]; + [Notification addObserver:self selector:@selector(stickersNewPackAdded:) name:STICKERS_NEW_PACK]; + } return self; } +-(void)stickersNeedFullReload:(NSNotification *)notification { + [self load:YES]; +} + +-(void)stickersNeedReorder:(NSNotification *)notification { + NSArray *order = notification.userInfo[KEY_ORDER]; + + [_sets sortUsingComparator:^NSComparisonResult(TL_stickerSet *obj1, TL_stickerSet *obj2) { + + NSNumber *idx1 = @([order indexOfObject:@(obj1.n_id)]); + NSNumber *idx2 = @([order indexOfObject:@(obj2.n_id)]); + + return [idx1 compare:idx2]; + }]; + + [self reloadData]; +} + +-(void)stickersNewPackAdded:(NSNotification *)notification { + TL_messages_stickerSet *set = notification.userInfo[KEY_STICKERSET]; + + [_sets insertObject:set.set atIndex:0]; + + [_stickers addObjectsFromArray:set.documents]; + + [self save:_sets stickers:_stickers n_hash:[self stickersHash:_sets] saveSets:YES]; + + [self reloadData]; +} + -(NSScrollView *)containerView { @@ -271,7 +303,6 @@ -(void)load:(BOOL)force { NSDictionary *info = [transaction objectForKey:@"allstickers" inCollection:STICKERS_COLLECTION]; - hash = info[@"hash"]; stickers = info[@"serialized"]; @@ -300,8 +331,7 @@ -(void)load:(BOOL)force { _stickers = [stickers mutableCopy]; if(!isRemoteStickersLoaded() || force) { - [RPCRequest sendRequest:[TLAPI_messages_getAllStickers createWithN_hash:hash] successHandler:^(RPCRequest *request, TL_messages_allStickers *response) { - + [RPCRequest sendRequest:[TLAPI_messages_getAllStickers createWithN_hash:[self stickersHash:_sets]] successHandler:^(RPCRequest *request, TL_messages_allStickers *response) { if(![response isKindOfClass:[TL_messages_allStickersNotModified class]]) { @@ -328,7 +358,33 @@ -(void)load:(BOOL)force { } --(void)loadSetsIfNeeded:(NSArray *)sets n_hash:(NSString *)n_hash { +-(void)save:(NSArray *)sets stickers:(NSArray *)stickers n_hash:(int)n_hash saveSets:(BOOL)saveSets { + [[Storage yap] readWriteWithBlock:^(YapDatabaseReadWriteTransaction * __nonnull transaction) { + + NSMutableArray *serializedStickers = [_stickers mutableCopy]; + + NSMutableDictionary *data = [[transaction objectForKey:@"allstickers" inCollection:STICKERS_COLLECTION] mutableCopy]; + + if(!data) + { + data = [[NSMutableDictionary alloc] init]; + data[@"sets"] = [[NSMutableArray alloc] init]; + } + + data[@"serialized"] = serializedStickers; + + if(saveSets) { + + data[@"sets"] = sets; + } + + [transaction setObject:data forKey:@"allstickers" inCollection:STICKERS_COLLECTION]; + + }]; + +} + +-(void)loadSetsIfNeeded:(NSArray *)sets n_hash:(int)n_hash { NSMutableArray *removed = [[NSMutableArray alloc] init]; @@ -354,6 +410,8 @@ -(void)loadSetsIfNeeded:(NSArray *)sets n_hash:(NSString *)n_hash { }]; + _sets = [sets mutableCopy]; + NSMutableArray *toremove = [[NSMutableArray alloc] init]; [_stickers enumerateObjectsUsingBlock:^(TL_document *obj, NSUInteger idx, BOOL *stop) { @@ -370,34 +428,8 @@ -(void)loadSetsIfNeeded:(NSArray *)sets n_hash:(NSString *)n_hash { [_stickers removeObjectsInArray:toremove]; - [[Storage yap] readWriteWithBlock:^(YapDatabaseReadWriteTransaction * __nonnull transaction) { - - NSMutableArray *serializedStickers = [_stickers mutableCopy]; - - - - NSMutableDictionary *data = [[transaction objectForKey:@"allstickers" inCollection:STICKERS_COLLECTION] mutableCopy]; - - if(!data) - { - data = [[NSMutableDictionary alloc] init]; - data[@"sets"] = [[NSMutableArray alloc] init]; - data[@"hash"] = @""; - } - - data[@"serialized"] = serializedStickers; - - if(changed.count == 0) { - - data[@"sets"] = sets; - data[@"hash"] = n_hash; - } - - [transaction setObject:data forKey:@"allstickers" inCollection:STICKERS_COLLECTION]; - - }]; - - _sets = [sets mutableCopy]; + [self save:sets stickers:_stickers n_hash:n_hash saveSets:changed.count == 0]; + [self reloadData]; @@ -420,7 +452,7 @@ -(void)loadSetsIfNeeded:(NSArray *)sets n_hash:(NSString *)n_hash { } --(void)performLoadSet:(TL_stickerSet *)set allSets:(NSArray *)allSets hash:(NSString *)n_hash save:(BOOL)save { +-(void)performLoadSet:(TL_stickerSet *)set allSets:(NSArray *)allSets hash:(int)n_hash save:(BOOL)save { [RPCRequest sendRequest:[TLAPI_messages_getStickerSet createWithStickerset:[TL_inputStickerSetID createWithN_id:set.n_id access_hash:set.access_hash]] successHandler:^(id request, TL_messages_stickerSet *response) { @@ -437,19 +469,20 @@ -(void)performLoadSet:(TL_stickerSet *)set allSets:(NSArray *)allSets hash:(NSSt if(!data) { data = [[NSMutableDictionary alloc] init]; data[@"serialized"] = [[NSMutableArray alloc] init]; - data[@"hash"] = @""; data[@"sets"] = [[NSMutableArray alloc] init]; } [stickers addObjectsFromArray:response.documents]; if(save) { - data[@"hash"] = n_hash; - - data[@"sets"] = allSets; + data[@"sets"] = allSets == nil ? [NSMutableArray array] : allSets; + } + + if(!data[@"sets"]) { + data[@"sets"] = [[NSMutableArray alloc] init]; } - [transaction setObject:@{@"hash":data[@"hash"],@"serialized":stickers,@"sets":data[@"sets"]} forKey:@"allstickers" inCollection:STICKERS_COLLECTION]; + [transaction setObject:@{@"serialized":stickers,@"sets":data[@"sets"]} forKey:@"allstickers" inCollection:STICKERS_COLLECTION]; }]; @@ -473,21 +506,11 @@ -(NSArray *)allStickers { -(NSArray *)sets { - - if(!_topSets) - return _sets; - - return [_sets sortedArrayUsingComparator:^NSComparisonResult(TL_stickerSet *obj1, TL_stickerSet *obj2) { - NSNumber *c1 = _topSets[@(obj1.n_id)]; - NSNumber *c2 = _topSets[@(obj2.n_id)]; - - if ([c1 longValue] > [c2 longValue]) - return NSOrderedAscending; - else if ([c1 longValue] < [c2 longValue]) - return NSOrderedDescending; - - return NSOrderedSame; - }]; + return _sets; +} + +-(void)updateSets:(NSArray *)sets { + _sets = [sets mutableCopy]; } -(void)removeSticker:(TL_outDocument *)document { @@ -543,21 +566,6 @@ -(void)reloadData { return NSOrderedSame; }]; - NSMutableDictionary *topSets = [[NSMutableDictionary alloc] init]; - - [recent enumerateObjectsUsingBlock:^(TL_document *obj, NSUInteger idx, BOOL *stop) { - - TL_documentAttributeSticker *sticker = (TL_documentAttributeSticker *) [obj attributeWithClass:[TL_documentAttributeSticker class]]; - - int count = [topSets[@(sticker.stickerset.n_id)] intValue]; - - count+= [sort[@(obj.n_id)] intValue]; - - topSets[@(sticker.stickerset.n_id)] = @(count); - - }]; - - _topSets = topSets; if(!_isCustomStickerPack) { recent = [recent subarrayWithRange:NSMakeRange(0, MIN(20,recent.count))]; @@ -608,9 +616,6 @@ -(void)reloadData { stickers = [stickers sortedArrayUsingComparator:^NSComparisonResult(TL_document *obj1, TL_document *obj2) { - - - NSNumber *sidx = @([sets indexOfObjectPassingTest:^BOOL(TL_stickerSet *obj, NSUInteger idx, BOOL *stop) { TL_documentAttributeSticker *sticker = (TL_documentAttributeSticker *) [obj1 attributeWithClass:[TL_documentAttributeSticker class]]; @@ -670,6 +675,10 @@ -(void)reloadData { [super reloadData]; + if(_didNeedReload) { + _didNeedReload(); + } + } - (CGFloat)rowHeight:(NSUInteger)row item:(TMRowItem *) item @@ -713,6 +722,19 @@ -(void)showWithStickerPack:(TL_messages_stickerSet *)stickerPack { } +-(int)stickersHash:(NSArray *)stickersets { + + __block long acc = 0; + + [stickersets enumerateObjectsUsingBlock:^(TL_stickerSet *obj, NSUInteger idx, BOOL * _Nonnull stop) { + acc = (acc + obj.n_hash) * 20261; + }]; + + return (int)(acc % 0x7FFFFFFF); + +} + + -(void)scrollToStickerPack:(long)packId { __block TGAllStickersTableItem *item; diff --git a/TelegramTest/TGAudioPlayerListView.h b/TelegramTest/TGAudioPlayerListView.h index 492bd5d6..6d228913 100644 --- a/TelegramTest/TGAudioPlayerListView.h +++ b/TelegramTest/TGAudioPlayerListView.h @@ -27,4 +27,6 @@ -(void)onShow; +-(void)close; + @end diff --git a/TelegramTest/TGAudioPlayerListView.m b/TelegramTest/TGAudioPlayerListView.m index b44816e4..9a97a2cc 100644 --- a/TelegramTest/TGAudioPlayerListView.m +++ b/TelegramTest/TGAudioPlayerListView.m @@ -155,7 +155,7 @@ -(void)onShow { }]; - if(!NSContainsRect([self.tableView visibleRect], [self.tableView rectOfRow:selectedIdx])) + if(![self.tableView rowIsVisible:selectedIdx]) [self.tableView.scrollView.clipView scrollPoint:[self.tableView rectOfRow:selectedIdx].origin]; } @@ -191,10 +191,8 @@ - (BOOL)isSelectable:(NSInteger)row item:(TMRowItem *) item { -(void)setConversation:(TL_conversation *)conversation { _conversation = conversation; - - - [self reload]; + } @@ -202,6 +200,7 @@ -(void)reload { if(_conversation) { _list = @[]; + [_tableView removeAllItems:YES]; _fullItems = [[NSMutableArray alloc] init]; _h_controller = [[ChatHistoryController alloc] initWithController:self historyFilter:[MP3HistoryFilter class]]; [_searchRow.searchField setStringValue:@""]; @@ -212,6 +211,7 @@ -(void)reload { [_tableView removeAllItems:YES]; _fullItems = nil; _list = nil; + _h_controller = nil; } [self check]; @@ -221,7 +221,7 @@ -(void)reload { -(void)loadNext { if(_h_controller.nextState != ChatHistoryStateFull) { - [_h_controller request:YES anotherSource:YES sync:NO selectHandler:^(NSArray *result, NSRange range) { + [_h_controller request:YES anotherSource:YES sync:NO selectHandler:^(NSArray *result, NSRange range, id controller) { NSArray *f = [result filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.class == %@",[MessageTableItemAudioDocument class]]]; @@ -244,13 +244,15 @@ -(void)loadNext { [self resort]; - [_tableView removeItemsInRange:NSMakeRange(1, _tableView.count-1) tableRedraw:YES]; + if(_tableView.count > 0) { + [_tableView removeItemsInRange:NSMakeRange(1, _tableView.count-1) tableRedraw:YES]; + } [_tableView insert:_fullItems startIndex:1 tableRedraw:YES]; [self check]; - if([TGAudioPlayerWindow currentItem] == nil && _tableView.count > 1) { + if([TGAudioPlayerWindow currentItem] == nil && _tableView.count > 1 && [TGAudioPlayerWindow autoStart]) { [self selectNext]; } @@ -314,7 +316,9 @@ -(void)setSelectedId:(long)messageId { [self.tableView redrawAll]; - if(NSContainsRect([self.tableView visibleRect], [self.tableView rectOfRow:selectedIdx])) + + + if(![self.tableView rowIsVisible:selectedIdx]) [self.tableView.scrollView.clipView scrollPoint:[self.tableView rectOfRow:selectedIdx].origin]; } @@ -323,38 +327,51 @@ -(void)reloadData { [_tableView redrawAll]; } +-(void)close { + _conversation = nil; + [_h_controller drop:YES]; + _h_controller = nil; +} + -(void)selectNext { - long rowId = (long) [_tableView indexOfItem:[_tableView itemByHash:_selectedId]]; - - if(rowId == NSNotFound) - { - rowId = 0; - } - - rowId++; - if(rowId == _tableView.count ) { - rowId = 1; - } + [ASQueue dispatchOnMainQueue:^{ + long rowId = (long) [_tableView indexOfItem:[_tableView itemByHash:_selectedId]]; + + if(rowId == NSNotFound) + { + rowId = 0; + } + + rowId++; + + if(rowId == _tableView.count ) { + rowId = 1; + } + + _changedAudio([(TGAudioRowItem *)[_tableView itemAtPosition:rowId] document]); + }]; - _changedAudio([(TGAudioRowItem *)[_tableView itemAtPosition:rowId] document]); + } -(void)selectPrev { - long rowId = (long) [_tableView indexOfItem:[_tableView itemByHash:_selectedId]]; - - if(rowId == NSNotFound) - { - rowId = 0; - } - - rowId--; - - if(rowId < 1) { - rowId = (int)_tableView.count - 1; - } - - _changedAudio([(TGAudioRowItem *)[_tableView itemAtPosition:rowId] document]); + [ASQueue dispatchOnMainQueue:^{ + long rowId = (long) [_tableView indexOfItem:[_tableView itemByHash:_selectedId]]; + + if(rowId == NSNotFound) + { + rowId = 0; + } + + rowId--; + + if(rowId < 1) { + rowId = (int)_tableView.count - 1; + } + + _changedAudio([(TGAudioRowItem *)[_tableView itemAtPosition:rowId] document]); + }]; } -(void)receivedMessage:(MessageTableItem *)message position:(int)position itsSelf:(BOOL)force { @@ -399,7 +416,9 @@ -(NSUInteger)posAsItem:(TGAudioRowItem *)item { return [_fullItems indexOfObject:item]; } --(void)deleteMessages:(NSArray *)ids { +-(void)deleteItems:(NSArray *)dItems orMessageIds:(NSArray *)ids { + + NSArray *items = [_fullItems filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.document.message.n_id IN (%@)",ids]]; [items enumerateObjectsUsingBlock:^(TGAudioRowItem *obj, NSUInteger idx, BOOL *stop) { diff --git a/TelegramTest/TGAudioPlayerWindow.h b/TelegramTest/TGAudioPlayerWindow.h index 2cb7660d..66c461ed 100644 --- a/TelegramTest/TGAudioPlayerWindow.h +++ b/TelegramTest/TGAudioPlayerWindow.h @@ -24,9 +24,15 @@ typedef enum { @interface TGAudioPlayerWindow : NSPanel +typedef enum { + TGAudioPlayerWindowStateMini, + TGAudioPlayerWindowStatePlayList +} TGAudioPlayerWindowState; + @property (nonatomic,strong,readonly) MessageTableItemAudioDocument *currentItem; +(void)show:(TL_conversation *)conversation; ++(void)show:(TL_conversation *)conversation playerState:(TGAudioPlayerWindowState)state; +(void)hide; +(MessageTableItemAudioDocument *)currentItem; @@ -37,6 +43,8 @@ typedef enum { +(void)pause; +(void)resume; ++(BOOL)autoStart; + +(void)addEventListener:(id)delegate; +(void)removeEventListener:(id)delegate; diff --git a/TelegramTest/TGAudioPlayerWindow.m b/TelegramTest/TGAudioPlayerWindow.m index e47e861d..e66cac05 100644 --- a/TelegramTest/TGAudioPlayerWindow.m +++ b/TelegramTest/TGAudioPlayerWindow.m @@ -60,10 +60,7 @@ -(void)updateTrackingAreas -typedef enum { - TGAudioPlayerWindowStateMini, - TGAudioPlayerWindowStatePlayList -} TGAudioPlayerWindowState; + @interface TGAudioPlayerWindow () { @@ -103,8 +100,12 @@ @interface TGAudioPlayerWindow () @property (nonatomic,assign) TGAudioPlayerWindowState windowState; +@property (nonatomic,strong) DownloadEventListener *downloadEventListener; + @property (nonatomic,strong) NSMutableArray *eventListeners; +@property (nonatomic,assign) BOOL autoStart; + @end @implementation TGAudioPlayerWindow @@ -444,9 +445,15 @@ -(void)setMouseInWindow:(BOOL)mouseInWindow { [self playAnimationForName]; } ++(void)show:(TL_conversation *)conversation playerState:(TGAudioPlayerWindowState)state { + [self instance].windowState = state; + [self show:conversation]; + [self instance].autoStart = NO; +} + +(void)show:(TL_conversation *)conversation { [[self instance] show:conversation]; - + [self instance].autoStart = YES; [[self instance] makeKeyAndOrderFront:nil]; } @@ -519,6 +526,8 @@ -(void)makeKeyAndOrderFront:(id)sender { -(void)orderOut:(id)sender { [super orderOut:sender]; _isVisibility = NO; + [self.currentItem.downloadItem removeEvent:_downloadEventListener]; + _downloadEventListener = nil; [self clear]; } @@ -626,6 +635,10 @@ +(void)resume { [[self instance] play:[self instance].currentTime]; } ++(BOOL)autoStart { + return [self instance].autoStart; +} + +(void)addEventListener:(id)delegate { [[self instance] addEventListener:delegate]; @@ -668,7 +681,7 @@ +(void)setCurrentItem:(MessageTableItemAudioDocument *)audioItem { -(void)setCurrentItem:(MessageTableItemAudioDocument *)audioItem { - [_currentItem.downloadItem removeEvent:audioItem.secondDownloadListener]; + [_currentItem.downloadItem removeEvent:_downloadEventListener]; if(_currentItem == audioItem) { @@ -676,7 +689,7 @@ -(void)setCurrentItem:(MessageTableItemAudioDocument *)audioItem { return; } - [_currentItem.downloadItem removeEvent:_currentItem.secondDownloadListener]; + [_currentItem.downloadItem removeEvent:_downloadEventListener]; _currentItem = audioItem; @@ -688,6 +701,7 @@ -(void)setCurrentItem:(MessageTableItemAudioDocument *)audioItem { if([_currentItem isset]) { + [_progressView setDisableChanges:NO]; [self play:self.currentTime]; } else { [_currentItem startDownload:NO force:YES]; @@ -706,16 +720,26 @@ -(void)updateDownloadListener { if(_currentItem.downloadItem) { + [_progressView setDisableChanges:YES]; + weak(); [self.progressView setDownloadProgress:_currentItem.downloadItem.progress]; - [_currentItem.downloadItem addEvent:_currentItem.secondDownloadListener]; - [_currentItem.secondDownloadListener setCompleteHandler:^(DownloadItem * item) { + [_currentItem.downloadItem removeEvent:_downloadEventListener]; + + _downloadEventListener = [[DownloadEventListener alloc] init]; + + [_currentItem.downloadItem addEvent:_downloadEventListener]; + + + [_downloadEventListener setCompleteHandler:^(DownloadItem * item) { [[ASQueue mainQueue] dispatchOnQueue:^{ + [weakSelf.progressView setDisableChanges:NO]; + [weakSelf.progressView setDownloadProgress:0]; [weakSelf play:weakSelf.currentTime]; @@ -728,7 +752,7 @@ -(void)updateDownloadListener { }]; - [_currentItem.secondDownloadListener setProgressHandler:^(DownloadItem * item) { + [_downloadEventListener setProgressHandler:^(DownloadItem * item) { [ASQueue dispatchOnMainQueue:^{ @@ -737,6 +761,8 @@ -(void)updateDownloadListener { }]; }]; + } else { + [_progressView setDisableChanges:NO]; } } diff --git a/TelegramTest/TGAudioProgressView.h b/TelegramTest/TGAudioProgressView.h index afc78b56..648c6030 100644 --- a/TelegramTest/TGAudioProgressView.h +++ b/TelegramTest/TGAudioProgressView.h @@ -19,4 +19,6 @@ @property (nonatomic,assign) BOOL showDivider; +@property (nonatomic,assign) BOOL disableChanges; + @end diff --git a/TelegramTest/TGAudioProgressView.m b/TelegramTest/TGAudioProgressView.m index 543506cb..e0f6ae3c 100644 --- a/TelegramTest/TGAudioProgressView.m +++ b/TelegramTest/TGAudioProgressView.m @@ -49,6 +49,9 @@ - (void)drawRect:(NSRect)dirtyRect { -(void)mouseDown:(NSEvent *)theEvent { + if(_disableChanges) + return; + _isUserUpdate = YES; NSPoint point = [self convertPoint:[theEvent locationInWindow] fromView:nil]; @@ -68,6 +71,9 @@ -(void)updateByPoint:(NSPoint)point { -(void)mouseUp:(NSEvent *)theEvent { + if(_disableChanges) + return; + _isUserUpdate = NO; if(_progressCallback) @@ -80,6 +86,9 @@ -(void)mouseUp:(NSEvent *)theEvent { -(void)mouseDragged:(NSEvent *)theEvent { + if(_disableChanges) + return; + NSPoint point = [self convertPoint:[theEvent locationInWindow] fromView:nil]; [self updateByPoint:point]; diff --git a/TelegramTest/TGBotCommandsPopup.m b/TelegramTest/TGBotCommandsPopup.m index d2fa082a..8f05ce93 100644 --- a/TelegramTest/TGBotCommandsPopup.m +++ b/TelegramTest/TGBotCommandsPopup.m @@ -8,26 +8,7 @@ #import "TGBotCommandsPopup.h" #import "TGMenuItemPhoto.h" -@interface TL_botCommand (BotCommandCategory) --(void)setUser:(TL_user *)user; --(TLUser *)user; - -@end - -@implementation TL_botCommand (BotCommandCategory) - -DYNAMIC_PROPERTY(DUser); - --(void)setUser:(TLUser *)user { - [self setDUser:user]; -} - --(TLUser *)user { - return [self getDUser]; -} - -@end @implementation TGBotCommandsPopup @@ -35,73 +16,73 @@ @implementation TGBotCommandsPopup +(void)show:(NSString *)string botInfo:(NSArray *)botInfo view:(NSView *)view ofRect:(NSRect)rect callback:(void (^)(NSString *command))callback { - - NSMenu *menu = [[NSMenu alloc] initWithTitle:@"menu"]; - - - NSMutableArray *commands = [[NSMutableArray alloc] init]; - - [botInfo enumerateObjectsUsingBlock:^(TLBotInfo *obj, NSUInteger idx, BOOL *stop) { - - TLUser *user = [[UsersManager sharedManager] find:obj.user_id]; - - [obj.commands enumerateObjectsUsingBlock:^(TL_botCommand *command, NSUInteger idx, BOOL *stop) { - - NSString *cmd = command.command; - - if([Telegram conversation].type == DialogTypeChat && (user.flags & TGUSERFLAGREADHISTORY) != TGUSERFLAGREADHISTORY) { - cmd = [cmd stringByAppendingString:[NSString stringWithFormat:@"@%@",user.username]]; - } - - TL_botCommand *c = [TL_botCommand createWithCommand:cmd n_description:command.n_description]; - - [c setUser:user]; - - [commands addObject:c]; - - }]; - - }]; - - - commands = string.length > 0 ? [[commands filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.command BEGINSWITH[c] %@",string]] mutableCopy] : commands; - - - [commands enumerateObjectsUsingBlock:^(TL_botCommand *obj, NSUInteger idx, BOOL *stop) { - - - NSMenuItem *item = [NSMenuItem menuItemWithTitle:[NSString stringWithFormat:@"/%@",obj.command] withBlock:^(id sender) { - - callback([obj command]); - - - [self close]; - - }]; - - if(obj.n_description.length > 0) - [item setSubtitle:obj.n_description]; - - item.representedObject = [[TGMenuItemPhoto alloc] initWithUser:obj.user menuItem:item]; - - [menu addItem:item]; - - }]; - - - if(menu.itemArray.count > 0) { - [self close]; - - [self setPopover:[[TMMenuPopover alloc] initWithMenu:menu]]; - - [[self popover] setAutoHighlight:NO]; - - [[self popover] showRelativeToRect:rect ofView:view preferredEdge:CGRectMinYEdge]; - - [[self popover].contentViewController selectNext]; - } else { - [self close]; - } +// +// NSMenu *menu = [[NSMenu alloc] initWithTitle:@"menu"]; +// +// +// NSMutableArray *commands = [[NSMutableArray alloc] init]; +// +// [botInfo enumerateObjectsUsingBlock:^(TLBotInfo *obj, NSUInteger idx, BOOL *stop) { +// +// TLUser *user = [[UsersManager sharedManager] find:obj.user_id]; +// +// [obj.commands enumerateObjectsUsingBlock:^(TL_botCommand *command, NSUInteger idx, BOOL *stop) { +// +// NSString *cmd = command.command; +// +// if([Telegram conversation].type == DialogTypeChat && (user.flags & TGUSERFLAGREADHISTORY) != TGUSERFLAGREADHISTORY) { +// cmd = [cmd stringByAppendingString:[NSString stringWithFormat:@"@%@",user.username]]; +// } +// +// TL_botCommand *c = [TL_botCommand createWithCommand:cmd n_description:command.n_description]; +// +// [c setUser:user]; +// +// [commands addObject:c]; +// +// }]; +// +// }]; +// +// +// commands = string.length > 0 ? [[commands filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.command BEGINSWITH[c] %@",string]] mutableCopy] : commands; +// +// +// [commands enumerateObjectsUsingBlock:^(TL_botCommand *obj, NSUInteger idx, BOOL *stop) { +// +// +// NSMenuItem *item = [NSMenuItem menuItemWithTitle:[NSString stringWithFormat:@"/%@",obj.command] withBlock:^(id sender) { +// +// callback([obj command]); +// +// +// [self close]; +// +// }]; +// +// if(obj.n_description.length > 0) +// [item setSubtitle:obj.n_description]; +// +// item.representedObject = [[TGMenuItemPhoto alloc] initWithUser:obj.user menuItem:item]; +// +// [menu addItem:item]; +// +// }]; +// +// +// if(menu.itemArray.count > 0) { +// [self close]; +// +// [self setPopover:[[TMMenuPopover alloc] initWithMenu:menu]]; +// +// [[self popover] setAutoHighlight:NO]; +// +// [[self popover] showRelativeToRect:rect ofView:view preferredEdge:CGRectMinYEdge]; +// +// [[self popover].contentViewController selectNext]; +// } else { +// [self close]; +// } } diff --git a/TelegramTest/TGCTextView.h b/TelegramTest/TGCTextView.h index bd4bd947..9b4c18ca 100644 --- a/TelegramTest/TGCTextView.h +++ b/TelegramTest/TGCTextView.h @@ -25,7 +25,7 @@ @property (nonatomic,assign,setter=setEditable:) BOOL isEditable; @property (nonatomic,assign,readonly) NSRange selectRange; - +@property (nonatomic,assign) BOOL disableLinks; @property (nonatomic,strong) NSColor *selectColor; @property (nonatomic,strong) NSColor *backgroundColor; @@ -45,7 +45,7 @@ -(BOOL)indexIsSelected:(int)index; - +-(void)open_link:(NSString *)link itsReal:(BOOL)itsReal; // its private not for use diff --git a/TelegramTest/TGCTextView.m b/TelegramTest/TGCTextView.m index 15b8a78c..ec14ae29 100644 --- a/TelegramTest/TGCTextView.m +++ b/TelegramTest/TGCTextView.m @@ -9,6 +9,7 @@ #import "TGCTextView.h" #import "NSString+Extended.h" #import "TGMultipleSelectTextView.h" +#import "MessageTableItemText.h" @interface DrawsRect : NSObject @property(nonatomic,assign) CGColorRef color; @@ -69,37 +70,6 @@ -(void)updateTrackingAreas } -//-(void)updateTrackingAreas { -// -// if(!self.needUpdateTrackingArea) -// return; -// -// -// if(self.trackingArea) { -// [self removeTrackingArea:self.trackingArea]; -// } -// -// self.trackingArea = [[NSTrackingArea alloc] initWithRect:self.bounds -// options: (NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved | NSTrackingActiveInActiveApp | NSTrackingInVisibleRect) -// owner:self userInfo:nil]; -// -// [self addTrackingArea:self.trackingArea]; -// -// self.needUpdateTrackingArea = NO; -//} -// -//-(void)setFrameSize:(NSSize)newSize { -// -// if(newSize.width != self.currentSize.width || newSize.height != self.currentSize.height) { -// self.currentSize = newSize; -// self.needUpdateTrackingArea = YES; -// [super setFrameSize:newSize]; -// } -// -// [self setNeedsDisplay:YES]; -// -//} - -(void)setAttributedString:(NSAttributedString *)attributedString { self->_attributedString = attributedString; @@ -193,11 +163,7 @@ - (void) drawRect:(CGRect)rect CGContextSetShouldSmoothFonts(context, !IS_RETINA); CGContextSetAllowsFontSmoothing(context,!IS_RETINA); - - - - - // CGContextSetFillColorWithColor(context, self.layer.backgroundColor); + NSRectFill(self.bounds); @@ -216,19 +182,18 @@ - (void) drawRect:(CGRect)rect } - - - CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString((CFAttributedStringRef) self.attributedString); if(CTFrame) CFRelease(CTFrame); + + CTFrame = CTFramesetterCreateFrame(framesetter, - CFRangeMake(0, 0), path, NULL); + CFRangeMake(0, 0), path, NULL); - CGContextSaveGState(context); + CGContextSaveGState(context); CTFrameDraw(CTFrame, context); @@ -243,7 +208,6 @@ - (void) drawRect:(CGRect)rect _selectRange = NSMakeRange(NSNotFound, 0); - [self.marks enumerateObjectsUsingBlock:^(TGCTextMark *mark, NSUInteger idx, BOOL *stop) { if( (currentSelectPosition.x != -1 && currentSelectPosition.y != -1) || mark.range.location != NSNotFound) { @@ -371,7 +335,7 @@ - (void) drawRect:(CGRect)rect runBounds.size.width = width; - runBounds.size.height = floor(ascent + ceil(descent) + leading); + runBounds.size.height = ceil(ascent + ceil(descent) + leading); if(runBounds.size.height == 22) runBounds.size.height--; @@ -392,7 +356,7 @@ - (void) drawRect:(CGRect)rect CGContextFillPath(context); CGPathRelease(highlightPath); - + // CFRelease(line); @@ -470,7 +434,7 @@ -(BOOL)isCurrentLine:(NSPoint)position linePosition:(NSPoint)linePosition idx:(i CTLineGetTypographicBounds(line, &ascent, &descent, &leading); - int lineHeight = floor(ascent + ceil(descent) + leading); + int lineHeight = ceil(ascent + ceil(descent) + leading); return (position.y > linePosition.y) && position.y < (linePosition.y + lineHeight); @@ -564,6 +528,11 @@ -(int)currentIndexInLocation:(NSPoint)location { return -1; } +-(void)dealloc { + if(CTFrame) + CFRelease(CTFrame); +} + -(BOOL)indexIsSelected:(int)index { return self.selectRange.location <= index && (self.selectRange.location + self.selectRange.length) > index; } @@ -597,7 +566,7 @@ -(BOOL)_checkClickCount:(NSEvent *)theEvent { _selectRange = NSMakeRange(0, self.attributedString.length); - } else if(theEvent.clickCount == 2) { + } else if(theEvent.clickCount == 2 || (theEvent.type == 3 && _selectRange.location == NSNotFound)) { int startIndex = [self currentIndexInLocation:[self convertPoint:[theEvent locationInWindow] fromView:nil]]; @@ -681,6 +650,7 @@ -(BOOL)_checkClickCount:(NSEvent *)theEvent { -(void)mouseDragged:(NSEvent *)theEvent { + [super mouseDragged:theEvent]; [[NSCursor IBeamCursor] set]; @@ -693,6 +663,8 @@ -(void)_mouseDragged:(NSEvent *)theEvent { if(!_isEditable) return; + + currentSelectPosition = [self convertPoint:[theEvent locationInWindow] fromView:nil]; [self setNeedsDisplay:YES]; @@ -705,9 +677,10 @@ -(void)mouseEntered:(NSEvent *)theEvent { --(NSString *)linkAtPoint:(NSPoint)location hitTest:(BOOL *)hitTest { +-(NSString *)linkAtPoint:(NSPoint)location hitTest:(BOOL *)hitTest itsReal:(BOOL *)itsReal { - + if(_disableLinks) + return nil; if([self mouse:location inRect:self.bounds]) { @@ -743,6 +716,12 @@ -(NSString *)linkAtPoint:(NSPoint)location hitTest:(BOOL *)hitTest { NSDictionary *attrs = [self.attributedString attributesAtIndex:position effectiveRange:&range]; link = [attrs objectForKey:NSLinkAttributeName]; + if(link.length > 0) { + NSString *real = [self.attributedString.string substringWithRange:range]; + + *itsReal = [link isEqualToString:real]; + } + *hitTest = YES; return link; @@ -763,9 +742,9 @@ -(void)checkCursor:(NSEvent *)theEvent { if([self mouse:location inRect:self.bounds]) { - BOOL hitTest; + BOOL hitTest,itsReal; - NSString *link = [self linkAtPoint:location hitTest:&hitTest]; + NSString *link = [self linkAtPoint:location hitTest:&hitTest itsReal:&itsReal]; if(hitTest) { if(link) { @@ -794,14 +773,16 @@ -(void)mouseExited:(NSEvent *)theEvent { -(void)mouseUp:(NSEvent *)theEvent { - if(self.selectRange.location == NSNotFound || !_isEditable) { + + + if((self.selectRange.location == NSNotFound || !_isEditable) && !_disableLinks) { NSPoint location = [self convertPoint:[theEvent locationInWindow] fromView:nil]; - BOOL hitTest; - NSString *link = [self linkAtPoint:location hitTest:&hitTest]; + BOOL hitTest,itsReal; + NSString *link = [self linkAtPoint:location hitTest:&hitTest itsReal:&itsReal]; if(link) { - [self open_link:link]; + [self open_link:link itsReal:itsReal]; } else if(![self _checkClickCount:theEvent]) { [super mouseUp:theEvent]; } @@ -813,13 +794,27 @@ -(void)mouseUp:(NSEvent *)theEvent { [[NSCursor arrowCursor] set]; } --(void)open_link:(NSString *)link { - open_link(link); +-(void)open_link:(NSString *)link itsReal:(BOOL)itsReal { + + itsReal = itsReal || [link rangeOfString:@"USER_PROFILE:"].location != NSNotFound || [link rangeOfString:@"openWithPeer"].location != NSNotFound; + + if(itsReal) { + open_link(link); + } else { + confirm(appName(), [NSString stringWithFormat:@"Open this link: %@?",link], ^{ + + open_link(link); + + }, nil); + } + } -(void)rightMouseDown:(NSEvent *)theEvent { + [self _checkClickCount:theEvent]; + if(self.selectRange.location != NSNotFound) { NSTextView *view = (NSTextView *) [self.window fieldEditor:YES forObject:self]; [view setEditable:NO]; diff --git a/TelegramTest/TGCache.m b/TelegramTest/TGCache.m index 50fe62ed..0552626b 100644 --- a/TelegramTest/TGCache.m +++ b/TelegramTest/TGCache.m @@ -8,7 +8,6 @@ #import "TGCache.h" #import "ASQueue.h" -#import "EMInMemoryImageCache.h" @interface TGCacheRecord : NSObject @property (nonatomic) NSTimeInterval date; @@ -49,8 +48,6 @@ @interface TGCache () @property (nonatomic,strong) ASQueue *queue; -@property (nonatomic,strong) EMInMemoryImageCache *emCache; - @end @@ -70,27 +67,22 @@ -(id)init { _queue = [[ASQueue alloc] initWithName:"tgcachequeue"]; - [_queue dispatchOnQueue:^{ - - _groups = [[NSMutableDictionary alloc] init]; - _groupMemoryTaken = [[NSMutableDictionary alloc] init]; - _groupMemoryLimit = [[NSMutableDictionary alloc] init]; - _groupCountLimit = [[NSMutableDictionary alloc] init]; - NSArray *keys = @[IMGCACHE,THUMBCACHE,PVCACHE,PCCACHE,AVACACHE]; - - [keys enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - - _groupMemoryLimit[obj] = @(defaultMemoryLimit); - _groupMemoryTaken[obj] = @(0); - _groups[obj] = [[NSMutableDictionary alloc] init]; - _groupCountLimit[obj] = @(0); - - }]; + _groups = [[NSMutableDictionary alloc] init]; + _groupMemoryTaken = [[NSMutableDictionary alloc] init]; + _groupMemoryLimit = [[NSMutableDictionary alloc] init]; + _groupCountLimit = [[NSMutableDictionary alloc] init]; + NSArray *keys = @[IMGCACHE,THUMBCACHE,PVCACHE,PCCACHE,AVACACHE]; + + [keys enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - _emCache = [[EMInMemoryImageCache alloc] initWithMaxResidentSize:100*1024*1024]; + _groupMemoryLimit[obj] = @(defaultMemoryLimit); + _groupMemoryTaken[obj] = @(0); + _groups[obj] = [[NSMutableDictionary alloc] init]; + _groupCountLimit[obj] = @(0); - } synchronous:YES]; + }]; + } return self; } @@ -221,10 +213,6 @@ -(void)cacheImage:(NSImage *)image forKey:(NSString *)key groups:(NSArray *)grou } - [_emCache setImageDataWithSize:image.size generator:^(uint8_t *memory, NSUInteger bytesPerRow) { - - - } forKey:[NSString stringWithFormat:@"%@_%@",key,obj]]; _groupMemoryTaken[obj] = @([_groupMemoryTaken[obj] integerValue] + size); diff --git a/TelegramTest/TGCaptionView.h b/TelegramTest/TGCaptionView.h index cfdc4bba..7941fe1b 100644 --- a/TelegramTest/TGCaptionView.h +++ b/TelegramTest/TGCaptionView.h @@ -7,9 +7,14 @@ // #import "TMView.h" +#import "MessageTableItem.h" +#import "TGCTextView.h" +@interface TGCaptionTextView : TGCTextView +@property (nonatomic,weak) MessageTableItem *item; +@end @interface TGCaptionView : TMView -@property (nonatomic,strong,readonly) TGCTextView *textView; +@property (nonatomic,strong,readonly) TGCaptionTextView *textView; -(void)setAttributedString:(NSAttributedString *)string fieldSize:(NSSize)size; - +@property (nonatomic,weak) MessageTableItem *item; @end diff --git a/TelegramTest/TGCaptionView.m b/TelegramTest/TGCaptionView.m index 248c6a43..f11e3c3e 100644 --- a/TelegramTest/TGCaptionView.m +++ b/TelegramTest/TGCaptionView.m @@ -12,6 +12,22 @@ @interface TGCaptionView () @end + + + + +@implementation TGCaptionTextView + +-(void)open_link:(NSString *)link itsReal:(BOOL)itsReal { + if(_item.message.peer_id < 0 && _item.message.fromUser.isBot && [link hasPrefix:TLBotCommandPrefix]) { + link = [NSString stringWithFormat:@"%@@%@",link,_item.message.fromUser.username]; + } + + open_link(link); +} + +@end + @implementation TGCaptionView - (void)drawRect:(NSRect)dirtyRect { @@ -21,7 +37,7 @@ - (void)drawRect:(NSRect)dirtyRect { -(instancetype)initWithFrame:(NSRect)frameRect { if(self = [super initWithFrame:frameRect]) { - _textView = [[TGCTextView alloc] initWithFrame:NSZeroRect]; + _textView = [[TGCaptionTextView alloc] initWithFrame:NSZeroRect]; [_textView setFrameOrigin:NSMakePoint(0, 0)]; [_textView setEditable:YES]; [self addSubview:_textView]; @@ -38,4 +54,9 @@ -(void)setAttributedString:(NSAttributedString *)string fieldSize:(NSSize)size { } +-(void)setItem:(MessageTableItem *)item { + _item = item; + _textView.item = item; +} + @end diff --git a/TelegramTest/TGChangeUserNameContainerView.h b/TelegramTest/TGChangeUserNameContainerView.h new file mode 100644 index 00000000..7d5d46dc --- /dev/null +++ b/TelegramTest/TGChangeUserNameContainerView.h @@ -0,0 +1,42 @@ +// +// TGChangeUserNameContainerView.h +// Telegram +// +// Created by keepcoder on 13.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TMView.h" + + +@interface TGChangeUserObserver : NSObject + +@property (nonatomic,copy) void (^willNeedSaveUserName)(NSString *userName); +@property (nonatomic,copy) void (^didChangedUserName)(NSString *userName,BOOL isAcceptable); + + +@property (nonatomic,strong) NSAttributedString *desc; +@property (nonatomic,strong) NSString *placeholder; +@property (nonatomic,strong) NSString *defaultUserName; + + + + +@property (nonatomic,strong) id (^needApiObjectWithUserName)(NSString *userName); +@property (nonatomic,strong) NSString* (^needDescriptionWithError)(NSString *error); + + +-(id)initWithDescription:(NSAttributedString *)desc placeholder:(NSString *)placeholder defaultUserName:(NSString *)defaultUserName; + +@end + +@interface TGChangeUserNameContainerView : TMView + +@property (nonatomic,strong) TGChangeUserObserver *oberser; + +-(void)dispatchSaveBlock; + +-(instancetype)initWithFrame:(NSRect)frameRect observer:(TGChangeUserObserver *)observer; + + +@end diff --git a/TelegramTest/TGChangeUserNameContainerView.m b/TelegramTest/TGChangeUserNameContainerView.m new file mode 100644 index 00000000..9d4cd261 --- /dev/null +++ b/TelegramTest/TGChangeUserNameContainerView.m @@ -0,0 +1,370 @@ +// +// TGChangeUserNameContainerView.m +// Telegram +// +// Created by keepcoder on 13.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TGChangeUserNameContainerView.h" +#import "UserInfoShortTextEditView.h" +#import "TGTimer.h" + + +@implementation TGChangeUserObserver + +-(id)initWithDescription:(NSAttributedString *)desc placeholder:(NSString *)placeholder defaultUserName:(NSString *)defaultUserName { + if(self = [super init]) { + + _desc = desc; + + _placeholder = placeholder; + _defaultUserName = defaultUserName; + } + + return self; +} + +@end + + +@interface TGChangeUserNameContainerView () +@property (nonatomic,strong) UserInfoShortTextEditView *textView; +@property (nonatomic,strong) TMTextButton *button; +@property (nonatomic,strong) TMTextField *descriptionView; + +@property (nonatomic,strong) NSProgressIndicator *progressView; +@property (nonatomic,strong) NSImageView *successView; +@property (nonatomic,strong) TGTimer *timer; +@property (nonatomic,assign) BOOL isSuccessChecked; +@property (nonatomic,assign) BOOL isRemoteChecked; +@property (nonatomic,strong) NSString *lastUserName; +@property (nonatomic,strong) NSString *checkedUserName; +@property (nonatomic,strong) RPCRequest *request; +@property (nonatomic,strong) TMTextField *telegramHolder; +@property (nonatomic,strong) TMTextField *statusTextField; + +@end + +#define GC NSColorFromRGB(0x61ad5e) + +@implementation TGChangeUserNameContainerView + +-(id)initWithFrame:(NSRect)frameRect observer:(TGChangeUserObserver *)observer { + if(self = [super initWithFrame:frameRect]) { + + + self.isFlipped = YES; + + _oberser = observer; + + self.successView = imageViewWithImage(image_UsernameCheck()); + + self.progressView = [[TGProgressIndicator alloc] initWithFrame:NSMakeRect(0, 0, 15, 15)]; + + [self.progressView setStyle:NSProgressIndicatorSpinningStyle]; + + + self.textView = [[UserInfoShortTextEditView alloc] initWithFrame:NSMakeRect(30, 14, NSWidth(self.frame) - 60, 20)]; + + [self.successView setFrameOrigin:NSMakePoint(NSWidth(self.textView.frame) - NSWidth(self.successView.frame), 8)]; + + [self.progressView setFrameOrigin:NSMakePoint(NSWidth(self.textView.frame) - NSWidth(self.progressView.frame), 5)]; + + self.successView.autoresizingMask = self.progressView.autoresizingMask = NSViewMinXMargin; + + [self.progressView setHidden:YES]; + + [self.successView setHidden:YES]; + + + [self.textView addSubview:self.successView]; + + [self.textView addSubview:self.progressView]; + + + + + self.statusTextField = [TMTextField defaultTextField]; + + [[self.statusTextField cell] setLineBreakMode:0]; + + [self.statusTextField setTextColor:[NSColor redColor]]; + + [self.statusTextField setStringValue:@"error cant set user name"]; + + [self.statusTextField sizeToFit]; + + [self.statusTextField setFrameOrigin:NSMakePoint(30, NSMaxY(_textView.frame) + 5)]; + + [self addSubview:self.statusTextField]; + + + _telegramHolder = [TMTextField defaultTextField]; + [_telegramHolder setStringValue:@"telegram.me/"]; + [_telegramHolder setFont:TGSystemFont(15)]; + [_telegramHolder setTextColor:TEXT_COLOR]; + [_telegramHolder sizeToFit]; + + [_telegramHolder setFrameOrigin:NSMakePoint(0, 2)]; + [self.textView addSubview:_telegramHolder]; + [self.textView.textView setFrameOrigin:NSMakePoint(NSMaxX(_telegramHolder.frame) - 5, 1)]; + + + NSMutableAttributedString *str = [[NSMutableAttributedString alloc] init]; + + [str appendString:NSLocalizedString(@"UserName.placeHolder", nil) withColor:DARK_GRAY]; + [str setAlignment:NSLeftTextAlignment range:str.range]; + [str setFont:TGSystemFont(15) forRange:str.range]; + + [[self.textView textView].cell setPlaceholderAttributedString:str]; + [[self.textView textView] setPlaceholderPoint:NSMakePoint(0, 0)]; + + self.textView.textView.delegate = self; + + [self addSubview:self.textView]; + + [self.textView.textView setAction:@selector(performEnter)]; + [self.textView.textView setTarget:self]; + [self.textView.textView setNextKeyView:self]; + [self.textView.textView setFrameOrigin:NSMakePoint(NSMaxX(_telegramHolder.frame) - 5, NSMinY(self.textView.textView.frame))]; + [self.textView.textView setFrameSize:NSMakeSize(NSWidth(self.textView.textView.frame), 20)]; + + self.descriptionView = [[TMTextField alloc] initWithFrame:NSMakeRect(26, NSMaxY(_textView.frame), NSWidth(self.frame) - 60, 100)]; + + [self.descriptionView setStringValue:NSLocalizedString(@"UserName.description", nil)]; + + [self.descriptionView setFont:TGSystemFont(12)]; + + [self.descriptionView sizeToFit]; + [self.descriptionView setSelectable:NO]; + [self.descriptionView setBordered:NO]; + [self.descriptionView setDrawsBackground:NO]; + [self addSubview:self.descriptionView]; + + + } + + return self; +} + +-(void)setOberser:(TGChangeUserObserver *)oberser { + _oberser = oberser; + + + + [_descriptionView setAttributedStringValue:oberser.desc]; + [_descriptionView sizeToFit]; + + NSMutableAttributedString *str = [[NSMutableAttributedString alloc] init]; + + [str appendString:oberser.placeholder withColor:DARK_GRAY]; + [str setAlignment:NSLeftTextAlignment range:str.range]; + [str setFont:TGSystemFont(15) forRange:str.range]; + + [[self.textView textView].cell setPlaceholderAttributedString:str]; + + + [self.textView.textView setStringValue:oberser.defaultUserName]; + self.checkedUserName = oberser.defaultUserName; + + [self updateChecker]; + + [self setFrameSize:self.frame.size]; + + // update interface +} + +-(void)dispatchSaveBlock { + [self performEnter]; +} + + +- (void)performEnter { + if([self accept]) { + [self.textView.textView resignFirstResponder]; + if(self.oberser.willNeedSaveUserName != nil) { + self.oberser.willNeedSaveUserName(self.textView.textView.stringValue); + } + } +} + +-(BOOL)accept { + return [[self defaultUsername] isEqualToString:self.textView.textView.stringValue] || (self.isRemoteChecked && self.isSuccessChecked) || self.textView.textView.stringValue.length == 0; +} + +-(void)updateSaveButton { + + + if(self.oberser.didChangedUserName != nil) { + self.oberser.didChangedUserName(self.textView.textView.stringValue,[self accept]); + } + +} + + + +- (void)controlTextDidChange:(NSNotification *)obj { + + [self.textView.textView setStringValue:[self.textView.textView.stringValue substringToIndex:MIN(40,self.textView.textView.stringValue.length)]]; + + if((self.textView.textView.stringValue.length >= 5 && [self isNumberValid]) || self.textView.textView.stringValue.length == 0) { + [self updateChecker]; + } else { + [self.progressView setHidden:YES]; + [self.progressView stopAnimation:self]; + [self.successView setHidden:YES]; + + self.isRemoteChecked = NO; + self.isSuccessChecked = NO; + + + if(![self isNumberValid]) { + [self setState:[self errorWithKey:@"USERNAME_CANT_FIRST_NUMBER"] color:[NSColor redColor]]; + } else { + [self setState:[self errorWithKey:@"USERNAME_MIN_SYMBOLS_ERROR"] color:[NSColor redColor]]; + } + + } + + [self updateSaveButton]; + +} + +-(BOOL)isNumberValid { + NSCharacterSet* nonNumbers = [[NSCharacterSet decimalDigitCharacterSet] invertedSet]; + NSRange r = [self.textView.textView.stringValue rangeOfCharacterFromSet: nonNumbers]; + + return r.location == 0; +} + +-(NSString *)defaultUsername { + return self.oberser.defaultUserName; +} + + +-(void)updateChecker { + + if([self.textView.textView.stringValue isEqualToString:[self defaultUsername]]) { + [self.progressView setHidden:YES]; + [self.progressView stopAnimation:self]; + [self.successView setHidden:self.textView.textView.stringValue.length == 0]; + + [self setState:nil color:nil]; + + [self updateSaveButton]; + + } else if(![self.lastUserName isEqualToString:self.textView.textView.stringValue] && self.textView.textView.stringValue.length != 0) { + + if(!self.timer) { + + self.isSuccessChecked = NO; + self.isRemoteChecked = [self.textView.textView.stringValue isEqualToString:[self defaultUsername]]; + [self updateSaveButton]; + + self.timer = [[TGTimer alloc] initWithTimeout:0.2 repeat:NO completion:^{ + + + + [self.successView setHidden:YES]; + [self.progressView setHidden:NO]; + [self.progressView startAnimation:self]; + + if(self.request) + [self.request cancelRequest]; + + + if([[self defaultUsername] isEqualToString:self.textView.textView.stringValue]) + { + [self updateChecker]; + return; + } + + NSString *userNameToCheck = self.lastUserName; + + + + self.request = [RPCRequest sendRequest:self.oberser.needApiObjectWithUserName(userNameToCheck) successHandler:^(RPCRequest *request, id response) { + + self.isSuccessChecked = [response isKindOfClass:[TL_boolTrue class]]; + self.isRemoteChecked = YES; + self.checkedUserName = userNameToCheck; + + + if(self.isSuccessChecked) { + [self setState:self.checkedUserName.length > 0 ? [NSString stringWithFormat:[self errorWithKey:@"UserName.avaiable"],self.checkedUserName] : nil color:GC]; + } else { + [self setState:[self errorWithKey:@"USERNAME_IS_ALREADY_TAKEN"] color:[NSColor redColor]]; + } + + + + [self updateSaveButton]; + + [self.progressView setHidden:YES]; + [self.progressView stopAnimation:self]; + + [self.successView setHidden:!self.isSuccessChecked]; + + } errorHandler:^(RPCRequest *request, RpcError *error) { + + [self.progressView setHidden:YES]; + [self.progressView stopAnimation:self]; + + [self.successView setHidden:YES]; + + [self setState:[self errorWithKey:error.error_msg] color:[NSColor redColor]]; + + }]; + + + } queue:dispatch_get_current_queue()]; + + [self.timer start]; + + } else { + [self.timer invalidate]; + self.timer = nil; + [self updateChecker]; + } + + + } else { + [self setState:nil color:nil]; + [self updateSaveButton]; + } + + self.lastUserName = self.textView.textView.stringValue; + +} + +-(NSString *)errorWithKey:(NSString *)key { + if(self.oberser.needDescriptionWithError != nil) { + return self.oberser.needDescriptionWithError(key); + } + + return NSLocalizedString(key, nil); +} + +-(void)setState:(NSString *)state color:(NSColor *)color { + [self.statusTextField setHidden:state.length == 0 || color == nil]; + self.statusTextField.stringValue = state; + self.statusTextField.textColor = color; + + + [self setFrameSize:self.frame.size]; +} + +-(void)setFrameSize:(NSSize)newSize { + [super setFrameSize:newSize]; + + NSSize size = [self.descriptionView.attributedStringValue sizeForTextFieldForWidth:newSize.width - 60]; + + [self.descriptionView setFrameSize:NSMakeSize(newSize.width - 60, size.height)]; + + [self.statusTextField setFrameSize:[self.statusTextField.attributedStringValue sizeForTextFieldForWidth:NSWidth(self.descriptionView.frame)]]; + [self.descriptionView setFrameOrigin:NSMakePoint(30, !self.statusTextField.isHidden ? NSMaxY(_statusTextField.frame) : NSMaxY(_textView.frame))]; +} + +@end + diff --git a/TelegramTest/TGChannelsPolling.h b/TelegramTest/TGChannelsPolling.h new file mode 100644 index 00000000..78c00f6b --- /dev/null +++ b/TelegramTest/TGChannelsPolling.h @@ -0,0 +1,34 @@ +// +// TGChannelsPolling.h +// Telegram +// +// Created by keepcoder on 27.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import + +@protocol TGChannelPollingDelegate + +-(void)pollingDidSaidTooLongWithHole:(TGMessageHole *)hole; + +-(void)pollingReceivedUpdates:(id)updates endPts:(int)pts; + +@end + +@interface TGChannelsPolling : NSObject + +@property (nonatomic,weak) id delegate; + +@property (nonatomic,assign,readonly) BOOL isActive; + +-(id)initWithDelegate:(id )delegate withUpdatesLimit:(int)limit; + +-(void)setCurrentConversation:(TL_conversation *)conversation; + +-(void)start; +-(void)stop; + +-(void)checkInvalidatedMessages:(NSArray *)result important:(BOOL)important; + +@end diff --git a/TelegramTest/TGChannelsPolling.m b/TelegramTest/TGChannelsPolling.m new file mode 100644 index 00000000..10264dc5 --- /dev/null +++ b/TelegramTest/TGChannelsPolling.m @@ -0,0 +1,182 @@ +// +// TGChannelsPolling.m +// Telegram +// +// Created by keepcoder on 27.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TGChannelsPolling.h" +#import "TGTimer.h" +#import "TGForceChannelUpdate.h" +@interface TGChannelsPolling () +@property (nonatomic,strong) TL_conversation *conversation; +@property (nonatomic,assign) int pts; +@property (nonatomic,assign) int limit; +@property (nonatomic,strong) TGTimer *timer; +@property (nonatomic,strong) RPCRequest *request; +@property (nonatomic,strong) NSMutableDictionary *lastRequestTime; + +@property (nonatomic,assign) BOOL isStoped; + +@end + +@implementation TGChannelsPolling + +static int pollingDelay = 5; + +-(id)initWithDelegate:(id )delegate withUpdatesLimit:(int)limit { + if(self = [super init]) { + _delegate = delegate; + _limit = limit; + _lastRequestTime = [NSMutableDictionary dictionary]; + } + + return self; +} + + +-(BOOL)isActive { + return !_isStoped; +} + +-(void)setCurrentConversation:(TL_conversation *)conversation { + + [ASQueue dispatchOnStageQueue:^{ + + [self stop]; + + _conversation = conversation; + + + }]; + +} + +-(void)stop { + [ASQueue dispatchOnStageQueue:^{ + [_request cancelRequest]; + [_timer invalidate]; + _timer = nil; + _isStoped = YES; + }]; + + +} + +-(void)start { + + [ASQueue dispatchOnStageQueue:^{ + [self stop]; + + _isStoped = NO; + + int time = [_lastRequestTime[@(_conversation.peer_id)] intValue]; + + + int dif = time; + + if(dif != 0) + dif = MIN(time + pollingDelay - [[MTNetwork instance] getTime],pollingDelay); + + [self launchTimer:dif repeat:NO]; + + + }]; + + +} + +-(void)launchTimer:(int)time repeat:(BOOL)repeat { + + _timer = [[TGTimer alloc] initWithTimeout:time repeat:repeat completion:^{ + + [[MTNetwork instance].updateService.proccessor failUpdateWithChannelId:_conversation.peer.channel_id limit:_limit withCallback:^(id response, TGMessageHole *longHole) { + + [ASQueue dispatchOnStageQueue:^{ + + _lastRequestTime[@(_conversation.peer_id)] = @([[MTNetwork instance] getTime]); + + if([response isKindOfClass:[TL_updates_channelDifferenceEmpty class]]) { + + + } else if([response isKindOfClass:[TL_updates_channelDifference class]]) { + + } else if([response isKindOfClass:[TL_updates_channelDifferenceTooLong class]]) { + + [_delegate pollingDidSaidTooLongWithHole:longHole]; + } + + if(!repeat && !_isStoped) + [self launchTimer:[response timeout] repeat:YES]; + + }]; + + + } errorCallback:^(RpcError *error) { + if(!repeat && !_isStoped) + [self launchTimer:15 repeat:YES]; + }]; + + + } queue:[ASQueue globalQueue].nativeQueue]; + + [_timer start]; + +} + + +-(void)checkInvalidatedMessages:(NSArray *)result important:(BOOL)important { + + + + + result = [result filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.n_id > 0"]]; + + BOOL invalidate = [result filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.invalidate == 1"]].count > 0; + + + + if(!invalidate || _conversation.pts == 0 || result.count == 0) + { + return; + } + + TL_localMessage *firstObject = [result firstObject]; + TL_localMessage *lastObject = [result lastObject]; + + int pts = lastObject.n_id; + + int limit = _conversation.pts - pts; + + + [RPCRequest sendRequest:[TLAPI_updates_getChannelDifference createWithChannel:[TL_inputChannel createWithChannel_id:_conversation.chat.n_id access_hash:_conversation.chat.access_hash] filter:[TL_channelMessagesFilter createWithFlags:important ? (1 << 0) : 0 ranges:[@[[TL_messageRange createWithMin_id:lastObject.n_id max_id:firstObject.n_id]] mutableCopy]] pts:pts limit:limit] successHandler:^(id request, TL_updates_channelDifference *response) { + + + if([response isKindOfClass:[TL_updates_channelDifference class]]) { + [response.other_updates enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + + [[MTNetwork instance].updateService.proccessor addUpdate:[[TGForceChannelUpdate alloc] initWithUpdate:obj]]; + + }]; + + } + + NSMutableArray *ids = [NSMutableArray array]; + + [result enumerateObjectsUsingBlock:^(TL_localMessage *obj, NSUInteger idx, BOOL *stop) { + [ids addObject:@(obj.channelMsgId)]; + }]; + + [[Storage manager] validateChannelMessages:ids]; + + + } errorHandler:^(id request, RpcError *error) { + + + } timeout:0 queue:dispatch_get_current_queue()]; + +} + + +@end diff --git a/TelegramTest/TGChatHeadLockView.h b/TelegramTest/TGChatHeadLockView.h new file mode 100644 index 00000000..4441a8dc --- /dev/null +++ b/TelegramTest/TGChatHeadLockView.h @@ -0,0 +1,13 @@ +// +// TGChatHeadLockView.h +// Telegram +// +// Created by keepcoder on 23.10.15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "TMView.h" + +@interface TGChatHeadLockView : TMView + +@end diff --git a/TelegramTest/TGChatHeadLockView.m b/TelegramTest/TGChatHeadLockView.m new file mode 100644 index 00000000..fc7b948e --- /dev/null +++ b/TelegramTest/TGChatHeadLockView.m @@ -0,0 +1,54 @@ +// +// TGChatHeadLockView.m +// Telegram +// +// Created by keepcoder on 23.10.15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "TGChatHeadLockView.h" + +@interface TGChatHeadLockView () +@property (nonatomic,strong) TMTextField *textField; +@end + +@implementation TGChatHeadLockView + +- (void)drawRect:(NSRect)dirtyRect { + [super drawRect:dirtyRect]; + + // Drawing code here. +} + +-(id)initWithFrame:(NSRect)frameRect { + if(self = [super initWithFrame:frameRect]) { + _textField = [TMTextField defaultTextField]; + + [_textField setStringValue:NSLocalizedString(@"LockedChatHead.Description", nil)]; + [_textField setFont:TGSystemBoldFont(13)]; + [[_textField cell] setLineBreakMode:NSLineBreakByWordWrapping]; + [_textField setTextColor:GRAY_TEXT_COLOR]; + + [self addSubview:_textField]; + + [_textField setAlignment:NSCenterTextAlignment]; + + self.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable; + + self.backgroundColor = [NSColor whiteColor]; + + [self setFrameSize:self.frame.size]; + } + + return self; +} + +-(void)setFrameSize:(NSSize)newSize { + [super setFrameSize:newSize]; + + [_textField setFrameSize:[_textField.attributedStringValue sizeForTextFieldForWidth:newSize.width - 20]]; + + [_textField setCenterByView:_textField.superview]; +} + +@end diff --git a/TelegramTest/TGConversation.h b/TelegramTest/TGConversation.h new file mode 100644 index 00000000..385660ae --- /dev/null +++ b/TelegramTest/TGConversation.h @@ -0,0 +1,12 @@ +// +// TGConversation.h +// Telegram +// +// Created by keepcoder on 04.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TLObject.h" + +@interface TGConversation : TLObject +@end diff --git a/TelegramTest/TGConversation.m b/TelegramTest/TGConversation.m new file mode 100644 index 00000000..88f915ca --- /dev/null +++ b/TelegramTest/TGConversation.m @@ -0,0 +1,13 @@ +// +// TGConversation.m +// Telegram +// +// Created by keepcoder on 04.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TGConversation.h" + +@implementation TGConversation + +@end diff --git a/TelegramTest/TGConversationTableCell.m b/TelegramTest/TGConversationTableCell.m index 90adc247..c4fa8e55 100644 --- a/TelegramTest/TGConversationTableCell.m +++ b/TelegramTest/TGConversationTableCell.m @@ -14,6 +14,7 @@ @interface ShortUnread : NSView @property (nonatomic, strong) NSString *unreadCount; @property (nonatomic) NSSize undreadSize; +@property (nonatomic,strong) NSColor *color; @end @implementation ShortUnread @@ -23,7 +24,7 @@ @implementation ShortUnread static NSDictionary *dictionary; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - dictionary = @{NSFontAttributeName: [NSFont fontWithName:@"HelveticaNeue-Bold" size:11], NSForegroundColorAttributeName:NSColorFromRGB(0xfafafa)}; + dictionary = @{NSFontAttributeName: TGSystemBoldFont(11), NSForegroundColorAttributeName:NSColorFromRGB(0xfafafa)}; }); return dictionary; } @@ -65,7 +66,8 @@ - (void)drawRect:(NSRect)dirtyRect { [[NSColor whiteColor] setStroke]; [path stroke]; - [NSColorFromRGB(0x4ba3e2) setFill]; + + [_color setFill]; [path fill]; [[NSColor whiteColor] set]; @@ -145,7 +147,7 @@ -(BOOL)performDragOperation:(id)sender { TL_conversation *conversation = [(TGConversationTableItem *)self.rowItem conversation]; - [[Telegram rightViewController] showByDialog:conversation sender:self]; + [appWindow().navigationController showMessagesViewController:conversation]; [MessageSender sendDraggedFiles:sender dialog:conversation asDocument:NO]; @@ -173,7 +175,7 @@ -(instancetype)initWithFrame:(NSRect)frameRect { _nameTextField = [[TMNameTextField alloc] init]; - [_nameTextField setFrameOrigin:NSMakePoint(68, 40)]; + [_nameTextField setFrameOrigin:NSMakePoint(68, 36)]; [[_nameTextField cell] setLineBreakMode:NSLineBreakByTruncatingTail]; [[_nameTextField cell] setTruncatesLastVisibleLine:YES]; @@ -181,6 +183,9 @@ -(instancetype)initWithFrame:(NSRect)frameRect { _nameTextField.wantsLayer = YES; +// [_nameTextField setBackgroundColor:[NSColor redColor]]; +// [_nameTextField setDrawsBackground:YES]; + _messageField = [TMTextField defaultTextField]; [_messageField setFrameOrigin:NSMakePoint(68, 3)]; @@ -194,10 +199,10 @@ -(instancetype)initWithFrame:(NSRect)frameRect { _dateField = [TMTextField defaultTextField]; - [_dateField setFrameOrigin:NSMakePoint(0, 46)]; + [_dateField setFrameOrigin:NSMakePoint(0, 40)]; _dateField.wantsLayer = YES; - [_dateField setFont:[NSFont fontWithName:@"HelveticaNeue" size:12]]; + [_dateField setFont:TGSystemFont(12)]; @@ -238,12 +243,15 @@ -(instancetype)initWithFrame:(NSRect)frameRect { NSRectFill(NSMakeRect(0, 0, self.bounds.size.width, self.bounds.size.height)); } - // - if(self.item.unreadText.length && self.style != ConversationTableCellShortStyle && self.item.conversation.unread_count > 0 && self.item.conversation.lastMessage.from_id != [UsersManager currentUserId]) - [self drawUnreadCount]; + if(self.item.conversation.isVerified) { + [self.isSelected ? image_VerifyWhite() : image_Verify() drawInRect:NSMakeRect(NSMaxX(self.nameTextField.frame),NSMinY(self.nameTextField.frame) + 6, image_Verify().size.width, image_Verify().size.height) fromRect:NSZeroRect operation:NSCompositeHighlight fraction:1]; + } + // + if(self.item.unreadText.length && self.style != ConversationTableCellShortStyle && self.item.conversation.unread_count > 0) + [self drawUnreadCount]; }; @@ -266,20 +274,25 @@ -(void)setFrameSize:(NSSize)newSize { [super setFrameSize:newSize]; + [self updateFrames]; } + -(void)updateFrames { + NSValue *point = [self stateImage][@"point"]; + [_swipe setFrameSize:self.frame.size]; self.style = NSWidth(self.frame) == 70 ? ConversationTableCellShortStyle : ConversationTableCellFullStyle; - [_nameTextField setFrameSize:NSMakeSize(NSWidth(self.frame) - NSMinX(_nameTextField.frame) - NSWidth(_dateField.frame) - 10 - (self.item.message.n_out ? 18 : 0), 23)]; + + [_nameTextField setFrameSize:NSMakeSize(MIN(NSWidth(self.frame) - NSMinX(_nameTextField.frame) - NSWidth(_dateField.frame) - 10 - (self.item.message.n_out ? 18 : 0), self.item.nameTextSize.width), 23)]; [_messageField setFrameSize:NSMakeSize(NSWidth(self.frame) - NSMinX(_messageField.frame) -40, 36)]; [_dateField setFrameOrigin:NSMakePoint(self.bounds.size.width - self.item.dateSize.width - 10, _dateField.frame.origin.y)]; - NSValue *point = [self stateImage][@"point"]; + point = [self stateImage][@"point"]; if(point) { [_stateImageView setFrame:NSMakeRect([point pointValue].x, [point pointValue].y, NSWidth(_stateImageView.frame), NSHeight(_stateImageView.frame))]; @@ -294,6 +307,7 @@ -(void)updateFrames { [self.layer addSublayer:_shortUnread.layer]; } + _shortUnread.color = self.item.conversation.isMute && ![SettingsArchiver checkMaskedSetting:IncludeMutedUnreadCount] ? NSColorFromRGB(0xd7d7d7) : NSColorFromRGB(0x4ba3e2); [_shortUnread setUnreadCount:self.item.unreadText]; } else { @@ -307,7 +321,7 @@ -(void)updateFrames { -(void)checkMessageState { - if(self.item.typing) { + if(self.item.typing.length > 0) { [self startAnimation]; } else { [_messageField setAttributedStringValue:self.item.messageText]; @@ -332,11 +346,19 @@ -(void)startAnimation { [attr appendString:[NSString stringWithFormat:@"%@%@",self.item.typing,_dots] withColor:GRAY_TEXT_COLOR]; [attr setSelectionColor:[NSColor whiteColor] forColor:GRAY_TEXT_COLOR]; - [attr setFont:[NSFont fontWithName:@"HelveticaNeue" size:13] forRange:attr.range]; + [attr setFont:TGSystemFont(13) forRange:attr.range]; [attr setSelected:self.isSelected]; + + [_messageField setAttributedStringValue:attr]; + if(self.item.typing.length == 0) { + [_timer invalidate]; + _timer = nil; + [self checkMessageState]; + } + } queue:[ASQueue mainQueue].nativeQueue]; [_timer start]; @@ -392,7 +414,7 @@ -(void)setItem:(TGConversationTableItem *)item { [self.dateField setAttributedStringValue:item.dateText]; - [self.dateField setFrameSize:item.dateSize]; + [self.dateField setFrameSize:NSMakeSize(item.dateSize.width, 18)]; NSDictionary *stateImage = [self stateImage]; @@ -412,7 +434,7 @@ -(void)setItem:(TGConversationTableItem *)item { _stateImageView = nil; } - + [self updateFrames]; @@ -428,7 +450,6 @@ -(NSDictionary *)stateImage { NSPoint point; - if(self.style != ConversationTableCellShortStyle) { if(self.item.message.dstate == DeliveryStateNormal) { if(!self.item.message.unread) { @@ -437,25 +458,24 @@ -(NSDictionary *)stateImage { stateImage = self.isSelected ? image_MessageStateSentWhite() : image_MessageStateSent(); } - point = NSMakePoint(NSMinX(self.dateField.frame) - stateImage.size.width , NSHeight(self.frame) - stateImage.size.height - 10); + point = NSMakePoint(NSMinX(self.dateField.frame) - stateImage.size.width , NSHeight(self.frame) - stateImage.size.height - 12); } else if(self.item.message.dstate == DeliveryStateError) { stateImage = self.isSelected ? image_DialogSelectedSendError() : image_ChatMessageError() ; - point = NSMakePoint(NSWidth(self.frame) - stateImage.size.width - 13, 6); + point = NSMakePoint(NSWidth(self.frame) - stateImage.size.width - 13, 10); } else if(self.item.message.dstate == DeliveryStatePending) { stateImage = self.isSelected ? image_SendingClockWhite() : image_SendingClockGray(); - point = NSMakePoint(NSMinX(self.dateField.frame) - stateImage.size.width -2, NSHeight(self.frame) - stateImage.size.height - 9); + point = NSMakePoint(NSMinX(self.dateField.frame) - stateImage.size.width -2, NSHeight(self.frame) - stateImage.size.height - 11); } return @{@"image":stateImage,@"point":[NSValue valueWithPoint:point]}; - } } return nil; @@ -463,9 +483,6 @@ -(NSDictionary *)stateImage { -(void)setStyle:(ConversationTableCellStyle)style { - if(_style == style) - return; - _style = style; [_nameTextField setHidden:style == ConversationTableCellShortStyle]; @@ -477,7 +494,7 @@ -(void)setStyle:(ConversationTableCellStyle)style { - (void)drawRect:(NSRect)dirtyRect { - + } @@ -513,13 +530,16 @@ - (void)drawUnreadCount { [NSColorFromRGB(0xffffff) set]; } else { - [NSColorFromRGB(0x4ba3e2) set]; + if(!self.item.conversation.isMute || [SettingsArchiver checkMaskedSetting:IncludeMutedUnreadCount]) + [NSColorFromRGB(0x4ba3e2) set]; + else + [NSColorFromRGB(0xd7d7d7) set]; } [path fill]; [path closePath]; int offsetX = (sizeWidth - self.item.unreadTextSize.width)/2; - [self.item.unreadText drawAtPoint:CGPointMake(offset1 - unreadCountRadius + offsetX, offsetY + 3) withAttributes:@{NSForegroundColorAttributeName: self.isSelected ? NSColorFromRGB(0x6896ba) : [NSColor whiteColor], NSFontAttributeName: [NSFont fontWithName:@"HelveticaNeue-Bold" size:11]}]; + [self.item.unreadText drawAtPoint:CGPointMake(offset1 - unreadCountRadius + offsetX, offsetY + 3) withAttributes:@{NSForegroundColorAttributeName: self.isSelected ? NSColorFromRGB(0x6896ba) : [NSColor whiteColor], NSFontAttributeName: TGSystemBoldFont(11)}]; } -(BOOL)isSelected { diff --git a/TelegramTest/TGConversationTableItem.h b/TelegramTest/TGConversationTableItem.h index 9e2b2733..66db120c 100644 --- a/TelegramTest/TGConversationTableItem.h +++ b/TelegramTest/TGConversationTableItem.h @@ -11,8 +11,6 @@ @interface TGConversationTableItem : TMRowItem -@property (nonatomic,weak) TMTableView *table; - @property (nonatomic,strong,readonly) TL_conversation *conversation; -(TL_localMessage *)message; @@ -20,6 +18,10 @@ @property (nonatomic,strong,readonly) NSMutableAttributedString *messageText; @property (nonatomic,strong,readonly) NSMutableAttributedString *dateText; + + +@property (nonatomic,assign) NSSize nameTextSize; + @property (nonatomic,strong,readonly) NSString *selectText; @property (nonatomic, strong,readonly) NSString *unreadText; @@ -35,6 +37,5 @@ -(void)needUpdateMessage:(NSNotification *)notification; --(void)update; -(void)performReload; @end diff --git a/TelegramTest/TGConversationTableItem.m b/TelegramTest/TGConversationTableItem.m index aac595f0..a1ade6f9 100644 --- a/TelegramTest/TGConversationTableItem.m +++ b/TelegramTest/TGConversationTableItem.m @@ -19,7 +19,7 @@ @implementation TGConversationTableItem -(id)initWithConversation:(TL_conversation *)conversation { if(self = [super init]) { - self.conversation = [[DialogsManager sharedManager] find:conversation.peer_id]; + self.conversation = conversation; [Notification addObserver:self selector:@selector(needUpdateMessage:) name:[Notification notificationNameByDialog:conversation action:@"message"]]; @@ -28,10 +28,8 @@ -(id)initWithConversation:(TL_conversation *)conversation { [Notification addObserver:self selector:@selector(didChangeNotifications:) name:[Notification notificationNameByDialog:conversation action:@"notification"]]; - [self needUpdateMessage:[[NSNotification alloc] initWithName:@"" object:nil userInfo:@{KEY_LAST_CONVRESATION_DATA:[MessagesUtils conversationLastData:conversation]}]]; + [self needUpdateMessage:[[NSNotification alloc] initWithName:@"" object:nil userInfo:@{KEY_LAST_CONVRESATION_DATA:[MessagesUtils conversationLastData:conversation],KEY_DIALOG:conversation,KEY_DIALOG:conversation}]]; - [self didChangeTyping:nil]; - } return self; @@ -44,19 +42,38 @@ -(void)didChangeNotifications:(NSNotification *)notification { -(void)needUpdateMessage:(NSNotification *)notification { + _conversation = notification.userInfo[KEY_DIALOG]; + + assert(_conversation != nil); + _checkMessage = self.conversation.lastMessage; - _messageText = notification.userInfo[KEY_LAST_CONVRESATION_DATA][@"messageText"]; + + _messageText = notification.userInfo[KEY_LAST_CONVRESATION_DATA][@"messageText"]; _dateText = notification.userInfo[KEY_LAST_CONVRESATION_DATA][@"dateText"]; _dateSize = [notification.userInfo[KEY_LAST_CONVRESATION_DATA][@"dateSize"] sizeValue]; _unreadText = notification.userInfo[KEY_LAST_CONVRESATION_DATA][@"unreadText"]; _unreadTextSize = [notification.userInfo[KEY_LAST_CONVRESATION_DATA][@"unreadTextSize"] sizeValue]; + + if(self.conversation.type != DialogTypeSecretChat && self.conversation.chat) + self.nameTextSize = [self.conversation.chat dialogTitleSize]; + else if(self.conversation.type == DialogTypeSecretChat) + self.nameTextSize = [self.conversation.user dialogEncryptedTitleSize]; + else + self.nameTextSize = [self.conversation.user dialogTitleSize]; + + + BOOL isNotForReload = [notification.userInfo[@"isNotForReload"] boolValue]; if(!isNotForReload) [self performReload]; } +-(NSSize)nameTextSize { + return NSMakeSize(_nameTextSize.width + (self.conversation.isMute ? 20 : 0), _nameTextSize.height);; +} + -(BOOL)itemIsUpdated { return _checkMessage == self.conversation.lastMessage; } @@ -64,11 +81,7 @@ -(BOOL)itemIsUpdated { -(void)didChangeTyping:(NSNotification *)notify { NSArray *actions; - if(!notify) { - actions = [[TGModernTypingManager typingForConversation:_conversation] currentActions]; - } else { - actions = notify.userInfo[@"users"]; - } + actions = notify.userInfo[@"users"]; if(actions.count > 0) { @@ -78,9 +91,12 @@ -(void)didChangeTyping:(NSNotification *)notify { TGActionTyping *action = actions[0]; - TLUser *user = [[UsersManager sharedManager] find:action.user_id]; - if(user) - string =[NSString stringWithFormat:NSLocalizedString(NSStringFromClass(action.action.class), nil),user.dialogFullName]; + if(action.user && _conversation.type != DialogTypeUser && _conversation.type != DialogTypeSecretChat) { + string =[NSString stringWithFormat:NSLocalizedString(NSStringFromClass(action.action.class), nil),action.user.dialogFullName]; + } else { + string = NSLocalizedString(@"Typing.Typing", nil); + } + } else { diff --git a/TelegramTest/TGConversationsTableView.m b/TelegramTest/TGConversationsTableView.m index 3e11bd24..eebf2e6b 100644 --- a/TelegramTest/TGConversationsTableView.m +++ b/TelegramTest/TGConversationsTableView.m @@ -56,33 +56,6 @@ - (void)setFrameSize:(NSSize)newSize { [[Telegram leftViewController].archiver save]; - if([self inLiveResize]) { - NSRange visibleRows = [self.tableView rowsInRect:self.tableView.scrollView.contentView.bounds]; - if(visibleRows.length > 0) { - [NSAnimationContext beginGrouping]; - [[NSAnimationContext currentContext] setDuration:0]; - - NSInteger count = visibleRows.location + visibleRows.length; - for(NSInteger i = visibleRows.location; i < count; i++) { - - TGConversationTableCell *view = [self.tableView viewAtColumn:0 row:i makeIfNecessary:NO]; - - if([view isKindOfClass:[TGConversationTableCell class]]) - [view updateFrames]; - else - [view redrawRow]; - - } - - [NSAnimationContext endGrouping]; - } - - - - - } else { - - } } -(void)viewDidEndLiveResize { @@ -158,7 +131,6 @@ - (void)selectRowIndexes:(NSIndexSet *)indexes byExtendingSelection:(BOOL)extend -(void)setFrameSize:(NSSize)newSize { [super setFrameSize:newSize]; - } - (BOOL)canSelectItem { diff --git a/TelegramTest/TGConversationsViewController.m b/TelegramTest/TGConversationsViewController.m index c7eea921..2c46891d 100644 --- a/TelegramTest/TGConversationsViewController.m +++ b/TelegramTest/TGConversationsViewController.m @@ -8,7 +8,6 @@ #import "TGConversationsViewController.h" #import "TGSecretAction.h" -#import "DialogsHistoryController.h" #import "SearchViewController.h" #import "SelfDestructionController.h" #import "TGModernTypingManager.h" @@ -19,7 +18,8 @@ #import "TGConversationTableCell.h" #import "TGConversationsTableView.h" #import "MessagesUtils.h" - +#import "TGModernConversationHistoryController.h" +#import "TGHeadChatPanel.h" @interface TestView : TMView @end @@ -32,11 +32,13 @@ -(void)mouseDown:(NSEvent *)theEvent { @end -@interface TGConversationsViewController () -@property (nonatomic, strong) DialogsHistoryController *history; +@interface TGConversationsViewController () +@property (nonatomic, strong) TGModernConversationHistoryController *modernHistory; @property (nonatomic, strong) TGConversationsTableView *tableView; @property (nonatomic, strong) NSMutableArray *list; +@property (nonatomic,assign) BOOL initedNext; + @end @implementation TGConversationsViewController @@ -49,11 +51,6 @@ - (void)loadView { int topOffset = 48; - // self.view.wantsLayer = NO; - - - _history = [DialogsHistoryController sharedController]; - self.searchViewController.type = SearchTypeDialogs | SearchTypeMessages | SearchTypeContacts | SearchTypeGlobalUsers; NSRect tableRect = NSMakeRect(0, 0, NSWidth(self.view.frame), NSHeight(self.view.frame) - topOffset); @@ -78,37 +75,44 @@ - (void)loadView { - [MTNetwork instance]; - if(![TGPasslock isEnabled]) { + if(![TGPasslock isEnabled] && [[MTNetwork instance] isAuth]) { [self initialize]; - // [[MTNetwork instance] startNetwork]; } - - +// [[MTNetwork instance] startNetwork]; +// +// [[MTNetwork instance].updateService.proccessor resetStateAndSync]; } -(void)initialize { + [[Storage manager] users:^(NSArray *result) { - - [[UsersManager sharedManager] addFromDB:result]; - [[BroadcastManager sharedManager] loadBroadcastList:^{ + [[Storage manager] broadcastList:^(NSArray *broadcasts) { + + [[BroadcastManager sharedManager] add:broadcasts]; [[Storage manager] loadChats:^(NSArray *chats) { + [[ChatsManager sharedManager] add:chats]; + [ASQueue dispatchOnStageQueue:^{ + + [self initConversations]; + }]; + + + }]; }]; + }]; - [MessagesManager updateUnreadBadge]; - } @@ -117,65 +121,70 @@ -(void)viewWillAppear:(BOOL)animated { [self.searchViewController viewWillAppear:animated]; - [self.tableView.scrollView.contentView setFrameSize:self.tableView.scrollView.frame.size]; - - dispatch_async(dispatch_get_main_queue(), ^{ + [self.tableView.scrollView.contentView setFrameSize:[Telegram leftViewController].view.frame.size]; + [self.tableView setFrameSize:[Telegram leftViewController].view.frame.size]; + // dispatch_async(dispatch_get_main_queue(), ^{ [self.tableView reloadData]; - - }); + // }); } +-(void)didLoadedConversations:(NSArray *)conversations withRange:(NSRange)range { + [self insertAll:conversations]; + + if(!_initedNext) { + [self didLoadedStartedConversationNeedNext]; + } + +} + +-(int)conversationsLoadingLimit { + return 20; +} + -(void)initConversations { [SecretChatAccepter instance]; - + + _initedNext = NO; + + [[MTNetwork instance] startNetwork]; + + _modernHistory = [[TGModernConversationHistoryController alloc] initWithQueue:[[ASQueue alloc] initWithName:"c_h_queue"] delegate:self]; + + + [self loadhistory:30]; - [[DialogsHistoryController sharedController] next:0 limit:20 callback:^(NSArray *result) { - - [[MTNetwork instance] startNetwork]; - - [EmojiViewController reloadStickers]; - - [[BlockedUsersManager sharedManager] remoteLoad]; - - if(result.count != 0 || _history.state == DialogsHistoryStateEnd) { - - [TMTaskRequest executeAll]; - - [self insertAll:result]; - - [Notification perform:APP_RUN object:nil]; - - [SelfDestructionController initialize]; - - [TGModernTypingManager initialize]; - - [[NewContactsManager sharedManager] fullReload]; - [[FullChatManager sharedManager] loadStored]; - - [TGSecretAction dequeAllStorageActions]; - - - dispatch_after_seconds(3, ^{ - [self loadhistory:35]; - }); - - - - } else if(_history.state != DialogsHistoryStateEnd) { - [self initConversations]; - } - - - - } usersCallback:nil]; +} + +-(void)didLoadedStartedConversationNeedNext { + [[BlockedUsersManager sharedManager] remoteLoad]; + + [TMTaskRequest executeAll]; + + + [Notification perform:APP_RUN object:nil]; + + [SelfDestructionController initialize]; + + [TGModernTypingManager initialize]; + + [[NewContactsManager sharedManager] fullReload]; + [[FullChatManager sharedManager] loadStored]; + + [TGSecretAction dequeAllStorageActions]; + + + [ASQueue dispatchOnMainQueue:^{ + [EmojiViewController reloadStickers]; + }]; [MessagesManager updateUnreadBadge]; + _initedNext = YES; } - (void)addScrollEvent { @@ -196,72 +205,61 @@ - (void)searchFieldDidEnter { } -(void)notificationLogout:(NSNotification *)notification { - [_history drop]; [self.tableView removeAllItems:NO]; [self.tableView reloadData]; + [_modernHistory clear]; + _modernHistory = nil; } - (void) scrollViewDocumentOffsetChangingNotificationHandler:(NSNotification *)aNotification { - if(_history.isLoading || _history.state == DialogsHistoryStateEnd || ![self.tableView.scrollView isNeedUpdateBottom]) + if(_modernHistory.isLoading || _modernHistory.state == TGModernCHStateFull || ![self.tableView.scrollView isNeedUpdateBottom]) return; - static int limit = 30; - [self loadhistory:limit]; + [_modernHistory requestNextConversation]; } -(void)loadhistory:(int)limit { - - - int offset = (int) self.tableView.count; - - if(_history.state == DialogsHistoryStateNeedRemote) { - NSArray *filtred = [self.tableView.list filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.conversation.peer.class != %@ AND self.conversation.peer.class != %@",[TL_peerSecret class], [TL_peerBroadcast class]]]; + if(_modernHistory != nil) { + [_modernHistory requestNextConversation]; - offset = (int) filtred.count; + dispatch_after_seconds(5, ^{ + [self loadhistory:limit]; + }); } - [_history next:offset limit:limit callback:^(NSArray *result) { - - [self insertAll:result]; - - if(_history.state != DialogsHistoryStateEnd) { - dispatch_after_seconds(5, ^{ - [self loadhistory:limit]; - }); - } - - } usersCallback:^(NSArray *users) { - - }]; } -(void)insertAll:(NSArray *)all { - NSMutableArray *dialogs = [[NSMutableArray alloc] init]; + + NSMutableArray *items = [[NSMutableArray alloc] init]; for(TL_conversation *conversation in all) { if(!conversation.isAddToList) continue; TGConversationTableItem *item = [[TGConversationTableItem alloc] initWithConversation:conversation]; - [dialogs addObject:item]; + [items addObject:item]; } - NSTableViewAnimationOptions animation = self.tableView.defaultAnimation; - - self.tableView.defaultAnimation = NSTableViewAnimationEffectNone; - - [self.tableView insert:dialogs startIndex:self.tableView.list.count tableRedraw:YES]; - - self.tableView.defaultAnimation = animation; - - if(self.tableView.selectedItem != self.selectedItem) { + [ASQueue dispatchOnMainQueue:^{ + NSTableViewAnimationOptions animation = self.tableView.defaultAnimation; - if([self.tableView itemByHash:[self.selectedItem hash]]) { - [self.tableView cancelSelection]; - [self.tableView setSelectedByHash:[self.selectedItem hash]]; + self.tableView.defaultAnimation = NSTableViewAnimationEffectNone; + + [self.tableView insert:items startIndex:self.tableView.list.count tableRedraw:YES]; + + self.tableView.defaultAnimation = animation; + + if(self.tableView.selectedItem != self.selectedItem) { + + if([self.tableView itemByHash:[self.selectedItem hash]]) { + [self.tableView cancelSelection]; + [self.tableView setSelectedByHash:[self.selectedItem hash]]; + } } - } + }]; + } - (void)dealloc { [Notification removeObserver:self]; @@ -286,7 +284,12 @@ - (void)notificationDialogSelectionChanged:(NSNotification *)notify { [self.tableView cancelSelection]; if(![conversation isKindOfClass:NSNull.class]) { - [self.tableView setSelectedByHash:[conversation peer_id]]; + [self.tableView setSelectedByHash:[[Telegram conversation] peer_id]]; + + if([Telegram isSingleLayout] && !conversation) { + [self.tableView cancelSelection]; + } + } } } @@ -295,6 +298,9 @@ - (void) notificationDialogRemove:(NSNotification *)notify { TL_conversation *conversation = [notify.userInfo objectForKey:KEY_DIALOG]; id object = [self.tableView itemByHash:[conversation peer_id]]; [self.tableView removeItem:object]; + + + } - (void) notificationDialogsReload:(NSNotification *)notify { @@ -324,7 +330,8 @@ - (void) notificationDialogsReload:(NSNotification *)notify { if(![item itemIsUpdated]) { - [item needUpdateMessage:[[NSNotification alloc] initWithName:@"" object:nil userInfo:@{KEY_LAST_CONVRESATION_DATA:[MessagesUtils conversationLastData:obj],@"isNotForReload":@(YES)}]]; + [item needUpdateMessage:[[NSNotification alloc] initWithName:@"" object:nil userInfo:@{KEY_LAST_CONVRESATION_DATA:[MessagesUtils conversationLastData:obj],@"isNotForReload":@(YES),KEY_DIALOG:obj}]]; + } } else { item = [[TGConversationTableItem alloc] initWithConversation:obj]; @@ -342,6 +349,8 @@ - (void) notificationDialogsReload:(NSNotification *)notify { [self.tableView insert:items startIndex:0 tableRedraw:NO]; [self.tableView reloadData]; + [self.tableView setSelectedByHash:self.tableView.selectedItem.hash]; + }]; }]; } @@ -359,6 +368,9 @@ - (void)notificationDialogChangePosition:(NSNotification *)notify { -(void)move:(int)position conversation:(TL_conversation *)conversation { + if(!conversation.isAddToList) + return; + if(position == 0 && conversation.top_message > TGMINFAKEID) { [self.tableView scrollToBeginningOfDocument:self]; } @@ -372,10 +384,11 @@ -(void)move:(int)position conversation:(TL_conversation *)conversation { } else { object = [[TGConversationTableItem alloc] initWithConversation:conversation]; [self.tableView insert:object atIndex:position tableRedraw:YES]; - if(conversation == [Telegram rightViewController].messagesViewController.conversation) - [self.tableView setSelectedByHash:object.hash]; } + if(conversation == [Telegram rightViewController].messagesViewController.conversation) + [self.tableView setSelectedByHash:object.hash]; + } - (CGFloat) rowHeight:(NSUInteger)row item:(TMRowItem *)item { @@ -407,7 +420,7 @@ - (BOOL) selectionWillChange:(NSInteger)row item:(TGConversationTableItem *) ite } - (void) selectionDidChange:(NSInteger)row item:(TGConversationTableItem *) item { - [[Telegram sharedInstance] showMessagesFromDialog:item.conversation sender:self]; + [[Telegram delegate].mainWindow.navigationController showMessagesViewController:item.conversation]; [self.tableView setSelectedByHash:[item hash]]; } @@ -431,19 +444,30 @@ + (void)showPopupMenuForDialog:(TL_conversation *)dialog withEvent:(NSEvent *)th __block TLChat *chat = dialog.chat; NSMenuItem *openConversationMenuItem = [NSMenuItem menuItemWithTitle:NSLocalizedString(@"Conversation.OpenConversation", nil) withBlock:^(id sender) { - [[Telegram rightViewController] showByDialog:dialog sender:self]; + [appWindow().navigationController showMessagesViewController:dialog]; }]; - if([Telegram rightViewController].messagesViewController.conversation == dialog) + if(appWindow().navigationController.messagesViewController.conversation == dialog) openConversationMenuItem.target = nil; [menu addItem:openConversationMenuItem]; + NSMenuItem *anotherWindow = [NSMenuItem menuItemWithTitle:NSLocalizedString(@"ShowConversationWithAnotherWindow", nil) withBlock:^(id sender) { + [TGHeadChatPanel showWithConversation:dialog]; + }]; + + + [menu addItem:anotherWindow]; + + + [menu addItem:[NSMenuItem separatorItem]]; - if(dialog.type != DialogTypeChat && dialog.type != DialogTypeBroadcast) { + if(dialog.type != DialogTypeChat && dialog.type != DialogTypeBroadcast && dialog.type != DialogTypeChannel) { NSMenuItem *showUserProfile = [NSMenuItem menuItemWithTitle:[NSString stringWithFormat:NSLocalizedString(@"Conversation.ShowProfile", nil), user.dialogFullName] withBlock:^(id sender) { - [[Telegram rightViewController] showUserInfoPage:user conversation:user.dialog]; + + [appWindow().navigationController showInfoPage:dialog]; + }]; [menu addItem:showUserProfile]; @@ -496,18 +520,29 @@ + (void)showPopupMenuForDialog:(TL_conversation *)dialog withEvent:(NSEvent *)th [menu addItem:clearHistory]; } + if(dialog.type == DialogTypeUser && dialog.user.isBot) { + + NSMenuItem *deleteAndStop = [NSMenuItem menuItemWithTitle:NSLocalizedString(@"Conversation.DeleteAndStopBot", nil) withBlock:^(id sender) { + [[Telegram rightViewController].messagesViewController deleteDialog:dialog]; + [[BlockedUsersManager sharedManager] block:dialog.user.n_id completeHandler:^(BOOL response) { + + }]; + }]; + [menu addItem:deleteAndStop]; + } + } else { NSMenuItem *showСhatProfile; - if(dialog.type == DialogTypeChat) { - showСhatProfile = [NSMenuItem menuItemWithTitle:NSLocalizedString(@"Conversation.ShowGroupInfo", nil) withBlock:^(id sender) { - [[Telegram rightViewController] showChatInfoPage:chat]; + if(dialog.type == DialogTypeChat || dialog.type == DialogTypeChannel) { + showСhatProfile = [NSMenuItem menuItemWithTitle:dialog.type != DialogTypeChannel || dialog.chat.isMegagroup ? NSLocalizedString(@"Conversation.ShowGroupInfo", nil) : NSLocalizedString(@"Conversation.ShowChannelInfo", nil) withBlock:^(id sender) { + [appWindow().navigationController showInfoPage:dialog]; }]; } else { showСhatProfile = [NSMenuItem menuItemWithTitle:NSLocalizedString(@"Conversation.ShowBroadcastInfo", nil) withBlock:^(id sender) { - [[Telegram rightViewController] showBroadcastInfoPage:dialog.broadcast]; + [appWindow().navigationController showInfoPage:dialog]; }]; } @@ -529,20 +564,24 @@ + (void)showPopupMenuForDialog:(TL_conversation *)dialog withEvent:(NSEvent *)th [menu addItem:[NSMenuItem separatorItem]]; - if(dialog.type == DialogTypeChat) { + if(dialog.type == DialogTypeChat || dialog.type == DialogTypeChannel) { - NSMenuItem *deleteAndExitItem = [NSMenuItem menuItemWithTitle:chat.type == TLChatTypeNormal ? NSLocalizedString(@"Profile.DeleteAndExit", nil) : NSLocalizedString(@"Profile.DeleteConversation", nil) withBlock:^(id sender) { + NSMenuItem *deleteAndExitItem = [NSMenuItem menuItemWithTitle:chat.type == TLChatTypeNormal ? (dialog.type != DialogTypeChannel ? NSLocalizedString(@"Profile.DeleteAndExit", nil) : (chat.isCreator ? NSLocalizedString(chat.isMegagroup ?@"Conversation.Confirm.DeleteGroup" : @"Profile.DeleteChannel", nil) : NSLocalizedString(chat.isMegagroup ? @"Conversation.Actions.LeaveGroup" : @"Profile.LeaveChannel", nil)) ) : NSLocalizedString(@"Profile.DeleteConversation", nil) withBlock:^(id sender) { [[Telegram rightViewController].messagesViewController deleteDialog:dialog]; }]; [menu addItem:deleteAndExitItem]; - NSMenuItem *leaveFromGroupItem = [NSMenuItem menuItemWithTitle:!dialog.chat.left ? NSLocalizedString(@"Conversation.Actions.LeaveGroup", nil) : NSLocalizedString(@"Conversation.Actions.ReturnToGroup", nil) withBlock:^(id sender) { - [[Telegram rightViewController].messagesViewController leaveOrReturn:dialog]; - }]; - if(chat.type != TLChatTypeNormal) - leaveFromGroupItem.target = nil; + if(dialog.type == DialogTypeChat) { + NSMenuItem *leaveFromGroupItem = [NSMenuItem menuItemWithTitle:!dialog.chat.left ? NSLocalizedString(@"Conversation.Actions.LeaveGroup", nil) : NSLocalizedString(@"Conversation.Actions.ReturnToGroup", nil) withBlock:^(id sender) { + [[Telegram rightViewController].messagesViewController leaveOrReturn:dialog]; + }]; + if(chat.type != TLChatTypeNormal) + leaveFromGroupItem.target = nil; + + [menu addItem:leaveFromGroupItem]; + } + - [menu addItem:leaveFromGroupItem]; } else { NSMenuItem *deleteBroadcast = [NSMenuItem menuItemWithTitle: NSLocalizedString(@"Profile.DeleteBroadcast", nil) withBlock:^(id sender) { [[Telegram rightViewController].messagesViewController deleteDialog:dialog]; @@ -558,8 +597,6 @@ + (void)showPopupMenuForDialog:(TL_conversation *)dialog withEvent:(NSEvent *)th - - - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [TMTableView setCurrent:self.tableView]; diff --git a/TelegramTest/TGDatabase.h b/TelegramTest/TGDatabase.h new file mode 100644 index 00000000..ff8e63e0 --- /dev/null +++ b/TelegramTest/TGDatabase.h @@ -0,0 +1,24 @@ +// +// TGDatabase.h +// Telegram +// +// Created by keepcoder on 04.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import +#import + +@interface TGDatabase : NSObject + + ++(void)dbSetKey:(NSString *)key; ++(void)dbRekey:(NSString *)key; + ++(SSignal *)initialize; + + ++(SSignal *)conversationsWithOffset:(NSUInteger)offset; + + +@end diff --git a/TelegramTest/TGDatabase.m b/TelegramTest/TGDatabase.m new file mode 100644 index 00000000..cbdbbaee --- /dev/null +++ b/TelegramTest/TGDatabase.m @@ -0,0 +1,342 @@ +// +// TGDatabase.m +// Telegram +// +// Created by keepcoder on 04.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TGDatabase.h" +#import "FMDatabase.h" +#import "FMDatabaseQueue.h" +#import "FMResultSet.h" +@implementation TGDatabase + + +NSString *dbfolder() { + NSFileManager *fm = [NSFileManager defaultManager]; + NSString *applicationSupportPath = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES)[0]; + NSString *applicationName = appName(); + NSString *path = [[applicationSupportPath stringByAppendingPathComponent:applicationName] stringByAppendingPathComponent:@"database"]; + + if (![fm createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil]) { + + } + return path; +} + +static FMDatabase *db; +static SQueue *queue; +static NSString *key = @"712yfihqwehg"; +static NSString *baseKey = @"712yfihqwehg"; // public encryption key +static NSString *unencryptedpath; +static NSString *dbpath; + + ++(void)dbRekey:(NSString *)key { + +} + ++(void)dbSetKey:(NSString *)key { + +} + ++(SSignal *)initialize { + + queue = [[SQueue alloc] init]; + + return [[[SSignal alloc] initWithGenerator:^id(SSubscriber *subscriber) { + + + unencryptedpath = [dbfolder() stringByAppendingPathComponent:@"t143.sqlite"]; + dbpath = [dbfolder() stringByAppendingPathComponent:@"encrypted.sqlite"]; + + SSignal *createSignal = [self createAndCheckDatabase]; + + + [createSignal startWithNext:^(id next) { + + [self initializeDatabase]; + + [subscriber putNext:nil]; + }]; + + + return nil; + }] startOn:queue]; +} + + ++(void)initializeDatabase { + + db = [[FMDatabase alloc] initWithPath:dbpath]; + + [db open]; + + [db setKey:key]; + + [db executeUpdate:@"create table if not exists messages (n_id INTEGER PRIMARY KEY,message_text TEXT, flags integer, from_id integer, peer_id integer, date integer, serialized blob, random_id, destruct_time, filter_mask integer, fake_id integer, dstate integer)"]; + + //messages indexes + { + [db executeUpdate:@"CREATE INDEX if not exists select_messages_idx ON messages(peer_id,date)"]; + [db executeUpdate:@"CREATE INDEX if not exists peer_idx ON messages(peer_id)"]; + [db executeUpdate:@"CREATE INDEX if not exists date_idx ON messages(date)"]; + [db executeUpdate:@"CREATE INDEX if not exists random_idx ON messages(random_id)"]; + [db executeUpdate:@"CREATE INDEX if not exists peer_flags_idx ON messages(peer_id,flags)"]; + } + + + [db executeUpdate:@"create table if not exists dialogs (peer_id INTEGER PRIMARY KEY, top_message integer, unread_count unsigned integer,last_message_date integer, type integer, notify_settings blob, last_marked_message integer, top_message_fake integer, dstate integer,sync_message_id integer,last_marked_date integer,last_real_message_date integer)"]; + + + //dialogs indexes + { + [db executeUpdate:@"CREATE INDEX if not exists select_conv_idx ON dialogs(top_message,last_real_message_date)"]; + + } + + + [db executeUpdate:@"create table if not exists chats (n_id INTEGER PRIMARY KEY, serialized blob)"]; + + + + [db executeUpdate:@"create table if not exists update_state (seq integer, pts integer, date integer, qts integer, pts_count integer)"]; + + + + [db executeUpdate:@"CREATE TABLE IF NOT EXISTS users (n_id INTEGER PRIMARY KEY, serialized blob, lastseen_update integer)"]; + + [db executeUpdate:@"create table if not exists contacts (user_id INTEGER PRIMARY KEY,mutual integer)"]; + + + [db executeUpdate:@"CREATE INDEX if not exists user_id_index ON contacts(user_id)"]; + + [db executeUpdate:@"create table if not exists chats_full_new (n_id INTEGER PRIMARY KEY, last_update_time integer, serialized blob)"]; + + [db executeUpdate:@"create table if not exists imported_contacts (hash blob primary key, hashObject string, user_id integer)"]; + + + [db executeUpdate:@"create table if not exists encrypted_chats (chat_id integer primary key,serialized blob)"]; + + [db executeUpdate:@"create table if not exists sharedmedia (message_id integer primary key, peer_id integer, serialized blob,date integer, filter_mask integer)"]; + + + [db executeUpdate:@"CREATE INDEX if not exists sm_peer_idx ON sharedmedia(peer_id)"]; + + + + [db executeUpdate:@"create table if not exists self_destruction (id integer primary key autoincrement, chat_id integer, max_id integer, ttl integer)"]; + + + [db executeUpdate:@"create table if not exists user_photos (id blob primary key, user_id integer, serialized blob,date integer)"]; + + + + [db executeUpdate:@"create table if not exists blocked_users (user_id integer primary key, date integer)"]; + + [db executeUpdate:@"create table if not exists tasks (task_id integer primary key, params blob, extender blob)"]; + + [db executeUpdate:@"create table if not exists files (hash string PRIMARY KEY, serialized blob)"]; + + + [db executeUpdate:@"create table if not exists broadcasts (n_id integer PRIMARY KEY, serialized blob, title string, date integer)"]; + + + [db executeUpdate:@"create table if not exists out_secret_actions (action_id integer primary key, message_data blob, chat_id integer, senderClass string, out_seq_no integer, layer integer)"]; + + [db executeUpdate:@"create table if not exists in_secret_actions (action_id integer primary key, message_data blob, file_data blob, chat_id integer, date integer, in_seq_no integer, layer integer)"]; + + + [db executeUpdate:@"create table if not exists support_messages (n_id INTEGER PRIMARY KEY, serialized blob)"]; + + + if([db hadError]) { + [self drop]; + } + +} + + + ++(SSignal *)drop { + + return [[[SSignal alloc] initWithGenerator:^id(SSubscriber *subscriber) { + + [[NSFileManager defaultManager] removeItemAtPath:dbpath error:nil]; + + + [[Storage yap] readWriteWithBlock:^(YapDatabaseReadWriteTransaction * __nonnull transaction) { + [transaction removeAllObjectsInAllCollections]; + }]; + + key = baseKey; + + + [SSignal single:[self initialize]]; + + + return nil; + + + + }] deliverOn:queue]; + + +} + ++(SSignal *) createAndCheckDatabase +{ + + return [[SSignal alloc] initWithGenerator:^id(SSubscriber *subscriber) { + + BOOL success; + + + NSFileManager *fileManager = [NSFileManager defaultManager]; + + NSString *copyDbPath = [NSString stringWithFormat:@"%@/%@",dbfolder(),@"cp_old_db"]; + + + success = [fileManager fileExistsAtPath:dbpath] && fileSize(dbpath) > 0 && ![fileManager fileExistsAtPath:unencryptedpath]; + + if (success) + { + [subscriber putNext:nil]; + return nil; + } + + + [fileManager copyItemAtPath:unencryptedpath toPath:copyDbPath error:nil]; + + + const char* sqlQ = [[NSString stringWithFormat:@"ATTACH DATABASE '%@' AS encrypted KEY '%@';", dbpath, key] UTF8String]; + + sqlite3 *unencrypted_DB; + if (sqlite3_open([copyDbPath UTF8String], &unencrypted_DB) == SQLITE_OK) { + + + + // Attach empty encrypted database to unencrypted database + sqlite3_exec(unencrypted_DB, sqlQ, NULL, NULL, NULL); + + // export database + sqlite3_exec(unencrypted_DB, "SELECT sqlcipher_export('encrypted');", NULL, NULL, NULL); + + // Detach encrypted database + sqlite3_exec(unencrypted_DB, "DETACH DATABASE encrypted;", NULL, NULL, NULL); + + sqlite3_close(unencrypted_DB); + + + + } + else { + sqlite3_close(unencrypted_DB); + NSAssert1(NO, @"Failed to open database with message '%s'.", sqlite3_errmsg(unencrypted_DB)); + } + + + [fileManager removeItemAtPath:copyDbPath error:nil]; + [fileManager removeItemAtPath:unencryptedpath error:nil]; + + [subscriber putNext:nil]; + + [subscriber putCompletion]; + + return nil; + + }]; + + +} + + ++(SSignal *)conversationsWithOffset:(NSUInteger)offset { + + return [[[SSignal alloc] initWithGenerator:^id(SSubscriber *subscriber) { + + + FMResultSet *result = [db executeQuery:@"select messages.message_text,messages.from_id, dialogs.peer_id, dialogs.type,dialogs.last_message_date, messages.serialized serialized_message, dialogs.top_message,dialogs.sync_message_id,dialogs.last_marked_date,dialogs.unread_count unread_count, dialogs.notify_settings notify_settings, dialogs.last_marked_message last_marked_message,dialogs.last_real_message_date last_real_message_date, messages.flags from dialogs left join messages on dialogs.top_message = messages.n_id ORDER BY dialogs.last_real_message_date DESC LIMIT ? OFFSET ?",@(20),@(offset)]; + + + NSMutableArray *conversations = [[NSMutableArray alloc] init]; + NSMutableArray *messages = [[NSMutableArray alloc] init]; + + + [self parseConversations:result conversations:conversations messages:messages]; + + [subscriber putNext:@{@"conversations":conversations,@"messages":messages}]; + + + + + [result close]; + + + return nil; + + }] startOn:queue]; + +} + + + ++ (void)parseConversations:(FMResultSet *)result conversations:(NSMutableArray *)conversations messages:(NSMutableArray *)messages { + while ([result next]) { + + TL_conversation *dialog = [[TL_conversation alloc] init]; + int type = [result intForColumn:@"type"]; + + if(type == DialogTypeSecretChat) { + dialog.peer = [TL_peerSecret createWithChat_id:[result intForColumn:@"peer_id"]]; + } else if(type == DialogTypeUser) { + dialog.peer = [TL_peerUser createWithUser_id:[result intForColumn:@"peer_id"]]; + } else if(type == DialogTypeChat) { + dialog.peer = [TL_peerChat createWithChat_id:-[result intForColumn:@"peer_id"]]; + } else if(type == DialogTypeBroadcast) { + dialog.peer = [TL_peerBroadcast createWithChat_id:[result intForColumn:@"peer_id"]]; + } + + + id notifyObject = [result dataForColumn:@"notify_settings"]; + + if(notifyObject != nil && ![notifyObject isKindOfClass:[NSNull class]]) { + dialog.notify_settings = [TLClassStore deserialize:notifyObject]; + } + + dialog.unread_count = [result intForColumn:@"unread_count"]; + dialog.top_message = [result intForColumn:@"top_message"]; + dialog.last_message_date = [result intForColumn:@"last_message_date"]; + dialog.last_marked_message = [result intForColumn:@"last_marked_message"]; + dialog.last_marked_date = [result intForColumn:@"last_marked_date"]; + dialog.sync_message_id = [result intForColumn:@"sync_message_id"]; + dialog.last_real_message_date = [result intForColumn:@"last_real_message_date"]; + + id serializedMessage =[[result resultDictionary] objectForKey:@"serialized_message"]; + TL_localMessage *message; + if(![serializedMessage isKindOfClass:[NSNull class]]) { + + @try { + message = [TLClassStore deserialize:serializedMessage]; + message.flags = -1; + message.message = [result stringForColumn:@"message_text"]; + message.flags = [result intForColumn:@"flags"]; + } + @catch (NSException *exception) { + + } + + if(message) + [messages addObject:message]; + } + + dialog.lastMessage = message; + + [conversations addObject:dialog]; + } +} + + + +@end diff --git a/TelegramTest/TGDatabaseRequest.h b/TelegramTest/TGDatabaseRequest.h new file mode 100644 index 00000000..56215d42 --- /dev/null +++ b/TelegramTest/TGDatabaseRequest.h @@ -0,0 +1,13 @@ +// +// TGDatabaseRequest.h +// Telegram +// +// Created by keepcoder on 12.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import + +@interface TGDatabaseRequest : NSObject + +@end diff --git a/TelegramTest/TGDatabaseRequest.m b/TelegramTest/TGDatabaseRequest.m new file mode 100644 index 00000000..fac1007b --- /dev/null +++ b/TelegramTest/TGDatabaseRequest.m @@ -0,0 +1,13 @@ +// +// TGDatabaseRequest.m +// Telegram +// +// Created by keepcoder on 12.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TGDatabaseRequest.h" + +@implementation TGDatabaseRequest + +@end diff --git a/TelegramTest/TGDispatcher.h b/TelegramTest/TGDispatcher.h new file mode 100644 index 00000000..f86c9148 --- /dev/null +++ b/TelegramTest/TGDispatcher.h @@ -0,0 +1,20 @@ +// +// TGDispatcher.h +// Telegram +// +// Created by keepcoder on 25.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import +#import "TGEvent.h" +@interface TGDispatcher : NSObject + ++(void)dispatchEvent:(TGEvent *)event onQueue:(ASQueue *)dispatchQueue; ++(void)dispatchEventSync:(TGEvent *)event onQueue:(ASQueue *)dispatchQueue; + ++ (void)addObserver:(id)target selector:(SEL)selector name:(NSString *)name; + ++ (void)removeObserver:(id)target; + +@end diff --git a/TelegramTest/TGDispatcher.m b/TelegramTest/TGDispatcher.m new file mode 100644 index 00000000..4f6d3780 --- /dev/null +++ b/TelegramTest/TGDispatcher.m @@ -0,0 +1,121 @@ + +// +// TGDispatcher.m +// Telegram +// +// Created by keepcoder on 25.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TGDispatcher.h" + +@interface TGListener : NSObject +@property (nonatomic,weak) dispatch_queue_t queue; +@property (nonatomic,weak) id target; +@property (nonatomic,assign) SEL selector; + +@end + +@implementation TGListener + +-(id)initWithQueue:(dispatch_queue_t)queue target:(id)target selector:(SEL)selector { + if(self = [super init]) { + _queue = queue; + _target = target; + _selector = selector; + } + + return self; +} + +-(BOOL)isEqual:(id)object { + return object == _target; +} + +@end + +@implementation TGDispatcher + +static NSMutableDictionary *listeners; + ++(void)initialize { + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + listeners = [[NSMutableDictionary alloc] init]; + }); +} + ++(void)dispatchEvent:(TGEvent *)event onQueue:(ASQueue *)dispatchQueue sync:(bool)sync { + + if(dispatchQueue != nil) { + [dispatchQueue dispatchOnQueue:^{ + [self dispatchEvent:event]; + } synchronous:sync]; + } else + [self dispatchEvent:event]; + + + +} + + ++(void)dispatchEvent:(TGEvent *)event { + NSMutableArray *observers = listeners[event.eventName]; + + [observers enumerateObjectsUsingBlock:^(TGListener *listener, NSUInteger idx, BOOL *stop) { + + IMP imp = [listener.target methodForSelector:listener.selector]; + + if(imp) { + void (*func)(id, SEL, id) = (void *)imp; + func(listener.target, listener.selector, event); + } + + }]; +} + ++(void)dispatchEvent:(TGEvent *)event onQueue:(ASQueue *)dispatchQueue { + [self dispatchEvent:event onQueue:dispatchQueue sync:NO]; +} ++(void)dispatchEventSync:(TGEvent *)event onQueue:(ASQueue *)dispatchQueue { + [self dispatchEvent:event onQueue:dispatchQueue sync:YES]; +} + + ++ (void)addObserver:(id)target selector:(SEL)selector name:(NSString *)name { + + [ASQueue dispatchOnStageQueue:^{ + + TGListener *listener = [[TGListener alloc] initWithQueue:dispatch_get_current_queue() target:target selector:selector]; + + NSMutableArray *eventListeners = listeners[name]; + + if(!eventListeners) { + eventListeners = [[NSMutableArray alloc] init]; + listeners[name] = eventListeners; + } + + [eventListeners addObject:listener]; + + }]; + + + + +} + ++ (void)removeObserver:(id)target { + + [ASQueue dispatchOnStageQueue:^{ + + [listeners enumerateKeysAndObjectsUsingBlock:^(id key, NSMutableArray *eventListeners, BOOL *stop) { + + [eventListeners removeObject:target]; + + }]; + + }]; + +} + +@end diff --git a/TelegramTest/TGDocumentMediaRowView.m b/TelegramTest/TGDocumentMediaRowView.m index ba1dd9d2..44604ba7 100644 --- a/TelegramTest/TGDocumentMediaRowView.m +++ b/TelegramTest/TGDocumentMediaRowView.m @@ -27,6 +27,9 @@ @interface TGDocumentMediaRowView () @property (nonatomic,strong) TL_conversation *conversation; @property (nonatomic,strong) TGDocumentsMediaTableView *tableView; @@ -30,10 +31,16 @@ -(id)initWithTableView:(TGDocumentsMediaTableView *)tableView; @interface TGDocumentsMediaTableView () - +{ + __block SMDelayedBlockHandle _remoteBlock; +} @property (nonatomic,strong) TGDocumentsController *controller; @property (nonatomic,assign,getter=isEditable) BOOL editable; @property (nonatomic,strong) NSMutableArray *selectedItems; + + +@property (nonatomic,weak) RPCRequest *request; + -(void)checkCap; @end @@ -68,13 +75,19 @@ -(void)setConversation:(TL_conversation *)conversation{ [self.tableView reloadData]; - [_loader drop:NO]; _loader = nil; - _loader = [[ChatHistoryController alloc] initWithController:self historyFilter:[self.tableView historyFilter]]; - [_loader setPrevState:ChatHistoryStateFull]; + if(_conversation) { + _loader = [[self.conversation.type == DialogTypeChannel ? ChatHistoryController.class : ChannelHistoryController.class alloc] initWithController:self historyFilter:[self.tableView historyFilter]]; + + + [_loader.filter setState:ChatHistoryStateFull next:NO]; + } else { + [_loader drop:YES]; + _loader = nil; + } [self loadNext:YES]; @@ -82,12 +95,13 @@ -(void)setConversation:(TL_conversation *)conversation{ -(void)loadNext:(BOOL)isFirst { - _loader.selectLimit = _loader.nextState != ChatHistoryStateRemote ? 500 : 50; + _loader.selectLimit = _loader.nextState != ChatHistoryStateRemote ? 50 : 50; - [_loader request:YES anotherSource:YES sync:isFirst selectHandler:^(NSArray *result, NSRange range) { + [_loader request:YES anotherSource:YES sync:isFirst selectHandler:^(NSArray *result, NSRange range,id controller) { self.tableView.isProgress = NO; + NSArray *filtred = [result filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) { return [self.tableView acceptMessageItem:evaluatedObject]; @@ -95,7 +109,7 @@ -(void)loadNext:(BOOL)isFirst { }]]; [filtred enumerateObjectsUsingBlock:^(MessageTableItem *obj, NSUInteger idx, BOOL *stop) { - [obj makeSizeByWidth:NSWidth(self.tableView.frame) - 30]; + [obj makeSizeByWidth:NSWidth(self.tableView.frame) - 60]; }]; [self.items addObjectsFromArray:filtred]; @@ -104,9 +118,11 @@ -(void)loadNext:(BOOL)isFirst { [self.tableView insertRowsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(self.items.count - filtred.count, filtred.count)] withAnimation:NSTableViewAnimationEffectNone]; + [self.tableView checkCap]; - if(self.items.count < 30 && _loader.nextState != ChatHistoryStateFull) { + + if(self.items.count < 30 && [_loader filterWithNext:YES].nextState != ChatHistoryStateFull) { [self loadNext:NO]; } @@ -119,22 +135,23 @@ -(void)receivedMessage:(MessageTableItem *)message position:(int)position itsSel if([self.tableView acceptMessageItem:message]) { [self.items insertObject:message atIndex:1]; - [message makeSizeByWidth:NSWidth(self.tableView.frame) - 30]; + [message makeSizeByWidth:NSWidth(self.tableView.frame) - 60]; [self.tableView insertRowsAtIndexes:[NSIndexSet indexSetWithIndex:1] withAnimation:NSTableViewAnimationEffectFade]; [self.tableView checkCap]; } } --(void)deleteMessages:(NSArray *)ids { +-(void)deleteItems:(NSArray *)items orMessageIds:(NSArray *)ids { if(self.items.count > 1) { - NSArray *items = [[self.items subarrayWithRange:NSMakeRange(1, self.items.count - 1)] filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.message.n_id IN %@",ids]]; [items enumerateObjectsUsingBlock:^(MessageTableItem *obj, NSUInteger idx, BOOL *stop) { - [self.tableView removeRowsAtIndexes:[NSIndexSet indexSetWithIndex:[self.items indexOfObject:obj]] withAnimation:NSTableViewAnimationEffectFade]; - + NSUInteger itemIndex = [self.items indexOfObject:obj]; + if(itemIndex != NSNotFound) { + [self.tableView removeRowsAtIndexes:[NSIndexSet indexSetWithIndex:itemIndex] withAnimation:NSTableViewAnimationEffectFade]; + } }]; [self.items removeObjectsInArray:items]; @@ -159,7 +176,7 @@ -(void)receivedMessageList:(NSArray *)list inRange:(NSRange)range itsSelf:(BOOL) }]]; [list enumerateObjectsUsingBlock:^(MessageTableItem *obj, NSUInteger idx, BOOL *stop) { - [obj makeSizeByWidth:NSWidth(self.tableView.frame) - 30]; + [obj makeSizeByWidth:NSWidth(self.tableView.frame) - 60]; }]; [self.items insertObjects:list atIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(1, list.count)]]; @@ -209,7 +226,7 @@ -(void)setFrameSize:(NSSize)newSize { if([item isKindOfClass:[MessageTableItem class]]) { // [self.tableView prepareItem:item]; - [item makeSizeByWidth:newSize.width - 30]; + [item makeSizeByWidth:newSize.width - 60]; id view = [self.tableView viewAtColumn:0 row:i makeIfNecessary:NO]; if(view) @@ -234,7 +251,7 @@ -(void)setFrameSize:(NSSize)newSize { for(NSUInteger i = 0; i < self.tableView.controller.items.count; i++) { MessageTableItem *item = self.tableView.controller.items[i]; if([item isKindOfClass:[MessageTableItem class]]) - [item makeSizeByWidth:newSize.width - 30]; + [item makeSizeByWidth:newSize.width - 60]; } } @@ -277,7 +294,7 @@ -(instancetype)initWithFrame:(NSRect)frameRect { -(void)checkCap { - [[Telegram rightViewController].collectionViewController checkCap]; + [self.collectionViewController checkCap]; } -(BOOL)isFlipped { @@ -329,12 +346,71 @@ -(void)reloadWithString:(NSString *)string { [self.controller.searchView.searchField becomeFirstResponder]; + if(_remoteBlock) + cancel_delayed_block(_remoteBlock); + + if(_request) + [_request cancelRequest]; + + _remoteBlock = perform_block_after_delay(0.4, ^{ + _remoteBlock = nil; + + [self remoteSearch:string]; + + }); + +} + + +-(void)remoteSearch:(NSString *)search { + + if(_request) + [_request cancelRequest]; + + + MessageTableItem *item = [self.controller.items lastObject]; + + if(![item isKindOfClass:[MessageTableItem class]]) + item = nil; + + _request = [RPCRequest sendRequest:[TLAPI_messages_search createWithFlags:0 peer:self.controller.conversation.inputPeer q:search filter:[self remoteFilter] min_date:0 max_date:0 offset:0 max_id:item.message.n_id limit:100] successHandler:^(id request, id response) { + + [TL_localMessage convertReceivedMessages:[response messages]]; + + NSArray *converted = [[Telegram rightViewController].messagesViewController messageTableItemsFromMessages:[response messages]]; + + NSArray *filtred = [converted filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) { + + return [self acceptMessageItem:evaluatedObject]; + + }]]; + + [filtred enumerateObjectsUsingBlock:^(MessageTableItem *obj, NSUInteger idx, BOOL *stop) { + [obj makeSizeByWidth:NSWidth(self.frame) - 60]; + }]; + + [self.controller.items addObjectsFromArray:filtred]; + + + [self insertRowsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(self.controller.items.count - filtred.count, filtred.count)] withAnimation:NSTableViewAnimationEffectNone]; + + + + } errorHandler:^(id request, RpcError *error) { + + }]; +} + + +-(id)remoteFilter { + return [TL_inputMessagesFilterDocument create]; } -(void)setEditable:(BOOL)editable animated:(BOOL)animated { _editable = editable; + self.selectedItems = [[NSMutableArray alloc] init]; [self.controller.items enumerateObjectsUsingBlock:^(MessageTableItem *obj, NSUInteger idx, BOOL *stop) { @@ -351,7 +427,7 @@ -(void)setEditable:(BOOL)editable animated:(BOOL)animated { } -(BOOL)isEditable { - return [[Telegram rightViewController].collectionViewController isEditable]; + return [self.collectionViewController isEditable]; } -(BOOL)isNeedCap { @@ -429,7 +505,15 @@ -(void)setSelected:(BOOL)selected forItem:(MessageTableItem *)item { [_selectedItems removeObject:item]; } - [[Telegram rightViewController].collectionViewController setSectedMessagesCount:self.selectedItems.count]; + + NSMutableArray *messages = [NSMutableArray array]; + + [_selectedItems enumerateObjectsUsingBlock:^(MessageTableItem *obj, NSUInteger idx, BOOL * _Nonnull stop) { + [messages addObject:obj.message]; + }]; + + [self.collectionViewController setSectedMessagesCount:self.selectedItems.count enable:[MessagesViewController canDeleteMessages:messages inConversation:self.controller.conversation]]; + } -(BOOL)isSelectedItem:(MessageTableItem *)item { @@ -461,13 +545,21 @@ - (void)prepareItem:(MessageTableItem *)item { } -(BOOL)acceptMessageItem:(MessageTableItem *)item { - return [item isKindOfClass:[MessageTableItemDocument class]] || [item isKindOfClass:[MessageTableItemAudioDocument class]]; + return [item isKindOfClass:[MessageTableItemDocument class]]; } -(int)heightWithItem:(MessageTableItem *)item { return 60; } +-(NSArray *)items { + return self.controller.defaultItems; +} + +-(NSUInteger)indexOfItem:(NSObject *)item { + return [self.controller.items indexOfObject:item]; +} + - (void) addScrollEvent { id clipView = [[self enclosingScrollView] contentView]; [[NSNotificationCenter defaultCenter] addObserver:self diff --git a/TelegramTest/TGEmbedModalView.m b/TelegramTest/TGEmbedModalView.m index b8aea5de..af795e5c 100644 --- a/TelegramTest/TGEmbedModalView.m +++ b/TelegramTest/TGEmbedModalView.m @@ -8,7 +8,7 @@ #import "TGEmbedModalView.h" #import -@interface TGEmbedModalView () +@interface TGEmbedModalView () @property (nonatomic,strong) WebView *webView; @property (nonatomic,strong) TLWebPage *webpage; @property (nonatomic,strong) NSProgressIndicator *progress; @@ -31,8 +31,12 @@ -(instancetype)initWithFrame:(NSRect)frameRect { [self addSubview:_progress]; + + _webView = [[WebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300)]; + _webView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable; + [self addSubview:_webView]; _webView.frameLoadDelegate = self; @@ -61,6 +65,10 @@ -(void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame { [_webView setHidden:NO]; } +-(void)dealloc { + _webView.frameLoadDelegate = nil; +} + -(void)modalViewDidHide { _webpage = nil; @@ -75,9 +83,16 @@ -(void)setFrameSize:(NSSize)newSize { [self setContainerFrameSize:embedSize]; +} + +-(void)setContainerFrameSize:(NSSize)size { + [super setContainerFrameSize:size]; + [_webView setFrame:NSMakeRect(3, 3, self.containerSize.width - 6, self.containerSize.height - 6)]; [_progress setCenterByView:_progress.superview]; + + } @end diff --git a/TelegramTest/TGEnterPasswordPanel.m b/TelegramTest/TGEnterPasswordPanel.m index 81dbf8e6..cbaa761f 100644 --- a/TelegramTest/TGEnterPasswordPanel.m +++ b/TelegramTest/TGEnterPasswordPanel.m @@ -78,7 +78,7 @@ -(TMView *)confirmEmailCodeContainer { [attrs appendString:NSLocalizedString(@"Code", nil) withColor:DARK_GRAY]; - [attrs setAttributes:@{NSFontAttributeName:[NSFont fontWithName:@"HelveticaNeue" size:14]} range:attrs.range]; + [attrs setAttributes:@{NSFontAttributeName:TGSystemFont(14)} range:attrs.range]; [attrs setAlignment:NSCenterTextAlignment range:attrs.range]; @@ -89,7 +89,7 @@ -(TMView *)confirmEmailCodeContainer { [_emailCodeField setCenterByView:_confirmEmailCodeContainer]; - [_emailCodeField.textView setFont:[NSFont fontWithName:@"HelveticaNeue" size:14]]; + [_emailCodeField.textView setFont:TGSystemFont(14)]; [_emailCodeField.textView setTextColor:DARK_BLACK]; @@ -117,7 +117,7 @@ -(TMView *)confirmEmailCodeContainer { [codeDescription setStringValue:NSLocalizedString(@"EnterPassword.EnterCodeDescription", nil)]; - [codeDescription setFont:[NSFont fontWithName:@"HelveticaNeue" size:13]]; + [codeDescription setFont:TGSystemFont(13)]; [codeDescription setTextColor:GRAY_TEXT_COLOR]; @@ -131,7 +131,7 @@ -(TMView *)confirmEmailCodeContainer { troubleAccess.stringValue = [NSString stringWithFormat:NSLocalizedString(@"EnterPassword.TroubleEmailAccess", nil)]; troubleAccess.textColor = BLUE_UI_COLOR; - troubleAccess.font = [NSFont fontWithName:@"HelveticaNeue" size:12]; + troubleAccess.font = TGSystemFont(12); [troubleAccess sizeToFit]; @@ -181,7 +181,7 @@ -(TMView *)enterPasswordContainer { - [titleField setFont:[NSFont fontWithName:@"HelveticaNeue" size:14]]; + [titleField setFont:TGSystemFont(14)]; [titleField setTextColor:DARK_BLACK]; @@ -202,7 +202,7 @@ -(TMView *)enterPasswordContainer { [attrs appendString:NSLocalizedString(@"Password.password", nil) withColor:DARK_GRAY]; - [attrs setAttributes:@{NSFontAttributeName:[NSFont fontWithName:@"HelveticaNeue" size:14]} range:attrs.range]; + [attrs setAttributes:@{NSFontAttributeName:TGSystemFont(14)} range:attrs.range]; [attrs setAlignment:NSCenterTextAlignment range:attrs.range]; @@ -212,7 +212,7 @@ -(TMView *)enterPasswordContainer { [self.secureField setCenterByView:_enterPasswordContainer]; - [self.secureField setFont:[NSFont fontWithName:@"HelveticaNeue" size:14]]; + [self.secureField setFont:TGSystemFont(14)]; [self.secureField setTextColor:DARK_BLACK]; [self.secureField setBordered:NO]; @@ -245,7 +245,7 @@ -(TMView *)enterPasswordContainer { [passwordDescription setStringValue:NSLocalizedString(@"EnterPassword.EnterPasswordDescription", nil)]; - [passwordDescription setFont:[NSFont fontWithName:@"HelveticaNeue" size:13]]; + [passwordDescription setFont:TGSystemFont(13)]; [passwordDescription setTextColor:GRAY_TEXT_COLOR]; @@ -261,7 +261,7 @@ -(TMView *)enterPasswordContainer { self.resetPass.stringValue = NSLocalizedString(@"EnterPassword.forgotPassword", nil); self.resetPass.textColor = BLUE_UI_COLOR; - self.resetPass.font = [NSFont fontWithName:@"HelveticaNeue" size:12]; + self.resetPass.font = TGSystemFont(12); [self.resetPass sizeToFit]; @@ -297,7 +297,7 @@ -(TMView *)enterPasswordContainer { - } timeout:10]; + } alwayContinueWithErrorContext:YES]; }]; @@ -321,7 +321,7 @@ -(TMView *)enterPasswordContainer { self.resetAccount.stringValue = NSLocalizedString(@"EnterPassword.ResetAccount", nil); self.resetAccount.textColor = [NSColor redColor]; - self.resetAccount.font = [NSFont fontWithName:@"HelveticaNeue" size:14]; + self.resetAccount.font = TGSystemFont(14); [self.resetAccount sizeToFit]; @@ -369,7 +369,7 @@ -(TMView *)enterPasswordContainer { [resetDescription setStringValue:NSLocalizedString(@"EnterPassword.ResetAccountDescription", nil)]; - [resetDescription setFont:[NSFont fontWithName:@"HelveticaNeue" size:13]]; + [resetDescription setFont:TGSystemFont(13)]; [resetDescription setTextColor:GRAY_TEXT_COLOR]; @@ -385,6 +385,31 @@ -(TMView *)enterPasswordContainer { return _enterPasswordContainer; } + +-(void)getHint { + + [RPCRequest sendRequest:[TLAPI_account_getPassword create] successHandler:^(id request, TL_account_password *response) { + + if([response isKindOfClass:[TL_account_password class]]) { + NSMutableAttributedString *attrs = [[NSMutableAttributedString alloc] init]; + + [attrs appendString:response.hint.length > 0 ? response.hint : NSLocalizedString(@"Password.password", nil) withColor:DARK_GRAY]; + + [attrs setAttributes:@{NSFontAttributeName:TGSystemFont(14)} range:attrs.range]; + + [attrs setAlignment:NSCenterTextAlignment range:attrs.range]; + + [self.secureField.cell setPlaceholderAttributedString:attrs]; + } + + + + } errorHandler:^(id request, RpcError *error) { + + } alwayContinueWithErrorContext:YES]; + +} + -(void)checkPassword { [TMViewController showModalProgress]; @@ -436,7 +461,7 @@ -(void)checkPassword { [TMViewController hideModalProgress]; - } timeout:10]; + } alwayContinueWithErrorContext:YES]; } -(void)checkCode { @@ -471,7 +496,7 @@ -(void)checkCode { [TMViewController hideModalProgress]; - } timeout:10]; + } alwayContinueWithErrorContext:YES]; } -(void)mouseDown:(NSEvent *)theEvent { @@ -503,6 +528,8 @@ -(void)showEnterPassword { -(void)prepare { [self.secureField setStringValue:@""]; [self.window makeFirstResponder:self.secureField]; + + [self getHint]; } -(void)hide { diff --git a/TelegramTest/TGEvent.h b/TelegramTest/TGEvent.h new file mode 100644 index 00000000..6dec345d --- /dev/null +++ b/TelegramTest/TGEvent.h @@ -0,0 +1,26 @@ +// +// TGEvent.h +// Telegram +// +// Created by keepcoder on 25.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import + +@interface TGEvent : NSObject + + +@property (nonatomic,assign,readonly) long uniqueId; +@property (nonatomic,strong,readonly) id resultObject; +@property (nonatomic,strong,readonly) NSString *eventName; + + +-(id)initWithEventName:(NSString *)eventName resultObject:(id)resultObject; + ++(id)eventWithName:(NSString *)eventName resultObject:(id)resultObject; + +-(void)dispatch; +-(void)dispatchOnQueue:(ASQueue *)queue sync:(bool)sync; + +@end diff --git a/TelegramTest/TGEvent.m b/TelegramTest/TGEvent.m new file mode 100644 index 00000000..1fabcaaf --- /dev/null +++ b/TelegramTest/TGEvent.m @@ -0,0 +1,42 @@ +// +// TGEvent.m +// Telegram +// +// Created by keepcoder on 25.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TGEvent.h" +#import "TGDispatcher.h" +@implementation TGEvent + +-(id)initWithEventName:(NSString *)eventName resultObject:(id)resultObject { + if(self = [super init]) { + + assert(eventName != nil); + + _uniqueId = rand_long(); + _eventName = [eventName copy]; + _resultObject = [resultObject copy]; + } + + return self; +} + ++(id)eventWithName:(NSString *)eventName resultObject:(id)resultObject { + return [[self alloc] initWithEventName:eventName resultObject:resultObject]; +} + +-(void)dispatch { + [TGDispatcher dispatchEvent:self onQueue:nil]; +} + +-(void)dispatchOnQueue:(ASQueue *)queue sync:(bool)sync { + [TGDispatcher dispatchEvent:self onQueue:queue]; +} + +-(void)dealloc { + +} + +@end diff --git a/TelegramTest/TGForceChannelUpdate.h b/TelegramTest/TGForceChannelUpdate.h new file mode 100644 index 00000000..99c6171c --- /dev/null +++ b/TelegramTest/TGForceChannelUpdate.h @@ -0,0 +1,17 @@ +// +// TL_updateChannelPts.h +// Telegram +// +// Created by keepcoder on 04.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import + +@interface TGForceChannelUpdate : NSObject + +@property (nonatomic,strong,readonly) id update; + +-(id)initWithUpdate:(id)update; + +@end diff --git a/TelegramTest/TGForceChannelUpdate.m b/TelegramTest/TGForceChannelUpdate.m new file mode 100644 index 00000000..16f39809 --- /dev/null +++ b/TelegramTest/TGForceChannelUpdate.m @@ -0,0 +1,21 @@ +// +// TL_updateChannelPts.m +// Telegram +// +// Created by keepcoder on 04.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TGForceChannelUpdate.h" + +@implementation TGForceChannelUpdate + +-(id)initWithUpdate:(id)update { + if(self = [super init]) { + _update = update; + } + + return self; +} + +@end diff --git a/TelegramTest/TGForwardContainer.m b/TelegramTest/TGForwardContainer.m index 47c34055..7ad25e4b 100644 --- a/TelegramTest/TGForwardContainer.m +++ b/TelegramTest/TGForwardContainer.m @@ -44,13 +44,12 @@ -(instancetype)initWithFrame:(NSRect)frameRect { [self.namesField setFrame:NSMakeRect(5, NSHeight(frameRect) - 13, NSWidth(frameRect), 20)]; - [self.descriptionField setFrame:NSMakeRect(5, 0, NSWidth(frameRect), 19)]; + [self.descriptionField setFrame:NSMakeRect(5, 0, NSWidth(frameRect), 17)]; [self addSubview:self.descriptionField]; [self addSubview:self.namesField]; - _deleteImageView = [[NSImageView alloc] initWithFrame:NSMakeRect(NSWidth(self.frame) - image_CancelReply().size.width , NSHeight(self.frame) - image_CancelReply().size.height , image_CancelReply().size.width , image_CancelReply().size.height)]; _deleteImageView.image = image_CancelReply(); diff --git a/TelegramTest/TGForwardObject.m b/TelegramTest/TGForwardObject.m index 0aba8010..b4c0bcc7 100644 --- a/TelegramTest/TGForwardObject.m +++ b/TelegramTest/TGForwardObject.m @@ -27,17 +27,24 @@ -(id)initWithMessages:(NSArray *)messages { [messages enumerateObjectsUsingBlock:^(TL_localMessage *obj, NSUInteger idx, BOOL *stop) { - if([exception indexOfObject:obj.fromUser] == NSNotFound) { - [firstNames addObject:obj.fromUser.first_name]; - [exception addObject:obj.fromUser]; + if(obj.from_id != 0) { + if([exception indexOfObject:obj.fromUser] == NSNotFound) { + [firstNames addObject:obj.fromUser.first_name]; + [exception addObject:obj.fromUser]; + } + } else { + [firstNames addObject:obj.chat.title]; + *stop = YES; } }]; + + [n appendString:[firstNames componentsJoinedByString:@", "] withColor:LINK_COLOR]; - [n setFont:[NSFont fontWithName:@"HelveticaNeue-Medium" size:13] forRange:n.range]; + [n setFont:TGSystemMediumFont(13) forRange:n.range]; _names = n; @@ -47,7 +54,7 @@ -(id)initWithMessages:(NSArray *)messages { [d appendString:[NSString stringWithFormat:NSLocalizedString(messages.count == 1 ? @"Forward.Message" : @"Forward.Messages", nil), messages.count] withColor:GRAY_TEXT_COLOR]; - [d setFont:[NSFont fontWithName:@"HelveticaNeue" size:13] forRange:d.range]; + [d setFont:TGSystemFont(13) forRange:d.range]; _fwd_desc = d; diff --git a/TelegramTest/TGGeneralInputRowItem.h b/TelegramTest/TGGeneralInputRowItem.h new file mode 100644 index 00000000..211557fd --- /dev/null +++ b/TelegramTest/TGGeneralInputRowItem.h @@ -0,0 +1,16 @@ +// +// TGGeneralInputRowItem.h +// Telegram +// +// Created by keepcoder on 05/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "TGGeneralRowItem.h" + +@interface TGGeneralInputRowItem : TGGeneralRowItem + +@property (nonatomic,strong) NSString *placeholder; +@property (nonatomic,strong) NSAttributedString *result; + +@end diff --git a/TelegramTest/TGGeneralInputRowItem.m b/TelegramTest/TGGeneralInputRowItem.m new file mode 100644 index 00000000..6aa2a8d4 --- /dev/null +++ b/TelegramTest/TGGeneralInputRowItem.m @@ -0,0 +1,27 @@ +// +// TGGeneralInputRowItem.m +// Telegram +// +// Created by keepcoder on 05/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "TGGeneralInputRowItem.h" + +@implementation TGGeneralInputRowItem + + +-(Class)viewClass { + return NSClassFromString(@"TGGeneralInputTextRowView"); +} + +-(BOOL)updateItemHeightWithWidth:(int)width { + + NSSize size = [_result sizeForTextFieldForWidth:width - (self.xOffset * 2)]; + + self.height = MAX(25, size.height + 5); + + return YES; +} + +@end diff --git a/TelegramTest/TGGeneralInputTextRowView.h b/TelegramTest/TGGeneralInputTextRowView.h new file mode 100644 index 00000000..fb89f4a1 --- /dev/null +++ b/TelegramTest/TGGeneralInputTextRowView.h @@ -0,0 +1,13 @@ +// +// TGGeneralInputTextRowView.h +// Telegram +// +// Created by keepcoder on 05/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "TMRowView.h" + +@interface TGGeneralInputTextRowView : TMRowView + +@end diff --git a/TelegramTest/TGGeneralInputTextRowView.m b/TelegramTest/TGGeneralInputTextRowView.m new file mode 100644 index 00000000..fd7e40d3 --- /dev/null +++ b/TelegramTest/TGGeneralInputTextRowView.m @@ -0,0 +1,138 @@ +// +// TGGeneralInputTextRowView.m +// Telegram +// +// Created by keepcoder on 05/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "TGGeneralInputTextRowView.h" +#import "TGGeneralInputRowItem.h" + +@interface TGGeneralInputTextRowView () +@property (nonatomic,strong) TMTextField *textField; +@property (nonatomic,strong) TMView *separator; + +@end + +@implementation TGGeneralInputTextRowView + +- (void)drawRect:(NSRect)dirtyRect { + [super drawRect:dirtyRect]; + +} + +-(instancetype)initWithFrame:(NSRect)frameRect { + if(self = [super initWithFrame:frameRect]) { + _textField = [[TMTextField alloc] init]; + [_textField setFont:TGSystemFont(13)]; + [_textField setEditable:YES]; + [_textField setBordered:NO]; + [_textField setDrawsBackground:NO]; + [_textField setFocusRingType:NSFocusRingTypeNone]; + + + [_textField setFrameSize:NSMakeSize(NSWidth(self.frame) - 60, 20)]; + + _textField.fieldDelegate = self; + _textField.delegate = self; + + [self addSubview:_textField]; + + _separator = [[TMView alloc] initWithFrame:NSZeroRect]; + + _separator.backgroundColor = DIALOG_BORDER_COLOR; + + [self addSubview:_separator]; + } + + return self; +} + + + +-(void)textFieldDidChange:(id)field { + +} + +-(void)textFieldDidBecomeFirstResponder:(id)field { + if( self.item.callback != nil) { + self.item.callback(self.item); + } +} + + +-(void)controlTextDidChange:(NSNotification *)obj { + + [_textField setStringValue:[_textField.stringValue substringToIndex:MIN(200,_textField.stringValue.length)]]; + + self.item.result = _textField.attributedStringValue; + + NSSize size = [_textField.attributedStringValue sizeForTextFieldForWidth:NSWidth(self.frame) - (self.item.xOffset * 2)]; + + + self.item.height = size.height + 5; + + NSSize oldSize = _textField.frame.size; + + if(oldSize.height != size.height) { + + + [[NSAnimationContext currentContext] setDuration:0]; + [self.rowItem.table noteHeightOfRowsWithIndexesChanged:[NSIndexSet indexSetWithIndex:self.row]]; + + + [_textField setFrameSize:NSMakeSize(NSWidth(self.frame) - self.item.xOffset * 2, size.height)]; + + + // [[_separator animator] setFrame:NSMakeRect(self.item.xOffset, 0, NSWidth(self.frame) - (self.item.xOffset * 2), DIALOG_BORDER_WIDTH)]; + // if(rand_limit(5) > 3) { + + // [NSAnimationContext runAnimationGroup:^(NSAnimationContext * _Nonnull context) { + // [context setDuration:0.5]; + [_textField setFrameOrigin:NSMakePoint(self.item.xOffset, 5)]; + // } completionHandler:^{ + + // }]; + + // } + + + + + } + + if( self.item.callback != nil) { + self.item.callback(self.item); + } + +} + + +-(void)setFrameSize:(NSSize)newSize { + [super setFrameSize:newSize]; + + [_textField setFrameOrigin:NSMakePoint(self.item.xOffset, 5)]; + [_textField setFrameSize:NSMakeSize(newSize.width - self.item.xOffset * 2, self.item.height - 5)]; + [_separator setFrame:NSMakeRect(self.item.xOffset, 0, NSWidth(self.frame) - (self.item.xOffset * 2), DIALOG_BORDER_WIDTH)]; +} + + +-(void)redrawRow { + [super redrawRow]; + + [_textField setAttributedStringValue:self.item.result]; + + if(self.item.placeholder.length > 0) { + [_textField setPlaceholderString:self.item.placeholder]; + } + + [self.window makeFirstResponder:_textField]; + +} + +-(TGGeneralInputRowItem *)item { + return (TGGeneralInputRowItem *)[self rowItem]; +} + +@end diff --git a/TelegramTest/TGGeneralRowItem.h b/TelegramTest/TGGeneralRowItem.h new file mode 100644 index 00000000..bcce1a4c --- /dev/null +++ b/TelegramTest/TGGeneralRowItem.h @@ -0,0 +1,43 @@ +// +// TGGeneralRowItem.h +// Telegram +// +// Created by keepcoder on 13.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TMRowItem.h" + +@interface TGGeneralRowItem : TMRowItem + +typedef enum +{ + SettingsRowItemTypeSwitch, + SettingsRowItemTypeChoice, + SettingsRowItemTypeNext, + SettingsRowItemTypeSelected, + SettingsRowItemTypeNone +} SettingsRowItemType; + + + +@property (nonatomic,strong) void (^callback)(TGGeneralRowItem *item); + +@property (nonatomic,strong) id (^stateback)(TGGeneralRowItem *item); + +@property (nonatomic,assign) SettingsRowItemType type; + + +@property (nonatomic,assign) int height; +@property (nonatomic,assign) int xOffset; +@property (nonatomic,assign) BOOL drawsSeparator; + + +-(id)initWithHeight:(int)height; + +-(Class)viewClass; + +-(BOOL)updateItemHeightWithWidth:(int)width; + + +@end diff --git a/TelegramTest/TGGeneralRowItem.m b/TelegramTest/TGGeneralRowItem.m new file mode 100644 index 00000000..7c5f35df --- /dev/null +++ b/TelegramTest/TGGeneralRowItem.m @@ -0,0 +1,49 @@ +// +// TGGeneralRowItem.m +// Telegram +// +// Created by keepcoder on 13.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TGGeneralRowItem.h" + +@interface TGGeneralRowItem () +@property (nonatomic,assign,readonly) int rand; +@end + +@implementation TGGeneralRowItem + + +-(id)initWithHeight:(int)height { + if(self = [super init]) { + _height = height; + _drawsSeparator = YES; + } + + return self; +} + +-(NSUInteger)hash { + if(_rand == 0) + _rand = rand_int(); + + return _rand; +} + +-(int)xOffset { + if(_xOffset < 1) + return 30; + return _xOffset; +} + + +-(Class)viewClass { + return [TMRowView class]; +} + +-(BOOL)updateItemHeightWithWidth:(int)width { + return NO; +} + +@end diff --git a/TelegramTest/TGGeneralSearchRowView.h b/TelegramTest/TGGeneralSearchRowView.h new file mode 100644 index 00000000..dbe31f19 --- /dev/null +++ b/TelegramTest/TGGeneralSearchRowView.h @@ -0,0 +1,13 @@ +// +// TGGeneralSearchRowView.h +// Telegram +// +// Created by keepcoder on 29/10/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "TMRowView.h" + +@interface TGGeneralSearchRowView : TMRowView + +@end diff --git a/TelegramTest/TGGeneralSearchRowView.m b/TelegramTest/TGGeneralSearchRowView.m new file mode 100644 index 00000000..a48299d8 --- /dev/null +++ b/TelegramTest/TGGeneralSearchRowView.m @@ -0,0 +1,59 @@ +// +// TGGeneralSearchRowView.m +// Telegram +// +// Created by keepcoder on 29/10/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "TGGeneralSearchRowView.h" +#import "TGSearchRowItem.h" +@interface TGGeneralSearchRowView () +@property (nonatomic,strong) TMSearchTextField *searchField; +@end + +@implementation TGGeneralSearchRowView + + +-(id)initWithFrame:(NSRect)frameRect { + if(self = [super initWithFrame:frameRect]) { + + _searchField = [[TMSearchTextField alloc] initWithFrame:NSMakeRect(10, 10, NSWidth(frameRect) - 20, 30)]; + + + [self addSubview:_searchField]; + + } + + return self; +} + + + +-(void)setFrameSize:(NSSize)newSize { + [super setFrameSize:newSize]; + + TGSearchRowItem *rowItem = (TGSearchRowItem *) [self rowItem]; + + [_searchField setFrame:NSMakeRect(MAX(rowItem.xOffset, 10), 10, newSize.width - MAX(rowItem.xOffset, 10)*2, rowItem.height - 20)]; +} + +-(void)mouseDown:(NSEvent *)theEvent { + [super mouseDown:theEvent]; + + [self.searchField becomeFirstResponder]; +} + +-(BOOL)becomeFirstResponder { + return [_searchField becomeFirstResponder]; +} + +-(void)redrawRow { + + TGSearchRowItem *rowItem = (TGSearchRowItem *) [self rowItem]; + + self.searchField.delegate = rowItem.delegate; + +} + +@end diff --git a/TelegramTest/TGHCMessagesViewController.h b/TelegramTest/TGHCMessagesViewController.h new file mode 100644 index 00000000..3df2f61d --- /dev/null +++ b/TelegramTest/TGHCMessagesViewController.h @@ -0,0 +1,13 @@ +// +// TGHCMessagesViewController.h +// Telegram +// +// Created by keepcoder on 19.10.15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "MessagesViewController.h" + +@interface TGHCMessagesViewController : MessagesViewController + +@end diff --git a/TelegramTest/TGHCMessagesViewController.m b/TelegramTest/TGHCMessagesViewController.m new file mode 100644 index 00000000..6dd1b6c0 --- /dev/null +++ b/TelegramTest/TGHCMessagesViewController.m @@ -0,0 +1,87 @@ +// +// TGHCMessagesViewController.m +// Telegram +// +// Created by keepcoder on 19.10.15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "TGHCMessagesViewController.h" +#import "TGModalForwardView.h" +@interface TGHCMessagesViewController () +@property (nonatomic,strong) TMTextButton *pinButton; +@property (nonatomic,strong) TMView *container; +@property (nonatomic,strong) NSImageView *imageView; +@property (nonatomic,strong) TGModalForwardView *forwardView; + +@end + +@implementation TGHCMessagesViewController + +-(void)loadView { + [super loadView]; +} + +-(TMView *)standartLeftBarView { + + + if(!_container) { + + _pinButton = [[TMTextButton alloc] initWithFrame:NSMakeRect(14, 6, 45, 20)]; + + [_pinButton setStringValue:NSLocalizedString(@"Conversation.Pin", nil)]; + [_pinButton setFont:TGSystemFont(13)]; + [_pinButton setTextColor:BLUE_UI_COLOR]; + [_pinButton sizeToFit]; + weak(); + + + [_pinButton setTapBlock:^{ + + [weakSelf pinOrUnpin]; + + }]; + + _container = [[TMView alloc] initWithFrame:NSMakeRect(0, 0, 60, 30)]; + + _imageView = imageViewWithImage(image_PinConversation()); + + [_imageView setCenteredYByView:_container]; + + + [_container addSubview:_pinButton]; + [_container addSubview:_imageView]; + + } + + + return (TMView *)_container; +} + + +-(void)didChangeDeleteDialog:(NSNotification *)notification { + TL_conversation *conversation = notification.userInfo[KEY_DIALOG]; + + if(conversation.peer_id == self.conversation.peer_id) { + [self.view.window close]; + } + +} + +-(void)pinOrUnpin { + [self.view.window setLevel:self.view.window.level == NSNormalWindowLevel ? NSScreenSaverWindowLevel : NSNormalWindowLevel]; + + [_pinButton setStringValue:self.view.window.level == NSNormalWindowLevel ? NSLocalizedString(@"Conversation.Pin", nil) : NSLocalizedString(@"Conversation.Pinned", nil)]; + [_pinButton sizeToFit]; + [_imageView setImage:self.view.window.level == NSNormalWindowLevel ? image_PinConversation() : image_PinnedConversation()]; +} + +- (void)showForwardMessagesModalView { + _forwardView = [[TGModalForwardView alloc] initWithFrame:NSMakeRect(0, 0, NSWidth(self.view.window.frame), NSHeight(self.view.window.frame))]; + + _forwardView.messagesViewController = self; + + [_forwardView show:self.view.window animated:YES]; +} + +@end diff --git a/TelegramTest/TGHeadChatPanel.h b/TelegramTest/TGHeadChatPanel.h new file mode 100644 index 00000000..dd5a440c --- /dev/null +++ b/TelegramTest/TGHeadChatPanel.h @@ -0,0 +1,20 @@ +// +// TGHeadChatPanel.h +// Telegram +// +// Created by keepcoder on 15.10.15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import + +@interface TGHeadChatPanel : TelegramWindow + ++(void)showWithConversation:(TL_conversation *)conversation; + +-(void)back; + ++(void)lockAllControllers; ++(void)unlockAllControllers; + +@end diff --git a/TelegramTest/TGHeadChatPanel.m b/TelegramTest/TGHeadChatPanel.m new file mode 100644 index 00000000..a74e366e --- /dev/null +++ b/TelegramTest/TGHeadChatPanel.m @@ -0,0 +1,162 @@ +// +// TGHeadChatPanel.m +// Telegram +// +// Created by keepcoder on 15.10.15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "TGHeadChatPanel.h" +#import "TGHCMessagesViewController.h" +#import "TGChatHeadLockView.h" +@interface TGHeadChatPanel () +@property (nonatomic,strong) TGHCMessagesViewController *messagesViewController; +@property (nonatomic,strong) TL_conversation *conversation; +@end + +@implementation TGHeadChatPanel + +-(instancetype)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag screen:(NSScreen *)screen { + if(self = [super initWithContentRect:contentRect styleMask:aStyle backing:bufferingType defer:flag screen:screen]) { + [self initializeHeadChatPanel]; + } + + return self; +} + +-(instancetype)init { + if(self = [super initWithContentRect:NSMakeRect(300, 300, 380, 400) styleMask:NSResizableWindowMask | NSTitledWindowMask | NSClosableWindowMask backing:NSBackingStoreBuffered defer:YES]) { + [self initializeHeadChatPanel]; + } + + return self; +} + +static NSMutableDictionary *allChatHeads; ++(void)initialize { + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + allChatHeads = [[NSMutableDictionary alloc] init]; + }); +} + ++(void)showWithConversation:(TL_conversation *)conversation { + + + TGHeadChatPanel *panel = allChatHeads[@(conversation.peer_id)]; + + if(!panel) { + panel = [[TGHeadChatPanel alloc] init]; + + allChatHeads[@(conversation.peer_id)] = panel; + + [panel showWithConversation:conversation]; + } + + [panel makeKeyAndOrderFront:self]; +} + +-(void)orderOut:(id)sender { + + [super orderOut:sender]; + +} + +-(void)back { + if(self.navigationController.viewControllerStack.count > 1) + [self.navigationController goBackWithAnimation:YES]; +} + + +-(void)dealloc { + [allChatHeads removeObjectForKey:@(self.conversation.peer_id)]; + + [self.navigationController.view removeFromSuperview]; + [_messagesViewController.view removeFromSuperview]; + + [self.navigationController.viewControllerStack removeAllObjects]; + + [_messagesViewController _didStackRemoved]; + [_messagesViewController viewDidDisappear:NO]; + [_messagesViewController drop]; + self.navigationController.currentController = nil; + _messagesViewController.navigationViewController = nil; + + + + _messagesViewController = nil; + self.navigationController = nil; +} + + +-(void)showWithConversation:(TL_conversation *)conversation { + _conversation = conversation; + + [_messagesViewController setCurrentConversation:conversation]; +} + + + + +-(void)initializeHeadChatPanel { + + self.canHide = NO; + self.acceptEvents = YES; + [self setReleasedWhenClosed:YES]; + + [self setMinSize:NSMakeSize(380, 400)]; + + self.contentView.wantsLayer = YES; + // self.contentView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable; + + self.navigationController = [[TMNavigationController alloc] initWithFrame:self.contentView.bounds]; + + + _messagesViewController = [[TGHCMessagesViewController alloc] initWithFrame:self.contentView.bounds]; + + self.navigationController.messagesViewController = _messagesViewController; + + [_messagesViewController loadViewIfNeeded]; + [self.contentView addSubview:self.navigationController.view]; + + [self.navigationController pushViewController:_messagesViewController animated:NO]; + +} + +-(void)setFrame:(NSRect)frameRect display:(BOOL)flag { + + [super setFrame:frameRect display:flag]; + + + + // [self.navigationController.view setFrameSize:NSMakeSize(frameRect.size.width, frameRect.size.height - 20)]; + +} + ++(void)lockAllControllers { + [allChatHeads enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, TGHeadChatPanel *obj, BOOL * _Nonnull stop) { + + if(obj.acceptEvents) { + [obj.contentView addSubview:[[TGChatHeadLockView alloc] initWithFrame:obj.contentView.bounds]]; + + [obj setAcceptEvents:NO]; + } + + }]; +} + ++(void)unlockAllControllers { + [allChatHeads enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, TGHeadChatPanel *obj, BOOL * _Nonnull stop) { + + if(!obj.acceptEvents) { + [[obj.contentView.subviews lastObject] removeFromSuperview]; + + [obj setAcceptEvents:YES]; + } + + }]; +} + + + +@end diff --git a/TelegramTest/TGHeader.h b/TelegramTest/TGHeader.h index 5445441d..1a72112f 100644 --- a/TelegramTest/TGHeader.h +++ b/TelegramTest/TGHeader.h @@ -13,12 +13,11 @@ #define TGUNREADMESSAGE 0x1 #define TGOUTUNREADMESSAGE 0x3 #define TGNOFLAGSMESSAGE 0x0 - #define TGFWDMESSAGE 0x4 #define TGREPLYMESSAGE 0x8 #define TGMENTIONMESSAGE 16 #define TGREADEDCONTENT 32 - +#define TGFROMIDMESSAGE 256 #define TGSESSIONCURRENT 0x1 #define TGSESSIONOFFICIAL 0x2 @@ -61,9 +60,23 @@ #define NSColorFromRGBWithAlpha(rgbValue, alphaValue) [NSColor colorWithDeviceRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:(alphaValue)] -#define TGSystemFont(s) [NSFont fontWithName:@"HelveticaNeue" size:(s)] -#define TGSystemMediumFont(s) [NSFont fontWithName:@"HelveticaNeue-Medium" size:(s)] -#define TGSystemLightFont(s) [NSFont fontWithName:@"HelveticaNeue-Light" size:(s)] +//#define TGSystemFont(s) [NSFont fontWithName:@"HelveticaNeue" size:(s)] +//#define TGSystemMediumFont(s) [NSFont fontWithName:@"HelveticaNeue-Medium" size:(s)] +//#define TGSystemLightFont(s) [NSFont fontWithName:@"HelveticaNeue-Light" size:(s)] +//#define TGSystemItalicFont(s) [NSFont fontWithName:@"HelveticaNeue-Italic" size:(s)] +//#define TGSystemBoldItalicFont(s) [NSFont fontWithName:@"HelveticaNeue-BoldItalic" size:(s)] +//#define TGSystemBoldFont(s) [NSFont fontWithName:@"HelveticaNeue-Bold" size:(s)] + +//[NSFont fontWithName:@".SFNSDisplay-Regular" size:(s)] +//[NSFont fontWithName:@".SFNSText-Medium" size:(s)] +//[NSFont fontWithName:@".SFNSText-Regular" size:(s)] +#define TGSystemFont(s) NSAppKitVersionNumber > NSAppKitVersionNumber10_10_Max ? [NSFont systemFontOfSize:(s)] : [NSFont fontWithName:@"HelveticaNeue" size:(s)] +#define TGSystemMediumFont(s) NSAppKitVersionNumber > NSAppKitVersionNumber10_10_Max ? [NSFont fontWithName:@".SFNSDisplay-Semibold" size:(s)] : [NSFont fontWithName:@"HelveticaNeue-Medium" size:(s)] +#define TGSystemLightFont(s) NSAppKitVersionNumber > NSAppKitVersionNumber10_10_Max ? [NSFont systemFontOfSize:(s) weight:0] : [NSFont fontWithName:@"HelveticaNeue-Light" size:(s)] +#define TGSystemItalicFont(s) NSAppKitVersionNumber > NSAppKitVersionNumber10_10_Max ? [NSFont fontWithName:@".SFNSText-Italic" size:(s)] : [NSFont fontWithName:@"HelveticaNeue-Italic" size:(s)] +#define TGSystemBoldItalicFont(s) NSAppKitVersionNumber > NSAppKitVersionNumber10_10_Max ? [NSFont fontWithName:@".SFNSText-BoldItalic" size:(s)] : [NSFont fontWithName:@"HelveticaNeue-BoldItalic" size:(s)] +#define TGSystemBoldFont(s) NSAppKitVersionNumber > NSAppKitVersionNumber10_10_Max ? [NSFont fontWithName:@".SFNSDisplay-Semibold" size:(s)] : [NSFont fontWithName:@"HelveticaNeue-Bold" size:(s)] + #define VIDEO_COMPRESSED_PROGRESS 10.0f #define MAX_FILE_SIZE 1500000000 @@ -86,6 +99,7 @@ #define GRAY_BORDER_COLOR NSColorFromRGB(0xe4e4e4) #define LIGHT_GRAY_BORDER_COLOR NSColorFromRGB(0xededed) #define LINK_COLOR BLUE_UI_COLOR +#define BLUE_SEPARATOR_COLOR NSColorFromRGB(0x66A7DB) #define MIN_IMG_SIZE NSMakeSize(250,40) #define weakify() __block __typeof(&*self)strongSelf = self; diff --git a/TelegramTest/TGHistoryResponse.h b/TelegramTest/TGHistoryResponse.h new file mode 100644 index 00000000..d9b737eb --- /dev/null +++ b/TelegramTest/TGHistoryResponse.h @@ -0,0 +1,20 @@ +// +// HistoryResponse.h +// Telegram +// +// Created by keepcoder on 27.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import + +@interface TGHistoryResponse : NSObject + +@property (nonatomic,strong,readonly) NSArray *result; +@property (nonatomic,strong,readonly) TGMessageHole *hole; + +@property (nonatomic,strong,readonly) NSArray *groupHoles; + +-(id)initWithResult:(NSArray *)result hole:(TGMessageHole *)hole groupHoles:(NSArray *)groupHoles; + +@end diff --git a/TelegramTest/TGHistoryResponse.m b/TelegramTest/TGHistoryResponse.m new file mode 100644 index 00000000..2c2c1dab --- /dev/null +++ b/TelegramTest/TGHistoryResponse.m @@ -0,0 +1,23 @@ +// +// HistoryResponse.m +// Telegram +// +// Created by keepcoder on 27.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TGHistoryResponse.h" + +@implementation TGHistoryResponse + +-(id)initWithResult:(NSArray *)result hole:(TGMessageHole *)hole groupHoles:(NSArray *)groupHoles { + if(self = [super init]) { + _result = result; + _hole = hole; + _groupHoles = groupHoles; + } + + return self; +} + +@end diff --git a/TelegramTest/TGImageView.h b/TelegramTest/TGImageView.h index 317fe553..d1db87a7 100644 --- a/TelegramTest/TGImageView.h +++ b/TelegramTest/TGImageView.h @@ -13,7 +13,6 @@ @interface TGImageView : BTRImageView - @property (nonatomic,strong) ImageObject *object; diff --git a/TelegramTest/TGInitializer.h b/TelegramTest/TGInitializer.h deleted file mode 100644 index 7ddd1eae..00000000 --- a/TelegramTest/TGInitializer.h +++ /dev/null @@ -1,13 +0,0 @@ -// -// MTProtoConnect.h -// TelegramTest -// -// Created by keepcoder on 07.09.13. -// Copyright (c) 2013 keepcoder. All rights reserved. -// - -#import - -@interface TGInitializer : NSObject -- (void) onAuthSuccess; -@end diff --git a/TelegramTest/TGInitializer.m b/TelegramTest/TGInitializer.m deleted file mode 100644 index 076efc08..00000000 --- a/TelegramTest/TGInitializer.m +++ /dev/null @@ -1,64 +0,0 @@ -// -// MTProtoConnect.m -// TelegramTest -// -// Created by keepcoder on 07.09.13. -// Copyright (c) 2013 keepcoder. All rights reserved. -// - -#import "TGInitializer.h" -#import "AppDelegate.h" -#import "NSString+NSStringHexToBytes.h" -#import -#import -#import "NSMutableData+Extension.h" -#import "NSData+Extensions.h" -#import "Crypto.h" -#import "CMath.h" -#import "RPCRequest.h" -#import "TLApi.h" -#import "DialogsHistoryController.h" -@implementation TGInitializer - --(id)init { - if(self = [super init]) { - if([[MTNetwork instance] isAuth]) { - [self localInitialize]; - } else { - [self showAuthWindow]; - } - } - return self; -} - - --(void)showAuthWindow { -// [[Telegram sharedInstance] showLoginViewController:YES]; -} - - -- (void) onAuthSuccess { - - [[DialogsHistoryController sharedController] setState:DialogsHistoryStateNeedRemote]; - [[DialogsHistoryController sharedController] next:0 limit:20 callback:^(NSArray *result) { - [Notification perform:APP_RUN object:nil]; - [Notification perform:DIALOGS_NEED_FULL_RESORT data:@{KEY_DIALOGS:result}]; - [Notification perform:PROTOCOL_UPDATED data:nil]; - [[NewContactsManager sharedManager] fullReload]; -// [PushNotificationsManager sharedManager]; - } usersCallback:nil]; - -// [[Telegram sharedInstance] showLoginViewController:NO]; -} - --(void)localInitialize { - - - - -} - - - - -@end diff --git a/TelegramTest/TGKeychain.h b/TelegramTest/TGKeychain.h index f1823f28..dfdcd06b 100644 --- a/TelegramTest/TGKeychain.h +++ b/TelegramTest/TGKeychain.h @@ -9,9 +9,12 @@ #import @interface TGKeychain : NSObject - +{ + @public + bool _encrypted; +} + (instancetype)unencryptedKeychainWithName:(NSString *)name; - ++ (instancetype)keychainWithName:(NSString *)name; @property (nonatomic,assign) BOOL notEncryptedKeychain; @property (nonatomic,assign,readonly) BOOL isNeedPasscode; @@ -20,7 +23,7 @@ -(NSData *)md5PasscodeHash; - +-(void)storeAllKeychain; -(void)loadIfNeeded; -(void)cleanup; diff --git a/TelegramTest/TGKeychain.m b/TelegramTest/TGKeychain.m index cb67f68b..708c4152 100644 --- a/TelegramTest/TGKeychain.m +++ b/TelegramTest/TGKeychain.m @@ -38,7 +38,7 @@ @interface TGKeychain () { NSString *_name; - bool _encrypted; + NSData *_aesKey; NSData *_aesIv; NSData *_passcodeHash; @@ -66,12 +66,21 @@ + (instancetype)unencryptedKeychainWithName:(NSString *)name keychain = [[TGKeychain alloc] initWithName:name encrypted:false]; [keychains() setObject:keychain forKey:name]; } + + keychain->_encrypted = false; + [keychain cleanup]; + [keychain loadIfNeeded]; + TG_SYNCHRONIZED_END(_keychains); return keychain; } +NSString * serviceName() { + return [[NSProcessInfo processInfo].environment[@"test_server"] boolValue] || [[NSUserDefaults standardUserDefaults] boolForKey:@"test-backend"] ? @"telegram-test-server" : @"Telegram"; +} + + (instancetype)keychainWithName:(NSString *)name { if (name == nil) @@ -84,6 +93,11 @@ + (instancetype)keychainWithName:(NSString *)name keychain = [[TGKeychain alloc] initWithName:name encrypted:true]; [keychains() setObject:keychain forKey:name]; } + + keychain->_encrypted = true; + [keychain cleanup]; + [keychain loadIfNeeded]; + TG_SYNCHRONIZED_END(_keychains); return keychain; @@ -110,7 +124,7 @@ - (NSString *)filePathForName:(NSString *)name group:(NSString *)group static NSString *dataDirectory = nil; NSString *applicationSupportPath = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES)[0]; - NSString *applicationName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"]; + NSString *applicationName = serviceName(); dataDirectory = [[applicationSupportPath stringByAppendingPathComponent:applicationName] stringByAppendingPathComponent:_notEncryptedKeychain ? @"mtkeychain" : @"encrypt-mtkeychain"]; [[NSFileManager defaultManager] createDirectoryAtPath:dataDirectory withIntermediateDirectories:YES attributes:nil error:nil]; @@ -120,8 +134,6 @@ - (NSString *)filePathForName:(NSString *)name group:(NSString *)group -(void)loadIfNeeded { - NSArray *groups = @[@"persistent",@"primes",@"temp"]; - [groups enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { [self _loadKeychainIfNeeded:obj]; @@ -131,7 +143,6 @@ -(void)loadIfNeeded { -(void)cleanup { - NSArray *groups = @[@"persistent",@"primes",@"temp"]; [groups enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { @@ -140,12 +151,17 @@ -(void)cleanup { }]; } ++(void)initialize { + groups = @[@"persistent",@"primes",@"temp"]; +} + +static NSArray *groups; + -(BOOL)updatePasscodeHash:(NSData *)md5Hash save:(BOOL)save { if(!md5Hash) md5Hash = [[NSData alloc] initWithEmptyBytes:32]; - NSArray *groups = @[@"persistent",@"primes",@"temp"]; NSData *part1 = [md5Hash subdataWithRange:NSMakeRange(0, 16)]; @@ -161,36 +177,13 @@ -(BOOL)updatePasscodeHash:(NSData *)md5Hash save:(BOOL)save { if(save) { - [groups enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - - [self _storeKeychain:obj]; - - }]; + [self storeAllKeychain]; } - + [self cleanup]; [self loadIfNeeded]; - if(!_isNeedPasscode) { - - NSString *pass = [NSString stringWithUTF8String:_passcodeHash.bytes]; - - Class sc = NSClassFromString(@"Storage"); - - if(sc) { - - [sc performSelector:@selector(dbSetKey:) withObject:pass]; - - if(save) { - [sc performSelector:@selector(dbRekey:) withObject:pass]; - } - } - - - } - - return !_isNeedPasscode; @@ -211,7 +204,7 @@ - (void)_loadKeychainIfNeeded:(NSString *)group { if(_encrypted) { - _readKeychainData = [NSKeyedUnarchiver unarchiveObjectWithData:[SSKeychain passwordDataForService:@"Telegram" account:@"authkeys"]]; + _readKeychainData = [NSKeyedUnarchiver unarchiveObjectWithData:[SSKeychain passwordDataForService:serviceName() account:@"authkeys"]]; } @@ -332,6 +325,14 @@ - (void)_loadKeychainIfNeeded:(NSString *)group } } +-(void)storeAllKeychain { + [groups enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + + [self _storeKeychain:obj]; + + }]; +} + - (void)_storeKeychain:(NSString *)group { if (_dictByGroup[group] != nil && _name != nil) @@ -378,7 +379,7 @@ - (void)_storeKeychain:(NSString *)group } -(void)saveKeychain { - [SSKeychain setPasswordData:[NSKeyedArchiver archivedDataWithRootObject:_saveKeychainData] forService:@"Telegram" account:@"authkeys"]; + [SSKeychain setPasswordData:[NSKeyedArchiver archivedDataWithRootObject:_saveKeychainData] forService:serviceName() account:@"authkeys"]; } - (void)setObject:(id)object forKey:(id)aKey group:(NSString *)group diff --git a/TelegramTest/TGMentionPopup.m b/TelegramTest/TGMentionPopup.m index b1e38773..e22f2f39 100644 --- a/TelegramTest/TGMentionPopup.m +++ b/TelegramTest/TGMentionPopup.m @@ -28,10 +28,22 @@ +(void)show:(NSString *)string chat:(TLChat *)chat view:(NSView *)view ofRect:(N NSMutableArray *uids = [[NSMutableArray alloc] init]; - [fullChat.participants.participants enumerateObjectsUsingBlock:^(TLChatParticipant * obj, NSUInteger idx, BOOL *stop) { - [uids addObject:@(obj.user_id)]; + if([chat isKindOfClass:[TL_chat class]]) { + [fullChat.participants.participants enumerateObjectsUsingBlock:^(TLChatParticipant * obj, NSUInteger idx, BOOL *stop) { + [uids addObject:@(obj.user_id)]; + + }]; + } else { - }]; + NSArray *contacts = [[NewContactsManager sharedManager] all]; + + [contacts enumerateObjectsUsingBlock:^(TLContact *obj, NSUInteger idx, BOOL *stop) { + + [uids addObject:@(obj.user_id)]; + + }]; + } + NSArray *users = [UsersManager findUsersByMention:string withUids:uids]; diff --git a/TelegramTest/TGMenuItemPhoto.m b/TelegramTest/TGMenuItemPhoto.m index b0fb6b62..5f709a2a 100644 --- a/TelegramTest/TGMenuItemPhoto.m +++ b/TelegramTest/TGMenuItemPhoto.m @@ -70,7 +70,7 @@ -(void)generatePhoto { NSString *text = [TMAvatarImageView text:_user]; - image = [TMAvatarImageView generateTextAvatar:colorMask size:NSMakeSize(30, 30) text:text type: TMAvatarTypeUser font:[NSFont fontWithName:@"HelveticaNeue" size:12] offsetY:2]; + image = [TMAvatarImageView generateTextAvatar:colorMask size:NSMakeSize(30, 30) text:text type: TMAvatarTypeUser font:TGSystemFont(12) offsetY:2]; self.menuItem.image = image; } diff --git a/TelegramTest/TGMessageGroupHole.h b/TelegramTest/TGMessageGroupHole.h new file mode 100644 index 00000000..84ac6b18 --- /dev/null +++ b/TelegramTest/TGMessageGroupHole.h @@ -0,0 +1,13 @@ +// +// TGMessageGroupHole.h +// Telegram +// +// Created by keepcoder on 28.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import +#import "TGMessageHole.h" +@interface TGMessageGroupHole : TGMessageHole + +@end diff --git a/TelegramTest/TGMessageGroupHole.m b/TelegramTest/TGMessageGroupHole.m new file mode 100644 index 00000000..ed41c576 --- /dev/null +++ b/TelegramTest/TGMessageGroupHole.m @@ -0,0 +1,18 @@ +// +// TGMessageGroupHole.m +// Telegram +// +// Created by keepcoder on 28.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TGMessageGroupHole.h" + +@implementation TGMessageGroupHole + + +-(int)type { + return 4; +} + +@end diff --git a/TelegramTest/TGMessageHole.h b/TelegramTest/TGMessageHole.h new file mode 100644 index 00000000..f3525485 --- /dev/null +++ b/TelegramTest/TGMessageHole.h @@ -0,0 +1,29 @@ +// +// TGMessageHole.h +// Telegram +// +// Created by keepcoder on 27.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import + +@interface TGMessageHole : NSObject + +@property (nonatomic,assign,readonly) int uniqueId; +@property (nonatomic,assign,readonly) int peer_id; +@property (nonatomic,assign) int min_id; +@property (nonatomic,assign) int max_id; +@property (nonatomic,assign) int date; +@property (nonatomic,assign) int messagesCount; + + +@property (nonatomic,assign) BOOL isImploded; + +-(id)initWithUniqueId:(int)uniqueId peer_id:(int)peer_id min_id:(int)min_id max_id:(int)max_id date:(int)date count:(int)count isImploded:(BOOL)isImploded; +-(id)initWithUniqueId:(int)uniqueId peer_id:(int)peer_id min_id:(int)min_id max_id:(int)max_id date:(int)date count:(int)count; +-(void)save; +-(void)remove; +-(int)type; + +@end diff --git a/TelegramTest/TGMessageHole.m b/TelegramTest/TGMessageHole.m new file mode 100644 index 00000000..e5382814 --- /dev/null +++ b/TelegramTest/TGMessageHole.m @@ -0,0 +1,51 @@ +// +// TGMessageHole.m +// Telegram +// +// Created by keepcoder on 27.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TGMessageHole.h" +#import "Storage.h" +@implementation TGMessageHole + +-(id)initWithUniqueId:(int)uniqueId peer_id:(int)peer_id min_id:(int)min_id max_id:(int)max_id date:(int)date count:(int)count { + if(self = [super init]) { + _uniqueId = uniqueId; + _peer_id = peer_id; + _min_id = min_id; + _max_id = max_id; + _date = date; + _messagesCount = count; + } + + return self; +} + +-(id)initWithUniqueId:(int)uniqueId peer_id:(int)peer_id min_id:(int)min_id max_id:(int)max_id date:(int)date count:(int)count isImploded:(BOOL)isImploded; +{ + if(self = [self initWithUniqueId:uniqueId peer_id:peer_id min_id:min_id max_id:max_id date:date count:count]) { + _isImploded = isImploded; + } + + return self; +} + +-(void)save { + [[Storage manager] insertMessagesHole:self]; +} + +-(void)remove { + [[Storage manager] removeHole:self]; +} + +-(void)setMessagesCount:(int)messagesCount { + _messagesCount = MAX(0,messagesCount); +} + +-(int)type { + return 2; +} + +@end diff --git a/TelegramTest/TGMessageViewSender.h b/TelegramTest/TGMessageViewSender.h new file mode 100644 index 00000000..2364145d --- /dev/null +++ b/TelegramTest/TGMessageViewSender.h @@ -0,0 +1,15 @@ +// +// TGMessageViewSender.h +// Telegram +// +// Created by keepcoder on 18.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import +#import "MessageTableItem.h" +@interface TGMessageViewSender : NSObject + ++(void)addItem:(MessageTableItem *)item; + +@end diff --git a/TelegramTest/TGMessageViewSender.m b/TelegramTest/TGMessageViewSender.m new file mode 100644 index 00000000..7b260da5 --- /dev/null +++ b/TelegramTest/TGMessageViewSender.m @@ -0,0 +1,156 @@ +// +// TGMessageViewSender.m +// Telegram +// +// Created by keepcoder on 18.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TGMessageViewSender.h" +#import "TGTimer.h" +#import "TGTLSerialization.h" + +@interface TGViewSender : NSObject +{ + TGTimer *timer; + MTRequest *request; + NSMutableArray *waitingItems; +} + +@end + + +@implementation TGViewSender + +-(instancetype)init { + if(self = [super init]) { + waitingItems = [[NSMutableArray alloc] init]; + } + + return self; +} + +-(void)addItem:(MessageTableItem *)item { + + [ASQueue dispatchOnMainQueue:^{ + [waitingItems addObject:item]; + + [timer invalidate]; + + [[MTNetwork instance] cancelRequestWithInternalId:request.internalId]; + + [request setCompleted:nil]; + + timer = [[TGTimer alloc] initWithTimeout:2 repeat:NO completion:^{ + + NSArray *items = [waitingItems copy]; + + NSMutableArray *ids = [[NSMutableArray alloc] init]; + + TL_conversation *conversation = [(MessageTableItem *)items[0] message].conversation; + + [waitingItems enumerateObjectsUsingBlock:^(MessageTableItem *obj, NSUInteger idx, BOOL *stop) { + [ids addObject:@(obj.message.n_id)]; + }]; + + + request = [[MTRequest alloc] init]; + + id body = [TLAPI_messages_getMessagesViews createWithPeer:conversation.inputPeer n_id:ids increment:YES]; + + request.body = body; + + + + [request setPayload:[TGTLSerialization serializeMessage:body] metadata:body responseParser:^id(NSData *data) { + + NSMutableArray *vector = [[NSMutableArray alloc] init]; + + SerializedData *stream = [[SerializedData alloc] init]; + NSInputStream *inputStream = [[NSInputStream alloc] initWithData:data]; + [inputStream open]; + [stream setInput:inputStream]; + + int constructor = [stream readInt]; + + if(constructor == 481674261) { + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + int views = [stream readInt]; + [vector addObject:@(views)]; + + } + } + + return vector; + + }]; + + weakify(); + + [request setCompleted:^(NSArray *result, NSTimeInterval t, id error) { + + + [ASQueue dispatchOnMainQueue:^{ + + [items enumerateObjectsUsingBlock:^(MessageTableItem *obj, NSUInteger idx, BOOL *stop) { + BOOL needUpdate = obj.message.views != [result[idx] intValue]; + + if([result[idx] intValue] != 0) { + obj.message.views = [result[idx] intValue]; + + if(needUpdate) { + [obj.message saveViews]; + [Notification perform:UPDATE_MESSAGE_ITEM data:@{@"item":obj}]; + } + } + + + + }]; + + [strongSelf->waitingItems removeObjectsInArray:items]; + + }]; + + }]; + + [[MTNetwork instance] addRequest:request]; + + + } queue:dispatch_get_main_queue()]; + + [timer start]; + }]; + + + +} + +@end + +@implementation TGMessageViewSender + + +static NSMutableDictionary *viewChannels; + ++(void)initialize { + viewChannels = [[NSMutableDictionary alloc] init]; +} + ++(void)addItem:(MessageTableItem *)item { + + TGViewSender *sender = viewChannels[@(item.message.peer_id)]; + + if(!sender) { + sender = [[TGViewSender alloc] init]; + viewChannels[@(item.message.peer_id)] = sender; + } + + [sender addItem:item]; + + + +} + +@end diff --git a/TelegramTest/TGMessagesHintView.h b/TelegramTest/TGMessagesHintView.h new file mode 100644 index 00000000..539ec571 --- /dev/null +++ b/TelegramTest/TGMessagesHintView.h @@ -0,0 +1,27 @@ +// +// TGMessagesHintView.h +// Telegram +// +// Created by keepcoder on 29.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TGView.h" + +@interface TGMessagesHintView : TGView + + + + +-(void)showCommandsHintsWithQuery:(NSString *)query conversation:(TL_conversation *)conversation botInfo:(NSArray *)botInfo choiceHandler:(void (^)(NSString *result))choiceHandler; +-(void)showHashtagHintsWithQuery:(NSString *)query conversation:(TL_conversation *)conversation peer_id:(int)peer_id choiceHandler:(void (^)(NSString *result))choiceHandler; +-(void)showMentionPopupWithQuery:(NSString *)query conversation:(TL_conversation *)conversation chat:(TLChat *)chat choiceHandler:(void (^)(NSString *result))choiceHandler; + +-(void)selectNext; +-(void)selectPrev; + +-(void)hide; + +-(void)performSelected; + +@end diff --git a/TelegramTest/TGMessagesHintView.m b/TelegramTest/TGMessagesHintView.m new file mode 100644 index 00000000..450198c8 --- /dev/null +++ b/TelegramTest/TGMessagesHintView.m @@ -0,0 +1,543 @@ +// +// TGMessagesHintView.m +// Telegram +// +// Created by keepcoder on 29.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TGMessagesHintView.h" +#import "TGImageView.h" + + +@interface TL_botCommand (BotCommandCategory2) + +-(void)setUser:(TLUser *)user; +-(TLUser *)user; + +@end + +@implementation TL_botCommand (BotCommandCategory2) + +DYNAMIC_PROPERTY(DUser); + +-(void)setUser:(TLUser *)user { + [self setDUser:user]; +} + +-(TLUser *)user { + return [self getDUser]; +} + +@end + +@interface TGMessagesHintRowItem : TMRowItem +@property (nonatomic,strong) id imageObject; +@property (nonatomic,strong) NSString *text; +@property (nonatomic,strong) NSString *desc; +@property (nonatomic,assign) NSUInteger h; + +@property (nonatomic,strong) NSString *result; + + +@end + +@interface TGMessagesHintRowView : TMRowView +@property (nonatomic,strong) TMTextField *textField; +@property (nonatomic,strong) TMAvatarImageView *imageView; +@property (nonatomic,strong) TMTextField *descField; + +@end + + + +@implementation TGMessagesHintRowItem + +-(id)initWithImageObject:(id)imageObject text:(NSString *)text desc:(NSString *)desc { + if(self = [super init]) { + _imageObject = imageObject; + _text = text; + _desc = desc; + _h = rand_long(); + } + + return self; +} + +-(NSUInteger)hash { + return _h; +} + +@end + + +@implementation TGMessagesHintRowView + + + +-(instancetype)initWithFrame:(NSRect)frameRect { + if(self = [super initWithFrame:frameRect]) { + _textField = [TMTextField defaultTextField]; + _descField = [TMTextField defaultTextField]; + + [_textField setFont:TGSystemFont(13)]; + [_textField setTextColor:TEXT_COLOR]; + + + [_descField setFont:TGSystemFont(12)]; + [_descField setTextColor:GRAY_TEXT_COLOR]; + + + [_textField setStringValue:@"test"]; + [_descField setStringValue:@"test"]; + + [_textField sizeToFit]; + [_descField sizeToFit]; + + _imageView = [TMAvatarImageView standartHintAvatar]; + [_imageView setFrameOrigin:NSMakePoint(10,5)]; + + //self.backgroundColor = [NSColor redColor]; + + [self addSubview:_textField]; + [self addSubview:_descField]; + [self addSubview:_imageView]; + + + } + + return self; +} + +-(void)redrawRow { + [super redrawRow]; + + TGMessagesHintRowItem *item = (TGMessagesHintRowItem *)[self rowItem]; + + int xOffset = item.imageObject == nil ? 10 : 30 + 15; + + [_imageView setHidden:item.imageObject == nil]; + + if([item.imageObject isKindOfClass:[TLUser class]]) { + [_imageView setUser:item.imageObject]; + } else if([item.imageObject isKindOfClass:[TLChat class]]) { + [_imageView setChat:item.imageObject]; + } + + + [_descField setHidden:item.desc.length == 0]; + + + [_textField setStringValue:item.text]; + + + [_descField setStringValue:item.desc]; + + [_textField setTextColor:self.isSelected ? [NSColor whiteColor] : TEXT_COLOR]; + [_descField setTextColor:self.isSelected ? [NSColor whiteColor] : GRAY_TEXT_COLOR]; + + [_textField setFrameOrigin:NSMakePoint(xOffset, roundf(NSHeight(self.frame)/2) - (_descField.isHidden ? roundf(NSHeight(_textField.frame)/2) - 3 : -1) )]; + + [_descField setFrameOrigin:NSMakePoint(xOffset, NSMinY(_textField.frame) - NSHeight(_descField.frame) + 2)]; +} + +-(void)drawRect:(NSRect)dirtyRect { + [super drawRect:dirtyRect]; + + [GRAY_BORDER_COLOR set]; + + TGMessagesHintRowItem *item = (TGMessagesHintRowItem *)[self rowItem]; + + int xOffset = item.imageObject == nil ? 10 : 30 + 15; + + + + if(self.isSelected) { + + [BLUE_COLOR_SELECT set]; + + NSRectFill(NSMakeRect(0, 0, NSWidth(dirtyRect) , NSHeight(dirtyRect))); + } else { + + TMTableView *table = item.table; + + if([table indexOfItem:item] != table.count - 1) { + NSRectFill(NSMakeRect(xOffset, 0, NSWidth(dirtyRect) - xOffset, 1)); + } + } +} + +-(void)setFrameSize:(NSSize)newSize { + [super setFrameSize:newSize]; + + [_textField setFrameSize:NSMakeSize(newSize.width - NSMinX(_textField.frame) - 10, NSHeight(_textField.frame))]; + [_descField setFrameSize:NSMakeSize(newSize.width - NSMinX(_descField.frame) - 10, NSHeight(_descField.frame))]; +} + +@end + + + + +@interface TGMessagesHintView () +@property (nonatomic,strong) TMTableView *tableView; +@property (nonatomic,copy) void (^choiceHandler)(NSString *result); +@property (nonatomic,strong) TMView *separator; +@end + +@implementation TGMessagesHintView + + + +- (CGFloat)rowHeight:(NSUInteger)row item:(TGMessagesHintRowItem *) item { + return 40; +} + +- (BOOL)isGroupRow:(NSUInteger)row item:(TGMessagesHintRowItem *) item { + return NO; +} + +- (TMRowView *)viewForRow:(NSUInteger)row item:(TGMessagesHintRowItem *) item { + return [_tableView cacheViewForClass:[TGMessagesHintRowView class] identifier:NSStringFromClass([TGMessagesHintRowView class]) withSize:NSMakeSize(NSWidth(self.frame), 40)]; +} + +- (void)selectionDidChange:(NSInteger)row item:(TGMessagesHintRowItem *) item { + [self performSelected]; +} + +- (BOOL)selectionWillChange:(NSInteger)row item:(TGMessagesHintRowItem *) item { + return YES; +} + +- (BOOL)isSelectable:(NSInteger)row item:(TGMessagesHintRowItem *) item { + return YES; +} + + +-(instancetype)initWithFrame:(NSRect)frameRect { + if(self = [super initWithFrame:frameRect]) { + + _tableView = [[TMTableView alloc] initWithFrame:NSMakeRect(0, 0, NSWidth(frameRect), NSHeight(frameRect))]; + _tableView.defaultAnimation = NSTableViewAnimationEffectFade; + _tableView.tm_delegate = self; + + [self addSubview:_tableView.containerView]; + + + self.autoresizingMask = NSViewWidthSizable; + + + _separator = [[TMView alloc] initWithFrame:NSMakeRect(0, NSHeight(frameRect) - DIALOG_BORDER_WIDTH, NSWidth(frameRect), DIALOG_BORDER_WIDTH)]; + + _separator.backgroundColor = DIALOG_BORDER_COLOR; + + _separator.autoresizingMask = NSViewWidthSizable | NSViewMinYMargin; + + [self addSubview:_separator]; + + } + + return self; +} + + + + +-(void)showCommandsHintsWithQuery:(NSString *)query conversation:(TL_conversation *)conversation botInfo:(NSArray *)botInfo choiceHandler:(void (^)(NSString *result))choiceHandler { + + _choiceHandler = choiceHandler; + + NSMutableArray *commands = [[NSMutableArray alloc] init]; + + [botInfo enumerateObjectsUsingBlock:^(TLBotInfo *obj, NSUInteger idx, BOOL *stop) { + + TLUser *user = [[UsersManager sharedManager] find:obj.user_id]; + + [obj.commands enumerateObjectsUsingBlock:^(TL_botCommand *command, NSUInteger idx, BOOL *stop) { + + NSString *cmd = command.command; + + if((conversation.type == DialogTypeChat || conversation.type == DialogTypeChannel) && (user.flags & TGUSERFLAGREADHISTORY) != TGUSERFLAGREADHISTORY) { + cmd = [cmd stringByAppendingString:[NSString stringWithFormat:@"@%@",user.username]]; + } + + TL_botCommand *c = [TL_botCommand createWithCommand:cmd n_description:command.n_description]; + [c setUser:user]; + [commands addObject:c]; + + }]; + + }]; + + + commands = query.length > 0 ? [[commands filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.command BEGINSWITH[c] %@",query]] mutableCopy] : commands; + + NSMutableArray *items = [[NSMutableArray alloc] init]; + + + [commands enumerateObjectsUsingBlock:^(TL_botCommand *obj, NSUInteger idx, BOOL *stop) { + + + TGMessagesHintRowItem *item = [[TGMessagesHintRowItem alloc] initWithImageObject:obj.user text:obj.command desc:obj.n_description]; + + item.result = obj.command; + + [items addObject:item]; + }]; + + [_tableView removeAllItems:YES]; + + [_tableView insert:items startIndex:0 tableRedraw:YES]; + + if(items.count > 0) + [self show:NO]; + else + [self hide]; + +} + +-(void)showHashtagHintsWithQuery:(NSString *)query conversation:(TL_conversation *)conversation peer_id:(int)peer_id choiceHandler:(void (^)(NSString *result))choiceHandler { + + _choiceHandler = choiceHandler; + + __block NSMutableDictionary *tags; + + + [[Storage yap] readWithBlock:^(YapDatabaseReadTransaction *transaction) { + + tags = [[transaction objectForKey:@"htags" inCollection:@"hashtags"] mutableCopy]; + + NSMutableDictionary *prs = [transaction objectForKey:[NSString stringWithFormat:@"htags_%d",peer_id] inCollection:@"hashtags"]; + + [tags addEntriesFromDictionary:prs]; + + }]; + + + NSArray *list = [[tags allValues] sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) { + + return obj1[@"count"] < obj2[@"count"]; + + }]; + + + if(query.length > 0) + { + list = [list filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.tag BEGINSWITH[c] %@",query]]; + } + + + NSMutableArray *items = [[NSMutableArray alloc] init]; + + [list enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + + TGMessagesHintRowItem *item = [[TGMessagesHintRowItem alloc] initWithImageObject:nil text:[NSString stringWithFormat:@"#%@",obj[@"tag"]]desc:nil]; + + item.result = obj[@"tag"]; + + [items addObject:item]; + + }]; + + [_tableView removeAllItems:YES]; + + [_tableView insert:items startIndex:0 tableRedraw:YES]; + + if(items.count > 0) + [self show:NO]; + else + [self hide]; + +} + +-(void)showMentionPopupWithQuery:(NSString *)query conversation:(TL_conversation *)conversation chat:(TLChat *)chat choiceHandler:(void (^)(NSString *result))choiceHandler { + + _choiceHandler = choiceHandler; + + TLChatFull *fullChat = [[FullChatManager sharedManager] find:chat.n_id]; + + NSMutableArray *uids = [[NSMutableArray alloc] init]; + + if(fullChat.participants.participants) { + [fullChat.participants.participants enumerateObjectsUsingBlock:^(TLChatParticipant * obj, NSUInteger idx, BOOL *stop) { + [uids addObject:@(obj.user_id)]; + + }]; + } else { + + NSArray *contacts = [[NewContactsManager sharedManager] all]; + + [contacts enumerateObjectsUsingBlock:^(TLContact *obj, NSUInteger idx, BOOL *stop) { + + [uids addObject:@(obj.user_id)]; + + }]; + } + + + + NSArray *users = [UsersManager findUsersByMention:query withUids:uids]; + + + NSMutableArray *items = [[NSMutableArray alloc] init]; + + + NSArray *chats = [ChatsManager findChatsByName:query]; + + [chats enumerateObjectsUsingBlock:^(TLChat *obj, NSUInteger idx, BOOL *stop) { + + TGMessagesHintRowItem *item = [[TGMessagesHintRowItem alloc] initWithImageObject:obj text:obj.title desc:[NSString stringWithFormat:@"@%@",obj.username]]; + + item.result = obj.username; + + [items addObject:item]; + }]; + + + [users enumerateObjectsUsingBlock:^(TLUser *obj, NSUInteger idx, BOOL *stop) { + + TGMessagesHintRowItem *item = [[TGMessagesHintRowItem alloc] initWithImageObject:obj text:obj.fullName desc:[NSString stringWithFormat:@"@%@",obj.username]]; + + item.result = obj.username; + + [items addObject:item]; + }]; + + + + + + [_tableView removeAllItems:YES]; + + [_tableView insert:items startIndex:0 tableRedraw:YES]; + + if(items.count > 0) + [self show:NO]; + else + [self hide]; +} + +-(void)show:(BOOL)animated { + if(self.alphaValue == 1.0f && !self.isHidden) { + [self updateFrames:YES]; + [self selectNext]; + return; + } + + self.hidden = NO; + + if(animated) { + self.alphaValue = 0.f; + + [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) { + + [[self animator] setAlphaValue:1.0f]; + + } completionHandler:^{ + + }]; + } else { + self.alphaValue = 1.0f; + } + + [self updateFrames:NO]; + + [self selectNext]; +} + +-(void)updateFrames:(BOOL)animated { + if(animated) { + + NSUInteger height = MIN(self.tableView.count * 40, 140 ); + + + [NSAnimationContext runAnimationGroup:^(NSAnimationContext * _Nonnull context) { + + [[self animator] setFrameSize:NSMakeSize(NSWidth(self.frame), height)]; + + + } completionHandler:^{ + }]; + + + } else { + [self setFrameSize:NSMakeSize(NSWidth(self.frame), MIN(self.tableView.count * 40, 140 ))]; + [self.tableView.containerView setFrameSize:NSMakeSize(NSWidth(self.frame), NSHeight(self.frame) )]; + + [_separator setFrame:NSMakeRect(0, NSHeight(self.frame) - DIALOG_BORDER_WIDTH, NSWidth(self.frame), DIALOG_BORDER_WIDTH)]; + [self.tableView scrollToBeginningOfDocument:self]; + } + + +} + +-(void)hide { + + [self hide:NO]; +} + +-(void)hide:(BOOL)animated { + + + if(self.alphaValue == 0.f || self.isHidden) + return; + + if(animated) { + + [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) { + + [[self animator] setAlphaValue:0.f]; + + } completionHandler:^{ + self.hidden = YES; + }]; + } else { + self.alphaValue = 0; + self.hidden = YES; + } +} + +-(void)performSelected { + if(_choiceHandler != nil) + { + TGMessagesHintRowItem *item = (TGMessagesHintRowItem *) _tableView.selectedItem; + + if(item != nil) { + _choiceHandler(item.result); + } + + + } +} + +-(void)selectNext { + + NSUInteger selectedIndex = _tableView.selectedItem == nil ? -1 : [_tableView indexOfItem:_tableView.selectedItem]; + + selectedIndex++; + + if(selectedIndex == _tableView.count) { + selectedIndex = 0; + } + + [_tableView setSelectedObject:[_tableView itemAtPosition:selectedIndex]]; + + [_tableView.scrollView.clipView scrollRectToVisible:[_tableView rectOfRow:selectedIndex] animated:NO]; + + +} +-(void)selectPrev { + NSUInteger selectedIndex = _tableView.selectedItem == nil ? _tableView.count : [_tableView indexOfItem:_tableView.selectedItem]; + + selectedIndex--; + + if(selectedIndex == -1) { + selectedIndex = _tableView.count-1; + } + + [_tableView setSelectedObject:[_tableView itemAtPosition:selectedIndex]]; + + [_tableView.scrollView.clipView scrollRectToVisible:[_tableView rectOfRow:selectedIndex] animated:NO]; +} + +@end diff --git a/TelegramTest/TGModalDeleteChannelMessagesView.h b/TelegramTest/TGModalDeleteChannelMessagesView.h new file mode 100644 index 00000000..fcc1e9a0 --- /dev/null +++ b/TelegramTest/TGModalDeleteChannelMessagesView.h @@ -0,0 +1,15 @@ +// +// TGModalDeleteChannelMessagesView.h +// Telegram +// +// Created by keepcoder on 17.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TGModalView.h" + +@interface TGModalDeleteChannelMessagesView : TGModalView + +-(void)showWithAction:(ComposeAction *)action; + +@end diff --git a/TelegramTest/TGModalDeleteChannelMessagesView.m b/TelegramTest/TGModalDeleteChannelMessagesView.m new file mode 100644 index 00000000..256cef03 --- /dev/null +++ b/TelegramTest/TGModalDeleteChannelMessagesView.m @@ -0,0 +1,173 @@ +// +// TGModalDeleteChannelMessagesView.m +// Telegram +// +// Created by keepcoder on 17.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TGModalDeleteChannelMessagesView.h" +#import "TGSettingsTableView.h" +@interface TGModalDeleteChannelMessagesView () +@property (nonatomic,strong) TGSettingsTableView *tableView; +@property (nonatomic,strong) ComposeAction *action; + +@property (nonatomic,strong) BTRButton *ok; +@property (nonatomic,strong) BTRButton *cancel; + + +@end + +@implementation TGModalDeleteChannelMessagesView + + +-(instancetype)initWithFrame:(NSRect)frameRect { + if(self = [super initWithFrame:frameRect]) { + [self setContainerFrameSize:NSMakeSize(280, 260)]; + + + weak(); + + _ok = [[BTRButton alloc] initWithFrame:NSMakeRect(self.containerSize.width/2, 0, self.containerSize.width/2, 49)]; + + _ok.layer.backgroundColor = [NSColor whiteColor].CGColor; + + [_ok setTitleColor:LINK_COLOR forControlState:BTRControlStateNormal]; + + [_ok setTitle:NSLocalizedString(@"OK", nil) forControlState:BTRControlStateNormal]; + + [_ok addBlock:^(BTRControlEvents events) { + + [weakSelf.action.behavior composeDidDone]; + + } forControlEvents:BTRControlEventMouseDownInside]; + + + [self addSubview:_ok]; + + + + _cancel = [[BTRButton alloc] initWithFrame:NSMakeRect(0, 0, self.containerSize.width/2, 50)]; + + _cancel.layer.backgroundColor = [NSColor whiteColor].CGColor; + + [_cancel setTitleColor:LINK_COLOR forControlState:BTRControlStateNormal]; + + [_cancel setTitle:NSLocalizedString(@"Cancel", nil) forControlState:BTRControlStateNormal]; + + [_cancel addBlock:^(BTRControlEvents events) { + + [weakSelf.action.behavior composeDidCancel]; + + weakSelf.action = nil; + [weakSelf close:YES]; + + + } forControlEvents:BTRControlEventMouseDownInside]; + + [self addSubview:_cancel]; + + + TMView *separator = [[TMView alloc] initWithFrame:NSMakeRect(0, 49, self.containerSize.width, 1)]; + [separator setBackgroundColor:DIALOG_BORDER_COLOR]; + [self addSubview:separator]; + + separator = [[TMView alloc] initWithFrame:NSMakeRect(self.containerSize.width/2, 0, 1, 50)]; + [separator setBackgroundColor:DIALOG_BORDER_COLOR]; + [self addSubview:separator]; + + + _tableView = [[TGSettingsTableView alloc] initWithFrame:NSMakeRect(0, 50, self.containerSize.width, self.containerSize.height - 49)]; + + [self addSubview:_tableView.containerView]; + } + + return self; +} + +-(void)behaviorDidEndRequest:(id)response { + [TMViewController hideModalProgressWithSuccess]; +} + +-(void)behaviorDidStartRequest { + [self close:NO]; + [TMViewController showModalProgress]; +} + + +-(void)showWithAction:(ComposeAction *)action { + + _action = action; + _action.behavior.delegate = self; + + assert(action.result.multiObjects.count == 4); + + [super show:[[NSApp delegate] mainWindow] animated:YES]; + + + GeneralSettingsBlockHeaderItem *header = [[GeneralSettingsBlockHeaderItem alloc] initWithString:NSLocalizedString(@"Channel.DeleteMessagesModalHeader", nil) height:42 flipped:NO]; + + + header.xOffset = 30; + + [header setAligment:NSCenterTextAlignment]; + [header setTextColor:TEXT_COLOR]; + [header setFont:TGSystemFont(15)]; + + [_tableView addItem:header tableRedraw:NO]; + + GeneralSettingsRowItem *deleteItem = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSelected callback:^(TGGeneralRowItem *item) {} description:NSLocalizedString(@"Channel.DeleteMessageModal", nil) height:42 stateback:^id(TGGeneralRowItem *item) { + return _action.result.multiObjects[0]; + }]; + + GeneralSettingsRowItem *banUser = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSelected callback:^(TGGeneralRowItem *item) { + + BOOL currentValue = [self.action.result.multiObjects[1] boolValue]; + + _action.result = [[ComposeResult alloc] initWithMultiObjects:@[@(YES),@(!currentValue),_action.result.multiObjects[2],_action.result.multiObjects[3]]]; + + [_tableView reloadData]; + + } description:NSLocalizedString(@"Channel.BanUserModal", nil) height:42 stateback:^id(TGGeneralRowItem *item) { + return _action.result.multiObjects[1]; + }]; + + GeneralSettingsRowItem *reportSpam = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSelected callback:^(TGGeneralRowItem *item) { + + BOOL currentValue = [self.action.result.multiObjects[2] boolValue]; + + _action.result = [[ComposeResult alloc] initWithMultiObjects:@[@(YES),_action.result.multiObjects[1],@(!currentValue),_action.result.multiObjects[3]]]; + + [_tableView reloadData]; + + } description:NSLocalizedString(@"Channel.ReportSpamModal", nil) height:42 stateback:^id(TGGeneralRowItem *item) { + return _action.result.multiObjects[2]; + }]; + + GeneralSettingsRowItem *deleteAllMesages = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSelected callback:^(TGGeneralRowItem *item) { + + BOOL currentValue = [self.action.result.multiObjects[3] boolValue]; + + _action.result = [[ComposeResult alloc] initWithMultiObjects:@[@(YES),_action.result.multiObjects[1],_action.result.multiObjects[2],@(!currentValue)]]; + + [_tableView reloadData]; + + } description:NSLocalizedString(@"Channel.DeleteAllMessagesModal", nil) height:42 stateback:^id(TGGeneralRowItem *item) { + return _action.result.multiObjects[3]; + }]; + + deleteAllMesages.drawsSeparator = NO; + + deleteItem.xOffset = banUser.xOffset = reportSpam.xOffset = deleteAllMesages.xOffset = 30; + + + [_tableView addItem:deleteItem tableRedraw:NO]; + [_tableView addItem:banUser tableRedraw:NO]; + [_tableView addItem:reportSpam tableRedraw:NO]; + // [_tableView addItem:deleteAllMesages tableRedraw:NO]; + + [_tableView reloadData]; + +} + +@end diff --git a/TelegramTest/TGModalForwardView.h b/TelegramTest/TGModalForwardView.h new file mode 100644 index 00000000..b1ff7c98 --- /dev/null +++ b/TelegramTest/TGModalForwardView.h @@ -0,0 +1,15 @@ +// +// TGModalForwardView.h +// Telegram +// +// Created by keepcoder on 21.10.15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "TGModalView.h" + +@interface TGModalForwardView : TGModalView + +@property (nonatomic,weak) MessagesViewController *messagesViewController; + +@end diff --git a/TelegramTest/TGModalForwardView.m b/TelegramTest/TGModalForwardView.m new file mode 100644 index 00000000..d6a123ed --- /dev/null +++ b/TelegramTest/TGModalForwardView.m @@ -0,0 +1,80 @@ +// +// TGModalForwardView.m +// Telegram +// +// Created by keepcoder on 21.10.15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "TGModalForwardView.h" +#import "SelectUsersTableView.h" +#import "MessageTableItem.h" +@interface TGModalForwardView () +@property (nonatomic,strong) SelectUsersTableView *tableView; +@end + +@implementation TGModalForwardView + + +-(instancetype)initWithFrame:(NSRect)frameRect { + if(self = [super initWithFrame:frameRect]) { + [self setContainerFrameSize:NSMakeSize(MIN(NSWidth(frameRect) - 60,400), MIN(NSHeight(frameRect) - 60,400))]; + + + [self initialize]; + } + + return self; +} + +-(void)setFrameSize:(NSSize)newSize { + [super setFrameSize:newSize]; + + [self setContainerFrameSize:NSMakeSize(MIN(NSWidth(self.frame) - 60,400), MIN(NSHeight(self.frame) - 60,400))]; + +} + +-(void)initialize { + _tableView = [[SelectUsersTableView alloc] initWithFrame:NSMakeRect(0, 50, self.containerSize.width, self.containerSize.height - 50)]; + + _tableView.selectDelegate = self; + _tableView.selectLimit = 10; + + [self enableCancelAndOkButton]; + + [self addSubview:_tableView.containerView]; + + [_tableView readyConversations]; +} + +-(void)okAction { + + NSMutableArray *ids = [[NSMutableArray alloc] init]; + for(MessageTableItem *item in _messagesViewController.selectedMessages) + [ids addObject:item.message]; + + [ids sortUsingComparator:^NSComparisonResult(TLMessage * a, TLMessage * b) { + return a.n_id > b.n_id ? NSOrderedDescending : NSOrderedAscending; + }]; + + + [_tableView.selectedItems enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + + TL_conversation *conversation = [obj isKindOfClass:[SelectUserItem class]] ? [[obj valueForKey:@"user"] dialog] : [[obj valueForKey:@"chat"] dialog]; + + [_messagesViewController forwardMessages:ids conversation:conversation callback:nil]; + + }]; + + [_messagesViewController cancelSelectionAndScrollToBottom]; + + [self close:YES]; + +} + + +-(void)selectTableDidChangedItem:(id)item { + +} + +@end diff --git a/TelegramTest/TGModalSetCaptionView.m b/TelegramTest/TGModalSetCaptionView.m index a89a5a0b..816228d6 100644 --- a/TelegramTest/TGModalSetCaptionView.m +++ b/TelegramTest/TGModalSetCaptionView.m @@ -82,7 +82,7 @@ -(instancetype)initWithFrame:(NSRect)frameRect { _textView.minHeight = _textView.maxHeight = NSHeight(_textView.containerView.frame); _textView.limit = 140; - [_textView setFont:[NSFont fontWithName:@"HelveticaNeue" size:13]]; + [_textView setFont:TGSystemFont(13)]; } diff --git a/TelegramTest/TGModalView.h b/TelegramTest/TGModalView.h index 7ca4c48c..215a4223 100644 --- a/TelegramTest/TGModalView.h +++ b/TelegramTest/TGModalView.h @@ -14,6 +14,11 @@ -(void)close:(BOOL)animated; +-(void)enableCancelAndOkButton; +-(void)okAction; +-(void)cancelAction; + + -(void)modalViewDidShow; -(void)modalViewDidHide; diff --git a/TelegramTest/TGModalView.m b/TelegramTest/TGModalView.m index 26b6f23b..34435fa7 100644 --- a/TelegramTest/TGModalView.m +++ b/TelegramTest/TGModalView.m @@ -11,6 +11,11 @@ @interface TGModalView () @property (nonatomic,strong) TMView *containerView; @property (nonatomic,strong) TMView *backgroundView; + +@property (nonatomic,strong) TMView *animationContainerView; + +@property (nonatomic,strong) BTRButton *ok; +@property (nonatomic,strong) BTRButton *cancel; @end @implementation TGModalView @@ -28,9 +33,74 @@ -(instancetype)initWithFrame:(NSRect)frameRect { } return self; +} + +-(void)enableCancelAndOkButton { + weak(); + + _ok = [[BTRButton alloc] initWithFrame:NSMakeRect(self.containerSize.width/2, 0, self.containerSize.width/2, 49)]; + _ok.autoresizingMask = NSViewWidthSizable; + _ok.layer.backgroundColor = [NSColor whiteColor].CGColor; + + [_ok setTitleColor:LINK_COLOR forControlState:BTRControlStateNormal]; + + [_ok setTitle:NSLocalizedString(@"OK", nil) forControlState:BTRControlStateNormal]; + + [_ok addBlock:^(BTRControlEvents events) { + + [weakSelf okAction]; + + } forControlEvents:BTRControlEventMouseDownInside]; + + + [self addSubview:_ok]; + + + + _cancel = [[BTRButton alloc] initWithFrame:NSMakeRect(0, 0, self.containerSize.width/2, 50)]; + _cancel.autoresizingMask = NSViewWidthSizable; + _cancel.layer.backgroundColor = [NSColor whiteColor].CGColor; + + [_cancel setTitleColor:LINK_COLOR forControlState:BTRControlStateNormal]; + + [_cancel setTitle:NSLocalizedString(@"Cancel", nil) forControlState:BTRControlStateNormal]; + + [_cancel addBlock:^(BTRControlEvents events) { + + [weakSelf cancelAction]; + + + } forControlEvents:BTRControlEventMouseDownInside]; + + [self addSubview:_cancel]; + + + TMView *separator = [[TMView alloc] initWithFrame:NSMakeRect(0, 49, self.containerSize.width, 1)]; + [separator setBackgroundColor:DIALOG_BORDER_COLOR]; + + separator.autoresizingMask = NSViewWidthSizable; + [self addSubview:separator]; + + separator = [[TMView alloc] initWithFrame:NSMakeRect(self.containerSize.width/2, 0, 1, 50)]; + separator.autoresizingMask = NSViewMaxXMargin | NSViewMinXMargin; + [separator setBackgroundColor:DIALOG_BORDER_COLOR]; + [self addSubview:separator]; + + + + + } +-(void)okAction { + +} + +-(void)cancelAction { + [self close:YES]; +} + -(void)initializeModalView { @@ -54,17 +124,25 @@ -(void)initializeModalView { _containerView.layer.backgroundColor = [NSColor whiteColor].CGColor; + [super addSubview:_backgroundView]; + - [_containerView setCenterByView:self]; - [super addSubview:_backgroundView]; - [super addSubview:_containerView]; + _animationContainerView = [[TMView alloc] initWithFrame:_containerView.bounds]; + _animationContainerView.wantsLayer = YES; + _animationContainerView.layer.cornerRadius = 4; + _animationContainerView.layer.backgroundColor = [NSColor whiteColor].CGColor; + [_animationContainerView addSubview:_containerView]; + + [super addSubview:_animationContainerView]; } -(void)mouseDown:(NSEvent *)theEvent { - if(![self mouse:[self convertPoint:[theEvent locationInWindow] fromView:nil] inRect:_containerView.frame]) { + + + if(![self mouse:[self convertPoint:[theEvent locationInWindow] fromView:nil] inRect:_animationContainerView.frame]) { [self close:YES]; } } @@ -73,7 +151,8 @@ -(void)setFrameSize:(NSSize)newSize { [super setFrameSize:newSize]; [_backgroundView setFrameSize:newSize]; - [_containerView setCenterByView:self]; + [_animationContainerView setCenterByView:self]; + } -(void)show:(NSWindow *)window animated:(BOOL)animated { @@ -83,16 +162,47 @@ -(void)show:(NSWindow *)window animated:(BOOL)animated { [window.contentView addSubview:self]; [window makeFirstResponder:self]; + + self.layer.opacity = 1; + + if(animated) { + + [window makeFirstResponder:self]; + + self.containerView.layer.opacity = 0; + //[_containerView.layer setFrameOrigin:]; - if(!animated) { - self.layer.opacity = 0; + POPBasicAnimation *anim = [TMViewController popAnimationForProgress:self.containerView.layer.opacity to:1]; + anim.duration = 0.2; + anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]; + [self.containerView.layer pop_addAnimation:anim forKey:@"fade"]; - [[[Telegram delegate] window] makeFirstResponder:self]; - POPBasicAnimation *anim = [TMViewController popAnimationForProgress:self.layer.opacity to:1]; - [self.layer pop_addAnimation:anim forKey:@"fade"]; + _animationContainerView.layer.anchorPoint = CGPointMake(0.5, 0.5); + + _animationContainerView.layer.position = CGPointMake(roundf(NSWidth(self.frame) / 2), roundf(NSHeight(self.frame) / 2)); + + POPBasicAnimation *sizeAnim = [POPBasicAnimation animationWithPropertyNamed:kPOPLayerSize]; + + sizeAnim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]; + + sizeAnim.fromValue = [NSValue valueWithSize:NSMakeSize(0, 0)]; + sizeAnim.toValue = [NSValue valueWithSize:self.containerSize]; + sizeAnim.duration = 0.1; + [_animationContainerView.layer pop_addAnimation:sizeAnim forKey:@"size"]; + + + + POPBasicAnimation *originContainerAnim = [POPBasicAnimation animationWithPropertyNamed:kPOPLayerPosition]; + originContainerAnim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]; + originContainerAnim.fromValue = [NSValue valueWithPoint:NSMakePoint(- roundf(NSWidth(_animationContainerView.frame)/2), - roundf(NSHeight(_animationContainerView.frame)/2))]; + originContainerAnim.toValue = [NSValue valueWithPoint:NSMakePoint(0, 0)]; + originContainerAnim.duration = 0.1; + + [_containerView.layer pop_addAnimation:originContainerAnim forKey:@"origin"]; + } @@ -101,6 +211,88 @@ -(void)show:(NSWindow *)window animated:(BOOL)animated { } +/* + [[[Telegram delegate] window] makeFirstResponder:self]; + + // self.layer.opacity = 0; + + //[_containerView.layer setFrameOrigin:]; + [self setContainerFrameSize:NSMakeSize(self.containerSize.width + 20, self.containerSize.height + 20)]; + + [self setFrameSize:self.frame.size]; + + POPBasicAnimation *anim = [TMViewController popAnimationForProgress:self.layer.opacity to:1]; + + // [self.layer pop_addAnimation:anim forKey:@"fade"]; + + _animationContainerView.layer.backgroundColor = [NSColor redColor].CGColor; + + _containerView.layer.backgroundColor = [NSColor blueColor].CGColor; + + _animationContainerView.layer.anchorPoint = CGPointMake(0.5, 0.5); + + _animationContainerView.layer.position = CGPointMake(roundf(NSWidth(self.frame) / 2), roundf(NSHeight(self.frame) / 2)); + + POPBasicAnimation *sizeAnim = [POPBasicAnimation animationWithPropertyNamed:kPOPLayerSize]; + + sizeAnim.fromValue = [NSValue valueWithSize:NSMakeSize(0, 0)]; + sizeAnim.toValue = [NSValue valueWithSize:self.containerSize]; + sizeAnim.duration = 0.2; + [_animationContainerView.layer pop_addAnimation:sizeAnim forKey:@"size"]; + + + [sizeAnim setCompletionBlock:^(POPAnimation *anim, BOOL completed) { + + POPBasicAnimation *c = (POPBasicAnimation *) anim; + c.removedOnCompletion = YES; + c.completionBlock = nil; + + c.fromValue = [NSValue valueWithSize:_animationContainerView.layer.frame.size]; + c.toValue = [NSValue valueWithSize:NSMakeSize(self.containerSize.width - 20, self.containerSize.height - 20)]; + + + [_animationContainerView.layer pop_addAnimation:c forKey:@"size"]; + + }]; + + POPBasicAnimation *originContainerAnim = [POPBasicAnimation animationWithPropertyNamed:kPOPLayerPosition]; + + originContainerAnim.fromValue = [NSValue valueWithPoint:NSMakePoint(- roundf(NSWidth(_animationContainerView.frame)/2), - roundf(NSHeight(_animationContainerView.frame)/2))]; + originContainerAnim.toValue = [NSValue valueWithPoint:NSMakePoint(-10, -10)]; + originContainerAnim.duration = 0.2; + + [_containerView.layer pop_addAnimation:originContainerAnim forKey:@"origin"]; + + + [originContainerAnim setCompletionBlock:^(POPAnimation *anim, BOOL completed) { + + + + POPBasicAnimation *c = (POPBasicAnimation *) anim; + c.removedOnCompletion = YES; + c.completionBlock = nil; + + c.fromValue = [NSValue valueWithPoint:_containerView.layer.frame.origin]; + c.toValue = [NSValue valueWithPoint:NSMakePoint(0, 0)]; + [_containerView.layer pop_addAnimation:c forKey:@"origin"]; + + + + POPBasicAnimation *s = [POPBasicAnimation animationWithPropertyNamed:kPOPLayerSize]; + s.removedOnCompletion = YES; + s.fromValue = [NSValue valueWithSize:_containerView.layer.frame.size]; + s.toValue = [NSValue valueWithSize:NSMakeSize(self.containerSize.width - 20, self.containerSize.height - 20)]; + s.duration = 5; + [_containerView.layer pop_addAnimation:s forKey:@"size"]; + + [s setCompletionBlock:^(POPAnimation *anim, BOOL completed) { + // [self setContainerFrameSize:NSMakeSize(self.containerSize.width - 20, self.containerSize.height - 20)]; + }]; + + }]; + + */ + -(void)close:(BOOL)animated { @@ -164,9 +356,14 @@ -(void)addSubview:(NSView *)aView { } -(void)setContainerFrameSize:(NSSize)size { + [_containerView setFrameSize:size]; + [_animationContainerView setFrameSize:size]; + [_animationContainerView setCenterByView:self]; + - [_containerView setCenterByView:self]; + [_ok setFrame:NSMakeRect(self.containerSize.width/2, 0, self.containerSize.width/2, 49)]; + [_cancel setFrame:NSMakeRect(0, 0, self.containerSize.width/2, 50)]; } -(NSSize)containerSize { diff --git a/TelegramTest/TGModernChannelInfoViewController.h b/TelegramTest/TGModernChannelInfoViewController.h new file mode 100644 index 00000000..fd36567a --- /dev/null +++ b/TelegramTest/TGModernChannelInfoViewController.h @@ -0,0 +1,15 @@ +// +// TGModernChannelInfoViewController.h +// Telegram +// +// Created by keepcoder on 04/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "ComposeViewController.h" + +@interface TGModernChannelInfoViewController : ComposeViewController + +-(void)setChat:(TLChat *)chat; + +@end diff --git a/TelegramTest/TGModernChannelInfoViewController.m b/TelegramTest/TGModernChannelInfoViewController.m new file mode 100644 index 00000000..c2cd0af0 --- /dev/null +++ b/TelegramTest/TGModernChannelInfoViewController.m @@ -0,0 +1,537 @@ +// +// TGModernChannelInfoViewController.m +// Telegram +// +// Created by keepcoder on 04/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "TGModernChannelInfoViewController.h" +#import "TGSettingsTableView.h" +#import "TGProfileHeaderRowItem.h" +#import "TGSProfileMediaRowItem.h" +#import "TGProfileParamItem.h" +#import "ComposeActionInfoProfileBehavior.h" +#import "MessagesUtils.h" +#import "TGUserContainerRowItem.h" +#import "TGUserContainerView.h" +#import "TGProfileHeaderRowView.h" +#import "TGModernUserViewController.h" +#import "ComposeActionAddGroupMembersBehavior.h" +#import "TGPhotoViewer.h" +#import "ChatAdminsViewController.h" +#import "ComposeActionBlackListBehavior.h" +#import "ComposeActionChannelMembersBehavior.h" +#import "ComposeChangeChannelDescriptionViewController.h" +#import "ComposeActionChangeChannelAboutBehavior.h" +#import "TGReportChannelModalView.h" +@interface TGModernChannelInfoViewController () +@property (nonatomic,strong) TGSettingsTableView *tableView; + +@property (nonatomic,strong) TLChat *chat; +@property (nonatomic,strong) TL_conversation *conversation; + + +@property (nonatomic,strong) TGProfileHeaderRowItem *headerItem; +@property (nonatomic,strong) TGSProfileMediaRowItem *mediaItem; +@property (nonatomic,strong) GeneralSettingsRowItem *notificationItem; +@property (nonatomic,strong) GeneralSettingsBlockHeaderItem *participantsHeaderItem; + + + +@property (nonatomic,strong) ComposeAction *composeActionManagment; +@end + +@implementation TGModernChannelInfoViewController + + +-(void)loadView { + [super loadView]; + + _tableView = [[TGSettingsTableView alloc] initWithFrame:self.view.bounds]; + + [self.view addSubview:_tableView.containerView]; +} + +-(void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; + + self.action.editable = NO; + + [self updateActionNavigation]; + + [self configure]; + + [self drawParticipants:_chat.chatFull.participants.participants]; + +} + +-(void)didUpdatedEditableState { + + if(!self.action.isEditable && ![self.headerItem.firstChangedValue isEqualToString:_chat.title] && self.headerItem.firstChangedValue.length > 0) { + + NSString *prev = _chat.title; + + _chat.title = self.headerItem.firstChangedValue; + + [Notification perform:CHAT_UPDATE_TITLE data:@{KEY_CHAT:_chat}]; + + + [RPCRequest sendRequest:[TLAPI_channels_editTitle createWithChannel:_chat.inputPeer title:self.headerItem.firstChangedValue] successHandler:^(RPCRequest *request, id response) { + + } errorHandler:^(RPCRequest *request, RpcError *error) { + _chat.title = prev; + + [Notification perform:CHAT_UPDATE_TITLE data:@{KEY_CHAT:_chat.title}]; + }]; + } + + + [_tableView.list enumerateObjectsUsingBlock:^(TMRowItem *obj, NSUInteger idx, BOOL * _Nonnull stop) { + + if([obj isKindOfClass:[TMRowItem class]]) { + [obj setEditable:self.action.isEditable]; + } + + }]; + + [self configure]; + + [self drawParticipants:_chat.chatFull.participants.participants]; + +} + +-(void)viewWillDisappear:(BOOL)animated { + [super viewWillDisappear:animated]; + + [Notification removeObserver:self]; +} + +-(void)setChat:(TLChat *)chat { + + _chat = chat; + _conversation = chat.dialog; + + if(_chat.isMegagroup) { + _chat.chatFull.participants = [TL_chatParticipants createWithChat_id:_chat.n_id participants:[NSMutableArray array] version:0]; + } + + _composeActionManagment = [[ComposeAction alloc] initWithBehaviorClass:[ComposeActionBehavior class] filter:@[] object:chat];; + + [self setAction:[[ComposeAction alloc] initWithBehaviorClass:[ComposeActionInfoProfileBehavior class] filter:nil object:_conversation]]; + + _tableView.defaultAnimation = NSTableViewAnimationEffectFade; + +} + + + +-(void)loadNextParticipants { + + [self removeScrollEvent]; + + int offset = (int) _chat.chatFull.participants.participants.count; + + [RPCRequest sendRequest:[TLAPI_channels_getParticipants createWithChannel:_chat.inputPeer filter:[TL_channelParticipantsRecent create] offset:offset limit:30] successHandler:^(id request, TL_channels_channelParticipants *response) { + + [SharedManager proccessGlobalResponse:response]; + + + [_chat.chatFull.participants.participants addObjectsFromArray:response.participants]; + + [self drawParticipants:response.participants]; + + + if(response.participants.count > 0) + [self addScrollEvent]; + else + [self removeScrollEvent]; + + + } errorHandler:^(id request, RpcError *error) { + + + }]; + +} + +-(void)drawParticipants:(NSArray *)participants { + + NSMutableArray *items = [NSMutableArray array]; + + [participants enumerateObjectsUsingBlock:^(TLChatParticipant *obj, NSUInteger idx, BOOL * _Nonnull stop) { + + TGUserContainerRowItem *user = [[TGUserContainerRowItem alloc] initWithUser:[[UsersManager sharedManager] find:obj.user_id]]; + user.height = 50; + user.type = SettingsRowItemTypeNone; + user.editable = self.action.isEditable; + + + [user setStateback:^id(TGGeneralRowItem *item) { + + BOOL canRemoveUser = ((obj.user_id != [UsersManager currentUserId] && (self.chat.isCreator || self.chat.isManager)) && ![obj isKindOfClass:[TL_channelParticipantCreator class]]); + + return @(canRemoveUser); + + }]; + + __weak TGUserContainerRowItem *weakItem = user; + + [user setStateCallback:^{ + + if(self.action.isEditable) { + if([weakItem.stateback(weakItem) boolValue]) + [self kickParticipant:weakItem]; + } else { + TGModernUserViewController *viewController = [[TGModernUserViewController alloc] initWithFrame:NSZeroRect]; + + [viewController setUser:weakItem.user conversation:weakItem.user.dialog]; + + [self.navigationViewController pushViewController:viewController animated:YES]; + } + + }]; + + [items addObject:user]; + }]; + + + [_tableView insert:items startIndex:_tableView.list.count tableRedraw:YES]; +} + + +- (void)scrollViewDocumentOffsetChangingNotificationHandler:(NSNotification *)aNotification { + + if([self.tableView.scrollView isNeedUpdateBottom] ) { + + [self loadNextParticipants]; + + } + +} + +- (void) addScrollEvent { + id clipView = [[self.tableView enclosingScrollView] contentView]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(scrollViewDocumentOffsetChangingNotificationHandler:) + name:NSViewBoundsDidChangeNotification + object:clipView]; +} + +- (void) removeScrollEvent { + id clipView = [[self.tableView enclosingScrollView] contentView]; + [[NSNotificationCenter defaultCenter] removeObserver:self name:NSViewBoundsDidChangeNotification object:clipView]; +} + + +-(void)kickParticipant:(TGUserContainerRowItem *)participant { + + + NSUInteger idx = [_tableView indexOfItem:participant]; + + _chat.chatFull.participants_count--; + [_participantsHeaderItem redrawRow]; + + if(idx != NSNotFound) { + [_tableView removeItem:participant tableRedraw:YES]; + + [RPCRequest sendRequest:[TLAPI_channels_kickFromChannel createWithChannel:self.chat.inputPeer user_id:participant.user.inputUser kicked:YES] successHandler:^(id request, id response) { + + } errorHandler:^(id request, RpcError *error) { + + [_tableView insert:participant atIndex:idx tableRedraw:YES]; + + }]; + } + + + +} + +-(void)configure { + + [self.doneButton setHidden:!_chat.isManager && !_chat.isCreator]; + + [_tableView removeAllItems:YES]; + + _headerItem = [[TGProfileHeaderRowItem alloc] initWithObject:_conversation]; + + _headerItem.height = 142; + + + + [_headerItem setEditable:self.action.isEditable]; + + [_tableView addItem:_headerItem tableRedraw:YES]; + + + if(!self.action.isEditable) { + GeneralSettingsRowItem *adminsItem; + GeneralSettingsRowItem *membersItem; + GeneralSettingsRowItem *blacklistItem; + GeneralSettingsRowItem *addMembersItem; + GeneralSettingsRowItem *inviteViaLink; + if(_chat.username.length > 0) { + TGProfileParamItem *linkItem = [[TGProfileParamItem alloc] initWithHeight:30]; + + [linkItem setHeader:NSLocalizedString(@"Profile.ShareLink", nil) withValue:_chat.usernameLink]; + + [_tableView addItem:linkItem tableRedraw:YES]; + + [_tableView addItem:[[TGGeneralRowItem alloc] initWithHeight:20] tableRedraw:YES]; + } + + + if(_chat.chatFull.about.length > 0) { + TGProfileParamItem *aboutItem = [[TGProfileParamItem alloc] initWithHeight:30]; + + [aboutItem setHeader:[NSLocalizedString(@"Compose.ChannelAboutPlaceholder", nil) lowercaseString] withValue:_chat.chatFull.about]; + + [_tableView addItem:aboutItem tableRedraw:YES]; + + [_tableView addItem:[[TGGeneralRowItem alloc] initWithHeight:20] tableRedraw:YES]; + } + + + if(_chat.isManager || _chat.isCreator) { + adminsItem = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(TGGeneralRowItem *item) { + + ComposeManagmentViewController *viewController = [[ComposeManagmentViewController alloc] initWithFrame:NSZeroRect]; + + [viewController setAction:_composeActionManagment]; + + [self.navigationViewController pushViewController:viewController animated:YES]; + + } description:NSLocalizedString(@"Channel.Managment", nil) subdesc:[NSString stringWithFormat:@"%d",_chat.chatFull.admins_count] height:42 stateback:nil]; + + membersItem = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(TGGeneralRowItem *item) { + + ComposeChannelParticipantsViewController *viewController = [[ComposeChannelParticipantsViewController alloc] initWithFrame:NSZeroRect]; + + [viewController setAction:[[ComposeAction alloc] initWithBehaviorClass:[ComposeActionChannelMembersBehavior class] filter:@[] object:_chat reservedObjects:@[[TL_channelParticipantsRecent create]]]]; + + [self.navigationViewController pushViewController:viewController animated:YES]; + + } description:NSLocalizedString(@"Channel.Members", nil) subdesc:[NSString stringWithFormat:@"%d",_chat.chatFull.participants_count] height:42 stateback:nil]; + + + addMembersItem = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNone callback:^(TGGeneralRowItem *item) { + + NSMutableArray *filter = [[NSMutableArray alloc] init]; + + [_chat.chatFull.participants.participants enumerateObjectsUsingBlock:^(TLChatParticipant *obj, NSUInteger idx, BOOL * _Nonnull stop) { + + [filter addObject:@(obj.user_id)]; + + ComposePickerViewController *viewController = [[ComposePickerViewController alloc] initWithFrame:NSZeroRect]; + + [viewController setAction:[[ComposeAction alloc]initWithBehaviorClass:[ComposeActionAddGroupMembersBehavior class] filter:filter object:_chat.chatFull reservedObjects:@[_chat]]]; + + [self.navigationViewController pushViewController:viewController animated:YES]; + + }]; + + } description:NSLocalizedString(@"Group.AddMembers", nil) height:42 stateback:nil]; + + + inviteViaLink = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNone callback:^(TGGeneralRowItem *item) { + + ChatExportLinkViewController *export = [[ChatExportLinkViewController alloc] initWithFrame:NSZeroRect]; + + [export setChat:_chat.chatFull]; + + [self.navigationViewController pushViewController:export animated:YES]; + + + } description:NSLocalizedString(@"Modern.Channel.InviteViaLink", nil) height:42 stateback:nil]; + + if(_chat.chatFull.kicked_count > 0) { + blacklistItem = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(TGGeneralRowItem *item) { + + ComposeChannelParticipantsViewController *viewController = [[ComposeChannelParticipantsViewController alloc] initWithFrame:NSZeroRect]; + + [viewController setAction:[[ComposeAction alloc] initWithBehaviorClass:[ComposeActionBlackListBehavior class] filter:@[] object:_chat reservedObjects:@[[TL_channelParticipantsKicked create]]]]; + + [self.navigationViewController pushViewController:viewController animated:YES]; + + } description:NSLocalizedString(@"Settings.BlackList", nil) subdesc:[NSString stringWithFormat:@"%d",_chat.chatFull.kicked_count] height:42 stateback:nil]; + } + + } else { + + if(!_chat.isMegagroup) { + GeneralSettingsRowItem *openChannel = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNone callback:^(TGGeneralRowItem *item) { + + [self.navigationViewController showMessagesViewController:_conversation]; + + } description:NSLocalizedString(@"Profile.OpenChannel", nil) height:42 stateback:nil]; + + openChannel.textColor = BLUE_UI_COLOR; + + [_tableView addItem:openChannel tableRedraw:YES]; + + [_tableView addItem:[[TGGeneralRowItem alloc] initWithHeight:20] tableRedraw:YES]; + } + + } + + if(adminsItem) + [_tableView addItem:adminsItem tableRedraw:YES]; + + if(_chat.isMegagroup) { + if(addMembersItem) + [_tableView addItem:addMembersItem tableRedraw:YES]; + if(_chat.isCreator) + [_tableView addItem:inviteViaLink tableRedraw:YES]; + } else { + if(membersItem) + [_tableView addItem:membersItem tableRedraw:YES]; + } + + + + if(blacklistItem) + [_tableView addItem:blacklistItem tableRedraw:YES]; + + if(adminsItem || membersItem || blacklistItem) { + [_tableView addItem:[[TGGeneralRowItem alloc] initWithHeight:20] tableRedraw:YES]; + } + + + _mediaItem = [[TGSProfileMediaRowItem alloc] initWithObject:_conversation]; + + _mediaItem.controller = self; + + weak(); + [_mediaItem setCallback:^(TGGeneralRowItem *item) { + + TMCollectionPageController *viewController = [[TMCollectionPageController alloc] initWithFrame:NSZeroRect]; + + [viewController setConversation:weakSelf.conversation]; + + [weakSelf.navigationViewController pushViewController:viewController animated:YES]; + + }]; + + _mediaItem.height = 50; + + [_tableView addItem:_mediaItem tableRedraw:YES]; + + + [_tableView addItem:[[TGGeneralRowItem alloc] initWithHeight:20] tableRedraw:YES]; + + _notificationItem = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSwitch callback:^(TGGeneralRowItem *item) { + + [_conversation muteOrUnmute:nil until:0]; + + } description:NSLocalizedString(@"Notifications", nil) height:42 stateback:^id(TGGeneralRowItem *item) { + return @(!_conversation.isMute); + }]; + + + [_tableView addItem:_notificationItem tableRedraw:YES]; + } else { + + GeneralSettingsRowItem *descriptionItem = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(TGGeneralRowItem *item) { + + ComposeChangeChannelDescriptionViewController *viewController = [[ComposeChangeChannelDescriptionViewController alloc] init]; + + [viewController setAction:[[ComposeAction alloc] initWithBehaviorClass:[ComposeActionChangeChannelAboutBehavior class] filter:nil object:_chat reservedObjects:@[NSLocalizedString(@"Compose.ChannelAboutPlaceholder", nil),(_chat.isMegagroup ? NSLocalizedString(@"Compose.ChatAboutDescription", nil) : NSLocalizedString(@"Compose.ChannelAboutDescription", nil))]]]; + + [self.navigationViewController pushViewController:viewController animated:YES]; + + } description:NSLocalizedString(@"Compose.ChannelAboutPlaceholder", nil) subdesc:[_chat.chatFull.about stringByReplacingOccurrencesOfString:@"\n" withString:@" "] height:42 stateback:nil]; + + [_tableView addItem:descriptionItem tableRedraw:YES]; + + + if(!_chat.isMegagroup) { + GeneralSettingsRowItem *linkItem = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(TGGeneralRowItem *item) { + + ComposeAction *action = [[ComposeAction alloc] initWithBehaviorClass:[ComposeActionBehavior class]]; + action.result = [[ComposeResult alloc] init]; + action.result.singleObject = _chat; + ComposeCreateChannelUserNameStepViewController *viewController = [[ComposeCreateChannelUserNameStepViewController alloc] initWithFrame:NSZeroRect]; + + [viewController setAction:action]; + + [self.navigationViewController pushViewController:viewController animated:YES]; + + } description:NSLocalizedString(@"Profile.EditLink", nil) subdesc:_chat.usernameLink height:42 stateback:nil]; + + [_tableView addItem:linkItem tableRedraw:YES]; + + } + + + [_tableView addItem:[[TGGeneralRowItem alloc] initWithHeight:20] tableRedraw:YES]; + + + if(_chat.isCreator) { + GeneralSettingsRowItem *deleteChannelItem = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNone callback:^(TGGeneralRowItem *item) { + + [self.navigationViewController.messagesViewController deleteDialog:_conversation]; + + + } description:_chat.isMegagroup ? NSLocalizedString(@"Conversation.Confirm.DeleteGroup", nil) : NSLocalizedString(@"Profile.DeleteChannel", nil) height:42 stateback:nil]; + + deleteChannelItem.textColor = [NSColor redColor]; + + [_tableView addItem:deleteChannelItem tableRedraw:YES]; + } + + } + + if(!_chat.isCreator && !_chat.isMegagroup) { + + [_tableView addItem:[[TGGeneralRowItem alloc] initWithHeight:20] tableRedraw:YES]; + + + GeneralSettingsRowItem *reportItem = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNone callback:^(TGGeneralRowItem *item) { + + TGReportChannelModalView *reportModalView = [[TGReportChannelModalView alloc] initWithFrame:[self.view.window.contentView bounds]]; + + reportModalView.conversation = _conversation; + + [reportModalView show:self.view.window animated:YES]; + + + } description:NSLocalizedString(@"Profile.ReportChannel", nil) height:42 stateback:nil]; + + reportItem.textColor = BLUE_UI_COLOR; + + [_tableView addItem:reportItem tableRedraw:YES]; + + + if(!_conversation.invisibleChannel) { + GeneralSettingsRowItem *deleteChannelItem = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNone callback:^(TGGeneralRowItem *item) { + + [self.navigationViewController.messagesViewController deleteDialog:_conversation]; + + + } description:_chat.isMegagroup ? NSLocalizedString(@"Conversation.Actions.LeaveGroup", nil) : NSLocalizedString(@"Profile.LeaveChannel", nil) height:42 stateback:nil]; + + deleteChannelItem.textColor = [NSColor redColor]; + + [_tableView addItem:deleteChannelItem tableRedraw:YES]; + } + + + } + + if(_chat.isMegagroup) { + [_tableView addItem:[[TGGeneralRowItem alloc] initWithHeight:20] tableRedraw:YES]; + + + _participantsHeaderItem = [[GeneralSettingsBlockHeaderItem alloc] initWithString:[NSString stringWithFormat:NSLocalizedString(@"Modern.Chat.Members", nil),_chat.chatFull.participants_count] height:42 flipped:NO]; + + [_tableView addItem:_participantsHeaderItem tableRedraw:YES]; + + [self loadNextParticipants]; + } + + + +} + +@end diff --git a/TelegramTest/TGModernChatInfoViewController.h b/TelegramTest/TGModernChatInfoViewController.h new file mode 100644 index 00000000..4797470e --- /dev/null +++ b/TelegramTest/TGModernChatInfoViewController.h @@ -0,0 +1,16 @@ +// +// TGModernChatInfoViewController.h +// Telegram +// +// Created by keepcoder on 03/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "ComposeViewController.h" + +@interface TGModernChatInfoViewController : ComposeViewController + + +-(void)setChat:(TLChat *)chat; + +@end diff --git a/TelegramTest/TGModernChatInfoViewController.m b/TelegramTest/TGModernChatInfoViewController.m new file mode 100644 index 00000000..8a9c5b71 --- /dev/null +++ b/TelegramTest/TGModernChatInfoViewController.m @@ -0,0 +1,572 @@ +// +// TGModernChatInfoViewController.m +// Telegram +// +// Created by keepcoder on 03/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "TGModernChatInfoViewController.h" +#import "TGSettingsTableView.h" +#import "TGProfileHeaderRowItem.h" +#import "TGSProfileMediaRowItem.h" +#import "TGProfileParamItem.h" +#import "ComposeActionInfoProfileBehavior.h" +#import "MessagesUtils.h" +#import "TGUserContainerRowItem.h" +#import "TGUserContainerView.h" +#import "TGProfileHeaderRowView.h" +#import "TGModernUserViewController.h" +#import "ComposeActionAddGroupMembersBehavior.h" +#import "TGPhotoViewer.h" +#import "ChatAdminsViewController.h" +@interface TGModernChatInfoViewController () +@property (nonatomic,strong) TGSettingsTableView *tableView; + +@property (nonatomic,strong) TLChat *chat; +@property (nonatomic,strong) TL_conversation *conversation; + + +@property (nonatomic,strong) GeneralSettingsBlockHeaderItem *participantsHeaderItem; +@property (nonatomic,strong) GeneralSettingsRowItem *notificationItem; +@property (nonatomic,strong) GeneralSettingsRowItem *adminsItem; +@property (nonatomic,strong) GeneralSettingsRowItem *deleteAndExitItem; +@property (nonatomic,strong) TGProfileHeaderRowItem *headerItem; +@property (nonatomic,strong) TGSProfileMediaRowItem *mediaItem; + +@end + +@implementation TGModernChatInfoViewController + + +-(void)loadView { + [super loadView]; + + _tableView = [[TGSettingsTableView alloc] initWithFrame:self.view.bounds]; + + [self.view addSubview:_tableView.containerView]; + + weak(); + + [self.doneButton setTapBlock:^{ + + [weakSelf changeEditable:!weakSelf.action.isEditable]; + + }]; + + + _adminsItem = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNone callback:^(TGGeneralRowItem *item) { + + ChatAdminsViewController *viewController = [[ChatAdminsViewController alloc] initWithFrame:NSZeroRect]; + + viewController.chat = self.chat; + + [self.navigationViewController pushViewController:viewController animated:YES]; + + } description:NSLocalizedString(@"Modern.Profile.SetAdmins", nil) height:42 stateback:nil]; + + _notificationItem = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSwitch callback:^(TGGeneralRowItem *item) { + + [_conversation muteOrUnmute:nil until:0]; + + } description:NSLocalizedString(@"Notifications", nil) height:42 stateback:^id(TGGeneralRowItem *item) { + return @(!_conversation.isMute); + }]; + + + _deleteAndExitItem = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNone callback:^(TGGeneralRowItem *item) { + + [self.messagesViewController deleteDialog:_conversation callback:^{ + + }]; + + } description:NSLocalizedString(@"Conversation.DeleteAndExit", nil) height:42 stateback:nil]; + _deleteAndExitItem.textColor = [NSColor redColor]; + +} + +-(void)changeEditable:(BOOL)editable { + + if(self.action.isEditable == editable) + return; + + if(!editable && ![self.headerItem.firstChangedValue isEqualToString:_chat.title] && self.headerItem.firstChangedValue.length > 0) { + + NSString *prev = _chat.title; + + _chat.title = self.headerItem.firstChangedValue; + + [Notification perform:CHAT_UPDATE_TITLE data:@{KEY_CHAT:_chat}]; + + [RPCRequest sendRequest:[TLAPI_messages_editChatTitle createWithChat_id:_chat.n_id title:self.headerItem.firstChangedValue] successHandler:^(RPCRequest *request, id response) { + + } errorHandler:^(RPCRequest *request, RpcError *error) { + _chat.title = prev; + + [Notification perform:CHAT_UPDATE_TITLE data:@{KEY_CHAT:_chat}]; + }]; + } + + + + [self.action setEditable:editable]; + + [self updateActionNavigation]; + + if(self.action.isEditable && _chat.isCreator) { + [_tableView insert:_adminsItem atIndex:[_tableView indexOfItem:_notificationItem]+1 tableRedraw:YES]; + } else { + [_tableView removeItem:_adminsItem tableRedraw:YES]; + } + + [_headerItem setEditable:self.action.isEditable]; + + + [_tableView.list enumerateObjectsUsingBlock:^(TMRowItem *obj, NSUInteger idx, BOOL * _Nonnull stop) { + + if([obj isKindOfClass:[TMRowItem class]]) { + [obj setEditable:self.action.isEditable]; + } + + }]; + + + [_tableView reloadDataForRowIndexes:[NSIndexSet indexSetWithIndex:[_tableView indexOfItem:_headerItem]] columnIndexes:[NSIndexSet indexSetWithIndex:0]]; + + + [_tableView enumerateAvailableRowViewsUsingBlock:^(__kindof NSTableRowView * _Nonnull rowView, NSInteger row) { + + TMRowView *view = [rowView.subviews firstObject]; + + TMRowItem *item = _tableView.list[row]; + if([view isKindOfClass:[TGUserContainerView class]]) { + + TGUserContainerView *v = (TGUserContainerView *) view; + + [v setEditable:item.isEditable animated:YES]; + + } + + }]; +} + +-(void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; + + self.action.editable = NO; + + [self updateActionNavigation]; + + [self configure]; + + [self drawParticipants]; + + [self checkSupergroup]; + + [Notification addObserver:self selector:@selector(chatParticipantsUpdateNotification:) name:CHAT_UPDATE_PARTICIPANTS]; + [Notification addObserver:self selector:@selector(didChangeChatFlags:) name:CHAT_FLAGS_UPDATED]; +} + +-(void)viewWillDisappear:(BOOL)animated { + [super viewWillDisappear:animated]; + + [Notification removeObserver:self]; +} + + +-(void)didChangeChatFlags:(NSNotification *)notification { + TLChat *chat = notification.userInfo[KEY_CHAT]; + + if(_chat == chat) { + + if(self.action.isEditable && ((_chat.isAdmins_enabled && !_chat.isAdmin) || !_chat.isCreator)) { + self.action.editable = NO; + } + + [self configure]; + [self drawParticipants]; + + } +} + +- (void)chatParticipantsUpdateNotification:(NSNotification *)notification { + + TLChat *chat = notification.userInfo[KEY_CHAT]; + + if(_chat == chat) { + + NSRange range = [self participantsRange]; + + if(range.length > 0) { + + if(range.length != _chat.chatFull.participants_count && (range.length >= maxChatUsers()+1 || _chat.chatFull.participants_count >= maxChatUsers()+1) ) { + [self checkSupergroup]; + } + } + + [self drawParticipants]; + + } +} + + +-(void)setChat:(TLChat *)chat { + _chat = chat; + _conversation = chat.dialog; + + [self setAction:[[ComposeAction alloc] initWithBehaviorClass:[ComposeActionInfoProfileBehavior class] filter:nil object:_conversation]]; + + _tableView.defaultAnimation = NSTableViewAnimationEffectFade; + + +} + +-(void)configure { + + [self.doneButton setHidden:(_chat.isAdmins_enabled && (!_chat.isAdmin && !_chat.isCreator))]; + + [_tableView removeAllItems:YES]; + + _headerItem = [[TGProfileHeaderRowItem alloc] initWithObject:_conversation]; + + _headerItem.height = 142; + [_headerItem setEditable:self.action.isEditable]; + + [_tableView addItem:_headerItem tableRedraw:YES]; + + + + + _mediaItem = [[TGSProfileMediaRowItem alloc] initWithObject:_conversation]; + _mediaItem.height = 50; + + + weak(); + + _mediaItem.controller = self; + + [_mediaItem setCallback:^(TGGeneralRowItem *item) { + + TMCollectionPageController *viewController = [[TMCollectionPageController alloc] initWithFrame:NSZeroRect]; + + [viewController setConversation:weakSelf.conversation]; + + [weakSelf.navigationViewController pushViewController:viewController animated:YES]; + + }]; + + [_tableView addItem:_mediaItem tableRedraw:YES]; + + [_tableView addItem:[[TGGeneralRowItem alloc] initWithHeight:20] tableRedraw:YES]; + + + [_tableView addItem:_notificationItem tableRedraw:YES]; + + + + _participantsHeaderItem = [[GeneralSettingsBlockHeaderItem alloc] initWithString:[NSString stringWithFormat:NSLocalizedString(@"Modern.Chat.Members", nil),_chat.chatFull.participants.participants.count] height:42 flipped:NO]; + + [_tableView addItem:_participantsHeaderItem tableRedraw:YES]; + + + + +} + + +-(void)drawParticipants { + + [_participantsHeaderItem redrawRow]; + + NSRange range = [self participantsRange]; + + if(range.length > 0) { + [_tableView removeItemsInRange:range tableRedraw:YES]; + } + + + NSArray *participants = [_chat.chatFull.participants.participants copy]; + + NSMutableArray *items = [NSMutableArray array]; + + [participants enumerateObjectsUsingBlock:^(TLChatParticipant *obj, NSUInteger idx, BOOL * _Nonnull stop) { + + TGUserContainerRowItem *user = [[TGUserContainerRowItem alloc] initWithUser:[[UsersManager sharedManager] find:obj.user_id]]; + user.height = 50; + user.type = SettingsRowItemTypeNone; + user.editable = self.action.isEditable; + + + [user setStateback:^id(TGGeneralRowItem *item) { + + BOOL canRemoveUser = _chat.isAdmins_enabled ? (obj.user_id != [UsersManager currentUserId] && (self.chat.isAdmin || self.chat.isCreator) && ![obj isKindOfClass:[TL_chatParticipantCreator class]]) : (obj.user_id != [UsersManager currentUserId] && obj.inviter_id == [UsersManager currentUserId]); + + return @(canRemoveUser); + + }]; + + __weak TGUserContainerRowItem *weakItem = user; + + [user setStateCallback:^{ + + if(self.action.isEditable) { + if([weakItem.stateback(weakItem) boolValue]) + [self kickParticipant:weakItem]; + } else { + TGModernUserViewController *viewController = [[TGModernUserViewController alloc] initWithFrame:NSZeroRect]; + + [viewController setUser:weakItem.user conversation:weakItem.user.dialog]; + + [self.navigationViewController pushViewController:viewController animated:YES]; + } + + }]; + + [items addObject:user]; + }]; + + [items sortWithOptions:NSSortStable usingComparator:^NSComparisonResult(TGUserContainerRowItem *obj1, TGUserContainerRowItem *obj2) { + + if(obj1.user.n_id == UsersManager.currentUserId) { + return NSOrderedAscending; + } + + if(obj2.user.n_id == UsersManager.currentUserId) { + return NSOrderedDescending; + } + + int online1 = obj1.user.lastSeenTime; + int online2 = obj2.user.lastSeenTime; + + return online1 > online2 ? NSOrderedAscending : NSOrderedDescending; + }]; + + [_tableView insert:items startIndex:_tableView.list.count tableRedraw:YES]; + + + [_tableView addItem:[[TGGeneralRowItem alloc] initWithHeight:20] tableRedraw:YES]; + + [_tableView addItem:_deleteAndExitItem tableRedraw:YES]; + +} + + +-(void)checkSupergroup { + + + NSUInteger startIdx = [_tableView indexOfItem:_headerItem]; + + NSUInteger stopIdx = [_tableView indexOfItem:_mediaItem]; + + if(startIdx != NSNotFound && stopIdx != NSNotFound) { + + startIdx++; + + if(stopIdx > startIdx) { + [_tableView removeItemsInRange:NSMakeRange(startIdx, stopIdx - startIdx) tableRedraw:YES]; + } + + } + + GeneralSettingsRowItem *addMembersItem; + + if(!_chat.isAdmins_enabled || (_chat.isManager)) { + addMembersItem = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNone callback:^(TGGeneralRowItem *item) { + + NSMutableArray *filter = [[NSMutableArray alloc] init]; + + for (TL_chatParticipant *participant in _chat.chatFull.participants.participants) { + [filter addObject:@(participant.user_id)]; + } + + + ComposePickerViewController *viewController = [[ComposePickerViewController alloc] initWithFrame:NSZeroRect]; + + [viewController setAction:[[ComposeAction alloc]initWithBehaviorClass:[ComposeActionAddGroupMembersBehavior class] filter:filter object:_chat.chatFull reservedObjects:@[_chat]]]; + + [self.navigationViewController pushViewController:viewController animated:YES]; + + + } description:NSLocalizedString(@"Group.AddMembers", nil) height:42 stateback:nil]; + addMembersItem.textColor = BLUE_UI_COLOR; + } + + GeneralSettingsRowItem *exportInviteLink; + + if(_chat.isCreator) { + exportInviteLink = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNone callback:^(TGGeneralRowItem *item) { + + dispatch_block_t cblock = ^ { + + ChatExportLinkViewController *viewController = [[ChatExportLinkViewController alloc] initWithFrame:NSZeroRect]; + + [viewController setChat:self.chat.chatFull]; + + [self.navigationViewController pushViewController:viewController animated:YES]; + + }; + + + if([_chat.chatFull.exported_invite isKindOfClass:[TL_chatInviteExported class]]) { + + cblock(); + + } else { + + [self showModalProgress]; + + [RPCRequest sendRequest:[TLAPI_messages_exportChatInvite createWithChat_id:self.chat.n_id] successHandler:^(RPCRequest *request, TL_chatInviteExported *response) { + + [self hideModalProgressWithSuccess]; + + _chat.chatFull.exported_invite = response; + + [[Storage manager] insertFullChat:self.chat.chatFull completeHandler:nil]; + + cblock(); + + + } errorHandler:^(RPCRequest *request, RpcError *error) { + [self hideModalProgress]; + } timeout:10]; + + } + + + } description:NSLocalizedString(@"Group.CopyExportChatInvite", nil) height:42 stateback:nil]; + + exportInviteLink.textColor = BLUE_UI_COLOR; + } + + + if(addMembersItem || exportInviteLink) { + [_tableView addItem:[[TGGeneralRowItem alloc] initWithHeight:20] tableRedraw:YES]; + } + + int upgradeCount = maxChatUsers()+1; + +//#ifdef TGDEBUG +// upgradeCount = ACCEPT_FEATURE ? 4 : upgradeCount; +//#endif + + if(self.participantsRange.length >= upgradeCount && _chat.isCreator && ACCEPT_FEATURE) { + + [_tableView addItem:[[TGGeneralRowItem alloc] initWithHeight:20] tableRedraw:YES]; + + GeneralSettingsRowItem *upgradeToMegagroup = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNone callback:^(TGGeneralRowItem *item) { + + confirm(NSLocalizedString(@"Modern.Chat.UpgradeConfirmHeader", nil), NSLocalizedString(@"Modern.Chat.UpgradeConfirmDescription", nil), ^{ + + [self showModalProgress]; + + [RPCRequest sendRequest:[TLAPI_messages_migrateChat createWithChat_id:_chat.n_id] successHandler:^(id request, id response) { + + TLChat *chat = [[ChatsManager sharedManager] find:_chat.migrated_to.channel_id]; + + if(chat) { + + [[FullChatManager sharedManager] performLoad:chat.n_id callback:^(TLChatFull *fullChat) { + + [self.navigationViewController showMessagesViewController:chat.dialog]; + + [self hideModalProgressWithSuccess]; + }]; + + + } + + + } errorHandler:^(id request, RpcError *error) { + [self hideModalProgress]; + + alert(appName(), NSLocalizedString(@"Alert.somethingIsWrong", nil)); + } timeout:0 queue:[ASQueue globalQueue].nativeQueue]; + + }, ^{ + + }); + + + } description:NSLocalizedString(@"Modern.Chat.UpgrateToMegagroup", nil) height:42 stateback:nil]; + upgradeToMegagroup.textColor = BLUE_UI_COLOR; + + + GeneralSettingsBlockHeaderItem *upgradeHeaderItem = [[GeneralSettingsBlockHeaderItem alloc] initWithString:[NSString stringWithFormat:NSLocalizedString(@"Modern.Chat.UpgradeToMegagroupDescription", nil),upgradeCount,megagroupSizeMax()] height:200 flipped:YES]; + + upgradeHeaderItem.autoHeight = YES; + + + [_tableView insert:[[TGGeneralRowItem alloc] initWithHeight:20] atIndex:startIdx tableRedraw:YES]; + [_tableView insert:upgradeHeaderItem atIndex:startIdx tableRedraw:YES]; + [_tableView insert:upgradeToMegagroup atIndex:startIdx tableRedraw:YES]; + + } else if(addMembersItem) { + [_tableView insert:[[TGGeneralRowItem alloc] initWithHeight:20] atIndex:startIdx tableRedraw:YES]; + + if(exportInviteLink) { + [_tableView insert:exportInviteLink atIndex:startIdx tableRedraw:YES]; + } + + [_tableView insert:addMembersItem atIndex:startIdx tableRedraw:YES]; + + + + } +} + +-(NSRange)participantsRange { + NSUInteger startIdx = [_tableView indexOfItem:_participantsHeaderItem]+1; + NSUInteger stopIdx = [_tableView indexOfItem:_deleteAndExitItem]; + + if(stopIdx != NSNotFound) + stopIdx--; + else + stopIdx = _tableView.count - startIdx; + + + if(startIdx != stopIdx && startIdx < stopIdx) { + + return NSMakeRange(startIdx, stopIdx - startIdx); + + } + + return NSMakeRange(startIdx, 0); +} + +-(void)kickParticipant:(TGUserContainerRowItem *)participant { + + NSRange range = [self participantsRange]; + + [_tableView removeItem:participant]; + + + if(range.length == maxChatUsers() && _chat.isCreator) { + [self checkSupergroup]; + } + + dispatch_block_t updateBlock = ^{ + NSArray *participants = [_chat.chatFull.participants.participants filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.user_id == %d",participant.user.n_id]]; + + if(participants.count == 1) { + id object = participants[0]; + + [_chat.chatFull.participants.participants removeObject:object]; + + [[Storage manager] insertFullChat:_chat.chatFull completeHandler:nil]; + } + }; + + updateBlock(); + + [RPCRequest sendRequest:[TLAPI_messages_deleteChatUser createWithChat_id:_chat.n_id user_id:participant.user.inputUser] successHandler:^(RPCRequest *request, id response) { + + } errorHandler:^(RPCRequest *request, RpcError *error) { + + [[FullChatManager sharedManager] performLoad:_chat.n_id callback:^(TLChatFull *fullChat) { + [self drawParticipants]; + }]; + + } timeout:0 queue:[ASQueue globalQueue].nativeQueue]; +} + +@end diff --git a/TelegramTest/TGModernConversationHistoryController.h b/TelegramTest/TGModernConversationHistoryController.h new file mode 100644 index 00000000..f6d2ca1b --- /dev/null +++ b/TelegramTest/TGModernConversationHistoryController.h @@ -0,0 +1,41 @@ +// +// TGModernConversationHistoryController.h +// Telegram +// +// Created by keepcoder on 24.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import + +typedef enum { + TGModernCHStateCache, + TGModernCHStateLocal, + TGModernCHStateRemote, + TGModernCHStateFull +} TGModernCHState; + + +@protocol TGModernConversationHistoryControllerDelegate + +-(void)didLoadedConversations:(NSArray *)conversations withRange:(NSRange)range; + +-(int)conversationsLoadingLimit; + +@end + +@interface TGModernConversationHistoryController : NSObject + +@property (nonatomic,assign,readonly) TGModernCHState state; +@property (atomic,assign,readonly) int offset; +@property (atomic,assign,readonly) int remoteOffset; +@property (atomic,assign,readonly) int localOffset; +@property (atomic,assign,readonly) BOOL isLoading; + +-(id)initWithQueue:(ASQueue *)queue delegate:(id)deleagte; + +-(void)requestNextConversation; + +-(void)clear; + +@end diff --git a/TelegramTest/TGModernConversationHistoryController.m b/TelegramTest/TGModernConversationHistoryController.m new file mode 100644 index 00000000..dc3af9d9 --- /dev/null +++ b/TelegramTest/TGModernConversationHistoryController.m @@ -0,0 +1,253 @@ +// +// TGModernConversationHistoryController.m +// Telegram +// +// Created by keepcoder on 24.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TGModernConversationHistoryController.h" +#import "TGObservableObject.h" + +#import "TLPeer+Extensions.h" + +@interface TGModernConversationHistoryController () +@property (nonatomic,strong) ASQueue *queue; +@property (nonatomic,weak) id delegate; +@property (nonatomic,assign) BOOL loadNextAfterLoadChannels; +@property (nonatomic,assign) int channelsOffset; + +@property (nonatomic,assign) BOOL needMergeChannels; + +@end + +@implementation TGModernConversationHistoryController + + +-(id)initWithQueue:(ASQueue *)queue delegate:(id)delegate { + + if(self = [super init]) { + _queue = queue; + _delegate = delegate; + _state = TGModernCHStateLocal; + } + + return self; +} + + + + +-(void)requestNextConversation { + + [_queue dispatchOnQueue:^{ + + if(_isLoading) + return; + + _isLoading = YES; + + [self performLoadNext]; + + }]; + + +} + +-(void)performLoadNext { + + if(_state == TGModernCHStateLocal) + { + + [[Storage manager] dialogsWithOffset:_offset limit:[self.delegate conversationsLoadingLimit] completeHandler:^(NSArray *d) { + + [[DialogsManager sharedManager] add:d]; + + [_queue dispatchOnQueue:^{ + + if(d.count < [self.delegate conversationsLoadingLimit]) { + + _state = TGModernCHStateRemote; + + [self performLoadNext]; + + } + + + [self dispatchWithFullList:[self mixChannelsWithConversations:d] offset:(int)d.count]; + + }]; + + + }]; + } else if(_state == TGModernCHStateRemote) { + + NSArray *all = [[DialogsManager sharedManager] all]; + + BOOL fullResort = [[all filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.type != 2"]] count] == 0; + + __block TL_conversation *conversation; + + [all enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(TL_conversation *obj, NSUInteger idx, BOOL * _Nonnull stop) { + + if(obj.type != DialogTypeSecretChat && obj.lastMessage && obj.lastMessage.n_id < TGMINFAKEID && !obj.fake && !obj.isInvisibleChannel) { + conversation = obj; + *stop = YES; + } + + }]; + + id inputPeer = conversation ? conversation.inputPeer : [TL_inputPeerEmpty create]; + int date = conversation.lastMessage.date; + + const int limit = 50; + + [RPCRequest sendRequest:[TLAPI_messages_getDialogs createWithOffset_date:date offset_id:conversation.lastMessage.n_id offset_peer:inputPeer limit:limit] successHandler:^(id request, TL_messages_dialogs *response) { + + + + + [SharedManager proccessGlobalResponse:response]; + + + NSMutableArray *converted = [[NSMutableArray alloc] init]; + + + [response.dialogs enumerateObjectsUsingBlock:^(TL_dialog *dialog, NSUInteger idx, BOOL *stop) { + + TL_localMessage *lastMessage = [[response.messages filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.n_id == %d",dialog.top_message]] firstObject]; + + + TLChat *chat = [[response.chats filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.n_id == %d",-dialog.peer.peer_id]] firstObject]; + + TL_conversation *conversation; + + + + if([dialog.peer isKindOfClass:[TL_peerChannel class]]) { + NSArray *f = [response.messages filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.peer_id == %d", dialog.peer.peer_id]]; + + __block TL_localMessage *topMsg; + __block TL_localMessage *minMsg; + + [f enumerateObjectsUsingBlock:^(TL_localMessage *obj, NSUInteger idx, BOOL *stop) { + + if(dialog.top_message == obj.n_id) + topMsg = obj; + + if(!minMsg || obj.n_id < minMsg.n_id) + minMsg = obj; + + }]; + + + + if(f.count == 2) { + + if(minMsg.n_id != topMsg.n_id) { + TGMessageHole *hole = [[TGMessageHole alloc] initWithUniqueId:-rand_int() peer_id:minMsg.peer_id min_id:minMsg.n_id max_id:topMsg.n_id date:minMsg.date count:0]; + + [[Storage manager] insertMessagesHole:hole]; + } + + // need create group hole + + if(!chat.isMegagroup) { + TGMessageGroupHole *groupHole = [[TGMessageGroupHole alloc] initWithUniqueId:-rand_int() peer_id:topMsg.peer_id min_id:minMsg.n_id max_id:topMsg.n_id+1 date:topMsg.date count:0]; + + [[Storage manager] insertMessagesHole:groupHole]; + } + + } + + int top_important_message = chat.isMegagroup ? topMsg.n_id : minMsg.n_id; + + int date = chat.isMegagroup ? topMsg.date : minMsg.date; + + lastMessage = chat.isMegagroup ? topMsg : minMsg; + + conversation = [TL_conversation createWithPeer:dialog.peer top_message:dialog.top_message unread_count:dialog.unread_important_count last_message_date:date notify_settings:dialog.notify_settings last_marked_message:top_important_message top_message_fake:top_important_message last_marked_date:minMsg.date sync_message_id:topMsg.n_id read_inbox_max_id:dialog.read_inbox_max_id unread_important_count:dialog.unread_important_count lastMessage:lastMessage pts:dialog.pts isInvisibleChannel:NO top_important_message:top_important_message]; + } else { + conversation = [TL_conversation createWithPeer:dialog.peer top_message:dialog.top_message unread_count:chat.migrated_to.channel_id != 0 ? 0 : dialog.unread_count last_message_date:lastMessage.date notify_settings:dialog.notify_settings last_marked_message:dialog.top_message top_message_fake:dialog.top_message last_marked_date:lastMessage.date sync_message_id:lastMessage.n_id read_inbox_max_id:dialog.read_inbox_max_id unread_important_count:dialog.unread_important_count lastMessage:lastMessage pts:dialog.pts isInvisibleChannel:NO top_important_message:dialog.top_important_message]; + } + + + [converted addObject:conversation]; + + }]; + + [[DialogsManager sharedManager] add:converted]; + [[Storage manager] insertDialogs:converted]; + +// NSArray *all = [[DialogsManager sharedManager] all]; +// +// if(all.count > 0) { +// NSArray *res =all;//[all subarrayWithRange:NSMakeRange(150, 10)]; +// +// [res enumerateObjectsUsingBlock:^(TL_conversation *obj, NSUInteger idx, BOOL * _Nonnull stop) { +// if(obj.chat) +// NSLog(@"chatTitle:%@ username:%@ peer_id:%d date:%d",obj.chat.title,obj.chat.username,obj.peer_id,obj.lastMessage.date); +// else +// NSLog(@"userTitle:%@ username:%@ peer_id:%d date:%d",obj.user.fullName,obj.user.username,obj.peer_id,obj.lastMessage.date); +// +// }]; +// +// int bp = 0; +// } + + [MessagesManager updateUnreadBadge]; + + if(converted.count < limit) { + _state = TGModernCHStateFull; + + } + + + + [self dispatchWithFullList:converted offset:(int)converted.count]; + + if(fullResort) + [Notification perform:DIALOGS_NEED_FULL_RESORT data:@{}]; + + } errorHandler:^(id request, RpcError *error) { + + + int bp = 0; + + } timeout:0 queue:_queue.nativeQueue]; + + } + +} + +- (NSArray *)mixChannelsWithConversations:(NSArray *)conversations { + + NSArray *join = conversations; + + return [join sortedArrayUsingComparator:^NSComparisonResult(TL_conversation * obj1, TL_conversation * obj2) { + return (obj1.last_real_message_date < obj2.last_real_message_date ? NSOrderedDescending : (obj1.last_real_message_date > obj2.last_real_message_date ? NSOrderedAscending : (obj1.top_message < obj2.top_message ? NSOrderedDescending : NSOrderedAscending))); + }]; + +} + +-(void)dispatchWithFullList:(NSArray *)all offset:(int)offset { + + [_delegate didLoadedConversations:all withRange:NSMakeRange(_offset, all.count)]; + + _offset+= offset; +// _remoteOffset+= [[all filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.type == 0 OR self.type == 1"]] count]; +// _localOffset+= [[all filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.type == 0 OR self.type == 1 OR self.type == 2 OR self.type == 3"]] count]; + _isLoading = NO; + +} + +-(void)clear { + _offset = 0; + _localOffset = 0; + _remoteOffset = 0; + _isLoading = NO; + _delegate = nil; +} + + +@end diff --git a/TelegramTest/TGModernEncryptedUpdates.m b/TelegramTest/TGModernEncryptedUpdates.m index 8ad7132b..bf9a69ee 100644 --- a/TelegramTest/TGModernEncryptedUpdates.m +++ b/TelegramTest/TGModernEncryptedUpdates.m @@ -171,34 +171,7 @@ -(BOOL)proccessServiceMessage:(id)message withLayer:(int)layer params:(Encrypted NSArray *random_ids = [action valueForKey:@"random_ids"]; - [[Storage manager] deleteMessagesWithRandomIds:random_ids completeHandler:^(BOOL result) { - - NSMutableDictionary *update = [[NSMutableDictionary alloc] init]; - - NSMutableArray *ids = [[NSMutableArray alloc] init]; - - - for (NSNumber *msgId in random_ids) { - - TL_destructMessage *message = [[MessagesManager sharedManager] findWithRandomId:[msgId longValue]]; - - if(message) { - [ids addObject:@(message.n_id)]; - } - - if(message && message.conversation) { - [update setObject:message.conversation forKey:@(message.conversation.peer.peer_id)]; - } - - } - - for (TL_conversation *dialog in update.allValues) { - [[DialogsManager sharedManager] updateLastMessageForDialog:dialog]; - } - - [Notification perform:MESSAGE_DELETE_EVENT data:@{KEY_MESSAGE_ID_LIST:ids}]; - - }]; + [[DialogsManager sharedManager] deleteMessagesWithRandomMessageIds:random_ids isChannelMessages:NO]; return YES; } @@ -220,30 +193,14 @@ -(BOOL)proccessServiceMessage:(id)message withLayer:(int)layer params:(Encrypted NSArray *items = [action valueForKey:@"random_ids"]; - NSMutableArray *storageMessages = [[NSMutableArray alloc] init]; - - [items enumerateObjectsUsingBlock:^(NSNumber *obj, NSUInteger idx, BOOL *stop) { - - - - TL_destructMessage *msg = (TL_destructMessage *) [[MessagesManager sharedManager] findWithRandomId:[obj longValue]]; - if(msg) { - [SelfDestructionController addMessage:msg force:YES]; - } else { - [storageMessages addObject:obj]; - } - - }]; [[Storage manager] messages:^(NSArray *result) { - [[MessagesManager sharedManager] add:result]; - [result enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { [SelfDestructionController addMessage:obj force:YES]; }]; - } forIds:storageMessages random:YES sync:YES queue:_queue ? _queue : [ASQueue globalQueue]]; + } forIds:items random:YES sync:NO queue:_queue ? _queue : [ASQueue globalQueue]]; return YES; } @@ -655,7 +612,7 @@ -(TLMessageMedia *)media:(id)media layer:(int)layer file:(TLEncryptedFile *)file NSMutableArray *size = [NSMutableArray arrayWithObjects:s0,s1,nil]; - return [TL_messageMediaPhoto createWithPhoto:[TL_photo createWithN_id:[file n_id] access_hash:[file access_hash] user_id:0 date:[[MTNetwork instance] getTime] geo:[TL_geoPointEmpty create] sizes:size] caption:@""]; + return [TL_messageMediaPhoto createWithPhoto:[TL_photo createWithN_id:[file n_id] access_hash:[file access_hash] date:[[MTNetwork instance] getTime] sizes:size] caption:@""]; } else if([media isKindOfClass:convertClass(@"Secret%d_DecryptedMessageMedia_decryptedMessageMediaDocument", layer)]) { @@ -672,13 +629,13 @@ -(TLMessageMedia *)media:(id)media layer:(int)layer file:(TLEncryptedFile *)file NSString *mime_type = [media respondsToSelector:@selector(mime_type)] ? [media valueForKey:@"mime_type"] : @"mp4"; - return [TL_messageMediaVideo createWithVideo:[TL_video createWithN_id:file.n_id access_hash:file.access_hash user_id:0 date:[[MTNetwork instance] getTime] duration:[[media valueForKey:@"duration"] intValue] size:file.size thumb:[TL_photoCachedSize createWithType:@"jpeg" location:location w:[[media valueForKey:@"thumb_w"] intValue] h:[[media valueForKey:@"thumb_h"] intValue] bytes:[media valueForKey:@"thumb"]] dc_id:[file dc_id] w:[[media valueForKey:@"w"] intValue] h:[[media valueForKey:@"h"] intValue]] caption:@""]; + return [TL_messageMediaVideo createWithVideo:[TL_video createWithN_id:file.n_id access_hash:file.access_hash date:[[MTNetwork instance] getTime] duration:[[media valueForKey:@"duration"] intValue] mime_type:mime_type size:file.size thumb:[TL_photoCachedSize createWithType:@"jpeg" location:location w:[[media valueForKey:@"thumb_w"] intValue] h:[[media valueForKey:@"thumb_h"] intValue] bytes:[media valueForKey:@"thumb"]] dc_id:[file dc_id] w:[[media valueForKey:@"w"] intValue] h:[[media valueForKey:@"h"] intValue]] caption:@""]; } else if([media isKindOfClass:convertClass(@"Secret%d_DecryptedMessageMedia_decryptedMessageMediaAudio", layer)]) { NSString *mime_type = [media respondsToSelector:@selector(mime_type)] ? [media valueForKey:@"mime_type"] : @"ogg"; - return [TL_messageMediaAudio createWithAudio:[TL_audio createWithN_id:file.n_id access_hash:file.access_hash user_id:0 date:[[MTNetwork instance] getTime] duration:[[media valueForKey:@"duration"] intValue] mime_type:mime_type size:file.size dc_id:file.dc_id]]; + return [TL_messageMediaAudio createWithAudio:[TL_audio createWithN_id:file.n_id access_hash:file.access_hash date:[[MTNetwork instance] getTime] duration:[[media valueForKey:@"duration"] intValue] mime_type:mime_type size:file.size dc_id:file.dc_id]]; } else { alert(@"Unknown secret media", @""); diff --git a/TelegramTest/TGModernHistoryController.h b/TelegramTest/TGModernHistoryController.h new file mode 100644 index 00000000..b823e7b2 --- /dev/null +++ b/TelegramTest/TGModernHistoryController.h @@ -0,0 +1,17 @@ +// +// TGModernHistoryController.h +// Telegram +// +// Created by keepcoder on 04.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import + +#import +#import "TGConversation.h" +@interface TGModernHistoryController : NSObject + +-(SSignal *)requestObserver:(TGConversation *)conversation startMsgId:(int)msg_id; + +@end diff --git a/TelegramTest/TGModernHistoryController.m b/TelegramTest/TGModernHistoryController.m new file mode 100644 index 00000000..5672dab7 --- /dev/null +++ b/TelegramTest/TGModernHistoryController.m @@ -0,0 +1,24 @@ +// +// TGModernHistoryController.m +// Telegram +// +// Created by keepcoder on 04.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TGModernHistoryController.h" + +@implementation TGModernHistoryController + + +-(SSignal *)requestObserver:(TGConversation *)conversation startMsgId:(int)msg_id { + + return [[SSignal alloc] initWithGenerator:^id(SSubscriber *subscriber) { + + + return nil; + }]; + +} + +@end diff --git a/TelegramTest/TGModernTypingManager.h b/TelegramTest/TGModernTypingManager.h index 82ff4452..5cd537c9 100644 --- a/TelegramTest/TGModernTypingManager.h +++ b/TelegramTest/TGModernTypingManager.h @@ -11,7 +11,8 @@ #import "TMTypingObject.h" @interface TGModernTypingManager : NSObject -+ (TMTypingObject *) typingForConversation:(TL_conversation *)conversation; ++ (TMTypingObject *) typingWithConversation:(TL_conversation *)conversation; ++ (void) asyncTypingWithConversation:(TL_conversation *)conversation handler:(void (^)(TMTypingObject *typing))handler; + (void) drop; @end diff --git a/TelegramTest/TGModernTypingManager.m b/TelegramTest/TGModernTypingManager.m index 130b29d8..f28d37be 100644 --- a/TelegramTest/TGModernTypingManager.m +++ b/TelegramTest/TGModernTypingManager.m @@ -49,29 +49,30 @@ - (void) userTypingNotification:(NSNotification *)notify { [ASQueue dispatchOnStageQueue:^{ TL_conversation *conversation = nil; - NSUInteger user_id = 0; + TLUser *user = nil; TLUpdate *update = [notify.userInfo objectForKey:KEY_SHORT_UPDATE]; if([update isKindOfClass:[TL_updateChatUserTyping class]]) { conversation = [[DialogsManager sharedManager] findByChatId:update.chat_id]; - user_id = update.user_id; + user = [[UsersManager sharedManager] find:update.user_id]; } else if([update isKindOfClass:[TL_updateUserTyping class]]) { conversation = [[DialogsManager sharedManager] findByUserId:update.user_id]; - user_id = update.user_id; + user = [[UsersManager sharedManager] find:update.user_id]; } else if([update isKindOfClass:[TL_updateEncryptedChatTyping class]]) { conversation = [[DialogsManager sharedManager] findBySecretId:update.chat_id]; - user_id = [UsersManager currentUserId] == conversation.encryptedChat.participant_id ? conversation.encryptedChat.admin_id : conversation.encryptedChat.participant_id; + + user = [[UsersManager sharedManager] find:[UsersManager currentUserId] == conversation.encryptedChat.participant_id ? conversation.encryptedChat.admin_id : conversation.encryptedChat.participant_id]; } - if(conversation) { + if(conversation && user) { TMTypingObject *object = [self typingForConversation:conversation]; if(![update action]) update.action = [TL_sendMessageTypingAction create]; - [object addMember:user_id withAction:[update action]]; + [object addMember:user withAction:[update action]]; } }]; @@ -80,7 +81,7 @@ - (void) userTypingNotification:(NSNotification *)notify { -+ (TMTypingObject *) typingForConversation:(TL_conversation *)conversation { ++ (TMTypingObject *) typingWithConversation:(TL_conversation *)conversation { __block TMTypingObject *obj; @@ -92,6 +93,20 @@ + (TMTypingObject *) typingForConversation:(TL_conversation *)conversation { } ++ (void) asyncTypingWithConversation:(TL_conversation *)conversation handler:(void (^)(TMTypingObject *typing))handler { + + dispatch_queue_t dqueue = dispatch_get_current_queue(); + + [ASQueue dispatchOnStageQueue:^{ + + dispatch_async(dqueue, ^{ + handler([[self manager] typingForConversation:conversation]); + }); + + }]; + +} + - (TMTypingObject *) typingForConversation:(TL_conversation *)conversation { diff --git a/TelegramTest/TGModernUserViewController.h b/TelegramTest/TGModernUserViewController.h new file mode 100644 index 00000000..428ddbfd --- /dev/null +++ b/TelegramTest/TGModernUserViewController.h @@ -0,0 +1,16 @@ +// +// TGModernUserViewController.h +// Telegram +// +// Created by keepcoder on 28.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "ComposeViewController.h" + +@interface TGModernUserViewController : ComposeViewController + + +-(void)setUser:(TLUser *)user conversation:(TL_conversation *)conversation; + +@end diff --git a/TelegramTest/TGModernUserViewController.m b/TelegramTest/TGModernUserViewController.m new file mode 100644 index 00000000..af4d2231 --- /dev/null +++ b/TelegramTest/TGModernUserViewController.m @@ -0,0 +1,484 @@ +// +// TGModernUserViewController.m +// Telegram +// +// Created by keepcoder on 28.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TGModernUserViewController.h" +#import "TGSettingsTableView.h" +#import "TGSProfileMediaRowItem.h" +#import "TGProfileParamItem.h" +#import "MessagesUtils.h" +#import "TGProfileHeaderRowItem.h" +#import +#import "ComposeActionInfoProfileBehavior.h" +#import "TGShareContactModalView.h" +#import "ComposeActionAddUserToGroupBehavior.h" +#import "TGReportChannelModalView.h" +#import "FullUsersManager.h" +@interface TGModernUserViewController () +@property (nonatomic,strong) TLUser *user; +@property (nonatomic,strong) TL_conversation *conversation; +@property (nonatomic,strong) TGSettingsTableView *tableView; + + +@property (nonatomic,strong) TGProfileParamItem *userNameItem; +@property (nonatomic,strong) TGProfileParamItem *phoneNumberItem; + +@property (nonatomic,strong) TGProfileHeaderRowItem *headerItem; + +@property (nonatomic,strong) TL_userFull *userFull; +@end + +@implementation TGModernUserViewController + +-(void)loadView { + [super loadView]; + + + _tableView = [[TGSettingsTableView alloc] initWithFrame:self.view.bounds]; + + [self.view addSubview:_tableView.containerView]; + + + + +} + + +- (TL_inputPhoneContact *)newContact { + NSString *first_name = self.headerItem.firstChangedValue; + NSString *last_name = self.headerItem.secondChangedValue; + + if( ([first_name isEqualToString:self.user.first_name] && [last_name isEqualToString:self.user.last_name]) || (first_name.length == 0)) + return nil; + + return [TL_inputPhoneContact createWithClient_id:0 phone:self.user.phone first_name:first_name last_name:last_name]; +} + +-(void)didUpdatedEditableState { + + if(!self.action.isEditable) { + TL_inputPhoneContact *contact = [self newContact]; + + if(contact) { + [[NewContactsManager sharedManager] importContact:contact callback:^(BOOL isAdd, TL_importedContact *contact, TLUser *user) { + + }]; + } + + } + + [self configure]; +} + +-(void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; + + [self setEditable:YES]; + [Notification addObserver:self selector:@selector(changeUserName:) name:USER_UPDATE_NAME]; + + [self configure]; +} + +-(void)viewWillDisappear:(BOOL)animated { + [super viewWillDisappear:animated]; + [Notification removeObserver:self]; +} + + +-(void)changeUserName:(NSNotification *)notification +{ + TLUser *user = [notification.userInfo objectForKey:KEY_USER]; + if(user.n_id == self.user.n_id) { + + _tableView.defaultAnimation = NSTableViewAnimationEffectFade; + if(![_userNameItem.value.string isEqualToString:user.username] && user.username.length > 0) { + + if(!_userNameItem) + { + _userNameItem = [[TGProfileParamItem alloc] init]; + [_userNameItem setHeader:NSLocalizedString(@"Profile.username", nil) withValue:[NSString stringWithFormat:@"@%@",_user.username]]; + + _userNameItem.height = 50; + } + + [_tableView insert:_userNameItem atIndex:_phoneNumberItem != nil ? 2 : 1 tableRedraw:YES]; + } else if(user.username.length == 0 && _userNameItem) { + [_tableView removeItem:_userNameItem tableRedraw:YES]; + } else if([_userNameItem.value.string isEqualToString:user.username]) { + [self configure]; + } + _tableView.defaultAnimation = NSTableViewAnimationEffectNone; + } +} + +-(void)setUser:(TLUser *)user conversation:(TL_conversation *)conversation { + + + [self loadViewIfNeeded]; + _conversation = conversation; + _user = user; + + if(!conversation) + _conversation = _user.dialog; + + self.tableView.defaultAnimation = NSTableViewAnimationEffectFade; + + [self setAction:[[ComposeAction alloc] initWithBehaviorClass:[ComposeActionInfoProfileBehavior class] filter:nil object:_conversation]]; + + _userFull = nil; + + if(user.isBot) { + [[FullUsersManager sharedManager] loadUserFull:_user callback:^(TL_userFull *userFull) { + + _userFull = userFull; + + [self configure]; + + }]; + } + + [self configure]; + +} + +-(void)changeEditableWithAnimation { + +} + +-(void)configure { + + [self.doneButton setHidden:_conversation.type == DialogTypeSecretChat || [_user isSelf]]; + + [_tableView removeAllItems:YES]; + + _headerItem = [[TGProfileHeaderRowItem alloc] initWithObject:_conversation]; + _headerItem.height = 142; + + [_headerItem setEditable:self.action.isEditable]; + self.tableView.defaultAnimation = NSTableViewAnimationEffectNone; + [_tableView addItem:_headerItem tableRedraw:YES]; + self.tableView.defaultAnimation = NSTableViewAnimationEffectFade; + + weak(); + + GeneralSettingsRowItem *sendMessage; + + if(_conversation.type != DialogTypeSecretChat) { + sendMessage = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNone callback:^(TGGeneralRowItem *item) { + + [weakSelf.navigationViewController showMessagesViewController:weakSelf.conversation]; + + } description:NSLocalizedString(@"Profile.SendMessage", nil) height:42 stateback:nil]; + } + + GeneralSettingsRowItem *startSecretChat; + + if(_user.type != TLUserTypeSelf && _conversation.type != DialogTypeSecretChat && !_user.isBot) { + startSecretChat = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNone callback:^(TGGeneralRowItem *item) { + + [weakSelf showModalProgress]; + + [MessageSender startEncryptedChat:weakSelf.user callback:^ { + + [weakSelf hideModalProgressWithSuccess]; + + }]; + + } description:NSLocalizedString(@"Conversation.StartSecretChat", nil) height:42 stateback:nil]; + } + + GeneralSettingsRowItem *shareContact; + if((_user.type == TLUserTypeContact || _user.type == TLUserTypeSelf || self.user.isBot) && _conversation.type != DialogTypeSecretChat) { + shareContact = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNone callback:^(TGGeneralRowItem *item) { + + + if(weakSelf.user.isBot) { + + + [weakSelf showModalProgress]; + + NSPasteboard* cb = [NSPasteboard generalPasteboard]; + + [cb declareTypes:[NSArray arrayWithObjects:NSStringPboardType, nil] owner:weakSelf]; + [cb setString:[NSString stringWithFormat:@"https://telegram.me/%@",weakSelf.user.username] forType:NSStringPboardType]; + + dispatch_after_seconds(0.2, ^{ + + [weakSelf hideModalProgressWithSuccess]; + + }); + + } else { + + TGShareContactModalView *shareContactModalView = [[TGShareContactModalView alloc] initWithFrame:NSMakeRect(0, 0, NSWidth(self.view.window.frame), NSHeight(self.view.window.frame))]; + + + [shareContactModalView setMessagesViewController:self.navigationViewController.messagesViewController]; + [shareContactModalView setUser:self.user]; + + [shareContactModalView show:self.view.window animated:YES]; + + } + + + } description:NSLocalizedString(_user.isBot ? @"Profile.ShareBot" : @"Profile.ShareContact", nil) height:42 stateback:nil]; + } + + GeneralSettingsRowItem *addToGroupItem; + + if(_user.isBot && !_user.isBot_nochats) { + + addToGroupItem = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNone callback:^(TGGeneralRowItem *item) { + + ComposeChooseGroupViewController *viewController = [[ComposeChooseGroupViewController alloc] init]; + + [viewController setAction:[[ComposeAction alloc] initWithBehaviorClass:[ComposeActionAddUserToGroupBehavior class] filter:nil object:weakSelf.user]]; + + [weakSelf.navigationViewController pushViewController:viewController animated:YES]; + + } description:NSLocalizedString(@"Profile.AddToGroup", nil) height:42 stateback:nil]; + + } + + GeneralSettingsRowItem *helpItem; + if(_user.isBot && _userFull) { + + __block BOOL canHelp = NO; + __block NSString *command = @"/help"; + + [_userFull.bot_info.commands enumerateObjectsUsingBlock:^(TL_botCommand *obj, NSUInteger idx, BOOL * _Nonnull stop) { + + if([obj.command hasPrefix:@"help"]) { + command = obj.command; + canHelp = YES; + *stop = YES; + } + + }]; + + if(canHelp) { + helpItem = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNone callback:^(TGGeneralRowItem *item) { + + [weakSelf.navigationViewController showMessagesViewController:_conversation]; + [weakSelf.navigationViewController.messagesViewController sendMessage:command forConversation:weakSelf.conversation]; + + } description:NSLocalizedString(@"Bot.Help", nil) height:42 stateback:nil]; + } + + } + + helpItem.textColor = BLUE_UI_COLOR; + addToGroupItem.textColor = BLUE_UI_COLOR; + sendMessage.textColor = BLUE_UI_COLOR; + startSecretChat.textColor = BLUE_UI_COLOR; + shareContact.textColor = BLUE_UI_COLOR; + + + GeneralSettingsRowItem *encryptionKeyItem = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(TGGeneralRowItem *item) { + + EncryptedKeyViewController *viewController = [[EncryptedKeyViewController alloc] initWithFrame:NSZeroRect]; + + [viewController showForChat:weakSelf.conversation.encryptedChat]; + + [weakSelf.navigationViewController pushViewController:viewController animated:YES]; + + } description:NSLocalizedString(@"Profile.ShowEncryptedKey", nil) height:42 stateback:^id(TGGeneralRowItem *item) { + + EncryptedParams *params = [EncryptedParams findAndCreate:weakSelf.conversation.encryptedChat.n_id]; + + NSData *hashData = MTSha1([params lastKey]); + + return TGIdenticonImage(hashData,NSMakeSize(20, 20)); + + }]; + + GeneralSettingsRowItem *notificationItem = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSwitch callback:^(TGGeneralRowItem *item) { + + [weakSelf.conversation muteOrUnmute:nil until:0]; + + } description:NSLocalizedString(@"Notifications", nil) height:42 stateback:^id(TGGeneralRowItem *item) { + return @(!_conversation.isMute); + }]; + + GeneralSettingsRowItem *blockUserItem = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNone callback:^(TGGeneralRowItem *item) { + + BlockedHandler handlerBlock = ^(BOOL result) { + + [weakSelf hideModalProgressWithSuccess]; + + if(!weakSelf.user.isBlocked && weakSelf.user.isBot) + { + [weakSelf.navigationViewController showMessagesViewController:weakSelf.conversation]; + [weakSelf.navigationViewController.messagesViewController sendMessage:@"/start" forConversation:weakSelf.conversation]; + } + + [weakSelf configure]; + }; + + [self showModalProgress]; + + if(weakSelf.user.isBlocked) { + [[BlockedUsersManager sharedManager] unblock:weakSelf.user.n_id completeHandler:handlerBlock]; + } else { + [[BlockedUsersManager sharedManager] block:weakSelf.user.n_id completeHandler:handlerBlock]; + } + + } description:_user.isBlocked ? (_user.isBot ? NSLocalizedString(@"RestartBot", nil) : NSLocalizedString(@"Profile.UnblockContact", nil)) : (_user.isBot ? NSLocalizedString(@"StopBot", nil) : NSLocalizedString(@"Profile.BlockContact", nil)) height:42 stateback:nil]; + blockUserItem.textColor = [NSColor redColor]; + + + GeneralSettingsRowItem *reportItem = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNone callback:^(TGGeneralRowItem *item) { + + TGReportChannelModalView *reportModalView = [[TGReportChannelModalView alloc] initWithFrame:[self.view.window.contentView bounds]]; + + reportModalView.conversation = _conversation; + + [reportModalView show:self.view.window animated:YES]; + + + } description:NSLocalizedString(@"Profile.ReportChannel", nil) height:42 stateback:nil]; + + reportItem.textColor = BLUE_UI_COLOR; + + GeneralSettingsRowItem *deleteSecretChatItem = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNone callback:^(TGGeneralRowItem *item) { + + [weakSelf showModalProgress]; + [weakSelf.navigationViewController.messagesViewController deleteDialog:weakSelf.conversation callback:^{ + [weakSelf hideModalProgressWithSuccess]; + }]; + + + } description:NSLocalizedString(@"Conversation.DeleteSecretChat", nil) height:42 stateback:nil]; + deleteSecretChatItem.textColor = [NSColor redColor]; + + TGSProfileMediaRowItem *profileMediaItem = [[TGSProfileMediaRowItem alloc] initWithObject:_conversation]; + + profileMediaItem.controller = self; + + [profileMediaItem setCallback:^(TGGeneralRowItem *item) { + TMCollectionPageController *viewController = [[TMCollectionPageController alloc] initWithFrame:NSZeroRect]; + + [viewController setConversation:weakSelf.conversation]; + + [weakSelf.navigationViewController pushViewController:viewController animated:YES]; + + }]; + + profileMediaItem.height = 50; + profileMediaItem.xOffset = 30; + + if(!self.action.isEditable) { + + + if(_userFull && _userFull.bot_info.n_description.length > 0) { + TGProfileParamItem *botInfo = [[TGProfileParamItem alloc] init]; + + [botInfo setHeader:NSLocalizedString(@"Profile.About", nil) withValue:_userFull.bot_info.n_description]; + [_tableView addItem:botInfo tableRedraw:YES]; + [_tableView addItem:[[TGGeneralRowItem alloc] initWithHeight:20] tableRedraw:YES]; + } + + + if(_user.username.length > 0) { + _userNameItem = [[TGProfileParamItem alloc] init]; + + [_userNameItem setHeader:NSLocalizedString(@"Profile.username", nil) withValue:[NSString stringWithFormat:@"@%@",_user.username]]; + + _userNameItem.height = 50; + + [_tableView addItem:_userNameItem tableRedraw:YES]; + } + + if(_user.phone.length > 0) { + _phoneNumberItem = [[TGProfileParamItem alloc] init]; + + [_phoneNumberItem setHeader:NSLocalizedString(@"Profile.MobilePhone", nil) withValue:_user.phoneWithFormat]; + + _phoneNumberItem.height = 50; + + if(_userNameItem) + [_tableView addItem:[[TGGeneralRowItem alloc] initWithHeight:20] tableRedraw:YES]; + + [_tableView addItem:_phoneNumberItem tableRedraw:YES]; + } + + + + if(sendMessage || startSecretChat || shareContact) { + [_tableView addItem:[[TGGeneralRowItem alloc] initWithHeight:20] tableRedraw:YES]; + } + + if(sendMessage) + [_tableView addItem:sendMessage tableRedraw:YES]; + if(startSecretChat) + [_tableView addItem:startSecretChat tableRedraw:YES]; + if(shareContact) + [_tableView addItem:shareContact tableRedraw:YES]; + + if(addToGroupItem) + [_tableView addItem:addToGroupItem tableRedraw:YES]; + if(helpItem) + [_tableView addItem:helpItem tableRedraw:YES]; + + [_tableView addItem:[[TGGeneralRowItem alloc] initWithHeight:20] tableRedraw:YES]; + + [_tableView addItem:profileMediaItem tableRedraw:YES]; + + [_tableView addItem:[[TGGeneralRowItem alloc] initWithHeight:20] tableRedraw:YES]; + + [_tableView addItem:notificationItem tableRedraw:YES]; + + if(_conversation.type == DialogTypeSecretChat) + [_tableView addItem:encryptionKeyItem tableRedraw:YES]; + + [_tableView addItem:[[TGGeneralRowItem alloc] initWithHeight:20] tableRedraw:YES]; + + if(_conversation.type != DialogTypeSecretChat) { + if(self.user.isBot) { + [_tableView addItem:reportItem tableRedraw:YES]; + } + + if(self.user.type != TLUserTypeSelf) + [_tableView addItem:blockUserItem tableRedraw:YES]; + } else + [_tableView addItem:deleteSecretChatItem tableRedraw:YES]; + } else { + [_tableView addItem:notificationItem tableRedraw:YES]; + + [_tableView addItem:[[TGGeneralRowItem alloc] initWithHeight:20] tableRedraw:YES]; + + if(_user.isContact) { + GeneralSettingsRowItem *deleteContact = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNone callback:^(TGGeneralRowItem *item) { + + [[NewContactsManager sharedManager] deleteContact:weakSelf.user completeHandler:^(BOOL result) { + weakSelf.action.editable = NO; + [weakSelf updateActionNavigation]; + [weakSelf didUpdatedEditableState]; + }]; + + } description:NSLocalizedString(@"Profile.DeleteContact", nil) height:42 stateback:nil]; + + deleteContact.textColor = [NSColor redColor]; + + [_tableView addItem:deleteContact tableRedraw:YES]; + } + + } +} + + +-(void)_didStackRemoved { + NSLog(@"Retain count is %ld", CFGetRetainCount((__bridge CFTypeRef)self)); + + int bp = 0; +} + +-(void)dealloc { + +} + +@end diff --git a/TelegramTest/TGMovableTableView.h b/TelegramTest/TGMovableTableView.h new file mode 100644 index 00000000..b7c54bd2 --- /dev/null +++ b/TelegramTest/TGMovableTableView.h @@ -0,0 +1,44 @@ +// +// TGMovableTableView.h +// Telegram +// +// Created by keepcoder on 26/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "TMTableView.h" + +@protocol TGMovableTableDelegate + +- (CGFloat)rowHeight:(NSUInteger)row item:(TMRowItem *) item; +- (TMRowView *)viewForRow:(NSUInteger)row item:(TMRowItem *) item; +- (void)selectionDidChange:(NSInteger)row item:(TMRowItem *) item; +- (BOOL)selectionWillChange:(NSInteger)row item:(TMRowItem *) item; +- (BOOL)isSelectable:(NSInteger)row item:(TMRowItem *) item; + +@optional +- (void)tableViewDidChangeOrder; + +@end + +@interface TGMovableTableView : BTRScrollView + +@property (nonatomic,weak) id mdelegate; + +-(NSUInteger)count; + + +- (void)insertItem:(TMRowItem *)item atIndex:(NSInteger)index; +- (void)addItems:(NSArray *)items; +- (void)removeItemAtIndex:(NSUInteger)index animated:(BOOL)animated; +- (void)removeItems:(NSArray *)items animated:(BOOL)animated; +- (void)removeItemsInRange:(NSRange)range animated:(BOOL)animated; +- (void)startMoveItemAtIndex:(NSUInteger)index; + +- (BOOL)itemIsMovable:(TMRowItem *)item; + +- (void)enumerateAvailableRowViewsUsingBlock:(void (^)(__kindof TMRowView *rowView, TMRowItem *rowItem, NSInteger row))handler; + +- (void)removeAllItems; +-(NSUInteger)indexOfObject:(TMRowItem *)item; +@end diff --git a/TelegramTest/TGMovableTableView.m b/TelegramTest/TGMovableTableView.m new file mode 100644 index 00000000..1288ad82 --- /dev/null +++ b/TelegramTest/TGMovableTableView.m @@ -0,0 +1,488 @@ +// +// TGMovableTableView.m +// Telegram +// +// Created by keepcoder on 26/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "TGMovableTableView.h" + +@interface TGMovableHoleView : TMView + +@end + + +@implementation TGMovableHoleView + + +@end + +@interface TGMovableTableClipView : NSClipView + +@end + +@implementation TGMovableTableClipView + +-(BOOL)isFlipped { + return YES; +} + +@end + +@interface TGMovableTableView () +@property (nonatomic,strong) id reorderItem; +@property (nonatomic,strong) NSMutableArray *items; +@property (nonatomic,strong) TMView *containerView;; + +@property (nonatomic,assign) BOOL locked; + +@property (nonatomic,strong) TMRowItem *movableItem; +@property (nonatomic,strong) TMRowView *movableView; +@property (nonatomic,assign) NSUInteger movableIndex; + +@property (nonatomic,assign) NSInteger prevHoleIndex; +@property (nonatomic,assign) NSInteger currentHoleIndex; +@end + +@implementation TGMovableTableView + +- (void)drawRect:(NSRect)dirtyRect { + [super drawRect:dirtyRect]; + + // Drawing code here. +} + +-(instancetype)initWithFrame:(NSRect)frameRect { + if(self = [super initWithFrame:frameRect]) { + [self initialize]; + } + + return self; +} + + +-(void)initialize { + + _items = [NSMutableArray array]; + _containerView = [[TMView alloc] initWithFrame:self.bounds]; + _containerView.isFlipped = YES; + + [self setHasVerticalScroller:YES]; + self.autoresizesSubviews = YES; + self.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable; + + self.documentView = _containerView; +} + + +-(void)setFrameSize:(NSSize)newSize { + [super setFrameSize:newSize]; + [_containerView setFrameSize:NSMakeSize(newSize.width, MAX(self.containerHeight,newSize.height))]; + + [_containerView.subviews enumerateObjectsUsingBlock:^(TMRowView *obj, NSUInteger idx, BOOL * _Nonnull stop) { + + TMRowItem *item = _items[idx]; + + TMRowView *prevView = idx == 0 ? nil : _containerView.subviews[idx - 1]; + + [obj setFrame:NSMakeRect(0, NSMaxY(prevView.frame), NSWidth(_containerView.frame), [_mdelegate rowHeight:idx item:item])]; + + }]; +} + +-(NSUInteger)count { + return _items.count; +} + +- (void)enumerateAvailableRowViewsUsingBlock:(void (^)(__kindof TMRowView *rowView, TMRowItem *rowItem, NSInteger row))handler { + + [_items enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + + handler([self viewAtIndex:idx],obj,idx); + + }]; + +} + +- (void)insertItem:(TMRowItem *)item atIndex:(NSInteger)index { + [self insertItemAtIndex:index item:item tile:YES]; +} + +- (void)addItems:(NSArray *)items { + + NSUInteger insertIndex = _items.count; + + [items enumerateObjectsUsingBlock:^(TMRowItem *obj, NSUInteger idx, BOOL * _Nonnull stop) { + + [self insertItemAtIndex:insertIndex+idx item:obj tile:NO]; + + }]; + + [self setFrameSize:self.frame.size]; +} + +- (void)removeAllItems { + [_items removeAllObjects]; + [_containerView removeAllSubviews]; + [self tile]; +} + +-(void)insertItemAtIndex:(NSUInteger)index item:(TMRowItem *)item { + [self insertItemAtIndex:index item:item tile:YES]; +} + +-(void)insertItemAtIndex:(NSUInteger)index item:(TMRowItem *)item tile:(BOOL)tile { + + TMRowView *lastView = self.count > 0 ? _containerView.subviews[MAX(index-1,0)] : nil; + + [_items insertObject:item atIndex:index]; + + int height = [_mdelegate rowHeight:index item:item]; + + TMRowView *view = [_mdelegate viewForRow:index item:item]; + + [view setRowItem:item]; + [view redrawRow]; + item.table = self; + + [view setFrameSize:NSMakeSize(NSWidth(_containerView.frame), height)]; + + [view setFrameOrigin:NSMakePoint(0, NSMaxY(lastView.frame))]; + + [_containerView addSubview:view positioned:NSWindowAbove relativeTo:lastView]; + + [_containerView setFrameSize:NSMakeSize(NSWidth(_containerView.frame), self.containerHeight)]; + + if(tile) + [self tile]; +} + + +- (void)removeItemAtIndex:(NSUInteger)index animated:(BOOL)animated { + + TMRowView *removeView = [self viewAtIndex:index]; + + BOOL reverse = (NSHeight(self.frame) != NSHeight(self.containerView.frame)) && (NSMaxY(self.documentVisibleRect) > NSHeight(self.containerView.frame) - NSHeight(removeView.frame)); + + int reverseScrollDif = reverse ? NSHeight(removeView.frame) - (NSMaxY(self.documentVisibleRect) - (NSHeight(self.containerView.frame) - NSHeight(removeView.frame))) : 0; + + __block int yHeight = reverse ? self.containerHeight - NSHeight(removeView.frame) : 0; + + [self beginUpdates]; + + [NSAnimationContext runAnimationGroup:^(NSAnimationContext * _Nonnull context) { + + [context setDuration:animated ? 0.2 : 0]; + + [[removeView animator] setAlphaValue:0]; + + [_items enumerateObjectsWithOptions:reverse ? NSEnumerationReverse : 0 usingBlock:^(TMRowItem *obj, NSUInteger idx, BOOL * _Nonnull stop) { + + TMRowView *view = [self viewAtIndex:idx]; + + if(view != removeView) { + + [[view animator] setFrameOrigin:NSMakePoint(NSMinX(view.frame),yHeight)]; + + yHeight+= reverse ? - NSHeight(view.frame) : NSHeight(view.frame); + } + + }]; + + } completionHandler:^{ + [removeView removeFromSuperview]; + [_items removeObjectAtIndex:index]; + + [self setFrameSize:self.frame.size]; + + if(reverseScrollDif > 0 && reverseScrollDif != NSHeight(removeView.frame)) { + [self.clipView scrollRectToVisible:NSMakeRect(0, self.documentVisibleRect.origin.y - reverseScrollDif, 1, 1) animated:NO]; + } + + + [self tile]; + + [self endUpdates]; + + }]; + +} + +-(int)containerHeight { + __block int height = 0; + + [_containerView.subviews enumerateObjectsWithOptions:0 usingBlock:^(TMRowView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + + height+=NSHeight(obj.frame); + + }]; + + + return height; +} + +- (void)removeItems:(NSArray *)items animated:(BOOL)animated { + +} +- (void)removeItemsInRange:(NSRange)range animated:(BOOL)animated { + +} + +- (void)startMoveItemAtIndex:(NSUInteger)index { + + if(_locked) + return; + + if(index != NSNotFound) { + + _movableItem = _items[index]; + _movableIndex = index; + _movableView = [self viewAtIndex:index]; + + + + NSShadow *dropShadow = [[NSShadow alloc] init]; + [dropShadow setShadowColor:[NSColor grayColor]]; + [dropShadow setShadowOffset:NSMakeSize(0, 0)]; + [dropShadow setShadowBlurRadius:10.0]; + + [[_movableView animator] setShadow:dropShadow]; + + [_movableView setDragInSuperView:YES]; + [_movableView setNeedsDisplay:YES]; + + NSMutableArray *subviews = [_containerView.subviews mutableCopy]; + + [subviews removeObject:_movableView]; + + [subviews addObject:_movableView]; + + + _containerView.subviews = subviews; + + [_items removeObject:_movableItem]; + + _prevHoleIndex = index-1; + _currentHoleIndex = index; + + } +} + + +-(void)moveHoleAtIndex:(NSUInteger)fromIndex toIndex:(NSUInteger)toIndex animated:(BOOL)animated { + + __block int yHeight = 0; + + [NSAnimationContext runAnimationGroup:^(NSAnimationContext * _Nonnull context) { + + [context setDuration:animated ? 0.2 : 0]; + + [_items enumerateObjectsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, _items.count)] options:0 usingBlock:^(TMRowItem *obj, NSUInteger idx, BOOL * _Nonnull stop) { + + TMRowView *view = [self viewAtIndex:idx]; + + if(idx == _currentHoleIndex) { + yHeight+=NSHeight(_movableView.frame); + } + + if(view != _movableView) { + [[view animator] setFrameOrigin:NSMakePoint(NSMinX(view.frame), yHeight)]; + } + + yHeight+=NSHeight(view.frame); + + + + }]; + + + } completionHandler:^{ + + }]; + +} + + + +-(TMRowView *)viewAtIndex:(NSUInteger)index { + return index >= _containerView.subviews.count ? nil : _containerView.subviews[index]; +} + +-(NSUInteger)indexOfObject:(TMRowItem *)item { + return [_items indexOfObject:item]; +} + + +-(void)beginUpdates { + _locked = YES; +} + + +-(void)endUpdates { + _locked = NO; +} + + + +-(void)mouseUp:(NSEvent *)theEvent { + if(_movableItem != nil && !_locked) { + + [self saveMovableItem]; + + } +} + +- (BOOL)itemIsMovable:(TMRowItem *)item { + return _movableItem == item; +} + + +-(void)saveMovableItem { + + [self beginUpdates]; + + [_movableView setDragInSuperView:NO]; + + [_movableView setNeedsDisplay:YES]; + + int y = [self yOfIndex:_currentHoleIndex-1]; + + + [NSAnimationContext runAnimationGroup:^(NSAnimationContext * _Nonnull context) { + + [[_movableView animator] setFrameOrigin:NSMakePoint(0, y)]; + + NSShadow *dropShadow = [[NSShadow alloc] init]; + [dropShadow setShadowColor:[NSColor whiteColor]]; + [dropShadow setShadowOffset:NSMakeSize(0, 0)]; + [dropShadow setShadowBlurRadius:0]; + [[_movableView animator] setShadow:dropShadow]; + + + } completionHandler:^{ + + + + [_movableView setShadow:nil]; + + [_items insertObject:_movableItem atIndex:_currentHoleIndex]; + NSMutableArray *subviews = [_containerView.subviews mutableCopy]; + + [subviews removeObject:_movableView]; + + [subviews insertObject:_movableView atIndex:_currentHoleIndex]; + + _containerView.subviews = subviews; + + + if(_movableIndex != _currentHoleIndex && [_mdelegate respondsToSelector:@selector(tableViewDidChangeOrder)]) { + [_mdelegate tableViewDidChangeOrder]; + } + + _movableItem = nil; + _movableIndex = 0; + _movableView = nil; + + + + _movableIndex = NSNotFound; + _currentHoleIndex = 0; + _prevHoleIndex = 0; + + + + + [self endUpdates]; + }]; + +} + +-(int)yOfIndex:(NSInteger)index { + + __block int y = 0; + + if(index == 0) + return [_mdelegate rowHeight:0 item:_items[0]]; + else if(index == -1) + return 0; + + [_items enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + + y+=[_mdelegate rowHeight:index item:obj]; + + if(index <= idx) { + *stop = YES; + } + + }]; + + return y; +} + +-(void)mouseDragged:(NSEvent *)theEvent { + + if(_movableItem != nil && !_locked) { + [self updateMovableItem:[_containerView convertPoint:[theEvent locationInWindow] fromView:nil]]; + } + +} + + +-(void)scrollWheel:(NSEvent *)theEvent { + [super scrollWheel:theEvent]; + + if(_movableItem != nil && !_locked) { + + [_movableView mouseDragged:theEvent]; + + [self updateMovableItem:[_containerView convertPoint:[theEvent locationInWindow] fromView:nil]]; + } +} + +-(NSRange)rangeOfRect:(NSRect)rect { + + __block int currentY = 0; + + __block NSRange range = NSMakeRange(NSNotFound, 0); + + [_containerView.subviews enumerateObjectsUsingBlock:^(TMRowView *obj, NSUInteger idx, BOOL * _Nonnull stop) { + + int prevY = currentY; + + currentY += NSHeight(obj.frame); + + if((prevY <= NSMinY(rect) && currentY >= NSMaxY(rect)) ) { + + if(range.location == NSNotFound) + range.location = idx; + + range.length++; + + } + + + }]; + + return range; + +} + +-(void)updateMovableItem:(NSPoint)point { + + + NSRange range = [self rangeOfRect:NSMakeRect(0, point.y, 0, 1)]; + + + if(range.location != NSNotFound) { + + _prevHoleIndex = _currentHoleIndex; + _currentHoleIndex = range.location; + + [self moveHoleAtIndex:_prevHoleIndex toIndex:_currentHoleIndex animated:YES]; + + } + +} + +@end diff --git a/TelegramTest/TGMultipleSelectTextView.m b/TelegramTest/TGMultipleSelectTextView.m index 003a5bd3..72983ecf 100644 --- a/TelegramTest/TGMultipleSelectTextView.m +++ b/TelegramTest/TGMultipleSelectTextView.m @@ -54,7 +54,7 @@ -(BOOL)_checkClickCount:(NSEvent *)theEvent { } --(void)open_link:(NSString *)link { +-(void)open_link:(NSString *)link itsReal:(BOOL)itsReal { MessageTableItemText *item = self.owner; if(item.message.peer_id < 0 && item.message.fromUser.isBot && [link hasPrefix:TLBotCommandPrefix]) { @@ -62,9 +62,10 @@ -(void)open_link:(NSString *)link { } - open_link(link); + [super open_link:link itsReal:itsReal]; } + -(void)rightMouseDown:(NSEvent *)theEvent { int index = [self currentIndexInLocation:[self convertPoint:[theEvent locationInWindow] fromView:nil]]; diff --git a/TelegramTest/TGObservableObject.h b/TelegramTest/TGObservableObject.h new file mode 100644 index 00000000..b61f1a0b --- /dev/null +++ b/TelegramTest/TGObservableObject.h @@ -0,0 +1,30 @@ +// +// TGObservableObject.h +// Telegram +// +// Created by keepcoder on 24.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import + +@protocol TGObservableDelegate + +-(void)didChangedEventStateWithObject:(id)object; + +@end + + +@interface TGObservableObject : NSObject + + +//strong listeners +-(void)addEventListener:(id )listener; +//weak +-(void)addWeakEventListener:(id )listener; + + +-(void)removeEventListener:(id )listener; +-(void)notifyListenersWithObject:(id)object; + +@end diff --git a/TelegramTest/TGObservableObject.m b/TelegramTest/TGObservableObject.m new file mode 100644 index 00000000..4ffcc522 --- /dev/null +++ b/TelegramTest/TGObservableObject.m @@ -0,0 +1,57 @@ +// +// TGObservableObject.m +// Telegram +// +// Created by keepcoder on 24.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TGObservableObject.h" + +@interface TGObservableObject () +@property (nonatomic,strong) NSMutableArray *observers; +@end + +@implementation TGObservableObject + + +-(instancetype)init { + if(self = [super init]) { + _observers = [[NSMutableArray alloc] init]; + } + + return self; +} + +-(void)addEventListener:(id )listener { + if([_observers indexOfObject:listener] == NSNotFound && [listener conformsToProtocol:@protocol(TGObservableDelegate)]) { + [_observers addObject:listener]; + } + +} + +-(void)removeEventListener:(id)listener { + [_observers removeObject:listener]; +} + + +-(void)addWeakEventListener:(id )listener { + if([_observers indexOfObject:listener] == NSNotFound && [listener conformsToProtocol:@protocol(TGObservableDelegate)]) { + NSValue *value = [NSValue valueWithNonretainedObject:listener]; + + [_observers addObject:value]; + + + } +} + +-(void)notifyListenersWithObject:(id)object { + [_observers enumerateObjectsUsingBlock:^(id observer, NSUInteger idx, BOOL *stop) { + + [observer didChangedEventStateWithObject:object]; + + }]; +} + + +@end diff --git a/TelegramTest/TGPVBehavior.h b/TelegramTest/TGPVBehavior.h index b92b23d1..c1efb85d 100644 --- a/TelegramTest/TGPVBehavior.h +++ b/TelegramTest/TGPVBehavior.h @@ -8,15 +8,19 @@ #import #import "TGPVImageObject.h" +#import "ChatHistoryController.h" +#import "TGPhotoViewerBehavior.h" @protocol TGPVBehavior @property (nonatomic,strong) TL_conversation *conversation; @property (nonatomic,strong) TLUser *user; @property (nonatomic,assign,readonly) int totalCount; + @property (nonatomic,strong) RPCRequest *request; + typedef enum { TGPVMediaBehaviorLoadingStateLocal = 0, TGPVMediaBehaviorLoadingStateRemote = 1, @@ -33,6 +37,5 @@ typedef enum { -(void)removeItems:(NSArray *)items; -(void)addItems:(NSArray *)items; --(BOOL)isReversedContentView; @end diff --git a/TelegramTest/TGPVContainer.h b/TelegramTest/TGPVContainer.h index d71e3a35..a0f7109a 100644 --- a/TelegramTest/TGPVContainer.h +++ b/TelegramTest/TGPVContainer.h @@ -24,5 +24,6 @@ -(BOOL)ifVideoFullScreenPlayingNeedToogle; -(BOOL)isInImageContainer:(NSEvent *)event; - +-(void)increaseZoom; +-(void)decreaseZoom; @end diff --git a/TelegramTest/TGPVContainer.m b/TelegramTest/TGPVContainer.m index daeead2c..84ff270e 100644 --- a/TelegramTest/TGPVContainer.m +++ b/TelegramTest/TGPVContainer.m @@ -17,6 +17,84 @@ +@interface TGZoomableImage : TGPVImageView +@property (nonatomic,assign) NSPoint startPoint; +@property (nonatomic,assign) BOOL isDragged; +@end + +@implementation TGZoomableImage + + +-(void)mouseDown:(NSEvent *)theEvent { + + _startPoint = [self convertPoint:[theEvent locationInWindow] fromView:nil]; + _isDragged = NO; +} + + +-(void)mouseUp:(NSEvent *)theEvent { + _startPoint = NSZeroPoint; + [super mouseUp:theEvent]; +} + +-(void)mouseDragged:(NSEvent *)theEvent { + [super mouseDragged:theEvent]; + + if(_startPoint.x == 0 || _startPoint.y == 0) + return; + + if(NSWidth(self.frame) > NSWidth(self.superview.frame) || NSHeight(self.frame) > NSHeight(self.superview.frame)) + { + + NSPoint currentPoint = [self convertPoint:[theEvent locationInWindow] fromView:nil]; + + + NSSize addXY = NSMakeSize(currentPoint.x - _startPoint.x, currentPoint.y - _startPoint.y); + + [self addSizeToScroll:addXY]; + + + + } + +} + +-(void)addSizeToScroll:(NSSize)size { + + [self setFrameOrigin:NSMakePoint(NSMinX(self.frame) + size.width, NSMinY(self.frame) + size.height)]; + + _isDragged = YES; +} + +-(void)scrollWheel:(NSEvent *)event { + [super scrollWheel:event]; + + + if(NSWidth(self.frame) > NSWidth(self.superview.frame) || NSHeight(self.frame) > NSHeight(self.superview.frame)) + { + + NSSize addXY = NSMakeSize([event scrollingDeltaX], -[event scrollingDeltaY]); + + [self addSizeToScroll:addXY]; + + } + + +} + +-(void)setFrameOrigin:(NSPoint)newOrigin { + [super setFrameOrigin:NSMakePoint(MIN(MAX(newOrigin.x,NSWidth(self.superview.frame) - NSWidth(self.frame)),0), MIN(MAX(newOrigin.y,NSHeight(self.superview.frame) - NSHeight(self.frame)),0))]; +} + +-(void)setObject:(ImageObject *)object { + [super setObject:object]; + + _isDragged = NO; +} + +@end + + @interface TGVideoPlayer : AVPlayerView @end @@ -28,7 +106,7 @@ @implementation TGVideoPlayer @interface TGPVContainer () -@property (nonatomic,strong) TGImageView *imageView; +@property (nonatomic,strong) TGZoomableImage *imageView; @property (nonatomic,strong) TMNameTextField *userNameTextField; @property (nonatomic,strong) TMTextField *dateTextField; @property (nonatomic, strong) TMMenuPopover *menuPopover; @@ -37,8 +115,20 @@ @interface TGPVContainer () @property (nonatomic,strong) MessageCellDescriptionView *photoCaptionView; + + +@property (nonatomic,assign) int currentIncrease; + + + + +@property (nonatomic,strong) TMView *imageContainerView; @end + +#define ZOOM_PERCENT 0.30 +#define ZOOM_COUNT 10 + @implementation TGPVContainer - (void)drawRect:(NSRect)dirtyRect { @@ -56,12 +146,12 @@ -(id)initWithFrame:(NSRect)frameRect { } -(BOOL)isInImageContainer:(NSEvent *)theEvent { - return [self mouse:[self convertPoint:[theEvent locationInWindow] fromView:nil] inRect:_imageView.frame]; + return [self mouse:[self convertPoint:[theEvent locationInWindow] fromView:nil] inRect:_imageContainerView.frame]; } --(void)mouseDown:(NSEvent *)theEvent { +-(void)mouseUp:(NSEvent *)theEvent { - if([self mouse:[self convertPoint:[theEvent locationInWindow] fromView:nil] inRect:_imageView.frame]) + if([self mouse:[self convertPoint:[theEvent locationInWindow] fromView:nil] inRect:_imageContainerView.frame]) [TGPhotoViewer nextItem]; else [[TGPhotoViewer viewer] hide]; @@ -73,37 +163,220 @@ -(void)initialize { // self.layer.cornerRadius = 6; - self.imageView = [[TGPVImageView alloc] initWithFrame:NSMakeRect(0, bottomHeight, 0, 0)]; - // [self.imageView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; + self.imageView = [[TGZoomableImage alloc] initWithFrame:NSMakeRect(0, bottomHeight, 0, 0)]; - // self.imageView.cornerRadius = 6; _photoCaptionView = [[MessageCellDescriptionView alloc] initWithFrame:NSZeroRect]; - [self addSubview:self.imageView]; + _imageContainerView = [[TMView alloc] initWithFrame:NSZeroRect]; + [_imageContainerView addSubview:self.imageView]; + + [self addSubview:_imageContainerView]; + + // [self addSubview:_decreaseZoomButton]; -// self.userNameTextField = [TMNameTextField defaultTextField]; -// [self.userNameTextField setSelector:@selector(titleForMessage)]; -// -// [self.userNameTextField setFrameOrigin:NSMakePoint(0, 30)]; -// [self.userNameTextField setFrameSize:NSMakeSize(NSWidth(self.frame), 25)]; -// [self.userNameTextField setAutoresizingMask:NSViewWidthSizable]; -// -// [self addSubview:self.userNameTextField]; -// -// self.dateTextField = [TMTextField defaultTextField]; -// [self.dateTextField setFont:[NSFont fontWithName:@"HelveticaNeue" size:13]]; -// [self.dateTextField setAlignment:NSCenterTextAlignment]; -// [self.dateTextField setFrameOrigin:NSMakePoint(0, 15)]; -// [self.dateTextField setFrameSize:NSMakeSize(NSWidth(self.frame), 20)]; -// [self.dateTextField setAutoresizingMask:NSViewWidthSizable]; -// -// [self addSubview:self.dateTextField]; } +- (void)touchesBeganWithEvent:(NSEvent *)event { + +} +- (void)touchesMovedWithEvent:(NSEvent *)event { + +} +- (void)touchesEndedWithEvent:(NSEvent *)event { + +} +- (void)touchesCancelledWithEvent:(NSEvent *)event { + +} + +-(BOOL)becomeFirstResponder { + + [self.window makeFirstResponder:self]; + + return [super becomeFirstResponder]; + +} + +-(void)increaseZoom { + self.currentIncrease++; +} +-(void)decreaseZoom { + self.currentIncrease--; +} + + +-(void)setCurrentIncrease:(int)currentIncrease { + + int n = MAX(MIN(ZOOM_COUNT,currentIncrease),0); + + if(n == _currentIncrease || _imageContainerView.isHidden) + return; + + _currentIncrease = n; + + + [_photoCaptionView setHidden:_currentIncrease > 0]; + + if(_currentIncrease > 0) + { + NSSize size = self.currentViewerItem.imageObject.imageSize; + + size.width+= roundf((size.width * ZOOM_PERCENT) * _currentIncrease); + size.height+= roundf((size.height * ZOOM_PERCENT) * _currentIncrease); + + + NSSize maxSize = [self maxSize]; + + + + NSSize difSize = NSMakeSize(NSWidth(_imageView.frame),NSHeight(_imageView.frame)); + + [_imageView setFrameSize:size]; + + + [_imageContainerView setFrameSize:NSMakeSize(MIN(maxSize.width,size.width), MIN(maxSize.height,size.height))]; + [self setFrameSize:NSMakeSize(_imageContainerView.frame.size.width, maxSize.height)]; + + + difSize.width = NSWidth(_imageView.frame) - difSize.width; + difSize.height = NSHeight(_imageView.frame) - difSize.height; + + + if(!_imageView.isDragged) + { + [_imageView setCenterByView:_imageContainerView]; + } else { + [_imageView setFrameOrigin:NSMakePoint(NSMinX(_imageView.frame) - difSize.width/2, NSMinY(_imageView.frame) - difSize.height/2)]; + } + + [self updateContainerOrigin]; + + [_imageContainerView setCenterByView:self]; + + + + } else { + [self setCurrentViewerItem:_currentViewerItem animated:NO]; + } + + + +} + + +/* + -(void)setCurrentIncrease:(int)currentIncrease { + + int n = MAX(MIN(ZOOM_COUNT,currentIncrease),0); + + if(n == _currentIncrease || _imageContainerView.isHidden) + return; + + _currentIncrease = n; + + + if(_currentIncrease > 0) + { + NSSize size = self.currentViewerItem.imageObject.imageSize; + + size.width+= roundf((size.width * ZOOM_PERCENT) * _currentIncrease); + size.height+= roundf((size.height * ZOOM_PERCENT) * _currentIncrease); + + + NSSize maxSize = [self maxSize]; + + NSSize difSize = NSMakeSize(NSWidth(_imageView.frame),NSHeight(_imageView.frame)); + + [_imageView setFrameSize:size]; + + + + NSSize containerSize = NSMakeSize(MIN(maxSize.width,size.width), MIN(maxSize.height,size.height)); + + NSPoint containerPoint = NSMakePoint(roundf((containerSize.width - containerSize.width) / 2), ((maxSize.height - containerSize.height) / 2)); + + + + + + [self setFrameSize:NSMakeSize(containerSize.width, maxSize.height)]; + [self updateContainerOrigin]; + + // self.backgroundColor = [NSColor redColor]; + + [_imageContainerView setCenterByView:self]; + + _imageContainerView.layer.backgroundColor = [NSColor blueColor].CGColor; + + { + + + if(_imageContainerView.layer.anchorPoint.x == 0) { + _imageContainerView.layer.anchorPoint = NSMakePoint(0.5, 0.5); + CGPoint point = _imageContainerView.layer.position; + + point.x += roundf(_imageContainerView.frame.size.width / 2); + point.y += roundf(_imageContainerView.frame.size.height / 2); + + _imageContainerView.layer.position = point; + } + + POPBasicAnimation *anim = [POPBasicAnimation animationWithPropertyNamed:kPOPLayerSize]; + anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]; + anim.fromValue = [NSValue valueWithSize:_imageContainerView.frame.size]; + anim.toValue = [NSValue valueWithSize:containerSize]; + anim.duration = 0.1; + anim.removedOnCompletion = YES; + + [anim setCompletionBlock:^(POPAnimation *anim, BOOL finish) { + [_imageContainerView setFrame:NSMakeRect(containerPoint.x, containerPoint.y, containerSize.width, containerSize.height)]; + }]; + + [_imageContainerView.layer pop_addAnimation:anim forKey:@"scale"]; + } + + + + { + POPBasicAnimation *anim = [POPBasicAnimation animationWithPropertyNamed:kPOPLayerPosition]; + anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; + anim.fromValue = [NSValue valueWithPoint:_imageContainerView.frame.origin]; + anim.toValue = [NSValue valueWithPoint:containerPoint]; + anim.removedOnCompletion = YES; + + + // [_imageContainerView.layer pop_addAnimation:anim forKey:@"position"]; + } + + + // [_imageContainerView setFrameSize:NSMakeSize(MIN(maxSize.width,size.width), MIN(maxSize.height,size.height))]; + + + difSize.width = NSWidth(_imageView.frame) - difSize.width; + difSize.height = NSHeight(_imageView.frame) - difSize.height; + + + if(!_imageView.isDragged) + { + [_imageView setCenterByView:_imageContainerView]; + } else { + [_imageView setFrameOrigin:NSMakePoint(NSMinX(_imageView.frame) - difSize.width/2, NSMinY(_imageView.frame) - difSize.height/2)]; + } + + [self updateContainerOrigin]; + + // [_imageContainerView setCenterByView:self]; + } else { + [self setCurrentViewerItem:_currentViewerItem animated:NO]; + } + + + } + */ -(NSSize)maxSize { NSRect screenFrame = [NSScreen mainScreen].frame; @@ -176,10 +449,19 @@ -(NSAttributedString *)caption { } +-(void)updateContainerOrigin { + float x = (self.superview.bounds.size.width - self.bounds.size.width) / 2; + float y = (self.superview.bounds.size.height - self.bounds.size.height + 75) / 2; + + [self setFrameOrigin:NSMakePoint(roundf(x),roundf(y))]; +} + -(void)setCurrentViewerItem:(TGPhotoViewerItem *)currentViewerItem animated:(BOOL)animated { _currentViewerItem = currentViewerItem; + _currentIncrease = 0; + self.imageView.object = currentViewerItem.imageObject; @@ -209,20 +491,9 @@ -(void)setCurrentViewerItem:(TGPhotoViewerItem *)currentViewerItem animated:(BOO [self setFrameSize:NSMakeSize(containerSize.width, [self maxSize].height)]; + [self updateContainerOrigin]; - float x = (self.superview.bounds.size.width - self.bounds.size.width) / 2; - float y = (self.superview.bounds.size.height - self.bounds.size.height + 75) / 2; - - [self setFrameOrigin:NSMakePoint(roundf(x),roundf(y))]; - - - - - // [self setCenterByView:self.superview]; - - - NSAttributedString *caption = [self caption]; NSSize c_s = NSZeroSize; @@ -245,17 +516,20 @@ -(void)setCurrentViewerItem:(TGPhotoViewerItem *)currentViewerItem animated:(BOO } [self.imageView setFrameSize:NSMakeSize(size.width , size.height )]; + [self.imageView setFrameOrigin:NSZeroPoint]; + + [self.imageContainerView setFrameSize:self.imageView.frame.size]; - [self.imageView setFrameOrigin:NSMakePoint(roundf((self.bounds.size.width - size.width) / 2) , roundf((self.bounds.size.height - size.height + c_s.height + 10 ) / 2) )]; + [self.imageContainerView setFrameOrigin:NSMakePoint(roundf((self.bounds.size.width - NSWidth(self.imageView.frame)) / 2) , roundf((self.bounds.size.height - NSHeight(self.imageView.frame) + c_s.height + 10 ) / 2) )]; if(caption) { - [_photoCaptionView setFrame:NSMakeRect(roundf((self.frame.size.width - c_s.width) / 2), MAX(NSHeight(self.frame) - NSMaxY(_imageView.frame) ,0) , c_s.width, c_s.height)]; + [_photoCaptionView setFrame:NSMakeRect(roundf((self.frame.size.width - c_s.width) / 2), MAX(NSHeight(self.frame) - NSMaxY(_imageContainerView.frame) ,0) , c_s.width, c_s.height)]; } - [self.imageView setHidden:[currentViewerItem.previewObject.reservedObject isKindOfClass:[NSDictionary class]]]; + [self.imageContainerView setHidden:[currentViewerItem.previewObject.reservedObject isKindOfClass:[NSDictionary class]]]; if([currentViewerItem.previewObject.reservedObject isKindOfClass:[NSDictionary class]]) { @@ -274,7 +548,16 @@ -(void)setCurrentViewerItem:(TGPhotoViewerItem *)currentViewerItem animated:(BOO AVPlayer *player = [AVPlayer playerWithURL:url]; _videoPlayerView.player = player; - [player play]; + + dispatch_async(dispatch_get_current_queue(), ^{ + if(player.status == AVPlayerStatusReadyToPlay && + player.currentItem.status == AVPlayerItemStatusReadyToPlay) { + [player play]; + } + }); + + + } diff --git a/TelegramTest/TGPVControls.m b/TelegramTest/TGPVControls.m index 271f5258..9ad50bb6 100644 --- a/TelegramTest/TGPVControls.m +++ b/TelegramTest/TGPVControls.m @@ -19,6 +19,9 @@ @interface TGPVControls () @property (nonatomic,strong) BTRButton *moreButton; @property (nonatomic,strong) BTRButton *closeButton; @property (nonatomic, strong) TMMenuPopover *menuPopover; + + + @end @@ -51,7 +54,7 @@ -(id)initWithFrame:(NSRect)frameRect { if([[TGPhotoViewer behavior] class] == [TGPVMediaBehavior class]) { [[TGPhotoViewer viewer] hide]; - [[Telegram rightViewController] showCollectionPage:weakSelf.convertsation]; + [appWindow().navigationController showInfoPage:weakSelf.convertsation]; } @@ -68,7 +71,7 @@ -(id)initWithFrame:(NSRect)frameRect { self.backgroundColor = NSColorFromRGBWithAlpha(0x000000, 0.6); - [self.countTextField setFont:[NSFont fontWithName:@"HelveticaNeue-Bold" size:18]]; + [self.countTextField setFont:TGSystemBoldFont(18)]; [self.countTextField sizeToFit]; @@ -134,6 +137,7 @@ -(id)initWithFrame:(NSRect)frameRect { [self addSubview:self.moreButton]; [self addSubview:self.closeButton]; + } return self; @@ -328,31 +332,34 @@ -(NSMenu *)TGPVMediaBehaviorMenu { NSMenuItem *photoDelete = [NSMenuItem menuItemWithTitle:NSLocalizedString(@"PhotoViewer.Delete", nil) withBlock:^(id sender) { - - - [Notification perform:MESSAGE_DELETE_EVENT data:@{KEY_MESSAGE_ID_LIST:@[@(msg.n_id)]}]; + [[DialogsManager sharedManager] deleteMessagesWithRandomMessageIds:@[@(msg.randomId)] isChannelMessages:msg.isChannelMessage]; }]; // [photoDelete setImage:image_AttachPhotoVideo()]; // [photoDelete setHighlightedImage:image_AttachPhotoVideoHighlighted()]; - [theMenu addItem:photoDelete]; + + if([MessagesViewController canDeleteMessages:@[msg] inConversation:msg.conversation]) + [theMenu addItem:photoDelete]; + + if(msg.conversation.type != DialogTypeSecretChat) { NSMenuItem *photoForward = [NSMenuItem menuItemWithTitle:NSLocalizedString(@"PhotoViewer.Forward", nil) withBlock:^(id sender) { - [[Telegram rightViewController] showByDialog:msg.conversation sender:[TGPhotoViewer viewer]]; - [[Telegram rightViewController].messagesViewController setState:MessagesViewControllerStateNone]; - [[Telegram rightViewController].messagesViewController unSelectAll:NO]; + [[TGPhotoViewer viewer].invokeWindow.navigationController showMessagesViewController:msg.conversation]; - MessageTableItem *item = [MessageTableItem messageItemFromObject:msg]; - [[Telegram rightViewController].messagesViewController setSelectedMessage:item selected:YES]; + [[TGPhotoViewer viewer].invokeWindow.navigationController.messagesViewController setState:MessagesViewControllerStateNone]; + [[TGPhotoViewer viewer].invokeWindow.navigationController.messagesViewController unSelectAll:NO]; + MessageTableItem *item = [MessageTableItem messageItemFromObject:msg]; + + [[TGPhotoViewer viewer].invokeWindow.navigationController.messagesViewController setSelectedMessage:item selected:YES]; - [[Telegram rightViewController] showForwardMessagesModalView:_convertsation messagesCount:1]; + [[TGPhotoViewer viewer].invokeWindow.navigationController.messagesViewController showForwardMessagesModalView]; [[TGPhotoViewer viewer] hide]; @@ -399,8 +406,10 @@ -(NSMenu *)TGPVMediaBehaviorMenu { NSMenuItem *photoGoto = [NSMenuItem menuItemWithTitle:NSLocalizedString(@"PhotoViewer.Goto", nil) withBlock:^(id sender) { - [[Telegram rightViewController] showByDialog:_convertsation withJump:(int)[TGPhotoViewer currentItem].previewObject.msg_id historyFilter:[HistoryFilter class] sender:[TGPhotoViewer viewer]]; + TL_localMessage *msg = [TGPhotoViewer currentItem].previewObject.media; + [[TGPhotoViewer viewer].invokeWindow.navigationController showMessagesViewController:msg.conversation]; + [[TGPhotoViewer viewer] hide]; }]; diff --git a/TelegramTest/TGPVDocumentObject.m b/TelegramTest/TGPVDocumentObject.m index ac076d4a..d0ef250b 100644 --- a/TelegramTest/TGPVDocumentObject.m +++ b/TelegramTest/TGPVDocumentObject.m @@ -8,17 +8,22 @@ #import "TGPVDocumentObject.h" #import "DownloadDocumentItem.h" - +#import "DownloadDocumentItem.h" @interface TGPVDocumentObject () @property (nonatomic,strong) TL_localMessage *message; @end @implementation TGPVDocumentObject +@synthesize supportDownloadListener = _supportDownloadListener; + + -(id)initWithMessage:(TL_localMessage *)message placeholder:(NSImage *)placeholder { if(self = [super initWithLocation:nil placeHolder:placeholder]) { _message = message; - self.imageSize = placeholder.size; + + + } return self; @@ -27,7 +32,71 @@ -(id)initWithMessage:(TL_localMessage *)message placeholder:(NSImage *)placehold -(void)initDownloadItem { + NSImage *image = [[NSImage alloc] initWithContentsOfFile:mediaFilePath(self.message.media)]; + + if(image.size.width > 0 && image.size.height > 0) { + + self.imageSize = image.size; + + [TGCache cacheImage:image forKey:[self cacheKey] groups:@[PVCACHE]]; + + [self.delegate didDownloadImage:image object:self]; + return; + } + + + + if((self.downloadItem && (self.downloadItem.downloadState != DownloadStateCompleted && self.downloadItem.downloadState != DownloadStateCanceled && self.downloadItem.downloadState != DownloadStateWaitingStart)) || !self.message) + return;//[_downloadItem cancel]; + + + self.downloadItem = [[DownloadDocumentItem alloc] initWithObject:self.message]; + + self.downloadListener = [[DownloadEventListener alloc] init]; + + _supportDownloadListener = [[DownloadEventListener alloc] init]; + + [self.downloadItem addEvent:self.supportDownloadListener]; + [self.downloadItem addEvent:self.downloadListener]; + + + weak(); + + [self.downloadListener setCompleteHandler:^(DownloadItem * item) { + weakSelf.isLoaded = YES; + + [weakSelf _didDownloadImage:item]; + weakSelf.downloadItem = nil; + weakSelf.downloadListener = nil; + }]; + + + [self.downloadListener setProgressHandler:^(DownloadItem * item) { + if([weakSelf.delegate respondsToSelector:@selector(didUpdatedProgress:)]) { + [weakSelf.delegate didUpdatedProgress:item.progress]; + } + }]; + + + [self.downloadItem start]; + +} + + +-(void)_didDownloadImage:(DownloadItem *)item { + NSImage *image = [[NSImage alloc] initWithData:item.result]; + + if(image != nil) { + + image = renderedImage(image, image.size.width > 0 && image.size.height > 0 ? image.size : self.imageSize); + + [TGCache cacheImage:image forKey:[self cacheKey] groups:@[PVCACHE]]; + } + + [[ASQueue mainQueue] dispatchOnQueue:^{ + [self.delegate didDownloadImage:image object:self]; + }]; } diff --git a/TelegramTest/TGPVDocumentsBehavior.h b/TelegramTest/TGPVDocumentsBehavior.h new file mode 100644 index 00000000..ad5e1f79 --- /dev/null +++ b/TelegramTest/TGPVDocumentsBehavior.h @@ -0,0 +1,13 @@ +// +// TGPVDocumentsBehavior.h +// Telegram +// +// Created by keepcoder on 23.10.15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import +#import "TGPVBehavior.h" +@interface TGPVDocumentsBehavior : TGPhotoViewerBehavior + +@end diff --git a/TelegramTest/TGPVDocumentsBehavior.m b/TelegramTest/TGPVDocumentsBehavior.m new file mode 100644 index 00000000..32b53cb9 --- /dev/null +++ b/TelegramTest/TGPVDocumentsBehavior.m @@ -0,0 +1,170 @@ +// +// TGPVDocumentsBehavior.m +// Telegram +// +// Created by keepcoder on 23.10.15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "TGPVDocumentsBehavior.h" +#import "TGPhotoViewerItem.h" +#import "TGPVDocumentObject.h" +#import "DocumentHistoryFilter.h" +#import "MessageTableItem.h" +@interface TGPVDocumentsBehavior () + +@end + +@implementation TGPVDocumentsBehavior +@synthesize conversation = _conversation; +@synthesize user = _user; +@synthesize request = _request; +@synthesize state = _state; +@synthesize totalCount = _totalCount; + +@synthesize controller = _controller; + + +-(id)initWithConversation:(TL_conversation *)conversation commonItem:(PreviewObject *)object { + + if(self = [super init]) { + _conversation = conversation; + _controller = [[ChatHistoryController alloc] initWithController:self historyFilter:[DocumentHistoryFilter class]]; + + if(object != nil) + [_controller addMessageWithoutSavingState:object.media]; + } + + return self; +} + +-(void)addItems:(NSArray *)items { + +} + +-(void)receivedMessage:(MessageTableItem *)message position:(int)position itsSelf:(BOOL)force { + +} + +-(void)deleteItems:(NSArray *)items orMessageIds:(NSArray *)ids { + +} + +-(void)flushMessages { + +} + +-(void)receivedMessageList:(NSArray *)list inRange:(NSRange)range itsSelf:(BOOL)force { + +} + +- (void)didAddIgnoredMessages:(NSArray *)items { + +} + +-(NSArray *)messageTableItemsFromMessages:(NSArray *)messages { + + NSMutableArray *previewObjects = [NSMutableArray array]; + + [messages enumerateObjectsUsingBlock:^(TL_localMessage *obj, NSUInteger idx, BOOL *stop) { + + PreviewObject *preview = [[PreviewObject alloc] initWithMsdId:obj.n_id media:obj peer_id:obj.peer_id]; + + [previewObjects addObject:preview]; + }]; + + return previewObjects; +} + +-(void)jumpToLastMessages:(BOOL)force { + +} + +-(TL_conversation *)conversation { + return _conversation; +} + +-(void)updateLoading { + +} + +-(void)load:(long)max_id next:(BOOL)next limit:(int)limit callback:(void (^)(NSArray *))callback { + + + [_controller request:next anotherSource:YES sync:NO selectHandler:^(NSArray *result, NSRange range,HistoryFilter *filter) { + + [ASQueue dispatchOnStageQueue:^{ + callback(result); + }]; + + }]; + + +} + +-(void)removeItems:(NSArray *)items { + +} + +-(void)addItems { + +} + +-(int)totalCount { + return [[Storage manager] countOfMedia:_conversation.peer_id]; +} + + +-(void)clear { + [_request cancelRequest]; +} + +-(NSArray *)convertObjects:(NSArray *)list { + NSMutableArray *converted = [[NSMutableArray alloc] init]; + + [list enumerateObjectsUsingBlock:^(PreviewObject *obj, NSUInteger idx, BOOL *stop) { + + + if([obj.media isKindOfClass:[TLPhotoSize class]]) { + + TGPVImageObject *imgObj = [[TGPVImageObject alloc] initWithLocation:[(TL_photoSize *)obj.media location] placeHolder:obj.reservedObject sourceId:_user.n_id size:0]; + + imgObj.imageSize = NSMakeSize([(TL_photoSize *)obj.media w], [(TL_photoSize *)obj.media h]); + + TGPhotoViewerItem *item = [[TGPhotoViewerItem alloc] initWithImageObject:imgObj previewObject:obj]; + + [converted addObject:item]; + } else if([[(TL_localMessage *)obj.media media] isKindOfClass:[TL_messageMediaDocument class]]) { + + TL_messageMediaDocument *media = (TL_messageMediaDocument *) [(TL_localMessage *)obj.media media]; + + if([media.document.mime_type hasPrefix:@"image"] && ![media.document.mime_type hasSuffix:@"gif"]) { + TL_documentAttributeImageSize *size = (TL_documentAttributeImageSize *) [[media document] attributeWithClass:[TL_documentAttributeImageSize class]]; + + TGPVDocumentObject *imgObj = [[TGPVDocumentObject alloc] initWithMessage:obj.media placeholder:nil]; + + if(size) { + imgObj.imageSize = NSMakeSize(size.w, size.h); + } else { + if(imgObj.placeholder.size.width == 0) { + imgObj.imageSize = NSMakeSize(500, 500); + } + } + + TGPhotoViewerItem *item = [[TGPhotoViewerItem alloc] initWithImageObject:imgObj previewObject:obj]; + [converted addObject:item]; + } + } + + }]; + + return converted; +} + +-(void)dealloc { + +} + + + +@end diff --git a/TelegramTest/TGPVEmptyBehavior.h b/TelegramTest/TGPVEmptyBehavior.h index d12f542d..de3937a3 100644 --- a/TelegramTest/TGPVEmptyBehavior.h +++ b/TelegramTest/TGPVEmptyBehavior.h @@ -8,6 +8,6 @@ #import #import "TGPVBehavior.h" -@interface TGPVEmptyBehavior : NSObject +@interface TGPVEmptyBehavior : TGPhotoViewerBehavior @end diff --git a/TelegramTest/TGPVEmptyBehavior.m b/TelegramTest/TGPVEmptyBehavior.m index b393482f..eeca0362 100644 --- a/TelegramTest/TGPVEmptyBehavior.m +++ b/TelegramTest/TGPVEmptyBehavior.m @@ -71,8 +71,6 @@ -(int)totalCount { return 1; } --(BOOL)isReversedContentView { - return NO; -} + @end diff --git a/TelegramTest/TGPVImageView.m b/TelegramTest/TGPVImageView.m index fd63caaf..30b8e232 100644 --- a/TelegramTest/TGPVImageView.m +++ b/TelegramTest/TGPVImageView.m @@ -40,6 +40,12 @@ -(NSImage *)cachedThumb:(NSString *)key { return self.object.placeholder; } +-(void)didDownloadImage:(NSImage *)image object:(TGImageObject *)object { + if([[object cacheKey] isEqualToString:[self.object cacheKey]]) { + [self setObject:object]; + } +} + -(void)setImage:(NSImage *)image { [super setImage:image]; diff --git a/TelegramTest/TGPVMediaBehavior.h b/TelegramTest/TGPVMediaBehavior.h index 1c1aac5f..f3aa691d 100644 --- a/TelegramTest/TGPVMediaBehavior.h +++ b/TelegramTest/TGPVMediaBehavior.h @@ -8,9 +8,8 @@ #import #import "TGPVBehavior.h" -@interface TGPVMediaBehavior : NSObject +@interface TGPVMediaBehavior : TGPhotoViewerBehavior -@property (nonatomic,strong) TL_conversation *conversation; @end diff --git a/TelegramTest/TGPVMediaBehavior.m b/TelegramTest/TGPVMediaBehavior.m index 77c1b5a9..dd654825 100644 --- a/TelegramTest/TGPVMediaBehavior.m +++ b/TelegramTest/TGPVMediaBehavior.m @@ -8,6 +8,13 @@ #import "TGPVMediaBehavior.h" #import "TGPhotoViewer.h" +#import "ChatHistoryController.h" +#import "PhotoHistoryFilter.h" +#import "MessageTableItem.h" +@interface TGPVMediaBehavior () + +@end + @implementation TGPVMediaBehavior @synthesize conversation = _conversation; @@ -16,89 +23,97 @@ @implementation TGPVMediaBehavior @synthesize state = _state; @synthesize totalCount = _totalCount; --(void)load:(long)max_id next:(BOOL)next limit:(int)limit callback:(void (^)(NSArray *))callback { +@synthesize controller = _controller; + + +-(id)initWithConversation:(TL_conversation *)conversation commonItem:(PreviewObject *)object { - if(_state == TGPVMediaBehaviorLoadingStateLocal) { - - [[Storage manager] media:^(NSArray *list) { - - - if(self != nil) { - [ASQueue dispatchOnStageQueue:^{ - callback(list); - - if(list.count == 0 && next) - _state = _conversation.type == DialogTypeSecretChat ? TGPVMediaBehaviorLoadingStateFull : TGPVMediaBehaviorLoadingStateRemote; - - }]; - } - - } max_id:max_id peer_id:_conversation.peer_id next:next limit:limit]; - - } else if(_state == TGPVMediaBehaviorLoadingStateRemote) { - - [self loadRemote:max_id limit:limit callback:callback]; + if(self = [super init]) { + _conversation = conversation; + _controller = [[ChatHistoryController alloc] initWithController:self historyFilter:[PhotoHistoryFilter class]]; + if(object != nil) + [_controller addMessageWithoutSavingState:object.media]; } + return self; } --(void)removeItems:(NSArray *)items { +-(void)addItems:(NSArray *)items { } --(void)addItems { +-(void)receivedMessage:(MessageTableItem *)message position:(int)position itsSelf:(BOOL)force { } --(int)totalCount { - return [[Storage manager] countOfMedia:_conversation.peer_id]; +-(void)deleteItems:(NSArray *)items orMessageIds:(NSArray *)ids { + } +-(void)flushMessages { + +} --(void)loadRemote:(long)max_id limit:(int)limit callback:(void (^)(NSArray *previewObjects))callback { +-(void)receivedMessageList:(NSArray *)list inRange:(NSRange)range itsSelf:(BOOL)force { - [_request cancelRequest]; +} + +- (void)didAddIgnoredMessages:(NSArray *)items { + +} + +-(NSArray *)messageTableItemsFromMessages:(NSArray *)messages { - _request = [RPCRequest sendRequest:[TLAPI_messages_search createWithPeer:_conversation.inputPeer q:@"" filter:[TL_inputMessagesFilterPhotoVideo create] min_date:0 max_date:0 offset:0 max_id:(int)max_id limit:limit] successHandler:^(RPCRequest *request, id response) { - - if(self == nil) - return; - - - NSMutableArray *messages = [response messages]; + NSMutableArray *previewObjects = [NSMutableArray array]; + + [messages enumerateObjectsUsingBlock:^(TL_localMessage *obj, NSUInteger idx, BOOL *stop) { - [TL_localMessage convertReceivedMessages:messages]; - - NSMutableArray *previewObjects = [[NSMutableArray alloc] init]; - + PreviewObject *preview = [[PreviewObject alloc] initWithMsdId:obj.n_id media:obj peer_id:obj.peer_id]; - [messages enumerateObjectsUsingBlock:^(TL_localMessage *obj, NSUInteger idx, BOOL *stop) { - - if(![obj isKindOfClass:[TL_messageEmpty class]]) { - PreviewObject *preview = [[PreviewObject alloc] initWithMsdId:obj.n_id media:obj peer_id:obj.peer_id]; - - [[Storage manager] insertMedia:obj]; - - [previewObjects addObject:preview]; - } - }]; - - if(messages.count == 0) - _state = TGPVMediaBehaviorLoadingStateFull; - - _request = nil; - - if(callback) - callback(previewObjects); + [previewObjects addObject:preview]; + }]; + + return previewObjects; +} + +-(void)jumpToLastMessages:(BOOL)force { + +} + +-(TL_conversation *)conversation { + return _conversation; +} + +-(void)updateLoading { + +} + +-(void)load:(long)max_id next:(BOOL)next limit:(int)limit callback:(void (^)(NSArray *))callback { + + + [_controller request:next anotherSource:YES sync:NO selectHandler:^(NSArray *result, NSRange range,HistoryFilter *filter) { - } errorHandler:^(RPCRequest *request, RpcError *error) { + [ASQueue dispatchOnStageQueue:^{ + callback(result); + }]; - _request = nil; - - } timeout:0 queue:[ASQueue globalQueue].nativeQueue]; + }]; + + +} + +-(void)removeItems:(NSArray *)items { + +} + +-(void)addItems { + } +-(int)totalCount { + return [_controller itemsCount]; +} -(void)clear { [_request cancelRequest]; @@ -117,7 +132,6 @@ -(NSArray *)convertObjects:(NSArray *)list { TL_photoSize *photoSize = ((TL_photoSize *)[photo.sizes lastObject]); - NSImage *thumb; if(photo.sizes.count > 0) { @@ -144,9 +158,5 @@ -(void)dealloc { } --(BOOL)isReversedContentView { - return [Telegram rightViewController].navigationViewController.currentController != [Telegram rightViewController].collectionViewController; -} - @end diff --git a/TelegramTest/TGPVUserBehavior.h b/TelegramTest/TGPVUserBehavior.h index 68ea8163..fe481f88 100644 --- a/TelegramTest/TGPVUserBehavior.h +++ b/TelegramTest/TGPVUserBehavior.h @@ -8,6 +8,6 @@ #import #import "TGPVBehavior.h" -@interface TGPVUserBehavior : NSObject +@interface TGPVUserBehavior : TGPhotoViewerBehavior @end diff --git a/TelegramTest/TGPVUserBehavior.m b/TelegramTest/TGPVUserBehavior.m index b9d4af1e..b616ad2f 100644 --- a/TelegramTest/TGPVUserBehavior.m +++ b/TelegramTest/TGPVUserBehavior.m @@ -52,10 +52,13 @@ -(void)load:(long)max_id next:(BOOL)next limit:(int)limit callback:(void (^)(NSA for (int i = 0; i < response.photos.count; i++) { + TL_photo *photo = response.photos[i]; PreviewObject *previewObject = [[PreviewObject alloc] initWithMsdId:[photo n_id] media:[photo.sizes lastObject] peer_id:_user.n_id]; + previewObject.date = [(TL_photo *)response.photos[response.photos.count - i - 1] date]; + previewObject.access_hash = photo.access_hash; [converted addObject:previewObject]; @@ -123,8 +126,6 @@ -(void)clear { } --(BOOL)isReversedContentView { - return NO; -} + @end diff --git a/TelegramTest/TGPVZoomControl.h b/TelegramTest/TGPVZoomControl.h new file mode 100644 index 00000000..d8398467 --- /dev/null +++ b/TelegramTest/TGPVZoomControl.h @@ -0,0 +1,13 @@ +// +// TGPVZoomControl.h +// Telegram +// +// Created by keepcoder on 07.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TMView.h" + +@interface TGPVZoomControl : TMView + +@end diff --git a/TelegramTest/TGPVZoomControl.m b/TelegramTest/TGPVZoomControl.m new file mode 100644 index 00000000..80b85b66 --- /dev/null +++ b/TelegramTest/TGPVZoomControl.m @@ -0,0 +1,96 @@ + +// +// TGPVZoomControl.m +// Telegram +// +// Created by keepcoder on 07.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TGPVZoomControl.h" +#import "TGPhotoViewer.h" +@interface TGPVZoomControl () +@property (nonatomic,strong) BTRButton *increaseZoomButton; +@property (nonatomic,strong) BTRButton *decreaseZoomButton; +@end + +@implementation TGPVZoomControl + +- (void)drawRect:(NSRect)dirtyRect { + [super drawRect:dirtyRect]; + + // Drawing code here. +} + +-(instancetype)initWithFrame:(NSRect)frameRect { + if(self = [super initWithFrame:frameRect]) { + + self.backgroundColor = NSColorFromRGBWithAlpha(0x000000, 0.6); + self.autoresizingMask = NSViewMinXMargin | NSViewMinYMargin | NSViewMaxYMargin; + + self.wantsLayer = YES; + self.layer.cornerRadius = 8; + + + _increaseZoomButton = [[BTRButton alloc] initWithFrame:NSMakeRect(NSWidth(frameRect)/2, 0, NSWidth(frameRect)/2, NSHeight(frameRect))]; + [_increaseZoomButton setImage:image_ZoomIn() forControlState:BTRControlStateNormal]; + + [_increaseZoomButton addBlock:^(BTRControlEvents events) { + + [TGPhotoViewer increaseZoom]; + + } forControlEvents:BTRControlEventClick]; + + + + _decreaseZoomButton = [[BTRButton alloc] initWithFrame:NSMakeRect(0, 0, NSWidth(frameRect)/2, NSHeight(frameRect))]; + [_decreaseZoomButton setImage:image_ZoomOut() forControlState:BTRControlStateNormal]; + + [_decreaseZoomButton addBlock:^(BTRControlEvents events) { + + [TGPhotoViewer decreaseZoom]; + + } forControlEvents:BTRControlEventClick]; + + + weak(); + + [_increaseZoomButton addBlock:^(BTRControlEvents events) { + + [weakSelf.decreaseZoomButton setAlphaValue:0.7]; + [weakSelf.increaseZoomButton setAlphaValue:1.0]; + + } forControlEvents:BTRControlEventMouseEntered]; + + [_increaseZoomButton addBlock:^(BTRControlEvents events) { + + [weakSelf.decreaseZoomButton setAlphaValue:0.7]; + [weakSelf.increaseZoomButton setAlphaValue:0.7]; + + } forControlEvents:BTRControlEventMouseExited]; + + + [_decreaseZoomButton addBlock:^(BTRControlEvents events) { + + [weakSelf.decreaseZoomButton setAlphaValue:1.0]; + [weakSelf.increaseZoomButton setAlphaValue:0.7]; + + } forControlEvents:BTRControlEventMouseEntered]; + + [_decreaseZoomButton addBlock:^(BTRControlEvents events) { + + [weakSelf.decreaseZoomButton setAlphaValue:0.7]; + [weakSelf.increaseZoomButton setAlphaValue:0.7]; + + } forControlEvents:BTRControlEventMouseExited]; + + + + [self addSubview:_increaseZoomButton]; + [self addSubview:_decreaseZoomButton]; + } + + return self; +} + +@end diff --git a/TelegramTest/TGPasscodeSettingsViewController.m b/TelegramTest/TGPasscodeSettingsViewController.m index ef455007..ea9e621a 100644 --- a/TelegramTest/TGPasscodeSettingsViewController.m +++ b/TelegramTest/TGPasscodeSettingsViewController.m @@ -44,7 +44,7 @@ -(void)rebuildController { [self.tableView removeAllItems:NO]; - GeneralSettingsRowItem *turnPasscode = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSelected callback:^(GeneralSettingsRowItem *item) { + GeneralSettingsRowItem *turnPasscode = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSelected callback:^(TGGeneralRowItem *item) { @@ -89,7 +89,7 @@ -(void)rebuildController { - } description:[[MTNetwork instance] passcodeIsEnabled] ? NSLocalizedString(@"PasscodeSettings.TurnOffPasscode", nil) : NSLocalizedString(@"PasscodeSettings.TurnOnPasscode", nil) height:82 stateback:^id(GeneralSettingsRowItem *item) { + } description:[[MTNetwork instance] passcodeIsEnabled] ? NSLocalizedString(@"PasscodeSettings.TurnOffPasscode", nil) : NSLocalizedString(@"PasscodeSettings.TurnOnPasscode", nil) height:82 stateback:^id(TGGeneralRowItem *item) { return @(NO); }]; @@ -97,11 +97,7 @@ -(void)rebuildController { if(![[MTNetwork instance] passcodeIsEnabled]) { - GeneralSettingsBlockHeaderItem *description = [[GeneralSettingsBlockHeaderItem alloc] initWithObject:NSLocalizedString(@"PasscodeSettings.TurnOnDescription", nil)]; - - - description.height = 100; - description.isFlipped = YES; + GeneralSettingsBlockHeaderItem *description = [[GeneralSettingsBlockHeaderItem alloc] initWithString:NSLocalizedString(@"PasscodeSettings.TurnOnDescription", nil) height:100 flipped:YES]; [self.tableView insert:description atIndex:self.tableView.count tableRedraw:NO]; } @@ -110,7 +106,7 @@ -(void)rebuildController { if([[MTNetwork instance] passcodeIsEnabled]) { - GeneralSettingsRowItem *changePasscode = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSelected callback:^(GeneralSettingsRowItem *item) { + GeneralSettingsRowItem *changePasscode = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSelected callback:^(TGGeneralRowItem *item) { [self showChangePasslock:^BOOL(BOOL result, NSString *md5Hash) { @@ -130,7 +126,7 @@ -(void)rebuildController { }]; - } description:NSLocalizedString(@"PasscodeSettings.ChangePasscode", nil) height:42 stateback:^id(GeneralSettingsRowItem *item) { + } description:NSLocalizedString(@"PasscodeSettings.ChangePasscode", nil) height:42 stateback:^id(TGGeneralRowItem *item) { return @(NO); }]; @@ -139,10 +135,10 @@ -(void)rebuildController { [self.tableView insert:changePasscode atIndex:self.tableView.list.count tableRedraw:NO]; - GeneralSettingsRowItem *autoLockPasscode = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeChoice callback:^(GeneralSettingsRowItem *item) { + GeneralSettingsRowItem *autoLockPasscode = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeChoice callback:^(TGGeneralRowItem *item) { - } description:NSLocalizedString(@"PasscodeSettings.AutoLock", nil) height:82 stateback:^id(GeneralSettingsRowItem *item) { + } description:NSLocalizedString(@"PasscodeSettings.AutoLock", nil) height:82 stateback:^id(TGGeneralRowItem *item) { return [TGPasslock autoLockDescription]; }]; @@ -156,6 +152,16 @@ -(void)rebuildController { [self.tableView reloadData]; }]]; +#ifdef TGDEBUG + if(ACCEPT_FEATURE) { + [menu addItem:[NSMenuItem menuItemWithTitle:NSLocalizedString(@"Passcode.AutoLockTime5", nil) withBlock:^(id sender) { + [TGPasslock setAutoLockTime:5]; + [self.tableView reloadData]; + }]]; + } + +#endif + [menu addItem:[NSMenuItem menuItemWithTitle:NSLocalizedString(@"Passcode.AutoLockTime60", nil) withBlock:^(id sender) { [TGPasslock setAutoLockTime:60]; [self.tableView reloadData]; diff --git a/TelegramTest/TGPasslockModalView.m b/TelegramTest/TGPasslockModalView.m index af84a90f..e7f3703d 100644 --- a/TelegramTest/TGPasslockModalView.m +++ b/TelegramTest/TGPasslockModalView.m @@ -73,7 +73,7 @@ -(instancetype)initWithFrame:(NSRect)frameRect { [attrs appendString:NSLocalizedString(@"Passcode.EnterPlaceholder", nil) withColor:NSColorFromRGB(0xc8c8c8)]; - [attrs setAttributes:@{NSFontAttributeName:[NSFont fontWithName:@"HelveticaNeue" size:12]} range:attrs.range]; + [attrs setAttributes:@{NSFontAttributeName:TGSystemFont(12)} range:attrs.range]; [[self.secureField cell] setPlaceholderAttributedString:attrs]; @@ -104,7 +104,7 @@ -(instancetype)initWithFrame:(NSRect)frameRect { [self.secureField setAction:@selector(checkPassword)]; [self.secureField setTarget:self]; - [self.secureField setFont:[NSFont fontWithName:@"HelveticaNeue" size:14]]; + [self.secureField setFont:TGSystemFont(14)]; [self.secureField setTextColor:DARK_BLACK]; [self.secureField setFrameOrigin:NSMakePoint(NSMinX(self.secureField.frame), NSMinY(self.avatar.frame) - 100)]; @@ -119,7 +119,7 @@ -(instancetype)initWithFrame:(NSRect)frameRect { [self.descriptionField setSelector:@selector(profileTitle)]; [self.descriptionField setUser:[UsersManager currentUser]]; - [self.descriptionField setFont:[NSFont fontWithName:@"HelveticaNeue" size:14]]; + [self.descriptionField setFont:TGSystemFont(14)]; [self.descriptionField setTextColor:DARK_BLACK]; diff --git a/TelegramTest/TGPasswordEmailViewController.m b/TelegramTest/TGPasswordEmailViewController.m index 4bab97f1..e4ce2216 100644 --- a/TelegramTest/TGPasswordEmailViewController.m +++ b/TelegramTest/TGPasswordEmailViewController.m @@ -131,7 +131,7 @@ -(void)setAction:(TGSetPasswordAction *)action { [str appendString:action.title withColor:DARK_GRAY]; [str setAlignment:NSLeftTextAlignment range:str.range]; - [str setFont:[NSFont fontWithName:@"HelveticaNeue" size:15] forRange:str.range]; + [str setFont:TGSystemFont(15) forRange:str.range]; [[self.textView textView].cell setPlaceholderAttributedString:str]; diff --git a/TelegramTest/TGPasswordSetViewController.m b/TelegramTest/TGPasswordSetViewController.m index 5b8291d8..5fed5401 100644 --- a/TelegramTest/TGPasswordSetViewController.m +++ b/TelegramTest/TGPasswordSetViewController.m @@ -27,7 +27,7 @@ - (id)initWithFrame:(NSRect)frame { [self.textView setFrameOrigin:NSMakePoint(8, 2)]; [self.textView setDrawsBackground:NO]; - [self.textView setFont:[NSFont fontWithName:@"HelveticaNeue" size:15]]; + [self.textView setFont:TGSystemFont(15)]; [self setAutoresizingMask:NSViewWidthSizable]; [self addSubview:self.textView]; } @@ -136,7 +136,7 @@ -(void)setAction:(TGSetPasswordAction *)action { [str appendString:action.title withColor:DARK_GRAY]; [str setAlignment:NSLeftTextAlignment range:str.range]; - [str setFont:[NSFont fontWithName:@"HelveticaNeue" size:15] forRange:str.range]; + [str setFont:TGSystemFont(15) forRange:str.range]; [[self.textView textView].cell setPlaceholderAttributedString:str]; // [[self.textView textView] setPlaceholderPoint:NSMakePoint(0, 0)]; diff --git a/TelegramTest/TGPasswosdMainViewController.m b/TelegramTest/TGPasswosdMainViewController.m index 9293dd1f..934503d1 100644 --- a/TelegramTest/TGPasswosdMainViewController.m +++ b/TelegramTest/TGPasswosdMainViewController.m @@ -65,7 +65,7 @@ -(void)rebuildController { if([self.passwordResult email_unconfirmed_pattern].length == 0) { if([self.passwordResult isKindOfClass:[TL_account_noPassword class]]) { - GeneralSettingsRowItem *turnPassword = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSelected callback:^(GeneralSettingsRowItem *item) { + GeneralSettingsRowItem *turnPassword = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSelected callback:^(TGGeneralRowItem *item) { TGSetPasswordAction *firstAction = [[TGSetPasswordAction alloc] init]; @@ -152,15 +152,13 @@ -(void)rebuildController { [[Telegram rightViewController] showSetPasswordWithAction:firstAction]; - } description:NSLocalizedString(@"PasswordSettings.TurnOnPassword", nil) height:82 stateback:^id(GeneralSettingsRowItem *item) { + } description:NSLocalizedString(@"PasswordSettings.TurnOnPassword", nil) height:82 stateback:^id(TGGeneralRowItem *item) { return @(NO); }]; [self.tableView insert:turnPassword atIndex:self.tableView.list.count tableRedraw:NO]; - GeneralSettingsBlockHeaderItem *description = [[GeneralSettingsBlockHeaderItem alloc] initWithObject:NSLocalizedString(@"PasswordSettings.AdditionDescription", nil)]; - - description.height = 60; + GeneralSettingsBlockHeaderItem *description = [[GeneralSettingsBlockHeaderItem alloc] initWithString:NSLocalizedString(@"PasswordSettings.AdditionDescription", nil) height:60 flipped:NO]; [self.tableView insert:description atIndex:self.tableView.count tableRedraw:NO]; @@ -172,7 +170,7 @@ -(void)rebuildController { - GeneralSettingsRowItem *changePassword = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSelected callback:^(GeneralSettingsRowItem *item) { + GeneralSettingsRowItem *changePassword = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSelected callback:^(TGGeneralRowItem *item) { TGSetPasswordAction *sAction = [[TGSetPasswordAction alloc] init]; @@ -251,7 +249,7 @@ -(void)rebuildController { [[Telegram rightViewController] showSetPasswordWithAction:sAction]; - } description: NSLocalizedString(@"PasswordSettings.ChangePassword", nil) height:82 stateback:^id(GeneralSettingsRowItem *item) { + } description: NSLocalizedString(@"PasswordSettings.ChangePassword", nil) height:82 stateback:^id(TGGeneralRowItem *item) { return @(NO); }]; @@ -259,7 +257,7 @@ -(void)rebuildController { - GeneralSettingsRowItem *turnPassword = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSelected callback:^(GeneralSettingsRowItem *item) { + GeneralSettingsRowItem *turnPassword = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSelected callback:^(TGGeneralRowItem *item) { TGSetPasswordAction *sAction = [[TGSetPasswordAction alloc] init]; @@ -308,13 +306,13 @@ -(void)rebuildController { - } description: NSLocalizedString(@"PasswordSettings.TurnOffPassword", nil) height:42 stateback:^id(GeneralSettingsRowItem *item) { + } description: NSLocalizedString(@"PasswordSettings.TurnOffPassword", nil) height:42 stateback:^id(TGGeneralRowItem *item) { return @(NO); }]; [self.tableView insert:turnPassword atIndex:self.tableView.list.count tableRedraw:NO]; - GeneralSettingsRowItem *recoveryEmail = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSelected callback:^(GeneralSettingsRowItem *item) { + GeneralSettingsRowItem *recoveryEmail = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSelected callback:^(TGGeneralRowItem *item) { TGSetPasswordAction *sAction = [[TGSetPasswordAction alloc] init]; @@ -391,7 +389,7 @@ -(void)rebuildController { - } description:pwd.has_recovery ? NSLocalizedString(@"PasswordSettings.ChangeRecoveryEmail", nil) : NSLocalizedString(@"PasswordSettings.SetRecoveryEmail", nil) height:42 stateback:^id(GeneralSettingsRowItem *item) { + } description:pwd.has_recovery ? NSLocalizedString(@"PasswordSettings.ChangeRecoveryEmail", nil) : NSLocalizedString(@"PasswordSettings.SetRecoveryEmail", nil) height:42 stateback:^id(TGGeneralRowItem *item) { return @(NO); }]; @@ -400,10 +398,7 @@ -(void)rebuildController { // description - GeneralSettingsBlockHeaderItem *description = [[GeneralSettingsBlockHeaderItem alloc] initWithObject:[NSString stringWithFormat:NSLocalizedString(@"PasswordSettings.EnabledDescription", nil),[_passwordResult email_unconfirmed_pattern]]]; - - description.height = 100; - description.isFlipped = YES; + GeneralSettingsBlockHeaderItem *description = [[GeneralSettingsBlockHeaderItem alloc] initWithString:[NSString stringWithFormat:NSLocalizedString(@"PasswordSettings.EnabledDescription", nil),[_passwordResult email_unconfirmed_pattern]] height:100 flipped:YES]; [self.tableView insert:description atIndex:self.tableView.count tableRedraw:NO]; } @@ -412,7 +407,7 @@ -(void)rebuildController { if(![_passwordResult isKindOfClass:[TL_account_noPassword class]]) { - GeneralSettingsRowItem *recoveryEmail = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSelected callback:^(GeneralSettingsRowItem *item) { + GeneralSettingsRowItem *recoveryEmail = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSelected callback:^(TGGeneralRowItem *item) { TGSetPasswordAction *sAction = [[TGSetPasswordAction alloc] init]; @@ -496,7 +491,7 @@ -(void)rebuildController { - } description:NSLocalizedString(@"PasswordSettings.ChangeRecoveryEmail", nil) height:82 stateback:^id(GeneralSettingsRowItem *item) { + } description:NSLocalizedString(@"PasswordSettings.ChangeRecoveryEmail", nil) height:82 stateback:^id(TGGeneralRowItem *item) { return @(NO); }]; @@ -508,7 +503,7 @@ -(void)rebuildController { - GeneralSettingsRowItem *turnPassword = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSelected callback:^(GeneralSettingsRowItem *item) { + GeneralSettingsRowItem *turnPassword = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSelected callback:^(TGGeneralRowItem *item) { if([_passwordResult isKindOfClass:[TL_account_noPassword class]]) { @@ -569,16 +564,15 @@ -(void)rebuildController { - } description: NSLocalizedString(@"PasswordSettings.AbortPassword", nil) height:self.tableView.count == 0 ? 82 : 42 stateback:^id(GeneralSettingsRowItem *item) { + } description: NSLocalizedString(@"PasswordSettings.AbortPassword", nil) height:self.tableView.count == 0 ? 82 : 42 stateback:^id(TGGeneralRowItem *item) { return @(NO); }]; [self.tableView insert:turnPassword atIndex:self.tableView.count tableRedraw:NO]; - GeneralSettingsBlockHeaderItem *description = [[GeneralSettingsBlockHeaderItem alloc] initWithObject:[NSString stringWithFormat:NSLocalizedString(@"PasswordSettings.ConfrimEmailDescription", nil),[_passwordResult email_unconfirmed_pattern]]]; + GeneralSettingsBlockHeaderItem *description = [[GeneralSettingsBlockHeaderItem alloc] initWithString:[NSString stringWithFormat:NSLocalizedString(@"PasswordSettings.ConfrimEmailDescription", nil),[_passwordResult email_unconfirmed_pattern]] height:100 flipped:NO]; - description.height = 100; [self.tableView insert:description atIndex:self.tableView.count tableRedraw:NO]; diff --git a/TelegramTest/TGPhotoViewer.h b/TelegramTest/TGPhotoViewer.h index 8917eeec..e77aa80f 100644 --- a/TelegramTest/TGPhotoViewer.h +++ b/TelegramTest/TGPhotoViewer.h @@ -17,10 +17,14 @@ @property (nonatomic,strong,readonly) TGPVContainer *photoContainer; @property (nonatomic,strong,readonly) TGPVControls *controls; + +@property (nonatomic,weak) TelegramWindow *invokeWindow; + -(void)show:(PreviewObject *)item conversation:(TL_conversation *)conversation; +-(void)show:(PreviewObject *)item conversation:(TL_conversation *)conversation isReversed:(BOOL)isReversed; -(void)show:(PreviewObject *)item user:(TLUser *)user; -(void)show:(PreviewObject *)item; - +-(void)showDocuments:(PreviewObject *)item conversation:(TL_conversation *)conversation; -(void)prepareUser:(TLUser *)user; @@ -39,4 +43,7 @@ +(BOOL)isVisibility; + ++(void)increaseZoom; ++(void)decreaseZoom; @end diff --git a/TelegramTest/TGPhotoViewer.m b/TelegramTest/TGPhotoViewer.m index 869b3c2d..0b4dad75 100644 --- a/TelegramTest/TGPhotoViewer.m +++ b/TelegramTest/TGPhotoViewer.m @@ -16,6 +16,8 @@ #import "TGPVUserBehavior.h" #import "TGPVEmptyBehavior.h" #import "TGCache.h" +#import "TGPVZoomControl.h" +#import "TGPVDocumentsBehavior.h" @interface TGPhotoViewer () @property (nonatomic,strong) TL_conversation *conversation; @property (nonatomic,strong) TLUser *user; @@ -34,6 +36,10 @@ @interface TGPhotoViewer () @property (nonatomic,assign) BOOL waitRequest; @property (nonatomic,assign) int totalCount; +@property (nonatomic,strong) TGPVZoomControl *zoomControl; + +@property (nonatomic,assign) BOOL isReversed; + @end @@ -44,10 +50,11 @@ -(void)mouseDown:(NSEvent *)theEvent { } + -(void)orderOut:(id)sender { - [self runAnimation:NO]; - + [self runAnimation:NO]; + [Notification removeObserver:self]; [super orderOut:sender]; [_photoContainer setCurrentViewerItem:nil animated:NO]; @@ -61,11 +68,24 @@ -(void)orderOut:(id)sender { [TGCache removeAllCachedImages:@[PVCACHE]]; [[NSApp mainWindow] makeFirstResponder:nil]; + + viewer = nil; } +-(void)dealloc { + [Notification removeObserver:self]; +} + +(BOOL)isVisibility { - return [self viewer].isVisibility; + return viewer.isVisibility; +} + ++(void)increaseZoom { + [viewer.photoContainer increaseZoom]; +} ++(void)decreaseZoom { + [viewer.photoContainer decreaseZoom]; } -(id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag screen:(NSScreen *)screen { @@ -81,7 +101,6 @@ -(id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle backin - (void)initialize { - [TGCache setMemoryLimit:32*1024*1024 group:PVCACHE]; [TGCache setCountLimit:25 group:PVCACHE]; @@ -96,15 +115,15 @@ - (void)initialize { self.background.layer.backgroundColor = NSColorFromRGBWithAlpha(0x222222, 0.7).CGColor; - weakify(); - [self.background setCallback:^ { - + weak(); + + [self.background setCallback:^{ NSEvent *currentEvent = [NSApp currentEvent]; NSPoint location = [currentEvent locationInWindow]; - NSPoint containerPoint = strongSelf.photoContainer.frame.origin; + NSPoint containerPoint = weakSelf.photoContainer.frame.origin; if(location.x > containerPoint.x) [[TGPhotoViewer viewer] hide]; @@ -133,6 +152,9 @@ - (void)initialize { [self.contentView addSubview:self.controls]; + self.zoomControl = [[TGPVZoomControl alloc] initWithFrame:NSMakeRect(50, 16, 200, controlsHeight)]; + + [self.contentView addSubview:self.zoomControl]; } @@ -158,7 +180,7 @@ -(void)didAddedPhoto:(NSNotification *)notification { [self insertObjects:@[previewObject]]; } else { - TGPVUserBehavior *behavior = [[TGPVUserBehavior alloc] init]; + TGPVUserBehavior *behavior = [[TGPVUserBehavior alloc] initWithConversation:_conversation commonItem:previewObject]; behavior.user = user; [behavior addItems:@[previewObject]]; @@ -181,8 +203,6 @@ -(void)mouseMoved:(NSEvent *)theEvent { if(![self.controls hitTest:point]) { - - if([self.photoContainer hitTest:point] && [self.photoContainer isInImageContainer:theEvent]) { highlight = TGPVControlHighLightNext; } else if(point.x > NSMinX(self.photoContainer.frame)) { @@ -209,20 +229,24 @@ -(void)didDeleteMessages:(NSNotification *)notification { [ASQueue dispatchOnStageQueue:^{ - NSArray *ids = notification.userInfo[KEY_MESSAGE_ID_LIST]; + NSArray *peer_update_data = notification.userInfo[KEY_DATA]; - [ids enumerateObjectsUsingBlock:^(NSNumber *msg_id, NSUInteger idx, BOOL *stop) { + [peer_update_data enumerateObjectsUsingBlock:^(NSDictionary *data, NSUInteger idx, BOOL *stop) { - [_list enumerateObjectsUsingBlock:^(TGPhotoViewerItem *obj, NSUInteger idx, BOOL *stop) { - - if(obj.previewObject.msg_id == [msg_id intValue]) { + if(self.conversation.peer_id == [data[KEY_PEER_ID] intValue]) { + [_list enumerateObjectsUsingBlock:^(TGPhotoViewerItem *obj, NSUInteger idx, BOOL *stop) { - [self deleteItem:obj]; + if(obj.previewObject.msg_id == [data[KEY_MESSAGE_ID] intValue]) { + + [self deleteItem:obj]; + + *stop = YES; + } - *stop = YES; - } - - }]; + }]; + } + + }]; @@ -248,18 +272,18 @@ -(void)didReceivedMedia:(NSNotification *)notification { } +(id)behavior { - return [[self viewer] behavior]; + return [viewer behavior]; } +(void)deleteItem:(TGPhotoViewerItem *)item { - [[self viewer] deleteItem:item]; + [viewer deleteItem:item]; } -(void)resort { [ASQueue dispatchOnStageQueue:^{ - [_list sortUsingDescriptors:@[[NSSortDescriptor sortDescriptorWithKey:@"previewObject.msg_id" ascending:NO]]]; + [_list sortUsingDescriptors:@[[NSSortDescriptor sortDescriptorWithKey:@"previewObject.date" ascending:NO],[NSSortDescriptor sortDescriptorWithKey:@"previewObject.msg_id" ascending:NO]]]; _totalCount = MAX([_behavior totalCount],(int)[self listCount]); @@ -295,8 +319,6 @@ -(void)deleteItem:(TGPhotoViewerItem *)item { pos = MAX(index - 1, 0); -// if(index != 0) -// pos--; if(pos >= ([self listCount] - 1)) { pos = [self listCount] - 1; @@ -319,21 +341,22 @@ -(void)deleteItem:(TGPhotoViewerItem *)item { +(TGPhotoViewerItem *)currentItem { - return [[self viewer] currentItem]; + return [viewer currentItem]; } +static TGPhotoViewer *viewer; + +(TGPhotoViewer *)viewer { - static TGPhotoViewer *viewer; - - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ + + if(!viewer) + { viewer = [[TGPhotoViewer alloc] initWithContentRect:[NSScreen mainScreen].frame styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO screen:[NSScreen mainScreen]]; [viewer setLevel:NSScreenSaverWindowLevel]; [viewer setOpaque:NO]; viewer.backgroundColor = [NSColor clearColor]; - }); - + + } return viewer; } @@ -346,7 +369,7 @@ -(NSInteger)indexOfObject:(PreviewObject *)item { [ASQueue dispatchOnStageQueue:^{ [self.list enumerateObjectsUsingBlock:^(TGPhotoViewerItem *obj, NSUInteger index, BOOL *stop) { - if(obj.previewObject.msg_id == item.msg_id) { + if(obj.previewObject.msg_id == item.msg_id && obj.previewObject.peerId == item.peerId) { idx = index; *stop = YES; } @@ -383,7 +406,7 @@ -(void)runAnimation:(BOOL)show { [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) { - [context setDuration:0.2]; + [context setDuration:0.1]; [[self.background animator] setAlphaValue:nextAlpha]; [[self.controls animator] setAlphaValue:nextAlpha]; @@ -394,16 +417,17 @@ -(void)runAnimation:(BOOL)show { }]; } --(void)show:(PreviewObject *)item conversation:(TL_conversation *)conversation { + +-(void)showDocuments:(PreviewObject *)item conversation:(TL_conversation *)conversation { _conversation = conversation; _controls.convertsation = conversation; _photoContainer.conversation = conversation; + _isReversed = YES; - _behavior = [[TGPVMediaBehavior alloc] init]; - [_behavior setConversation:_conversation]; + _behavior = [[TGPVDocumentsBehavior alloc] initWithConversation:_conversation commonItem:item]; [ASQueue dispatchOnStageQueue:^{ @@ -421,22 +445,79 @@ -(void)show:(PreviewObject *)item conversation:(TL_conversation *)conversation { _waitRequest = YES; - [self.behavior load:[[[self itemAtIndex:[self listCount]-1] previewObject] msg_id] next:NO limit:10000 callback:^(NSArray *previewObjects) { + self.currentItemId = 0; + + [self.behavior load:0 next:YES limit:100 callback:^(NSArray *nextObjects) { + + [self insertObjects:nextObjects]; - [self insertObjects:previewObjects]; + [self.behavior load:0 next:NO limit:100 callback:^(NSArray *prevObjects) { + + [self insertObjects:prevObjects]; + + _waitRequest = NO; + }]; - _waitRequest = NO; }]; +} + +-(void)show:(PreviewObject *)item conversation:(TL_conversation *)conversation { + [self show:item conversation:conversation isReversed:NO]; +} + +-(void)show:(PreviewObject *)item conversation:(TL_conversation *)conversation isReversed:(BOOL)isReversed { + _conversation = conversation; + + _isReversed = isReversed; + + _controls.convertsation = conversation; + _photoContainer.conversation = conversation; + + _behavior = [[TGPVMediaBehavior alloc] initWithConversation:_conversation commonItem:item]; + [_behavior setConversation:_conversation]; + + [ASQueue dispatchOnStageQueue:^{ + + self.list = [[NSMutableArray alloc] init]; + [self insertObjects:@[item]]; + + } synchronous:YES]; + + [self makeKeyAndOrderFront:self]; + + [self mouseEntered:[NSApp currentEvent]]; + + _waitRequest = YES; + + + self.currentItemId = 0; + + [self.behavior load:0 next:YES limit:100 callback:^(NSArray *nextObjects) { + + [self insertObjects:nextObjects]; + + [self.behavior load:0 next:NO limit:100 callback:^(NSArray *prevObjects) { + + [self insertObjects:prevObjects]; + + _waitRequest = NO; + }]; + + }]; + + + } -(void)show:(PreviewObject *)item user:(TLUser *)user { - _behavior = [[TGPVUserBehavior alloc] init]; + _behavior = [[TGPVUserBehavior alloc] initWithConversation:_conversation commonItem:item]; [_behavior setUser:user]; + _isReversed = YES; [ASQueue dispatchOnStageQueue:^{ @@ -449,6 +530,10 @@ -(void)show:(PreviewObject *)item user:(TLUser *)user { [self makeKeyAndOrderFront:self]; + [self.behavior load:0 next:YES limit:100 callback:^(NSArray *result) { + [self insertObjects:result]; + }]; + } -(void)show:(PreviewObject *)item { @@ -463,7 +548,7 @@ -(void)show:(PreviewObject *)item { } - _behavior = [[TGPVEmptyBehavior alloc] init]; + _behavior = [[TGPVEmptyBehavior alloc] initWithConversation:_conversation commonItem:item]; [ASQueue dispatchOnStageQueue:^{ @@ -480,6 +565,8 @@ -(void)show:(PreviewObject *)item { -(void)makeKeyAndOrderFront:(id)sender { + self.invokeWindow = appWindow(); + [Notification addObserver:self selector:@selector(didReceivedMedia:) name:MEDIA_RECEIVE]; [Notification addObserver:self selector:@selector(didDeleteMessages:) name:MESSAGE_DELETE_EVENT]; @@ -517,7 +604,7 @@ -(NSUInteger)listCount { -(void)nextItem { - if([self.behavior isReversedContentView]) { + if(_isReversed) { [self performPrevItem]; @@ -533,7 +620,7 @@ -(void)nextItem { -(void)prevItem { - if([self.behavior isReversedContentView]) { + if(_isReversed) { [self performNextItem]; @@ -565,44 +652,52 @@ -(void)performPrevItem { } +(void)prevItem { - [[self viewer] prevItem]; + [viewer prevItem]; } +(void)nextItem { - [[self viewer] nextItem]; + [viewer nextItem]; } -(void)setCurrentItemId:(NSInteger)currentItemId { + if(currentItemId == NSNotFound) return; - _currentItemId = currentItemId; - _currentItem = [self itemAtIndex:currentItemId]; + BOOL next = _isReversed ? currentItemId > _currentItemId : currentItemId < _currentItemId; + _currentItemId = currentItemId; - - [self.controls setCurrentPosition:[self.behavior isReversedContentView] ? _totalCount - _currentItemId : _currentItemId+1 ofCount:_totalCount]; + + _currentItem = [self itemAtIndex:currentItemId]; + + [self.controls setCurrentPosition:_isReversed ? _totalCount - _currentItemId : _currentItemId+1 ofCount:_totalCount]; + [[self photoContainer] setCurrentViewerItem:_currentItem animated:NO]; - if( (_currentItemId + 15 ) >= [self listCount] && !_waitRequest) { - - _waitRequest = YES; - - - [self.behavior load:[[[self itemAtIndex:[self listCount]-1] previewObject] msg_id] next:YES limit:100 callback:^(NSArray *previewObjects) { - - [self insertObjects:previewObjects]; + [_zoomControl setHidden:[_currentItem.previewObject.reservedObject isKindOfClass:[NSDictionary class]]]; + + if(_list.count > 1 && !_waitRequest) { + int rcurrent = _isReversed ? _totalCount - (int)_currentItemId : (int)_currentItemId; + if((next && (rcurrent <= 15 )) || (!next && ( rcurrent >= (_totalCount - 15)))) { + _waitRequest = YES; - _waitRequest = NO; - }]; - + [self.behavior load:0 next:next limit:100 callback:^(NSArray *previewObjects) { + + if(previewObjects.count > 0) + [self insertObjects:previewObjects]; + + _waitRequest = NO; + }]; + } } + [ASQueue dispatchOnStageQueue:^{ @@ -615,7 +710,7 @@ -(void)setCurrentItemId:(NSInteger)currentItemId { [_list enumerateObjectsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:range] options:NSEnumerationReverse usingBlock:^(TGPhotoViewerItem *obj, NSUInteger idx, BOOL *stop) { - if(![TGCache cachedImage:obj.imageObject.location.cacheKey group:@[PVCACHE]]) { + if(![TGCache cachedImage:obj.imageObject.cacheKey group:@[PVCACHE]]) { [obj.imageObject initDownloadItem]; } @@ -646,10 +741,8 @@ -(void)hide { if(!self.photoContainer.ifVideoFullScreenPlayingNeedToogle) { [self orderOut:self]; - [Notification removeObserver:self]; } - - + } diff --git a/TelegramTest/TGPhotoViewerBehavior.h b/TelegramTest/TGPhotoViewerBehavior.h new file mode 100644 index 00000000..26a502c0 --- /dev/null +++ b/TelegramTest/TGPhotoViewerBehavior.h @@ -0,0 +1,20 @@ +// +// TGPhotoViewerBehavior.h +// Telegram +// +// Created by keepcoder on 09/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import + +@interface TGPhotoViewerBehavior : NSObject + +@property (nonatomic,strong,readonly) ChatHistoryController *controller; + + +-(id)initWithConversation:(TL_conversation *)conversation commonItem:(PreviewObject *)object; + +-(void)drop; + +@end diff --git a/TelegramTest/TGPhotoViewerBehavior.m b/TelegramTest/TGPhotoViewerBehavior.m new file mode 100644 index 00000000..666b84be --- /dev/null +++ b/TelegramTest/TGPhotoViewerBehavior.m @@ -0,0 +1,26 @@ +// +// TGPhotoViewerBehavior.m +// Telegram +// +// Created by keepcoder on 09/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "TGPhotoViewerBehavior.h" +#import "ChatHistoryController.h" +@implementation TGPhotoViewerBehavior + +-(id)initWithConversation:(TL_conversation *)conversation commonItem:(PreviewObject *)object { + if(self = [super init]) { + + } + + return self; +} + +-(void)drop { + [_controller drop:YES]; + _controller = nil; +} + +@end diff --git a/TelegramTest/TGProccessUpdates.h b/TelegramTest/TGProccessUpdates.h index a50a95dc..8e69b138 100644 --- a/TelegramTest/TGProccessUpdates.h +++ b/TelegramTest/TGProccessUpdates.h @@ -18,6 +18,8 @@ -(void)resetStateAndSync; -+(void)checkAndLoadIfNeededSupportMessages:(NSArray *)messages asyncCompletionHandler:(dispatch_block_t)completionHandler; -+(void)checkAndLoadIfNeededSupportMessages:(NSArray *)messages; + +-(void)failUpdateWithChannelId:(int)channel_id limit:(int)limit withCallback:(void (^)(id response, TGMessageHole *longHole))callback errorCallback:(void (^)(RpcError *error))errorCallback; + + @end diff --git a/TelegramTest/TGProccessUpdates.m b/TelegramTest/TGProccessUpdates.m index 8698c749..d0746b4e 100644 --- a/TelegramTest/TGProccessUpdates.m +++ b/TelegramTest/TGProccessUpdates.m @@ -19,13 +19,15 @@ #import "TGDateUtils.h" #import "TGModernEncryptedUpdates.h" #import "FullUsersManager.h" +#import "TGUpdateChannels.h" +#import "TGForceChannelUpdate.h" @interface TGProccessUpdates () @property (nonatomic,strong) TGUpdateState *updateState; @property (nonatomic,strong) NSMutableArray *statefulUpdates; @property (nonatomic,strong) TGTimer *sequenceTimer; @property (atomic,assign) BOOL holdUpdates; @property (nonatomic,strong) TGModernEncryptedUpdates *encryptedUpdates; - +@property (nonatomic,strong) TGUpdateChannels *channelsUpdater; @end @@ -42,48 +44,54 @@ @implementation TGProccessUpdates @synthesize holdUpdates = _holdUpdates; --(id)init { - if(self = [super init]) { + +static NSArray *channelUpdates; + +-(id)initWithQueue:(ASQueue *)q { + if(self = [self init]) { self.holdUpdates = NO; _statefulUpdates = [[NSMutableArray alloc] init]; _updateState = [[Storage manager] updateState]; - // _updateState = [[TGUpdateState alloc] initWithPts:1 qts:1 date:_updateState.date seq:1 pts_count:1]; - _encryptedUpdates = [[TGModernEncryptedUpdates alloc] init]; + if(_updateState.pts == 0) { + _updateState = nil; + } + + // _updateState = [[TGUpdateState alloc] initWithPts:1 qts:1 date:_updateState.date seq:1 pts_count:1]; + _encryptedUpdates = [[TGModernEncryptedUpdates alloc] init]; + _channelsUpdater = [[TGUpdateChannels alloc] initWithQueue:q]; static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ - queue = [[ASQueue alloc] initWithName:"UpdatesQueue"]; + + channelUpdates = @[NSStringFromClass([TL_updateNewChannelMessage class]),NSStringFromClass([TL_updateReadChannelInbox class]),NSStringFromClass([TL_updateDeleteChannelMessages class]),NSStringFromClass([TGForceChannelUpdate class]),NSStringFromClass([TL_updateChannelTooLong class]),NSStringFromClass([TL_updateChannelGroup class]),NSStringFromClass([TL_updateChannelMessageViews class]),NSStringFromClass([TL_updateChannel class])]; }); + queue = q; + [_encryptedUpdates setQueue:queue]; } return self; } --(id)initWithQueue:(ASQueue *)q { - if(self = [self init]) { - self.holdUpdates = NO; - _statefulUpdates = [[NSMutableArray alloc] init]; +- (void)resetStateAndSync { + + [queue dispatchOnQueue:^{ + _updateState = [[TGUpdateState alloc] initWithPts:989352 qts:1 date:_updateState.date seq:1 pts_count:1]; - _updateState = [[Storage manager] updateState]; - // _updateState = [[TGUpdateState alloc] initWithPts:1 qts:1 date:_updateState.date seq:1 pts_count:1]; - _encryptedUpdates = [[TGModernEncryptedUpdates alloc] init]; + [self saveUpdateState]; - queue = q; - } - return self; + [self uptodateWithConnectionState:YES]; + }]; } -- (void)resetStateAndSync { - +-(void)failUpdateWithChannelId:(int)channel_id limit:(int)limit withCallback:(void (^)(id response, TGMessageHole *longHole))callback errorCallback:(void (^)(RpcError *error))errorCallback { [queue dispatchOnQueue:^{ - _updateState = [[TGUpdateState alloc] initWithPts:1 qts:1 date:_updateState.date seq:1 pts_count:1]; - [self saveUpdateState]; + [_channelsUpdater failUpdateWithChannelId:channel_id limit:limit withCallback:callback errorCallback:errorCallback]; - [self uptodate:_updateState.pts qts:_updateState.qts date:_updateState.date updateConnectionState:YES]; }]; } @@ -118,37 +126,59 @@ -(void)processUpdates:(NSArray *)updates stateSeq:(int)stateSeq { -(void)processUpdates:(NSArray *)updates stateSeq:(int)stateSeq { - int statePts = 0; - int stateDate = 0; - int stateQts = 0; - int statePts_count = 0; - for(TLUpdate *update in updates) { - if ([update date] > stateDate) - stateDate = [update date]; - - if([update isKindOfClass:[TL_updateNewEncryptedMessage class]]) { - if ([update qts] > stateQts) - stateQts = [update qts]; - } else { - if ([update pts] > statePts) - statePts = [update pts]; - - statePts_count+= [update pts_count]; - } - + [self addStatefullUpdate:update seq:0 pts:[update pts] date:[update date] qts:[update qts] pts_count:[update pts_count]]; } - [self addStatefullUpdate:updates seq:stateSeq pts:statePts date:stateDate qts:stateQts pts_count:statePts_count]; - } + + + + -(void)addUpdate:(id)update { [queue dispatchOnQueue:^{ - if([update isKindOfClass:[TL_messages_sentMessage class]] || - [update isKindOfClass:[TL_messages_affectedHistory class]]) { + + + + if([channelUpdates indexOfObject:[update className]] != NSNotFound) + { + [_channelsUpdater addUpdate:update]; + + return; + } else if([update respondsToSelector:@selector(update)] && [channelUpdates indexOfObject:[[(TL_updateShort *)update update] className]] != NSNotFound) { + [_channelsUpdater addUpdate:[(TL_updateShort *)update update]]; + + [_updateState setDate:[(TL_updateShort *)update date]]; + [self saveUpdateState]; + return; + } + + if([update isKindOfClass:[TL_updates class]]) { + + [SharedManager proccessGlobalResponse:update]; + + [[update updates] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + + if([obj isKindOfClass:[TL_updateMessageID class]]) { + [self proccessUpdate:obj]; + } + + if([channelUpdates indexOfObject:[obj className]] != NSNotFound) + { + [_channelsUpdater addUpdate:obj]; + } + + }]; + + [_updateState setDate:[(TL_updates *)update date]]; + [self saveUpdateState]; + + } + + if([update isKindOfClass:[TL_messages_affectedMessages class]]) { [self addStatefullUpdate:update seq:0 pts:[update pts] date:0 qts:0 pts_count:[update pts_count]]; @@ -179,27 +209,27 @@ -(void)addUpdate:(id)update { if([update isKindOfClass:[TL_updates class]]) { - [SharedManager proccessGlobalResponse:update]; - [self processUpdates:[update updates] stateSeq:[update seq]]; + NSArray *updates = [[[update updates] copy] filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) { + + return [channelUpdates indexOfObject:[evaluatedObject className]] == NSNotFound; + + }]]; + + if(updates.count > 0) + [self processUpdates:updates stateSeq:[update seq]]; } if([update isKindOfClass:[TL_updateShortChatMessage class]]) { TL_updateShortChatMessage *shortMessage = update; - if(![[UsersManager sharedManager] find:shortMessage.from_id] || ![[ChatsManager sharedManager] find:shortMessage.chat_id] || (shortMessage.fwd_from_id > 0 && ![[UsersManager sharedManager] find:shortMessage.fwd_from_id])) { - [self failSequence]; - return; - } + [self addStatefullUpdate:update seq:[shortMessage seq] pts:[shortMessage pts] date:[shortMessage date] qts:0 pts_count:[shortMessage pts_count]]; } - if([update isKindOfClass:[TL_updateShortMessage class]]) { + if([update isKindOfClass:[TL_updateShortMessage class]] || [update isKindOfClass:[TL_updateShortSentMessage class]]) { TL_updateShortMessage *shortMessage = update; - if(![[UsersManager sharedManager] find:shortMessage.user_id] || (shortMessage.fwd_from_id > 0 && ![[UsersManager sharedManager] find:shortMessage.fwd_from_id])) { - [self failSequence]; - return; - } + [self addStatefullUpdate:update seq:[shortMessage seq] pts:[shortMessage pts] date:[shortMessage date] qts:0 pts_count:[shortMessage pts_count]]; } @@ -219,10 +249,11 @@ -(void)addUpdate:(id)update { -(void)addStatefullUpdate:(id)update seq:(int)seq pts:(int)pts date:(int)date qts:(int)qts pts_count:(int)pts_count { + TGUpdateContainer *statefulMessage = [[TGUpdateContainer alloc] initWithSequence:seq pts:pts date:date qts:qts pts_count:pts_count update:update]; - if(statefulMessage.pts > 0 && _updateState.pts + statefulMessage.pts_count == statefulMessage.pts && !_holdUpdates) { + if(statefulMessage.pts > 0 && ((_updateState.pts + statefulMessage.pts_count == statefulMessage.pts) || _updateState.pts >= statefulMessage.pts) && !_holdUpdates) { [self proccessStatefulMessage:statefulMessage needSave:YES]; return; } @@ -237,12 +268,11 @@ -(void)addStatefullUpdate:(id)update seq:(int)seq pts:(int)pts date:(int)date qt return; } - if([statefulMessage isEmpty]) { + if([statefulMessage isEmpty] && _updateState != nil) { [self proccessStatefulMessage:statefulMessage needSave:NO]; return; } - [_statefulUpdates addObject:statefulMessage]; [self cancelSequenceTimer]; @@ -254,6 +284,7 @@ -(void)addStatefullUpdate:(id)update seq:(int)seq pts:(int)pts date:(int)date qt [_sequenceTimer start]; [self checkSequence]; + } -(void)failSequence { @@ -375,6 +406,7 @@ -(void)checkSequence { -(void)applyUpdate:(TGUpdateContainer *)container { + _updateState.seq = container.beginSeq; _updateState.pts = container.pts; @@ -393,50 +425,45 @@ -(BOOL)proccessStatefulMessage:(TGUpdateContainer *)container needSave:(BOOL)nee TL_updateShortChatMessage *shortMessage = (TL_updateShortChatMessage *) container.update; - if(![[UsersManager sharedManager] find:[shortMessage from_id]] || ![[ChatsManager sharedManager] find:shortMessage.chat_id]) { + + + TL_localMessage *message = [TL_localMessage createWithN_id:shortMessage.n_id flags:shortMessage.flags from_id:[shortMessage from_id] to_id:[TL_peerChat createWithChat_id:shortMessage.chat_id] fwd_from_id:shortMessage.fwd_from_id fwd_date:shortMessage.fwd_date reply_to_msg_id:shortMessage.reply_to_msg_id date:shortMessage.date message:shortMessage.message media:[TL_messageMediaEmpty create] fakeId:[MessageSender getFakeMessageId] randomId:rand_long() reply_markup:nil entities:shortMessage.entities views:0 isViewed:YES state:DeliveryStateNormal]; + + if(![[UsersManager sharedManager] find:shortMessage.from_id] || ![[ChatsManager sharedManager] find:shortMessage.chat_id] || (message.fwd_from_id != nil && !message.fwdObject)) { + + if(![[ChatsManager sharedManager] find:shortMessage.chat_id]) { + [[FullChatManager sharedManager] loadIfNeed:shortMessage.chat_id force:YES]; + } + [self failSequence]; return NO; } - TL_localMessage *message = [TL_localMessage createWithN_id:shortMessage.n_id flags:shortMessage.flags from_id:[shortMessage from_id] to_id:[TL_peerChat createWithChat_id:shortMessage.chat_id] fwd_from_id:shortMessage.fwd_from_id fwd_date:shortMessage.fwd_date reply_to_msg_id:shortMessage.reply_to_msg_id date:shortMessage.date message:shortMessage.message media:[TL_messageMediaEmpty create] fakeId:[MessageSender getFakeMessageId] randomId:rand_long() reply_markup:nil state:DeliveryStateNormal]; - - if(message.reply_to_msg_id != 0 && message.replyMessage == nil) { - [self failSequence]; - return NO; - } - [MessagesManager addAndUpdateMessage:message]; } if([container.update isKindOfClass:[TL_updateShortMessage class]]) { TL_updateShortMessage *shortMessage = (TL_updateShortMessage *) container.update; - if(![[UsersManager sharedManager] find:[shortMessage user_id]]) { + TL_localMessage *message = [TL_localMessage createWithN_id:shortMessage.n_id flags:shortMessage.flags from_id:[shortMessage user_id] to_id:[TL_peerUser createWithUser_id:[shortMessage user_id]] fwd_from_id:shortMessage.fwd_from_id fwd_date:shortMessage.fwd_date reply_to_msg_id:shortMessage.reply_to_msg_id date:shortMessage.date message:shortMessage.message media:[TL_messageMediaEmpty create] fakeId:[MessageSender getFakeMessageId] randomId:rand_long() reply_markup:nil entities:shortMessage.entities views:0 isViewed:YES state:DeliveryStateNormal]; + + + if(![[UsersManager sharedManager] find:shortMessage.user_id] || (message.fwd_from_id != nil && !message.fwdObject)) { [self failSequence]; return NO; } - TL_localMessage *message = [TL_localMessage createWithN_id:shortMessage.n_id flags:shortMessage.flags from_id:[shortMessage user_id] to_id:[TL_peerUser createWithUser_id:[shortMessage user_id]] fwd_from_id:shortMessage.fwd_from_id fwd_date:shortMessage.fwd_date reply_to_msg_id:shortMessage.reply_to_msg_id date:shortMessage.date message:shortMessage.message media:[TL_messageMediaEmpty create] fakeId:[MessageSender getFakeMessageId] randomId:rand_long() reply_markup:nil state:DeliveryStateNormal]; - if(message.n_out) { message.from_id = [UsersManager currentUserId]; } else { message.to_id.user_id = [UsersManager currentUserId]; } - if(message.reply_to_msg_id != 0 && message.replyMessage == nil) { - [self failSequence]; - return NO; - } - [MessagesManager addAndUpdateMessage:message]; + } - if([container.update isKindOfClass:[NSArray class]]) { - for (TLUpdate *update in container.update) { - [self proccessUpdate:update]; - } - } + [self proccessUpdate:container.update]; if(needSave) [self applyUpdate:container]; @@ -454,448 +481,428 @@ -(void)updateShort:(TL_updateShort *)shortUpdate { [self proccessUpdate:shortUpdate.update]; } -+(void)checkAndLoadIfNeededSupportMessages:(NSArray *)messages { - [self checkAndLoadIfNeededSupportMessages:messages asyncCompletionHandler:nil]; -} -+(void)checkAndLoadIfNeededSupportMessages:(NSArray *)messages asyncCompletionHandler:(dispatch_block_t)completionHandler { +-(void)proccessUpdate:(TLUpdate *)update { - NSMutableArray *supportMessages = [[NSMutableArray alloc] init]; - - [messages enumerateObjectsUsingBlock:^(TL_localMessage * obj, NSUInteger idx, BOOL *stop) { + @try { + if([update isKindOfClass:[TL_updateWebPage class]]) { - if(obj.reply_to_msg_id != 0 && obj.replyMessage == nil) { - [supportMessages addObject:@(obj.reply_to_msg_id)]; - } + TLWebPage *page = [update webpage]; - }]; - - if(supportMessages.count > 0) - { - - [self loadSupportSyncMessages:supportMessages syncCompletionHandler:completionHandler]; - - } else if(completionHandler != nil) { - completionHandler(); - } - - -} - -+(void)loadSupportSyncMessages:(NSArray *)ids syncCompletionHandler:(dispatch_block_t)completionHandler { - - - dispatch_semaphore_t semaphore = NULL; - - if(completionHandler == nil) { - semaphore = dispatch_semaphore_create(0); - } - - [RPCRequest sendRequest:[TLAPI_messages_getMessages createWithN_id:[ids mutableCopy]] successHandler:^(RPCRequest *request, TL_messages_messages *response) { - - NSMutableArray *messages = [response.messages mutableCopy]; - - [[response messages] removeAllObjects]; - - [SharedManager proccessGlobalResponse:response]; - - [TL_localMessage convertReceivedMessages:messages]; - - [[Storage manager] addSupportMessages:messages]; - [[MessagesManager sharedManager] addSupportMessages:messages]; - - - if(completionHandler == nil) { - dispatch_semaphore_signal(semaphore); - } else { - completionHandler(); + TLMessageMedia *media = [TL_messageMediaWebPage createWithWebpage:page]; + + [[Storage manager] messagesWithWebpage:media callback:^(NSDictionary *peers) { + + [Notification perform:UPDATE_WEB_PAGES data:@{KEY_WEBPAGE:page}]; + + [Notification perform:UPDATE_WEB_PAGE_ITEMS data:@{KEY_DATA:peers,KEY_WEBPAGE:page}]; + }]; + + + return; } + if([update isKindOfClass:[TL_updateStickerSets class]]) { - } errorHandler:^(RPCRequest *request, RpcError *error) { - - }]; - - if(completionHandler == nil) { - dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER); - } - - -} - - --(void)proccessUpdate:(TLUpdate *)update { - - if([update isKindOfClass:[TL_updateWebPage class]]) { - - TLWebPage *page = [update webpage]; - - NSArray *updateMessages = [[MessagesManager sharedManager] findWithWebPageId:page.n_id]; - - NSMutableArray *ids = [[NSMutableArray alloc] initWithCapacity:updateMessages.count]; + [Notification perform:STICKERS_ALL_CHANGED data:@{}]; + + return; + } - [updateMessages enumerateObjectsUsingBlock:^(TL_localMessage *obj, NSUInteger idx, BOOL *stop) { + if([update isKindOfClass:[TL_updateNewStickerSet class]]) { - obj.media.webpage = page; + [Notification perform:STICKERS_NEW_PACK data:@{KEY_STICKERSET:update.stickerset}]; - [ids addObject:@(obj.n_id)]; - - }]; - - [[Storage manager] updateMessages:updateMessages]; - - [Notification perform:UPDATE_WEB_PAGES data:@{KEY_WEBPAGE:page}]; - - [Notification perform:UPDATE_WEB_PAGE_ITEMS data:@{KEY_MESSAGE_ID_LIST:ids}]; - - } - - if([update isKindOfClass:[TL_updateMessageID class]]) { - - TL_localMessage *msg = [[MessagesManager sharedManager] findWithRandomId:[update random_id]]; - - msg.n_id = [update n_id]; - - if(msg) { - [[MessagesManager sharedManager] add:@[msg]]; + return; } - - - [[Storage manager] updateMessageId:update.random_id msg_id:[update n_id]]; - - return; - - } - - if([update isKindOfClass:[TL_updateNewMessage class]]) { - - TL_localMessage *message = [TL_localMessage convertReceivedMessage:(TL_localMessage *)[update message]]; - - if(message.reply_to_msg_id != 0 && message.replyMessage == nil) { - [self failSequence]; + if([update isKindOfClass:[TL_updateStickerSetsOrder class]]) { + + [Notification perform:STICKERS_REORDER data:@{KEY_ORDER:update.order}]; + return; } - return [MessagesManager addAndUpdateMessage:message]; - } - - - if([update isKindOfClass:[TL_updateReadHistoryInbox class]]) { - [[DialogsManager sharedManager] markAllMessagesAsRead:update.peer max_id:update.max_id]; - return; - } - - if([update isKindOfClass:[TL_updateReadHistoryOutbox class]]) { - [[DialogsManager sharedManager] markAllMessagesAsRead:update.peer max_id:update.max_id]; - return; - } - - if([update isKindOfClass:[TL_updateReadMessagesContents class]]) { - [[MessagesManager sharedManager] readMessagesContent:[[update messages] copy]]; - } - - if([update isKindOfClass:[TL_updateDeleteMessages class]]) { - [Notification perform:MESSAGE_DELETE_EVENT data:@{KEY_MESSAGE_ID_LIST:[update messages]}]; - return; - } - - if([update isKindOfClass:[TL_updateUserName class]]) { - - TLUser *user = [[UsersManager sharedManager] find:update.user_id]; - if(user) { + if([update isKindOfClass:[TL_updateMessageID class]]) { + + [[Storage manager] updateMessageId:update.random_id msg_id:[update n_id]]; - TLUser *copy = [user copy]; + [Notification performOnStageQueue:MESSAGE_UPDATE_MESSAGE_ID data:@{KEY_MESSAGE_ID:@(update.n_id),KEY_RANDOM_ID:@(update.random_id)}]; - copy.first_name = update.first_name; - copy.last_name = update.last_name; - copy.username = update.username; - [[UsersManager sharedManager] add:@[copy]]; + return; } - - - return; - } - - if([update isKindOfClass:[TL_updateServiceNotification class]]) { + if([update isKindOfClass:[TL_updateNewMessage class]]) { + + if([[update message] isKindOfClass:[TL_messageEmpty class]]) + return; + + TL_localMessage *message = [TL_localMessage convertReceivedMessage:(TL_localMessage *)[update message]]; + + if(message.reply_to_msg_id != 0 && message.replyMessage == nil) { + [self failSequence]; + return; + } + + + + return [MessagesManager addAndUpdateMessage:message]; + } - TL_updateServiceNotification *updateNotification = (TL_updateServiceNotification *)update; - TL_conversation *conversation = [[Storage manager] selectConversation:[TL_peerUser createWithUser_id:777000]]; - TLUser *user = [[UsersManager sharedManager] find:777000]; - if(!conversation) { - conversation = [[DialogsManager sharedManager] createDialogForUser:user]; - [conversation save]; + if([update isKindOfClass:[TL_updateReadHistoryInbox class]]) { + [[DialogsManager sharedManager] markAllMessagesAsRead:update.peer max_id:update.max_id out:NO]; + return; } - TL_localMessage *msg = [TL_localMessage createWithN_id:0 flags:TGUNREADMESSAGE from_id:777000 to_id:[TL_peerUser createWithUser_id:[UsersManager currentUserId]] fwd_from_id:0 fwd_date:0 reply_to_msg_id:0 date:[[MTNetwork instance] getTime] message:updateNotification.message media:updateNotification.media fakeId:[MessageSender getFakeMessageId] randomId:rand_long() reply_markup:nil state:DeliveryStateNormal]; - - [MessagesManager addAndUpdateMessage:msg]; + if([update isKindOfClass:[TL_updateReadHistoryOutbox class]]) { + [[DialogsManager sharedManager] markAllMessagesAsRead:update.peer max_id:update.max_id out:YES]; + return; + } + if([update isKindOfClass:[TL_updateReadMessagesContents class]]) { + [[MessagesManager sharedManager] readMessagesContent:[[update messages] copy]]; + } - if(updateNotification.popup) { - [[ASQueue mainQueue] dispatchOnQueue:^{ - alert(NSLocalizedString(@"UpdateNotification.Alert", nil), updateNotification.message); - }]; + if([update isKindOfClass:[TL_updateDeleteMessages class]]) { + [[DialogsManager sharedManager] deleteMessagesWithMessageIds:[update messages]]; + return; } - - return; - } - - if([update isKindOfClass:[TL_updateNotifySettings class]]) { - - TL_updateNotifySettings *notifyUpdate = (TL_updateNotifySettings *)update; - - TL_notifyPeer *peer = (TL_notifyPeer *) notifyUpdate.peer; - - TL_conversation *dialog = [[DialogsManager sharedManager] find:peer.peer.peer_id]; - - if(!dialog) { - dialog = [[Storage manager] selectConversation:peer.peer]; + if([update isKindOfClass:[TL_updateUserName class]]) { + + + TLUser *user = [[UsersManager sharedManager] find:update.user_id]; + + if(user) { + + TLUser *copy = [user copy]; + + copy.first_name = update.first_name; + copy.last_name = update.last_name; + copy.username = update.username; + [[UsersManager sharedManager] add:@[copy]]; + + } + + + return; } - if(dialog) { - [dialog updateNotifySettings:notifyUpdate.notify_settings]; + if([update isKindOfClass:[TL_updateServiceNotification class]]) { + + TL_updateServiceNotification *updateNotification = (TL_updateServiceNotification *)update; + + TL_conversation *conversation = [[Storage manager] selectConversation:[TL_peerUser createWithUser_id:777000]]; + TLUser *user = [[UsersManager sharedManager] find:777000]; + if(!conversation) { + conversation = [[DialogsManager sharedManager] createDialogForUser:user]; + [conversation save]; + } + + TL_localMessage *msg = [TL_localMessage createWithN_id:0 flags:TGUNREADMESSAGE from_id:777000 to_id:[TL_peerUser createWithUser_id:[UsersManager currentUserId]] fwd_from_id:0 fwd_date:0 reply_to_msg_id:0 date:[[MTNetwork instance] getTime] message:(NSString *)updateNotification.message media:updateNotification.media fakeId:[MessageSender getFakeMessageId] randomId:rand_long() reply_markup:nil entities:nil views:0 isViewed:YES state:DeliveryStateNormal]; + + [MessagesManager addAndUpdateMessage:msg]; + + + if(updateNotification.popup) { + [[ASQueue mainQueue] dispatchOnQueue:^{ + alert(NSLocalizedString(@"UpdateNotification.Alert", nil), (NSString *)updateNotification.message); + }]; + + } + + + return; } - return; - } - - if([update isKindOfClass:[TL_updateChatParticipants class]]) { - TLChatParticipants *chatParticipants = ((TL_updateChatParticipants *)update).participants; - - TLChatFull *fullChat = [[FullChatManager sharedManager] find:chatParticipants.chat_id]; - - [[FullChatManager sharedManager] loadIfNeed:chatParticipants.chat_id force:YES]; - if(fullChat) { - fullChat.participants = chatParticipants; - [[Storage manager] insertFullChat:fullChat completeHandler:nil]; + if([update isKindOfClass:[TL_updateNotifySettings class]]) { - [Notification perform:CHAT_UPDATE_PARTICIPANTS data:@{KEY_CHAT_ID: @(fullChat.n_id), @"participants": fullChat.participants}]; + TL_updateNotifySettings *notifyUpdate = (TL_updateNotifySettings *)update; + + TL_notifyPeer *peer = (TL_notifyPeer *) notifyUpdate.peer; + + TL_conversation *dialog = [[DialogsManager sharedManager] find:peer.peer.peer_id]; + + if(!dialog) { + dialog = [[Storage manager] selectConversation:peer.peer]; + } + + if(dialog) { + [dialog updateNotifySettings:notifyUpdate.notify_settings]; + } + return; } - return; - } - - if([update isKindOfClass:[TL_updateContactLink class]]) { - TL_updateContactLink *contactLink = (TL_updateContactLink *)update; - - BOOL isContact = [contactLink.my_link isKindOfClass:[TL_contactLinkContact class]]; - - - MTLog(@"%@ contact %d", isContact ? @"add" : @"delete", contactLink.user_id); - - - TLUser *user = [[[UsersManager sharedManager] find:contactLink.user_id] copy]; - - if([contactLink.my_link isKindOfClass:[TL_contactLinkContact class]]) { - user.type = TLUserTypeContact; - } else if([contactLink.my_link isKindOfClass:[TL_contactLinkHasPhone class]]) { - user.type = TLUserTypeRequest; - } else { - user.type = TLUserTypeForeign; + if([update isKindOfClass:[TL_updateChatParticipants class]]) { + TLChatParticipants *chatParticipants = ((TL_updateChatParticipants *)update).participants; + + TLChatFull *fullChat = [[FullChatManager sharedManager] find:chatParticipants.chat_id]; + + [[FullChatManager sharedManager] performLoad:chatParticipants.chat_id force:YES callback:nil]; + + if(fullChat) { + fullChat.participants = chatParticipants; + [[Storage manager] insertFullChat:fullChat completeHandler:nil]; + + [Notification perform:CHAT_UPDATE_PARTICIPANTS data:@{KEY_CHAT_ID: @(fullChat.n_id), @"participants": fullChat.participants}]; + } + + return; } - - [[UsersManager sharedManager] add:@[user]]; - - if(isContact) { - [[NewContactsManager sharedManager] insertContact:[TL_contact createWithUser_id:contactLink.user_id mutual:NO]]; - } else { - [[NewContactsManager sharedManager] removeContact:[TL_contact createWithUser_id:contactLink.user_id mutual:NO]]; - } - return; - } - - if([update isKindOfClass:[TL_updateEncryption class]]) { - TL_encryptedChat *chat = (TL_encryptedChat *) [update chat]; - if(chat) { + if([update isKindOfClass:[TL_updateContactLink class]]) { + TL_updateContactLink *contactLink = (TL_updateContactLink *)update; - if([chat isKindOfClass:[TL_encryptedChatRequested class]]) { - [[ChatsManager sharedManager] acceptEncryption:(TL_encryptedChatRequested *)chat]; + BOOL isContact = [contactLink.my_link isKindOfClass:[TL_contactLinkContact class]]; + + + MTLog(@"%@ contact %d", isContact ? @"add" : @"delete", contactLink.user_id); + + + TLUser *user = [[[UsersManager sharedManager] find:contactLink.user_id] copy]; + + if([contactLink.my_link isKindOfClass:[TL_contactLinkContact class]]) { + user.type = TLUserTypeContact; + } else if([contactLink.my_link isKindOfClass:[TL_contactLinkHasPhone class]]) { + user.type = TLUserTypeRequest; + } else { + user.type = TLUserTypeForeign; } - if([chat isKindOfClass:[TL_encryptedChat class]]) { - - EncryptedParams *params = [EncryptedParams findAndCreate:chat.n_id]; - - NSData *key_hash = [Crypto exp:[chat g_a_or_b] b:[params a] dhPrime:params.p]; - NSData *key_fingerprints = [[Crypto sha1:key_hash] subdataWithRange:NSMakeRange(12, 8)]; - long keyId; - [key_fingerprints getBytes:&keyId]; - - params.key_fingerprint = keyId; - - [params setKey:key_hash forFingerprint:keyId]; + + [[UsersManager sharedManager] add:@[user]]; + + if(isContact) { + [[NewContactsManager sharedManager] insertContact:[TL_contact createWithUser_id:contactLink.user_id mutual:NO]]; + } else { + [[NewContactsManager sharedManager] removeContact:[TL_contact createWithUser_id:contactLink.user_id mutual:NO]]; + } + return; + } + + if([update isKindOfClass:[TL_updateEncryption class]]) { + TL_encryptedChat *chat = (TL_encryptedChat *) [update chat]; + if(chat) { - params.access_hash = chat.access_hash; - [params setState:EncryptedAllowed]; - [params save]; - [[Storage manager] insertEncryptedChat:chat]; - [[ChatsManager sharedManager] add:@[chat]]; + if([chat isKindOfClass:[TL_encryptedChatRequested class]]) { + [[ChatsManager sharedManager] acceptEncryption:(TL_encryptedChatRequested *)chat]; + } - if(!chat.dialog) { - TL_conversation *conversation = [[Storage manager] selectConversation:[TL_peerSecret createWithChat_id:chat.n_id]]; - if(conversation) { - [[DialogsManager sharedManager] add:@[conversation]]; + if([chat isKindOfClass:[TL_encryptedChat class]]) { + + EncryptedParams *params = [EncryptedParams findAndCreate:chat.n_id]; + + NSData *key_hash = [Crypto exp:[chat g_a_or_b] b:[params a] dhPrime:params.p]; + NSData *key_fingerprints = [[Crypto sha1:key_hash] subdataWithRange:NSMakeRange(12, 8)]; + long keyId; + [key_fingerprints getBytes:&keyId]; + + params.key_fingerprint = keyId; + + [params setKey:key_hash forFingerprint:keyId]; + + params.access_hash = chat.access_hash; + [params setState:EncryptedAllowed]; + [params save]; + [[Storage manager] insertEncryptedChat:chat]; + [[ChatsManager sharedManager] add:@[chat]]; + + if(!chat.dialog) { + TL_conversation *conversation = [[Storage manager] selectConversation:[TL_peerSecret createWithChat_id:chat.n_id]]; + if(conversation) { + [[DialogsManager sharedManager] add:@[conversation]]; + } + } - + + if(chat.dialog) { + [Notification perform:[Notification notificationNameByDialog:chat.dialog action:@"message"] data:@{KEY_DIALOG:chat.dialog,KEY_LAST_CONVRESATION_DATA:[MessagesUtils conversationLastData:chat.dialog]}]; + + [MessagesManager notifyConversation:chat.dialog.peer.peer_id title:chat.peerUser.fullName text:NSLocalizedString(@"MessageService.Action.JoinedSecretChat", nil)]; + } + + + } - if(chat.dialog) { - [Notification perform:[Notification notificationNameByDialog:chat.dialog action:@"message"] data:@{KEY_DIALOG:chat.dialog,KEY_LAST_CONVRESATION_DATA:[MessagesUtils conversationLastData:chat.dialog]}]; + if([chat isKindOfClass:[TL_encryptedChatDiscarded class]]) { + + TL_encryptedChat *local = [[ChatsManager sharedManager] find:[chat n_id]]; + if(!local) + return; + + + + EncryptedParams *params = [EncryptedParams findAndCreate:[chat n_id]]; + [params setState:EncryptedDiscarted]; + [params save]; + + [Notification perform:[Notification notificationNameByDialog:local.dialog action:@"message"] data:@{KEY_DIALOG:chat.dialog,KEY_LAST_CONVRESATION_DATA:[MessagesUtils conversationLastData:chat.dialog]}]; + + + [SecretChatAccepter removeChatId:chat.n_id]; + + } + if([chat isKindOfClass:[TL_encryptedChatEmpty class]]) { - [MessagesManager notifyConversation:chat.dialog.peer.peer_id title:chat.peerUser.fullName text:NSLocalizedString(@"MessageService.Action.JoinedSecretChat", nil)]; } - - - - } - - if([chat isKindOfClass:[TL_encryptedChatDiscarded class]]) { - - TL_encryptedChat *local = [[ChatsManager sharedManager] find:[chat n_id]]; - if(!local) - return; - - - - EncryptedParams *params = [EncryptedParams findAndCreate:[chat n_id]]; - [params setState:EncryptedDiscarted]; - [params save]; - - [Notification perform:[Notification notificationNameByDialog:local.dialog action:@"message"] data:@{KEY_DIALOG:chat.dialog,KEY_LAST_CONVRESATION_DATA:[MessagesUtils conversationLastData:chat.dialog]}]; - - - [SecretChatAccepter removeChatId:chat.n_id]; - - } - if([chat isKindOfClass:[TL_encryptedChatEmpty class]]) { - } + return; } - return; - } - - if([update isKindOfClass:[TL_updateNewEncryptedMessage class]]) { - [_encryptedUpdates proccessUpdate:(TLEncryptedMessage *)[update message]]; + if([update isKindOfClass:[TL_updateNewEncryptedMessage class]]) { + + [_encryptedUpdates proccessUpdate:(TLEncryptedMessage *)[update message]]; + + return; + } - return; - } - - if([update isKindOfClass:[TL_updateEncryptedMessagesRead class]]) { - TL_conversation *dialog = [[DialogsManager sharedManager] findBySecretId:update.chat_id]; - if(dialog) { - [[DialogsManager sharedManager] markAllMessagesAsRead:dialog]; + if([update isKindOfClass:[TL_updateEncryptedMessagesRead class]]) { + TL_conversation *dialog = [[DialogsManager sharedManager] findBySecretId:update.chat_id]; + if(dialog) { + [[DialogsManager sharedManager] markAllMessagesAsRead:dialog.peer max_id:INT32_MAX out:YES]; + } + return; } - return; - } - - if([update isKindOfClass:[TL_updateUserPhoto class]]) { - TLUser *user = [[UsersManager sharedManager] find:update.user_id]; - if(user.photo.photo_id != [update photo].photo_id) { - user.photo = [update photo]; + if([update isKindOfClass:[TL_updateUserPhoto class]]) { + TLUser *user = [[UsersManager sharedManager] find:update.user_id]; - if(user) { - [[Storage manager] insertUser:user completeHandler:nil]; - PreviewObject *previewObject = [[PreviewObject alloc] initWithMsdId:user.photo.photo_id media:[TL_photoSize createWithType:@"x" location:user.photo.photo_big w:640 h:640 size:0] peer_id:user.n_id]; - [Notification perform:USER_UPDATE_PHOTO data:@{KEY_USER:user,KEY_PREVIOUS:@([update previous]), KEY_PREVIEW_OBJECT:previewObject}]; + if(user.photo.photo_id != [update photo].photo_id) { + user.photo = [update photo]; + + if(user) { + [[Storage manager] insertUser:user completeHandler:nil]; + PreviewObject *previewObject = [[PreviewObject alloc] initWithMsdId:user.photo.photo_id media:[TL_photoSize createWithType:@"x" location:user.photo.photo_big w:640 h:640 size:0] peer_id:user.n_id]; + [Notification perform:USER_UPDATE_PHOTO data:@{KEY_USER:user,KEY_PREVIOUS:@([update previous]), KEY_PREVIEW_OBJECT:previewObject}]; + } } + + + return; } - - return; - } - - if([update isKindOfClass:[TL_updateUserStatus class]]) { - -// if(update.user_id == [UsersManager currentUserId]) { -// [[Telegram sharedInstance] setIsOnline:NO]; -// [[Telegram sharedInstance] setAccountOnline]; -// -// return; -// } - [[UsersManager sharedManager] setUserStatus:[update status] forUid:update.user_id]; - - return; - } - - - if([update isKindOfClass:[TL_updateChatUserTyping class]] || [update isKindOfClass:[TL_updateUserTyping class]] || [update isKindOfClass:[TL_updateEncryptedChatTyping class]]) { - [Notification perform:USER_TYPING data:@{KEY_SHORT_UPDATE:update}]; - return; - } - - if([update isKindOfClass:[TL_updateUserBlocked class]]) { - BOOL blocked = ((TL_updateUserBlocked *)update).blocked; - int user_id = ((TL_updateUserBlocked *)update).user_id; - - [[BlockedUsersManager sharedManager] updateBlocked:user_id isBlocked:blocked]; - } - - if([update isKindOfClass:[TL_updateNewAuthorization class]]) { - - - TL_conversation *conversation = [[Storage manager] selectConversation:[TL_peerUser createWithUser_id:777000]]; - TLUser *user = [[UsersManager sharedManager] find:777000]; - if(!conversation) { - conversation = [[DialogsManager sharedManager] createDialogForUser:user]; - [conversation save]; + if([update isKindOfClass:[TL_updateUserStatus class]]) { + + // if(update.user_id == [UsersManager currentUserId]) { + // [[Telegram sharedInstance] setIsOnline:NO]; + // [[Telegram sharedInstance] setAccountOnline]; + // + // return; + // } + [[UsersManager sharedManager] setUserStatus:[update status] forUid:update.user_id]; + + return; } - NSString *displayDate = [[NSString alloc] initWithFormat:@"%@, %@ at %@", [TGDateUtils stringForDayOfWeek:update.date], [TGDateUtils stringForDialogTime:update.date], [TGDateUtils stringForShortTime:update.date]]; - - NSString *messageText = [[NSString alloc] initWithFormat:NSLocalizedString(@"Notification.NewAuthDetected",nil), [UsersManager currentUser].first_name, displayDate, update.device, update.location];; - TL_localMessage *msg = [TL_localMessage createWithN_id:0 flags:TGUNREADMESSAGE from_id:777000 to_id:[TL_peerUser createWithUser_id:[UsersManager currentUserId]] fwd_from_id:0 fwd_date:0 reply_to_msg_id:0 date:[[MTNetwork instance] getTime] message:messageText media:[TL_messageMediaEmpty create] fakeId:[MessageSender getFakeMessageId] randomId:rand_long() reply_markup:nil state:DeliveryStateNormal]; + if([update isKindOfClass:[TL_updateChatParticipantAdmin class]]) { + + TLChatFull *chatFull = [[FullChatManager sharedManager] find:[update chat_id]]; + + NSArray *f = [chatFull.participants.participants filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.user_id == %d",update.user_id]]; + + if(f.count == 1) + { + TLChatParticipant *participant = [f firstObject]; + + TLChatParticipant *newParticipant = [update is_admin] ? [TL_chatParticipantAdmin createWithUser_id:participant.user_id inviter_id:participant.inviter_id date:participant.date] : [TL_chatParticipant createWithUser_id:participant.user_id inviter_id:participant.inviter_id date:participant.date]; + + [chatFull.participants.participants replaceObjectAtIndex:[chatFull.participants.participants indexOfObject:participant] withObject:newParticipant]; + + } + + [Notification perform:CHAT_UPDATE_PARTICIPANTS data:@{KEY_CHAT_ID:@([update chat_id]),@"participants":chatFull.participants}]; + + } - [MessagesManager addAndUpdateMessage:msg]; + if([update isKindOfClass:[TL_updateChatAdmins class]]) { + + TLChat *chat = [[ChatsManager sharedManager] find:[update chat_id]]; + + if(chat.version != update.version) { + [[FullChatManager sharedManager] loadIfNeed:[update chat_id] force:YES]; + } + + + } - return; - } - - if([update isKindOfClass:[TL_updateContactRegistered class]]) { + if([update isKindOfClass:[TL_updateChatUserTyping class]] || [update isKindOfClass:[TL_updateUserTyping class]] || [update isKindOfClass:[TL_updateEncryptedChatTyping class]]) { + [Notification perform:USER_TYPING data:@{KEY_SHORT_UPDATE:update}]; + return; + } - TLUser *user = [[UsersManager sharedManager] find:[update user_id]]; + if([update isKindOfClass:[TL_updateUserBlocked class]]) { + BOOL blocked = ((TL_updateUserBlocked *)update).blocked; + int user_id = ((TL_updateUserBlocked *)update).user_id; + + [[BlockedUsersManager sharedManager] updateBlocked:user_id isBlocked:blocked]; + } - if(!user) { - [self failSequence]; + if([update isKindOfClass:[TL_updateNewAuthorization class]]) { + + + TL_conversation *conversation = [[Storage manager] selectConversation:[TL_peerUser createWithUser_id:777000]]; + TLUser *user = [[UsersManager sharedManager] find:777000]; + if(!conversation) { + conversation = [[DialogsManager sharedManager] createDialogForUser:user]; + [conversation save]; + } + + NSString *displayDate = [[NSString alloc] initWithFormat:@"%@, %@ at %@", [TGDateUtils stringForDayOfWeek:update.date], [TGDateUtils stringForDialogTime:update.date], [TGDateUtils stringForShortTime:update.date]]; + + NSString *messageText = [[NSString alloc] initWithFormat:NSLocalizedString(@"Notification.NewAuthDetected",nil), [UsersManager currentUser].first_name, displayDate, update.device, update.location];; + + TL_localMessage *msg = [TL_localMessage createWithN_id:0 flags:TGUNREADMESSAGE from_id:777000 to_id:[TL_peerUser createWithUser_id:[UsersManager currentUserId]] fwd_from_id:0 fwd_date:0 reply_to_msg_id:0 date:[[MTNetwork instance] getTime] message:messageText media:[TL_messageMediaEmpty create] fakeId:[MessageSender getFakeMessageId] randomId:rand_long() reply_markup:nil entities:nil views:0 isViewed:YES state:DeliveryStateNormal]; + + [MessagesManager addAndUpdateMessage:msg]; + return; } - NSString *text = [NSString stringWithFormat:NSLocalizedString(@"Notification.UserRegistred", nil),user.fullName]; - - TL_localMessageService *message = [TL_localMessageService createWithN_id:0 flags:TGOUTMESSAGE from_id:[update user_id] to_id:[TL_peerUser createWithUser_id:[update user_id]] date:[update date] action:[TL_messageActionEncryptedChat createWithTitle:text] fakeId:[MessageSender getFakeMessageId] randomId:rand_long() dstate:DeliveryStateNormal]; + if([update isKindOfClass:[TL_updateContactRegistered class]]) { + + TLUser *user = [[UsersManager sharedManager] find:[update user_id]]; + + if(!user) { + [self failSequence]; + return; + } + + NSString *text = [NSString stringWithFormat:NSLocalizedString(@"Notification.UserRegistred", nil),user.fullName]; + + TL_localMessageService *message = [TL_localMessageService createWithFlags:0 n_id:0 from_id:[update user_id] to_id:[TL_peerUser createWithUser_id:[update user_id]] date:[update date] action:[TL_messageActionEncryptedChat createWithTitle:text] fakeId:[MessageSender getFakeMessageId] randomId:rand_long() dstate:DeliveryStateNormal]; + + [MessagesManager addAndUpdateMessage:message]; + + return; + } - [MessagesManager addAndUpdateMessage:message]; - - return; + if([update isKindOfClass:[TL_updatePrivacy class]]) { + + + + PrivacyArchiver *privacy = [PrivacyArchiver privacyFromRules:[(TL_updatePrivacy *)update rules] forKey:NSStringFromClass([(TL_updatePrivacy *)update n_key].class)]; + + [privacy _save]; + + + [[NewContactsManager sharedManager] getStatuses:^{ + [Notification perform:PRIVACY_UPDATE data:@{KEY_PRIVACY:privacy}]; + }]; + + } } - - if([update isKindOfClass:[TL_updatePrivacy class]]) { - - - - PrivacyArchiver *privacy = [PrivacyArchiver privacyFromRules:[(TL_updatePrivacy *)update rules] forKey:NSStringFromClass([(TL_updatePrivacy *)update n_key].class)]; - - [privacy _save]; - - - [[NewContactsManager sharedManager] getStatuses:^{ - [Notification perform:PRIVACY_UPDATE data:@{KEY_PRIVACY:privacy}]; - }]; + @catch (NSException *exception) { } - + } -(void)cancelSequenceTimer { @@ -913,7 +920,7 @@ -(void)updateDifference { -(void)updateDifference:(BOOL)force updateConnectionState:(BOOL)updateConnectionState { - if(_holdUpdates || ![[MTNetwork instance] isAuth] ) return; + if(![[MTNetwork instance] isAuth] ) return; _holdUpdates = YES; @@ -921,6 +928,10 @@ -(void)updateDifference:(BOOL)force updateConnectionState:(BOOL)updateConnection [RPCRequest sendRequest:[TLAPI_updates_getState create] successHandler:^(RPCRequest *request, TL_updates_state * state) { + _updateState = [[Storage manager] updateState]; + + MTLog(@"update dif broken pts:%d, date:%d, qts:%d,seq:%d",_updateState.pts,_updateState.date,_updateState.qts,_updateState.seq); + _updateState = [[TGUpdateState alloc] initWithPts:_updateState.pts == 0 ? state.pts : _updateState.pts qts:_updateState.qts == 0 ? state.qts : _updateState.qts date:_updateState.date == 0 ? state.date : _updateState.date seq:_updateState.seq == 0 ? state.seq : _updateState.seq pts_count:_updateState.pts_count]; [self saveUpdateState]; @@ -930,12 +941,14 @@ -(void)updateDifference:(BOOL)force updateConnectionState:(BOOL)updateConnection _holdUpdates = NO; - [self uptodate:_updateState.pts qts:_updateState.qts date:_updateState.date updateConnectionState:updateConnectionState]; + [self uptodateWithConnectionState:updateConnectionState]; - } errorHandler:nil]; + } errorHandler:^(id request, RpcError *error) { + _holdUpdates = NO; + } timeout:0 queue:queue.nativeQueue]; } else { _holdUpdates = NO; - [self uptodate:_updateState.pts qts:_updateState.qts date:_updateState.date updateConnectionState:updateConnectionState]; + [self uptodateWithConnectionState:updateConnectionState]; } } @@ -943,16 +956,20 @@ -(void)updateDifference:(BOOL)force updateConnectionState:(BOOL)updateConnection --(void)uptodate:(int)pts qts:(int)qts date:(int)date updateConnectionState:(BOOL)updateConnectionState { +-(void)uptodateWithConnectionState:(BOOL)updateConnectionState { - if(_holdUpdates || ![[MTNetwork instance] isAuth] ) return; + if( ![[MTNetwork instance] isAuth] ) + return; _holdUpdates = YES; if(updateConnectionState) [Telegram setConnectionState:ConnectingStatusTypeUpdating]; - TLAPI_updates_getDifference *dif = [TLAPI_updates_getDifference createWithPts:pts date:date qts:qts]; + + MTLog(@"updateDifference:%@, pts:%d,date:%d,qts:%d",_updateState,_updateState.pts,_updateState.date,_updateState.qts); + + TLAPI_updates_getDifference *dif = [TLAPI_updates_getDifference createWithPts:_updateState.pts date:_updateState.date qts:_updateState.qts]; [RPCRequest sendRequest:dif successHandler:^(RPCRequest *request, id response) { TL_updates_difference *updates = response; @@ -986,83 +1003,67 @@ -(void)uptodate:(int)pts qts:(int)qts date:(int)date updateConnectionState:(BOOL } NSMutableArray *copy = [[response n_messages] mutableCopy]; - + [TL_localMessage convertReceivedMessages:copy]; - NSMutableArray *ids = [[NSMutableArray alloc] init]; - [copy enumerateObjectsUsingBlock:^(TLMessage *obj, NSUInteger idx, BOOL *stop) { - [ids addObject:@(obj.n_id)]; - }]; + [[response n_messages] removeAllObjects]; + + [SharedManager proccessGlobalResponse:response]; + - if(ids.count > 0) { + [[Storage manager] insertMessages:copy completeHandler:^{ + [response setN_messages:copy]; - NSArray *res = [[Storage manager] issetMessages:ids]; + for (TLUpdate *update in [updates other_updates]) { + + if([channelUpdates indexOfObject:update.className] != NSNotFound) + [self.channelsUpdater addUpdate:update]; + else + [self proccessUpdate:update]; + } - [ids removeAllObjects]; - - NSArray *f = [copy filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.n_id IN %@",res]]; + if([response n_messages].count > 0) { + [Notification performOnStageQueue:MESSAGE_LIST_UPDATE_TOP data:@{KEY_MESSAGE_LIST:[response n_messages]}]; + } - [copy removeObjectsInArray:f]; - } - - - - - [response setN_messages:copy]; - - [SharedManager proccessGlobalResponse:updates]; - - - for (TLUpdate *update in [updates other_updates]) { - [self proccessUpdate:update]; - } - - [TGProccessUpdates checkAndLoadIfNeededSupportMessages:[response n_messages] asyncCompletionHandler:^{ - - [queue dispatchOnQueue:^{ - - if([response n_messages].count > 0) { - [Notification perform:MESSAGE_LIST_UPDATE_TOP data:@{KEY_MESSAGE_LIST:[response n_messages]}]; - } - - - _updateState.checkMinimum = NO; - _updateState.qts = stateQts; - _updateState.pts = statePts; - _updateState.date = stateDate; - _updateState.seq = stateSeq; - _updateState.checkMinimum = YES; - - [self saveUpdateState]; - - _holdUpdates = NO; + _updateState.checkMinimum = NO; + _updateState.qts = stateQts; + _updateState.pts = statePts; + _updateState.date = stateDate; + _updateState.seq = stateSeq; + _updateState.checkMinimum = YES; + + [self saveUpdateState]; + + _holdUpdates = NO; + + if(intstate != nil) { + dispatch_after_seconds_queue(0.5, ^{ + [self uptodateWithConnectionState:updateConnectionState]; + }, queue.nativeQueue); - if(intstate != nil) { - [self uptodate:statePts qts:stateQts date:stateDate updateConnectionState:updateConnectionState]; - } else { - [Notification perform:PROTOCOL_UPDATED data:nil]; - [Telegram setConnectionState:ConnectingStatusTypeNormal]; - } + } else { + [Notification perform:PROTOCOL_UPDATED data:nil]; + [Telegram setConnectionState:ConnectingStatusTypeNormal]; + } - }]; - }]; - - } errorHandler:^(RPCRequest *request, RpcError *error) { + _holdUpdates = NO; + if(error.error_code == 502) { - [self uptodate:pts qts:qts date:date updateConnectionState:updateConnectionState]; - } else { + [self uptodateWithConnectionState:updateConnectionState]; + } else if(error.error_code == 400) { [self updateDifference:YES updateConnectionState:updateConnectionState]; } - } timeout:10 queue:queue.nativeQueue]; + } timeout:0 queue:queue.nativeQueue]; } diff --git a/TelegramTest/TGProfileHeaderRowItem.h b/TelegramTest/TGProfileHeaderRowItem.h new file mode 100644 index 00000000..d0a05ec9 --- /dev/null +++ b/TelegramTest/TGProfileHeaderRowItem.h @@ -0,0 +1,18 @@ +// +// TGProfileHeaderRowItem.h +// Telegram +// +// Created by keepcoder on 03/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "TGGeneralRowItem.h" + +@interface TGProfileHeaderRowItem : TGGeneralRowItem + +@property (nonatomic,strong) TL_conversation *conversation; + +@property (nonatomic,strong) NSString *firstChangedValue; +@property (nonatomic,strong) NSString *secondChangedValue; + +@end diff --git a/TelegramTest/TGProfileHeaderRowItem.m b/TelegramTest/TGProfileHeaderRowItem.m new file mode 100644 index 00000000..5cd5979d --- /dev/null +++ b/TelegramTest/TGProfileHeaderRowItem.m @@ -0,0 +1,27 @@ +// +// TGProfileHeaderRowItem.m +// Telegram +// +// Created by keepcoder on 03/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "TGProfileHeaderRowItem.h" + +@implementation TGProfileHeaderRowItem + +-(id)initWithObject:(id)object { + if(self = [super initWithObject:object]) { + _conversation = object; + } + + return self; +} + + +-(Class)viewClass { + return NSClassFromString(@"TGProfileHeaderRowView"); +} + + +@end diff --git a/TelegramTest/TGProfileHeaderRowView.h b/TelegramTest/TGProfileHeaderRowView.h new file mode 100644 index 00000000..3872960e --- /dev/null +++ b/TelegramTest/TGProfileHeaderRowView.h @@ -0,0 +1,13 @@ +// +// TGProfileHeaderRowView.h +// Telegram +// +// Created by keepcoder on 03/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "TMRowView.h" + +@interface TGProfileHeaderRowView : TMRowView + +@end diff --git a/TelegramTest/TGProfileHeaderRowView.m b/TelegramTest/TGProfileHeaderRowView.m new file mode 100644 index 00000000..1c3e1e4f --- /dev/null +++ b/TelegramTest/TGProfileHeaderRowView.m @@ -0,0 +1,207 @@ +// +// TGProfileHeaderRowView.m +// Telegram +// +// Created by keepcoder on 03/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "TGProfileHeaderRowView.h" +#import "TGProfileHeaderRowItem.h" +#import "UserInfoShortTextEditView.h" +#import "ChatAvatarImageView.h" +@interface TGProfileHeaderRowView () +@property (nonatomic,strong) ChatAvatarImageView *imageView; +@property (nonatomic,strong) TMNameTextField *nameTextField; +@property (nonatomic,strong) TMStatusTextField *statusTextField; + +@property (nonatomic,strong) TMView *editableContainerView; + + +@property (nonatomic,strong) UserInfoShortTextEditView *firstNameView; +@property (nonatomic,strong) UserInfoShortTextEditView *lastNameView; + +@end + +@implementation TGProfileHeaderRowView + +- (void)drawRect:(NSRect)dirtyRect { + [super drawRect:dirtyRect]; + + if(self.item.conversation.isVerified) { + [image_Verify() drawInRect:NSMakeRect(NSMaxX(_nameTextField.frame),NSMinY(_nameTextField.frame) , image_Verify().size.width, image_Verify().size.height) fromRect:NSZeroRect operation:NSCompositeHighlight fraction:1]; + } +} + +-(instancetype)initWithFrame:(NSRect)frameRect { + if(self = [super initWithFrame:frameRect]) { + _imageView = [[ChatAvatarImageView alloc] initWithFrame:NSMakeRect(0, 0, 70, 70)]; + + _nameTextField = [[TMNameTextField alloc] initWithFrame:NSZeroRect]; + [[_nameTextField cell] setTruncatesLastVisibleLine:YES]; + [[_nameTextField cell] setLineBreakMode:NSLineBreakByTruncatingTail]; + + _statusTextField = [[TMStatusTextField alloc] init]; + [[_nameTextField cell] setTruncatesLastVisibleLine:YES]; + [[_nameTextField cell] setLineBreakMode:NSLineBreakByTruncatingTail]; + [_statusTextField setSelector:@selector(statusForMessagesHeaderView)]; + + [self addSubview:_statusTextField]; + [self addSubview:_nameTextField]; + [self addSubview:_imageView]; + + + _editableContainerView = [self createEditContainerView]; + + [self addSubview:_editableContainerView]; + } + + return self; +} + +-(TGProfileHeaderRowItem *)item { + return (TGProfileHeaderRowItem *)[self rowItem]; +} + + +- (void)TMStatusTextFieldDidChanged:(TMStatusTextField *)textField { + [_statusTextField sizeToFit]; + [self setFrameSize:self.frame.size]; +} + + +- (void)TMNameTextFieldDidChanged:(TMNameTextField *)textField { + [_nameTextField sizeToFit]; + [self setFrameSize:self.frame.size]; +} + +- (void)controlTextDidChange:(NSNotification *)obj { + self.item.firstChangedValue = _firstNameView.textView.stringValue; + self.item.secondChangedValue = _lastNameView.textView.stringValue; +} + +-(void)redrawRow { + [super redrawRow]; + + [_imageView setEditable:self.item.isEditable && self.item.conversation.type != DialogTypeUser && self.item.conversation.type != DialogTypeSecretChat]; + + [_imageView updateWithConversation:self.item.conversation]; + [_nameTextField updateWithConversation:self.item.conversation]; + [_statusTextField updateWithConversation:self.item.conversation]; + + + _firstNameView.textView.delegate = self; + _lastNameView.textView.delegate = self; + + [_firstNameView.textView setStringValue:self.item.conversation.user.first_name]; + [_lastNameView.textView setStringValue:self.item.conversation.user.last_name]; + + if(self.item.conversation.chat) { + [_firstNameView.textView setStringValue:self.item.conversation.chat.title]; + } + + [_nameTextField sizeToFit]; + [_statusTextField sizeToFit]; + + _nameTextField.nameDelegate = self; + _statusTextField.statusDelegate = self; + + [self setFrameSize:self.frame.size]; + + [_editableContainerView setHidden:!self.item.isEditable]; + [_nameTextField setHidden:self.item.isEditable]; + [_statusTextField setHidden:self.item.isEditable]; + + +} + + + +-(TMView *)createEditContainerView { + + TMView *container = [[TMView alloc] initWithFrame:NSMakeRect(100, 0, 100, 70)]; + + container.isFlipped = YES; + + container.wantsLayer = YES; + + + self.firstNameView = [[UserInfoShortTextEditView alloc] initWithFrame:NSZeroRect]; + [self.firstNameView setFrameOrigin:NSMakePoint(10, 5)]; + [self.firstNameView setFrameSize:NSMakeSize(100, 30)]; + + [container addSubview:self.firstNameView]; + + + + self.lastNameView = [[UserInfoShortTextEditView alloc] initWithFrame:NSZeroRect]; + [self.lastNameView setFrameOrigin:NSMakePoint(10, self.firstNameView.bounds.size.height + 5)]; + [self.lastNameView setFrameSize:NSMakeSize(100, 30)]; + [container addSubview:self.lastNameView]; + + [self.firstNameView.textView setNextKeyView:self.lastNameView.textView]; + [self.firstNameView.textView setTarget:self]; + [self.firstNameView.textView setAction:@selector(enterClick)]; + + + + [self.lastNameView.textView setNextKeyView:self.firstNameView.textView]; + [self.lastNameView.textView setTarget:self]; + [self.lastNameView.textView setAction:@selector(enterClick)]; + + [self.firstNameView.textView setFont:TGSystemFont(14)]; + [self.lastNameView.textView setFont:TGSystemFont(14)]; + + [self.firstNameView.textView setAlignment:NSLeftTextAlignment]; + [self.lastNameView.textView setAlignment:NSLeftTextAlignment]; + + [self.firstNameView.textView setFrameOrigin:NSMakePoint(0, 2)]; + [self.lastNameView.textView setFrameOrigin:NSMakePoint(0, 2)]; + + + [self.firstNameView.textView setStringValue:@"Mikhail"]; + [self.lastNameView.textView setStringValue:@"Filimonov"]; + + [container setAutoresizingMask:NSViewWidthSizable]; + + return container; +} + +-(void)enterClick { + +} + +-(void)setFrameSize:(NSSize)newSize { + [super setFrameSize:newSize]; + + [_imageView setCenteredYByView:self]; + [_imageView setFrameOrigin:NSMakePoint(self.item.xOffset, NSMinY(_imageView.frame))]; + + + [_nameTextField setFrameSize:NSMakeSize(MIN(NSWidth(_nameTextField.frame), newSize.width - NSMaxX(_imageView.frame) - self.item.xOffset - 10), NSHeight(_nameTextField.frame))]; + [_statusTextField setFrameSize:NSMakeSize(MIN(NSWidth(_statusTextField.frame), newSize.width - NSMaxX(_imageView.frame) - self.item.xOffset - 8), NSHeight(_statusTextField.frame))]; + + + int totalHeight = NSHeight(_nameTextField.frame) + NSHeight(_statusTextField.frame); + + [_statusTextField setFrameOrigin:NSMakePoint(NSMaxX(_imageView.frame) + 8, roundf((newSize.height - totalHeight)/2))]; + [_nameTextField setFrameOrigin:NSMakePoint(NSMaxX(_imageView.frame) + 10, roundf((newSize.height - totalHeight)/2 + NSHeight(_statusTextField.frame)))]; + + + [_editableContainerView setFrame:NSMakeRect(NSMaxX(_imageView.frame) + 10, 0, newSize.width - NSMaxX(_imageView.frame) - self.item.xOffset - 10, 72)]; + + [_editableContainerView setCenteredYByView:self]; + + + if(self.item.conversation.type != DialogTypeUser && self.item.conversation.type != DialogTypeSecretChat) { + [_lastNameView setHidden:YES]; + [_firstNameView setCenteredYByView:_firstNameView.superview]; + } else { + [_lastNameView setHidden:NO]; + [self.firstNameView setFrameOrigin:NSMakePoint(10, 5)]; + } + +} + + +@end diff --git a/TelegramTest/TGProfileParamItem.h b/TelegramTest/TGProfileParamItem.h new file mode 100644 index 00000000..42db9650 --- /dev/null +++ b/TelegramTest/TGProfileParamItem.h @@ -0,0 +1,20 @@ +// +// TGProfileParamItem.h +// Telegram +// +// Created by keepcoder on 03/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "TGGeneralRowItem.h" + +@interface TGProfileParamItem : TGGeneralRowItem + + +@property (nonatomic,strong) NSString *header; +@property (nonatomic,strong) NSAttributedString *value; + +@property (nonatomic,assign) NSSize size; + +-(void)setHeader:(NSString *)header withValue:(NSString *)value; +@end diff --git a/TelegramTest/TGProfileParamItem.m b/TelegramTest/TGProfileParamItem.m new file mode 100644 index 00000000..12d92818 --- /dev/null +++ b/TelegramTest/TGProfileParamItem.m @@ -0,0 +1,40 @@ +// +// TGProfileParamItem.m +// Telegram +// +// Created by keepcoder on 03/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "TGProfileParamItem.h" + +@implementation TGProfileParamItem + + +-(void)setHeader:(NSString *)header withValue:(NSString *)value { + _header = header; + + NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; + [paragraphStyle setAlignment:NSLeftTextAlignment]; + + NSAttributedString *attr = [[NSAttributedString alloc] initWithString:[value trim] attributes:@{NSForegroundColorAttributeName: NSColorFromRGB(0x333333), (NSString *)kCTFontAttributeName:TGSystemLightFont(14), NSParagraphStyleAttributeName: paragraphStyle}]; + + + _value = attr; + +} + +-(Class)viewClass { + return NSClassFromString(@"TGProfileParamView"); +} + +-(BOOL)updateItemHeightWithWidth:(int)width { + + NSSize size = [_value coreTextSizeForTextFieldForWidth:roundf(width) - (self.xOffset * 2)]; + + self.height = size.height + 33; + _size = size; + return YES; +} + +@end diff --git a/TelegramTest/TGProfileParamView.h b/TelegramTest/TGProfileParamView.h new file mode 100644 index 00000000..5dcd7712 --- /dev/null +++ b/TelegramTest/TGProfileParamView.h @@ -0,0 +1,13 @@ +// +// TGProfileParamView.h +// Telegram +// +// Created by keepcoder on 03/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "TMRowView.h" + +@interface TGProfileParamView : TMRowView + +@end diff --git a/TelegramTest/TGProfileParamView.m b/TelegramTest/TGProfileParamView.m new file mode 100644 index 00000000..944fff43 --- /dev/null +++ b/TelegramTest/TGProfileParamView.m @@ -0,0 +1,91 @@ +// +// TGProfileParamView.m +// Telegram +// +// Created by keepcoder on 03/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "TGProfileParamView.h" + +#import "NS(Attributed)String+Geometrics.h" +#import "TGCTextView.h" +#import "TGProfileParamItem.h" +@interface TGProfileParamView() +@property (nonatomic, strong) TGCTextView *textView; +@property (nonatomic,strong) TMTextField *headerField; +@end + +@implementation TGProfileParamView + +- (id)initWithFrame:(NSRect)frame { + self = [super initWithFrame:frame]; + if (self) { + [self setAutoresizingMask:NSViewWidthSizable]; + self.textView = [[TGCTextView alloc] initWithFrame:NSZeroRect]; + [self.textView setEditable:YES]; + [self addSubview:self.textView]; + + _headerField = [TMTextField defaultTextField]; + + [_headerField setFont:TGSystemFont(13)]; + [_headerField setTextColor:BLUE_UI_COLOR]; + + [self addSubview:_headerField]; + + } + return self; +} + + +-(TGProfileParamItem *)item { + return (TGProfileParamItem *)[self rowItem]; +} + +-(void)redrawRow { + [super redrawRow]; + + [self setHeader:self.item.header]; + [self.textView setAttributedString:self.item.value]; + + [self.textView setFrameSize:self.item.size]; +} + + + +-(void)setFrameSize:(NSSize)newSize { + [super setFrameSize:newSize]; + + int totalHeight = NSHeight(_textView.frame) + NSHeight(_headerField.frame); + + [_textView setFrameOrigin:NSMakePoint(self.item.xOffset, roundf((newSize.height - totalHeight)/2))]; + [_headerField setFrameOrigin:NSMakePoint(self.item.xOffset - 2, roundf((newSize.height - totalHeight)/2 + NSHeight(_textView.frame)))]; + +} + +-(void)mouseDown:(NSEvent *)theEvent { + +} + +-(NSString *)string { + return [self.textView attributedString].string; +} + +- (void)setHeader:(NSString *)header { + + + [_headerField setStringValue:header]; + [_headerField sizeToFit]; + + [self setFrameSize:self.frame.size]; +} + + +- (void)drawRect:(NSRect)dirtyRect { + [super drawRect:dirtyRect]; + + [DIALOG_BORDER_COLOR set]; + NSRectFill(NSMakeRect(self.item.xOffset, 0, self.bounds.size.width - self.item.xOffset * 2, DIALOG_BORDER_WIDTH)); +} + +@end \ No newline at end of file diff --git a/TelegramTest/TGRaceEmoji.m b/TelegramTest/TGRaceEmoji.m index ca78ecfd..c63225ad 100644 --- a/TelegramTest/TGRaceEmoji.m +++ b/TelegramTest/TGRaceEmoji.m @@ -63,7 +63,7 @@ -(BOOL)makeWithEmoji:(NSString *)emoji { for(int i = 0; i < _currentElements.count; i++) { EmojiButton *button = [[EmojiButton alloc] initWithFrame:NSMakeRect(2+ (34 * i), 2, 34, 34)]; [button setTitle:_currentElements[i] forControlState:BTRControlStateNormal]; - [button setTitleFont:[NSFont fontWithName:@"HelveticaNeue" size:17] forControlState:BTRControlStateNormal]; + [button setTitleFont:TGSystemFont(17) forControlState:BTRControlStateNormal]; [button addTarget:self action:@selector(emojiClick:) forControlEvents:BTRControlEventLeftClick]; [self.view addSubview:button]; diff --git a/TelegramTest/TGRecentSearchRowItem.h b/TelegramTest/TGRecentSearchRowItem.h new file mode 100644 index 00000000..353c1c57 --- /dev/null +++ b/TelegramTest/TGRecentSearchRowItem.h @@ -0,0 +1,13 @@ +// +// TGRecentTableItem.h +// Telegram +// +// Created by keepcoder on 14.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TMRowItem.h" + +@interface TGRecentSearchRowItem : TMRowItem +@property (nonatomic,strong,readonly) TL_conversation *conversation; +@end diff --git a/TelegramTest/TGRecentSearchRowItem.m b/TelegramTest/TGRecentSearchRowItem.m new file mode 100644 index 00000000..05506b1a --- /dev/null +++ b/TelegramTest/TGRecentSearchRowItem.m @@ -0,0 +1,28 @@ +// +// TGRecentTableItem.m +// Telegram +// +// Created by keepcoder on 14.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TGRecentSearchRowItem.h" + + + +@implementation TGRecentSearchRowItem + +-(id)initWithObject:(id)object { + if(self = [super initWithObject:object]) { + _conversation = object; + _conversation.fake = YES; + } + + return self; +} + +-(NSUInteger)hash { + return _conversation.peer_id; +} + +@end diff --git a/TelegramTest/TGRecentSearchRowView.h b/TelegramTest/TGRecentSearchRowView.h new file mode 100644 index 00000000..216fe975 --- /dev/null +++ b/TelegramTest/TGRecentSearchRowView.h @@ -0,0 +1,13 @@ +// +// TGRecentSearchRowView.h +// Telegram +// +// Created by keepcoder on 14.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TMRowView.h" +#import "TGRecentSearchRowItem.h" +@interface TGRecentSearchRowView : TMRowView + +@end diff --git a/TelegramTest/TGRecentSearchRowView.m b/TelegramTest/TGRecentSearchRowView.m new file mode 100644 index 00000000..68f12083 --- /dev/null +++ b/TelegramTest/TGRecentSearchRowView.m @@ -0,0 +1,106 @@ +// +// TGRecentSearchRowView.m +// Telegram +// +// Created by keepcoder on 14.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TGRecentSearchRowView.h" + +@interface TGRecentSearchRowView () +@property (nonatomic,strong) TMNameTextField *textField; +@property (nonatomic,strong) TMAvatarImageView *imageView; +@property (nonatomic,strong) BTRButton *removeButton; +@property (nonatomic, strong) NSTrackingArea *trackingArea; +@end + +@implementation TGRecentSearchRowView + + +-(instancetype)initWithFrame:(NSRect)frameRect { + if(self = [super initWithFrame:frameRect]) { + _textField = [[TMNameTextField alloc] initWithFrame:NSMakeRect(60, 0, frameRect.size.width - 70, 22)]; + _imageView = [TMAvatarImageView standartMessageTableAvatar]; + + + [self addSubview:_textField]; + + [self addSubview:_imageView]; + + [_imageView setCenteredYByView:self]; + + [_imageView setFrameOrigin:NSMakePoint(12, NSMinY(_imageView.frame))]; + + [_textField setCenteredYByView:self]; + + _removeButton = [[BTRButton alloc] initWithFrame:NSMakeRect(0, 0, image_RemoveSticker().size.width, image_RemoveSticker().size.height)]; + + [_removeButton setImage:image_RemoveSticker() forControlState:BTRControlStateNormal]; + + [_removeButton addTarget:self action:@selector(removeRecentItem:) forControlEvents:BTRControlEventClick]; + + + [_removeButton setFrameOrigin:NSMakePoint(12, NSHeight(frameRect)/2 + 7)]; + + + [self addSubview:_removeButton]; + } + + return self; +} + +- (void) updateTrackingAreas { + [self removeTrackingArea:self.trackingArea]; + self.trackingArea = [[NSTrackingArea alloc] initWithRect:self.bounds + options: (NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved | NSTrackingActiveInKeyWindow) + owner:self userInfo:nil]; + [self addTrackingArea:self.trackingArea]; +} + +-(void)mouseEntered:(NSEvent *)theEvent { + [super mouseEntered:theEvent]; + [_removeButton setHidden:NO]; +} + +-(void)mouseExited:(NSEvent *)theEvent { + [super mouseExited:theEvent]; + [_removeButton setHidden:YES]; +} + +-(void)removeRecentItem:(BTRButton *)sender { + [(TMTableView *)self.rowItem.table removeItem:self.rowItem]; +} + +- (void)drawRect:(NSRect)dirtyRect { + [super drawRect:dirtyRect]; + + [DIALOG_BORDER_COLOR set]; + NSRectFill(NSMakeRect(60, 0, NSWidth(dirtyRect) - 60, 1)); + + + // Drawing code here. +} + + + +-(void)setFrameSize:(NSSize)newSize { + [super setFrameSize:newSize]; + + [_textField setFrameSize:NSMakeSize(newSize.width - 70, NSHeight(_textField.frame))]; +} + +-(void)redrawRow { + + [super redrawRow]; + + + TGRecentSearchRowItem *item = (TGRecentSearchRowItem *)[self rowItem]; + + [_textField updateWithConversation:item.conversation]; + [_imageView updateWithConversation:item.conversation]; + + [_removeButton setHidden:YES]; +} + +@end diff --git a/TelegramTest/TGRecentSearchTableView.h b/TelegramTest/TGRecentSearchTableView.h new file mode 100644 index 00000000..dcb79898 --- /dev/null +++ b/TelegramTest/TGRecentSearchTableView.h @@ -0,0 +1,17 @@ +// +// TGRecentSearchTableView.h +// Telegram +// +// Created by keepcoder on 14.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TMTableView.h" + +@interface TGRecentSearchTableView : TMTableView + +-(BOOL)loadRecentSearchItems; + + + +@end diff --git a/TelegramTest/TGRecentSearchTableView.m b/TelegramTest/TGRecentSearchTableView.m new file mode 100644 index 00000000..b9c15c11 --- /dev/null +++ b/TelegramTest/TGRecentSearchTableView.m @@ -0,0 +1,185 @@ +// +// TGRecentSearchTableView.m +// Telegram +// +// Created by keepcoder on 14.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TGRecentSearchTableView.h" +#import "TGRecentSearchRowView.h" +@interface TGRecentSearchTableView () +@property (nonatomic,strong) TMView *border; +@end + +@implementation TGRecentSearchTableView + +- (void)drawRect:(NSRect)dirtyRect { + [super drawRect:dirtyRect]; +} + +-(instancetype)initWithFrame:(NSRect)frameRect { + if(self = [super initWithFrame:frameRect]) { + self.tm_delegate = self; + + _border = [[TMView alloc] initWithFrame:NSMakeRect(NSWidth(frameRect) - DIALOG_BORDER_WIDTH, 0, DIALOG_BORDER_WIDTH, NSHeight(frameRect))]; + _border.backgroundColor = DIALOG_BORDER_COLOR; + + [self.containerView addSubview:_border]; + } + + return self; +} + +#define MAX_RECENT_ITEMS 20 + +-(void)setFrameSize:(NSSize)newSize { + [super setFrameSize:newSize]; + + [_border setFrame:NSMakeRect(NSWidth(self.containerView.frame) - DIALOG_BORDER_WIDTH, 0, DIALOG_BORDER_WIDTH, NSHeight(self.containerView.frame))]; +} + + +-(BOOL)loadRecentSearchItems { + + if(![Storage isInitialized]) + return NO; + + __block NSArray *peerIds; + + [[Storage yap] readWithBlock:^(YapDatabaseReadTransaction * __nonnull transaction) { + + peerIds = [transaction objectForKey:@"peerIds" inCollection:RECENT_SEARCH]; + + }]; + + peerIds = [peerIds subarrayWithRange:NSMakeRange(0, MIN(peerIds.count,MAX_RECENT_ITEMS))]; + + + [self removeAllItems:NO]; + [self reloadData]; + + if(peerIds.count > 0) { + NSArray *conversations = [[Storage manager] conversationsWithIds:peerIds]; + + conversations = [conversations sortedArrayUsingComparator:^NSComparisonResult(TL_conversation *obj1, TL_conversation *obj2) { + + NSNumber *idx1 = @([peerIds indexOfObject:@(obj1.peer_id)]); + NSNumber *idx2 = @([peerIds indexOfObject:@(obj2.peer_id)]); + + return [idx1 compare:idx2]; + + }]; + + [conversations enumerateObjectsUsingBlock:^(TL_conversation *obj, NSUInteger idx, BOOL *stop) { + + if(obj.type == DialogTypeChat && obj.chat.isDeactivated) + return; + + TGRecentSearchRowItem *item = [[TGRecentSearchRowItem alloc] initWithObject:obj]; + + [self addItem:item tableRedraw:NO]; + + }]; + + [self reloadData]; + } + + + + return self.count > 0; + +} + +-(BOOL)removeItem:(TGRecentSearchRowItem *)item { + + __block NSMutableArray *peerIds; + + NSUInteger count = [self count]; + + __block int next_peer_id = 0; + + [[Storage yap] readWriteWithBlock:^(YapDatabaseReadWriteTransaction * __nonnull transaction) { + + peerIds = [transaction objectForKey:@"peerIds" inCollection:RECENT_SEARCH]; + + [peerIds removeObject:@(item.conversation.peer_id)]; + + [transaction setObject:peerIds forKey:@"peerIds" inCollection:RECENT_SEARCH]; + + if(count == MAX_RECENT_ITEMS && peerIds.count >= MAX_RECENT_ITEMS) { + next_peer_id = [peerIds[MAX_RECENT_ITEMS-1] intValue]; + } + + }]; + + + + dispatch_block_t rm = ^{ + self.defaultAnimation = NSTableViewAnimationEffectFade; + + [super removeItem:item tableRedraw:YES]; + + self.defaultAnimation = NSTableViewAnimationEffectNone; + + + if(peerIds.count == 0) { + StandartViewController *controller = (StandartViewController *) [[Telegram leftViewController] currentTabController]; + if([controller isKindOfClass:[StandartViewController class]]) { + [(StandartViewController *)controller searchByString:@""]; + } + } + }; + + + rm(); + + if(next_peer_id != 0) { + + NSArray *list = [[Storage manager] conversationsWithIds:@[@(next_peer_id)]]; + + if(list.count == 1) { + self.defaultAnimation = NSTableViewAnimationEffectFade; + [self addItem:[[TGRecentSearchRowItem alloc] initWithObject:list[0]] tableRedraw:YES]; + self.defaultAnimation = NSTableViewAnimationEffectNone; + + } + + } + return YES; +} + +- (CGFloat)rowHeight:(NSUInteger)row item:(TMRowItem *) item { + return 50; +} +- (BOOL)isGroupRow:(NSUInteger)row item:(TMRowItem *) item { + return NO; +} +- (TMRowView *)viewForRow:(NSUInteger)row item:(TMRowItem *) item { + return [self cacheViewForClass:[TGRecentSearchRowView class] identifier:@"TGRecentSearchRowView" withSize:NSMakeSize(NSWidth(self.frame), 50)]; +} +- (void)selectionDidChange:(NSInteger)row item:(TGRecentSearchRowItem *) item { + TL_conversation *conv = [[DialogsManager sharedManager] find:item.conversation.peer_id]; + + if(!conv) + conv = item.conversation; + + [appWindow().navigationController showMessagesViewController:conv]; + + +} +- (BOOL)selectionWillChange:(NSInteger)row item:(TGRecentSearchRowItem *) item { + + if([[Telegram rightViewController] isModalViewActive]) { + [[Telegram rightViewController] modalViewSendAction:item.conversation]; + return NO; + } + + return YES; +} +- (BOOL)isSelectable:(NSInteger)row item:(TMRowItem *) item { + return YES; +} + + +@end diff --git a/TelegramTest/TGReplayMessage.m b/TelegramTest/TGReplayMessage.m index 67687035..93bdb50b 100644 --- a/TelegramTest/TGReplayMessage.m +++ b/TelegramTest/TGReplayMessage.m @@ -27,7 +27,7 @@ -(id)initWithFrame:(NSRect)frameRect message:(TL_localMessage *)message { self.nameTextField = [[TMHyperlinkTextField alloc] initWithFrame:NSMakeRect(15, NSHeight(frameRect) - 12, 200, 20)]; [self.nameTextField setBordered:NO]; - [self.nameTextField setFont:[NSFont fontWithName:@"HelveticaNeue-Medium" size:13]]; + [self.nameTextField setFont:TGSystemMediumFont(13)]; [self.nameTextField setDrawsBackground:NO]; [self addSubview:self.nameTextField]; @@ -65,7 +65,7 @@ -(void)update { - if([self.message.message.media isKindOfClass:[TL_messageMediaEmpty class]]) { + if([self.message.message.media isKindOfClass:[TL_messageMediaEmpty class]] || self.message.message.media == nil) { [self.messageField setAttributedStringValue:((MessageTableItemText *)self.message).textAttributed]; diff --git a/TelegramTest/TGReplyObject.h b/TelegramTest/TGReplyObject.h index 117cdd19..fa87c968 100644 --- a/TelegramTest/TGReplyObject.h +++ b/TelegramTest/TGReplyObject.h @@ -17,10 +17,15 @@ @property (nonatomic,strong,readonly) NSURL *geoURL; @property (nonatomic,assign,readonly) int replyHeight; +@property (nonatomic,assign,readonly) int replyHeaderHeight; @property (nonatomic,assign,readonly) int containerHeight; @property (nonatomic,strong,readonly) TL_localMessage *replyMessage; --(id)initWithReplyMessage:(TL_localMessage *)message; +@property (nonatomic,strong,readonly) TL_localMessage *fromMessage; + +@property (nonatomic,weak,readonly) MessageTableItem *item; + +-(id)initWithReplyMessage:(TL_localMessage *)replyMessage fromMessage:(TL_localMessage *)fromMessage tableItem:(MessageTableItem *)item; @end diff --git a/TelegramTest/TGReplyObject.m b/TelegramTest/TGReplyObject.m index 72204841..c84803b3 100644 --- a/TelegramTest/TGReplyObject.m +++ b/TelegramTest/TGReplyObject.m @@ -9,158 +9,224 @@ #import "TGReplyObject.h" #import "MessagesUtils.h" #import "NSString+Extended.h" +#import "MessageTableItem.h" +#import "TGArticleImageObject.h" +@interface TGReplyObject () +@property (nonatomic,strong) RPCRequest *request; +@end + @implementation TGReplyObject --(id)initWithReplyMessage:(TL_localMessage *)replyMessage { +-(id)initWithReplyMessage:(TL_localMessage *)replyMessage fromMessage:(TL_localMessage *)fromMessage tableItem:(MessageTableItem *)item { if(self = [super init]) { + _item = item; + _fromMessage = fromMessage; _replyMessage = replyMessage; + assert(_fromMessage != nil || _replyMessage != nil); - NSColor *nameColor = LINK_COLOR; + _containerHeight = 15+18; -// static NSColor * colors[6]; -// static NSMutableDictionary *cacheColorIds; -// -// static dispatch_once_t onceToken; -// dispatch_once(&onceToken, ^{ -// colors[0] = NSColorFromRGB(0xce5247); -// colors[1] = NSColorFromRGB(0xcda322); -// colors[2] = NSColorFromRGB(0x5eaf33); -// colors[3] = NSColorFromRGB(0x468ec4); -// colors[4] = NSColorFromRGB(0xac6bc8); -// colors[5] = NSColorFromRGB(0xe28941); -// -// cacheColorIds = [[NSMutableDictionary alloc] init]; -// }); -// -// -// if(replyMessage.from_id != [UsersManager currentUserId]) { -// -// int colorMask = [TMAvatarImageView colorMask:replyMessage.fromUser]; -// -// nameColor = colors[colorMask % (sizeof(colors) / sizeof(colors[0]))]; -// -// } + if(_replyMessage != nil) + [self updateObject]; + else + [self loadReplyMessage]; - //NSString *name = replyMessage.fwd_from_id != 0 ? replyMessage.fromFwdUser.fullName : replyMessage.fromUser.fullName; - NSString *name = replyMessage.fromUser.fullName; + } + + return self; +} + +-(void)updateObject { + + if([_replyMessage isKindOfClass:[TL_localEmptyMessage class]]) { + _item.replyObject = nil; + return; + } + + NSColor *nameColor = LINK_COLOR; + + NSString *name = _replyMessage.from_id == 0 ? _replyMessage.chat.title : _replyMessage.fromUser.fullName; + + + NSMutableAttributedString *replyHeader = [[NSMutableAttributedString alloc] init]; + + [replyHeader appendString:name withColor:nameColor]; + + [replyHeader setFont:TGSystemMediumFont(13) forRange:replyHeader.range]; + + // [replyHeader addAttribute:NSLinkAttributeName value:[TMInAppLinks peerProfile:_replyMessage.fwd_from_id != nil ? _replyMessage.fwd_from_id : [TL_peerUser createWithUser_id:_replyMessage.from_id]] range:replyHeader.range]; + + _replyHeader = replyHeader; + + + NSMutableAttributedString *replyText = [[NSMutableAttributedString alloc] init]; + + if((_replyMessage.media == nil || [_replyMessage.media isKindOfClass:[TL_messageMediaEmpty class]]) || [_replyMessage.media isKindOfClass:[TL_messageMediaWebPage class]]) { - NSMutableAttributedString *replyHeader = [[NSMutableAttributedString alloc] init]; + if(![_replyMessage isKindOfClass:[TL_localMessageService class]]) { + [replyText appendString:[[_replyMessage.message stringByReplacingOccurrencesOfString:@"\n" withString:@" "] fixEmoji] withColor:TEXT_COLOR]; + } else { + [replyText appendString:[MessagesUtils serviceMessage:_replyMessage forAction:_replyMessage.action] withColor:GRAY_TEXT_COLOR]; + } - [replyHeader appendString:name withColor:nameColor]; - [replyHeader setFont:[NSFont fontWithName:@"HelveticaNeue-Medium" size:13] forRange:replyHeader.range]; - [replyHeader addAttribute:NSLinkAttributeName value:[TMInAppLinks userProfile:replyMessage.fwd_from_id != 0 ? replyMessage.fwd_from_id : replyMessage.from_id] range:replyHeader.range]; + } else { + [replyText appendString:[[[MessagesUtils mediaMessage:_replyMessage] stringByReplacingOccurrencesOfString:@"\n" withString:@" "] fixEmoji] withColor:GRAY_TEXT_COLOR]; + } + + + + NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init]; + style.lineBreakMode = NSLineBreakByTruncatingTail; + + [replyText addAttribute:NSParagraphStyleAttributeName value:style range:replyText.range]; + + [replyText setFont:TGSystemFont(13) forRange:replyText.range]; + + _replyText = replyText; + + _replyHeight = [_replyText coreTextSizeForTextFieldForWidth:INT32_MAX].height; + + + _replyHeaderHeight = [replyHeader sizeForTextFieldForWidth:INT32_MAX].height; + + _containerHeight = 15 + _replyHeight; + + + + if([_replyMessage.media isKindOfClass:[TL_messageMediaPhoto class]]) { - _replyHeader = replyHeader; + NSImage *thumb; + TLPhoto *photo = _replyMessage.media.photo; - NSMutableAttributedString *replyText = [[NSMutableAttributedString alloc] init]; - if([replyMessage.media isKindOfClass:[TL_messageMediaEmpty class]] || [replyMessage.media isKindOfClass:[TL_messageMediaWebPage class]]) { - - NSString *str = [replyMessage.message stringByReplacingOccurrencesOfString:@"\n" withString:@" "]; - - [replyText appendString:[str fixEmoji] withColor:TEXT_COLOR]; - - } else { - [replyText appendString:[[MessagesUtils mediaMessage:replyMessage] fixEmoji] withColor:GRAY_TEXT_COLOR]; + for(TLPhotoSize *photoSize in photo.sizes) { + if([photoSize isKindOfClass:[TL_photoCachedSize class]]) { + thumb = [[NSImage alloc] initWithData:photoSize.bytes]; + break; + } } + TLPhotoSize *photoSize = photo.sizes[0]; - if([replyMessage.media isKindOfClass:[TL_messageMediaPhoto class]]) { - - NSImage *thumb; - - TLPhoto *photo = replyMessage.media.photo; - + + + _replyThumb = [[TGArticleImageObject alloc] initWithLocation:!thumb ? photoSize.location : nil placeHolder:thumb]; + + _replyThumb.imageSize = NSMakeSize(_containerHeight-2, _containerHeight-2); + + } + + if([_replyMessage.media isKindOfClass:[TL_messageMediaGeo class]]) { + + + } + + if([_replyMessage.media isKindOfClass:[TL_messageMediaVideo class]]) { + + TLPhotoSize *photoSize = _replyMessage.media.video.thumb; + + NSImage *thumb; + if([photoSize isKindOfClass:[TL_photoCachedSize class]]) { + thumb = [[NSImage alloc] initWithData:photoSize.bytes]; + } + + + + _replyThumb = [[TGImageObject alloc] initWithLocation:!thumb ? photoSize.location : nil placeHolder:thumb]; + + _replyThumb.imageSize = strongsize(NSMakeSize(photoSize.w, photoSize.h), _containerHeight-2); + + } + + if([_replyMessage.media isKindOfClass:[TL_messageMediaDocument class]]) { + + if(![_replyMessage.media.document isSticker]) { - for(TLPhotoSize *photoSize in photo.sizes) { - if([photoSize isKindOfClass:[TL_photoCachedSize class]]) { - thumb = [[NSImage alloc] initWithData:photoSize.bytes]; - break; + if(_replyMessage.media.document.thumb && ![_replyMessage.media.document.thumb isKindOfClass:[TL_photoSizeEmpty class]]) { + + NSImage *thumb; + + if(_replyMessage.media.document.thumb.bytes) { + thumb = [[NSImage alloc] initWithData:_replyMessage.media.document.thumb.bytes]; + thumb = renderedImage(thumb, strongsize(NSMakeSize(_replyMessage.media.document.thumb.w, _replyMessage.media.document.thumb.h), _containerHeight-2)); } + + _replyThumb = [[TGImageObject alloc] initWithLocation:!thumb ? _replyMessage.media.document.thumb.location : nil placeHolder:thumb]; + + _replyThumb.imageSize = strongsize(NSMakeSize(_replyMessage.media.document.thumb.w, _replyMessage.media.document.thumb.h), _containerHeight-2); + } - TLPhotoSize *photoSize = photo.sizes[0]; - - - - _replyThumb = [[TGImageObject alloc] initWithLocation:!thumb ? photoSize.location : nil placeHolder:thumb]; - - _replyThumb.imageSize = strongsize(NSMakeSize(photoSize.w, photoSize.h), 30); - } + } + + + + +} + + +-(void)loadReplyMessage { + + id request = [TLAPI_messages_getMessages createWithN_id:[@[@(_fromMessage.reply_to_msg_id)] mutableCopy]]; + + if([_fromMessage.to_id isKindOfClass:[TL_peerChannel class]]) { - if([replyMessage.media isKindOfClass:[TL_messageMediaGeo class]]) { + + request = [TLAPI_channels_getMessages createWithChannel:[TL_inputChannel createWithChannel_id:_fromMessage.chat.n_id access_hash:_fromMessage.chat.access_hash] n_id:[@[@(_fromMessage.reply_to_msg_id)] mutableCopy]]; + } + + [RPCRequest sendRequest:request successHandler:^(id request, TL_messages_messages *response) { + + + if(response.messages.count == 1 ) { - // _geoURL = [NSURL URLWithString:[NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/staticmap?center=%f,%f&zoom=15&size=%@&sensor=true",replyMessage.media.geo.lat, replyMessage.media.geo.n_long, @"30x30"]]; - } - - if([replyMessage.media isKindOfClass:[TL_messageMediaVideo class]]) { + NSMutableArray *messages = [response.messages mutableCopy]; + [[response messages] removeAllObjects]; - TLPhotoSize *photoSize = replyMessage.media.video.thumb; - NSImage *thumb; - if([photoSize isKindOfClass:[TL_photoCachedSize class]]) { - thumb = [[NSImage alloc] initWithData:photoSize.bytes]; - } + [TL_localMessage convertReceivedMessages:messages]; + if([messages[0] isKindOfClass:[TL_messageEmpty class]]) { + messages[0] = [TL_localEmptyMessage createWithN_Id:[(TL_messageEmpty *)messages[0] n_id] to_id:_fromMessage.to_id]; + } - _replyThumb = [[TGImageObject alloc] initWithLocation:!thumb ? photoSize.location : nil placeHolder:thumb]; + [SharedManager proccessGlobalResponse:response]; - _replyThumb.imageSize = strongsize(NSMakeSize(photoSize.w, photoSize.h), 30); + [[Storage manager] addSupportMessages:messages]; + [MessagesManager addSupportMessages:messages]; - } - - if([replyMessage.media isKindOfClass:[TL_messageMediaDocument class]]) { - if(![replyMessage.media.document isSticker]) { - - if(replyMessage.media.document.thumb && ![replyMessage.media.document.thumb isKindOfClass:[TL_photoSizeEmpty class]]) { - - NSImage *thumb; - - if(replyMessage.media.document.thumb.bytes) { - thumb = [[NSImage alloc] initWithData:replyMessage.media.document.thumb.bytes]; - thumb = renderedImage(thumb, strongsize(NSMakeSize(replyMessage.media.document.thumb.w, replyMessage.media.document.thumb.h), 30)); - } - - _replyThumb = [[TGImageObject alloc] initWithLocation:!thumb ? replyMessage.media.document.thumb.location : nil placeHolder:thumb]; - - _replyThumb.imageSize = strongsize(NSMakeSize(replyMessage.media.document.thumb.w, replyMessage.media.document.thumb.h), 30); - - } - + _replyMessage = messages[0]; + _fromMessage.replyMessage = _replyMessage; + [self updateObject]; + + if(_item != nil) { + [Notification perform:UPDATE_MESSAGE_ITEM data:@{@"item":_item}]; } + } - - NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init]; - style.lineBreakMode = NSLineBreakByTruncatingTail; - - [replyText addAttribute:NSParagraphStyleAttributeName value:style range:replyText.range]; - - [replyText setFont:[NSFont fontWithName:@"HelveticaNeue" size:13] forRange:replyText.range]; - - _replyText = replyText; + } errorHandler:^(id request, RpcError *error) { - _replyHeight = [_replyText coreTextSizeForTextFieldForWidth:INT32_MAX].height; - - _containerHeight = 15 + _replyHeight; - - } - - return self; + }]; +} + +-(void)dealloc { + [_request cancelRequest]; + _request = nil; } @end diff --git a/TelegramTest/TGReportChannelModalView.h b/TelegramTest/TGReportChannelModalView.h new file mode 100644 index 00000000..0bdf663f --- /dev/null +++ b/TelegramTest/TGReportChannelModalView.h @@ -0,0 +1,15 @@ +// +// TGReportChannelModalView.h +// Telegram +// +// Created by keepcoder on 20/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "TGModalView.h" + +@interface TGReportChannelModalView : TGModalView + +@property (nonatomic,strong) TL_conversation *conversation; + +@end diff --git a/TelegramTest/TGReportChannelModalView.m b/TelegramTest/TGReportChannelModalView.m new file mode 100644 index 00000000..acf01c1d --- /dev/null +++ b/TelegramTest/TGReportChannelModalView.m @@ -0,0 +1,122 @@ +// +// TGReportChannelModalView.m +// Telegram +// +// Created by keepcoder on 20/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "TGReportChannelModalView.h" +#import "TGSettingsTableView.h" +#import "TGGeneralInputRowItem.h" +@interface TGReportChannelModalView () +@property (nonatomic,strong) TGSettingsTableView *tableView; + +@property (nonatomic,strong) id reason; +@end + +@implementation TGReportChannelModalView + +-(instancetype)initWithFrame:(NSRect)frameRect { + if(self = [super initWithFrame:frameRect]) { + [self setContainerFrameSize:NSMakeSize(300, 248)]; + + + [self initialize]; + } + + return self; +} + + +-(void)configure { + [self.tableView removeAllItems:YES]; + + + [_tableView addItem:[[TGGeneralRowItem alloc] initWithHeight:10] tableRedraw:YES]; + + GeneralSettingsRowItem *spam = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSelected callback:^(TGGeneralRowItem *item) { + + _reason = [TL_inputReportReasonSpam create]; + [self configure]; + + } description:NSLocalizedString(@"Report.ReportSpam", nil) height:42 stateback:^id(TGGeneralRowItem *item) { + return @([_reason isKindOfClass:[TL_inputReportReasonSpam class]]); + }]; + + GeneralSettingsRowItem *violence = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSelected callback:^(TGGeneralRowItem *item) { + + _reason = [TL_inputReportReasonViolence create]; + [self configure]; + + } description:NSLocalizedString(@"Report.ReportViolence", nil) height:42 stateback:^id(TGGeneralRowItem *item) { + return @([_reason isKindOfClass:[TL_inputReportReasonViolence class]]); + }]; + + GeneralSettingsRowItem *porno = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeSelected callback:^(TGGeneralRowItem *item) { + + _reason = [TL_inputReportReasonPornography create]; + [self configure]; + + } description:NSLocalizedString(@"Report.ReportPorno", nil) height:42 stateback:^id(TGGeneralRowItem *item) { + return @([_reason isKindOfClass:[TL_inputReportReasonPornography class]]); + }]; + + TGGeneralInputRowItem *other = [[TGGeneralInputRowItem alloc] initWithHeight:42]; + other.placeholder = NSLocalizedString(@"Report.ReportOther", nil); + + [other setCallback:^(TGGeneralRowItem *item) { + BOOL needConfigure = ![_reason isKindOfClass:[TL_inputReportReasonOther class]]; + _reason = [TL_inputReportReasonOther createWithText:other.result.string]; + if(needConfigure) + [_tableView reloadDataForRowIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 3)] columnIndexes:[NSIndexSet indexSetWithIndex:0]]; + }]; + + spam.xOffset = violence.xOffset = porno.xOffset = other.xOffset = 0; + + [_tableView addItem:spam tableRedraw:YES]; + [_tableView addItem:violence tableRedraw:YES]; + [_tableView addItem:porno tableRedraw:YES]; + [_tableView addItem:[[TGGeneralRowItem alloc] initWithHeight:20] tableRedraw:YES]; + [_tableView addItem:other tableRedraw:YES]; + + [_tableView addItem:[[TGGeneralRowItem alloc] initWithHeight:20] tableRedraw:YES]; + +} + +-(void)okAction { + [super okAction]; + + + [TMViewController showModalProgress]; + + [self close:YES]; + + [RPCRequest sendRequest:[TLAPI_account_reportPeer createWithPeer:_conversation.inputPeer reason:_reason] successHandler:^(id request, id response) { + + [TMViewController hideModalProgress]; + + alert(NSLocalizedString(@"Report.AlertText", nil), NSLocalizedString(@"Report.AlertDescription", nil)); + + } errorHandler:^(id request, RpcError *error) { + [TMViewController hideModalProgress]; + }]; +} + +-(void)cancelAction { + [super cancelAction]; +} + +-(void)initialize { + _tableView = [[TGSettingsTableView alloc] initWithFrame:NSMakeRect(0, 50, self.containerSize.width, self.containerSize.height - 50)]; + + [self addSubview:_tableView.containerView]; + + _reason = [TL_inputReportReasonSpam create]; + + [self configure]; + + [self enableCancelAndOkButton]; +} + +@end diff --git a/TelegramTest/TGSProfileMediaRowItem.h b/TelegramTest/TGSProfileMediaRowItem.h new file mode 100644 index 00000000..d076b45f --- /dev/null +++ b/TelegramTest/TGSProfileMediaRowItem.h @@ -0,0 +1,17 @@ +// +// TGSProfileMediaRowItem.h +// Telegram +// +// Created by keepcoder on 03/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "TGGeneralRowItem.h" + +@interface TGSProfileMediaRowItem : TGGeneralRowItem + +@property (nonatomic,strong) TL_conversation *conversation; + +@property (nonatomic,weak) TMViewController *controller; + +@end diff --git a/TelegramTest/TGSProfileMediaRowItem.m b/TelegramTest/TGSProfileMediaRowItem.m new file mode 100644 index 00000000..45e13925 --- /dev/null +++ b/TelegramTest/TGSProfileMediaRowItem.m @@ -0,0 +1,28 @@ +// +// TGSProfileMediaRowItem.m +// Telegram +// +// Created by keepcoder on 03/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "TGSProfileMediaRowItem.h" + + + +@implementation TGSProfileMediaRowItem + +-(id)initWithObject:(id)object { + if(self = [super initWithObject:object]) { + _conversation = object; + } + + return self; +} + + +-(Class)viewClass { + return NSClassFromString(@"TGSProfileMediaRowView"); +} + +@end diff --git a/TelegramTest/TGSProfileMediaRowView.h b/TelegramTest/TGSProfileMediaRowView.h new file mode 100644 index 00000000..ad450cac --- /dev/null +++ b/TelegramTest/TGSProfileMediaRowView.h @@ -0,0 +1,14 @@ +// +// TGSProfileMediaRowView.h +// Telegram +// +// Created by keepcoder on 03/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "TMRowView.h" + +@interface TGSProfileMediaRowView : TMRowView + + +@end diff --git a/TelegramTest/TGSProfileMediaRowView.m b/TelegramTest/TGSProfileMediaRowView.m new file mode 100644 index 00000000..23d520fd --- /dev/null +++ b/TelegramTest/TGSProfileMediaRowView.m @@ -0,0 +1,391 @@ +// +// TGSProfileMediaRowView.m +// Telegram +// +// Created by keepcoder on 03/11/15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "TGSProfileMediaRowView.h" +#import "TGSProfileMediaRowItem.h" +#import "TGAudioPlayerWindow.h" +@interface TGMediaCounterLoader : NSObject +@property (nonatomic,assign) int photoAndVideoCounter; +@property (nonatomic,assign) int filesCounter; +@property (nonatomic,assign) int audioCounter; +@property (nonatomic,assign) int linksCounter; + + +@property (nonatomic,copy) dispatch_block_t changeHandler; +@property (nonatomic,strong) NSAttributedString *loaderString; + + +@property (nonatomic,assign) BOOL isLoaded; + + +@end + + +@implementation TGMediaCounterLoader + +-(instancetype)init { + if(self = [super init]) { + _photoAndVideoCounter = 0; + _filesCounter = 0; + _audioCounter = 0; + _linksCounter = 0; + } + + return self; +} + +-(void)loadWithConversation:(TL_conversation *)conversation inputPeer:(TLInputPeer *)inputPeer { + + if(conversation.type == DialogTypeSecretChat) { + _isLoaded = YES; + + if( _changeHandler) { + _changeHandler(); + } + + return; + } + + + NSArray *filters = @[[TL_inputMessagesFilterPhotoVideo create],[TL_inputMessagesFilterDocument create],[TL_inputMessagesFilterAudioDocuments create],[TL_inputMessagesFilterUrl create]]; + + + + NSArray *properties = @[@"photoAndVideoCounter",@"filesCounter",@"audioCounter",@"linksCounter"]; + + + NSMutableArray *_inwork = [filters mutableCopy]; + + [filters enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + + // dispatch_after_seconds(idx, ^{ + [RPCRequest sendRequest:[TLAPI_messages_search createWithFlags:0 peer:inputPeer q:@"" filter:obj min_date:0 max_date:0 offset:0 max_id:0 limit:0] successHandler:^(RPCRequest *request, TL_messages_messages *response) { + + + NSString *property = properties[idx]; + + int value = [[self valueForKey:property] intValue]; + + value += MAX([response n_count],[[response messages] count]); + + [self setValue:@(value) forKey:property]; + + [_inwork removeObject:obj]; + + [self updateCountersText]; + + _isLoaded = _inwork.count == 0; + + if( _changeHandler) { + _changeHandler(); + } + + if(_isLoaded && conversation.type == DialogTypeChannel && conversation.chat.chatFull.migrated_from_chat_id != 0) { + _isLoaded = NO; + + [self loadWithConversation:nil inputPeer:[TL_inputPeerChat createWithChat_id:conversation.chat.chatFull.migrated_from_chat_id]]; + } + + + } errorHandler:^(RPCRequest *request, RpcError *error) { + + + }]; + // }); + + + }]; + + + + +} + +-(void)updateCountersText { + + NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] init]; + + if(_photoAndVideoCounter > 0) { + + NSString *key = _photoAndVideoCounter == 1 ? NSLocalizedString(@"Modern.SharedMedia.PhotoOrVideo", nil) : NSLocalizedString(@"Modern.SharedMedia.PhotosAndVideos", nil); + + NSRange range = [attr appendString:[NSString stringWithFormat:@"%d",_photoAndVideoCounter] withColor:BLUE_UI_COLOR]; + [attr appendString:@" "]; + NSRange secondRange = [attr appendString:key withColor:GRAY_TEXT_COLOR]; + + range.length+= (secondRange.location - range.length - range.location) + secondRange.length; + + [attr addAttribute:NSLinkAttributeName value:@"photoOrVideo" range:range]; + + + } + + if(_filesCounter > 0) { + NSString *key = _filesCounter == 1 ? NSLocalizedString(@"Modern.SharedMedia.File", nil) : NSLocalizedString(@"Modern.SharedMedia.Files", nil); + + + if(attr.string.length > 0) { + [attr appendString:@"," withColor:GRAY_TEXT_COLOR]; + [attr appendString:@" "]; + } + + + + NSRange range = [attr appendString:[NSString stringWithFormat:@"%d",_filesCounter] withColor:BLUE_UI_COLOR]; + [attr appendString:@" "]; + NSRange secondRange = [attr appendString:key withColor:GRAY_TEXT_COLOR]; + + range.length+= (secondRange.location - range.length - range.location) + secondRange.length; + + [attr addAttribute:NSLinkAttributeName value:@"files" range:range]; + + } + + if(_audioCounter > 0) { + + NSString *key = _audioCounter == 1 ? NSLocalizedString(@"Modern.SharedMedia.Audio", nil) : NSLocalizedString(@"Modern.SharedMedia.Audios", nil); + + if(attr.string.length > 0) { + [attr appendString:@"," withColor:GRAY_TEXT_COLOR]; + [attr appendString:@" "]; + } + NSRange range = [attr appendString:[NSString stringWithFormat:@"%d",_audioCounter] withColor:BLUE_UI_COLOR]; + [attr appendString:@" "]; + NSRange secondRange = [attr appendString:key withColor:GRAY_TEXT_COLOR]; + + range.length+= (secondRange.location - range.length - range.location) + secondRange.length; + + [attr addAttribute:NSLinkAttributeName value:@"audio" range:range]; + + + } + + if(_linksCounter > 0) { + + NSString *key = _linksCounter == 1 ? NSLocalizedString(@"Modern.SharedMedia.Link", nil) : NSLocalizedString(@"Modern.SharedMedia.Links", nil); + + if(attr.string.length > 0) { + [attr appendString:@"," withColor:GRAY_TEXT_COLOR]; + [attr appendString:@" "]; + } + NSRange range = [attr appendString:[NSString stringWithFormat:@"%d",_linksCounter] withColor:BLUE_UI_COLOR]; + [attr appendString:@" "]; + NSRange secondRange = [attr appendString:key withColor:GRAY_TEXT_COLOR]; + + range.length+= (secondRange.location - range.length - range.location) + secondRange.length; + + [attr addAttribute:NSLinkAttributeName value:@"links" range:range]; + + } + + + [attr setFont:TGSystemFont(14) forRange:attr.range]; + + _loaderString = attr; + +} + + +@end + + +@interface TGSProfileMediaRowView () +@property (nonatomic,strong) TMTextField *headerTextField; +@property (nonatomic,strong) TMHyperlinkTextField *countersTextField; + +@property (nonatomic,strong) NSProgressIndicator *progressIndicator; + +@end + +@implementation TGSProfileMediaRowView + +- (void)drawRect:(NSRect)dirtyRect { + [super drawRect:dirtyRect]; + + [DIALOG_BORDER_COLOR setFill]; + + NSRectFill(NSMakeRect(self.item.xOffset, 0, NSWidth(dirtyRect) - self.item.xOffset * 2, DIALOG_BORDER_WIDTH)); +} + + +static NSMutableDictionary *counters; +static NSMutableDictionary *loaders; ++(void)initialize { + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + counters = [[NSMutableDictionary alloc] init]; + loaders = [[NSMutableDictionary alloc] init]; + }); +} + + +-(instancetype)initWithFrame:(NSRect)frameRect { + if(self = [super initWithFrame:frameRect]) { + _headerTextField = [TMTextField defaultTextField]; + _countersTextField = [TMHyperlinkTextField defaultTextField]; + + _countersTextField.url_delegate = self; + + [_countersTextField setFont:TGSystemFont(13)]; + + [_headerTextField setStringValue:NSLocalizedString(@"Profile.SharedMedia", nil)]; + [_headerTextField setFont:TGSystemFont(14)]; + [_headerTextField setTextColor:TEXT_COLOR]; + [_headerTextField sizeToFit]; + + + [[_headerTextField cell] setTruncatesLastVisibleLine:YES]; + [[_headerTextField cell] setTruncatesLastVisibleLine:YES]; + + + [[_countersTextField cell] setTruncatesLastVisibleLine:YES]; + [[_countersTextField cell] setLineBreakMode:NSLineBreakByTruncatingTail]; + _progressIndicator = [[NSProgressIndicator alloc] initWithFrame:NSMakeRect(0, 0, 15, 15)]; + [_progressIndicator setStyle:NSProgressIndicatorSpinningStyle]; + [self addSubview:_progressIndicator]; + + [self addSubview:_headerTextField]; + [self addSubview:_countersTextField]; + + } + + return self; +} + +-(void)textField:(id)textField handleURLClick:(NSString *)url { + + // handle + if([url isEqualToString:@"audio"]) { + [TGAudioPlayerWindow show:self.item.conversation playerState:TGAudioPlayerWindowStatePlayList]; + return; + } + + TMCollectionPageController *viewController = [[TMCollectionPageController alloc] initWithFrame:NSZeroRect]; + + [self.item.controller.navigationViewController pushViewController:viewController animated:YES]; + + [viewController setConversation:self.item.conversation]; + + if([url isEqualToString:@"files"]) { + + [viewController showFiles]; + + } else if([url isEqualToString:@"links"]) { + + [viewController showSharedLinks]; + + } + + + +} + +-(void)redrawRow { + [super redrawRow]; + + [self loadOrConfigure]; + +} + +-(TL_conversation *)conversation { + return [(TGSProfileMediaRowItem *)[self rowItem] conversation]; +} + + + +-(void)loadOrConfigure { + + TGMediaCounterLoader *loader = loaders[@(self.conversation.peer_id)]; + + if(!loader) { + loader = [[TGMediaCounterLoader alloc] init]; + [loader loadWithConversation:self.conversation inputPeer:self.conversation.inputPeer]; + + loaders[@(self.conversation.peer_id)] = loader; + } + + [loader setChangeHandler:^{ + [self updateText:YES]; + }]; + + + [self updateText:NO]; + +} + + +-(void)updateText:(BOOL)animated { + TGMediaCounterLoader *loader = loaders[@(self.conversation.peer_id)]; + + + [_progressIndicator setHidden:loader.isLoaded]; + + if(loader.isLoaded) + [_progressIndicator stopAnimation:self]; + else + [_progressIndicator startAnimation:self]; + + [_countersTextField setAttributedStringValue:loader.loaderString]; + + [_countersTextField sizeToFit]; + + + + if(loader.isLoaded && loader.loaderString.length == 0 && animated) { + + [NSAnimationContext runAnimationGroup:^(NSAnimationContext * _Nonnull context) { + + [[_headerTextField animator] setFrameOrigin:NSMakePoint(self.item.xOffset - 2, roundf((NSHeight(self.frame) - NSHeight(_headerTextField.frame)))/2)]; + + } completionHandler:^{ + [self updateFrames:NO]; + }]; + } else { + [self updateFrames:animated]; + } +} + +-(void)updateFrames:(BOOL)animated { + [_countersTextField setFrameSize:NSMakeSize(MIN(NSWidth(_countersTextField.frame), NSWidth(self.frame) - 60 - NSWidth(_progressIndicator.frame)) , NSHeight(_countersTextField.frame))]; + + + TGMediaCounterLoader *loader = loaders[@(self.conversation.peer_id)]; + + int totalHeight = NSHeight(_countersTextField.frame) + NSHeight(_headerTextField.frame); + [_countersTextField setFrameOrigin:NSMakePoint(self.item.xOffset - 2, roundf((NSHeight(self.frame) - totalHeight)/2))]; + [_headerTextField setFrameOrigin:NSMakePoint(self.item.xOffset - 2, roundf((NSHeight(self.frame) - totalHeight)/2) + NSHeight(_countersTextField.frame))]; + + if(loader.isLoaded && loader.loaderString.length == 0) { + [_headerTextField setCenteredYByView:self]; + } + + id progress = animated ? [_progressIndicator animator] : _progressIndicator; + + [progress setFrameOrigin:NSMakePoint(NSMaxX(_countersTextField.frame) + (_countersTextField.attributedStringValue.length == 0 ? 0 : 3), NSMinY(_countersTextField.frame) + 1)]; + +} + +-(TGSProfileMediaRowItem *)item { + return (TGSProfileMediaRowItem *) [self rowItem]; +} + +-(void)setFrameSize:(NSSize)newSize { + [super setFrameSize:newSize]; + + [self updateFrames:NO]; + +} + +-(void)mouseDown:(NSEvent *)theEvent { + [super mouseDown:theEvent]; + + if(self.item.callback) + self.item.callback(self.item); +} + +@end diff --git a/TelegramTest/TGSearchRowItem.h b/TelegramTest/TGSearchRowItem.h index 0653ef80..c857ad2f 100644 --- a/TelegramTest/TGSearchRowItem.h +++ b/TelegramTest/TGSearchRowItem.h @@ -7,9 +7,9 @@ // #import "TMRowItem.h" +#import "TGGeneralRowItem.h" +@interface TGSearchRowItem : TGGeneralRowItem -@interface TGSearchRowItem : TMRowItem - - +@property (nonatomic,weak) id delegate; @end diff --git a/TelegramTest/TGSearchRowItem.m b/TelegramTest/TGSearchRowItem.m index c471dd1d..a72635e0 100644 --- a/TelegramTest/TGSearchRowItem.m +++ b/TelegramTest/TGSearchRowItem.m @@ -14,4 +14,8 @@ -(NSUInteger)hash { return -1; } +-(Class)viewClass { + return NSClassFromString(@"TGGeneralSearchRowView"); +} + @end diff --git a/TelegramTest/TGSearchRowView.m b/TelegramTest/TGSearchRowView.m index e26d20aa..7dd83c1d 100644 --- a/TelegramTest/TGSearchRowView.m +++ b/TelegramTest/TGSearchRowView.m @@ -30,7 +30,13 @@ -(void)setXOffset:(int)xOffset { -(void)setFrameSize:(NSSize)newSize { [super setFrameSize:newSize]; - [_searchField setFrame:NSMakeRect(_xOffset, NSMinY(_searchField.frame), newSize.width - MAX(_xOffset, 10)*2, NSHeight(_searchField.frame))]; + [_searchField setFrame:NSMakeRect(MAX(_xOffset, 10), NSMinY(_searchField.frame), newSize.width - MAX(_xOffset, 10)*2, NSHeight(_searchField.frame))]; +} + +-(void)mouseDown:(NSEvent *)theEvent { + [super mouseDown:theEvent]; + + [self.searchField becomeFirstResponder]; } -(BOOL)becomeFirstResponder { diff --git a/TelegramTest/TGSendTypingManager.m b/TelegramTest/TGSendTypingManager.m index 37b7c084..8cce0b3a 100644 --- a/TelegramTest/TGSendTypingManager.m +++ b/TelegramTest/TGSendTypingManager.m @@ -34,6 +34,8 @@ -(void)perform { id api; + + if(_conversation.type == DialogTypeSecretChat) api = [TLAPI_messages_setEncryptedTyping createWithPeer:(TLInputEncryptedChat *)[_conversation.encryptedChat inputPeer] typing:YES]; else @@ -107,9 +109,15 @@ -(void)addAction:(TLSendMessageAction *)action forConversation:(TL_conversation TGSendingAction *saction = [[TGSendingAction alloc] initWithAction:action time:[[NSDate date] timeIntervalSince1970]+3 conversation:conversation]; + if(conversation.type == DialogTypeChannel) { + if(conversation.chat.isBroadcast) + return; + } NSMutableDictionary *actions = _conversations[@(conversation.peer_id)]; + + if(!actions) { actions = [[NSMutableDictionary alloc] init]; diff --git a/TelegramTest/TGSessionRowView.m b/TelegramTest/TGSessionRowView.m index b07ace6d..ef8f727c 100644 --- a/TelegramTest/TGSessionRowView.m +++ b/TelegramTest/TGSessionRowView.m @@ -23,16 +23,16 @@ - (id)initWithFrame:(NSRect)frame self.textField = [TMTextField defaultTextField]; - [self.textField setFont:[NSFont fontWithName:@"HelveticaNeue" size:13]]; + [self.textField setFont:TGSystemFont(13)]; [self addSubview:self.textField]; - [self.textField setFrameOrigin:NSMakePoint(100, 0)]; + [self.textField setFrameOrigin:NSMakePoint(30, 0)]; self.resetSession = [TMTextButton standartUserProfileButtonWithTitle:NSLocalizedString(@"Authorization.Reset", nil)]; - [self.resetSession setFont:[NSFont fontWithName:@"HelveticaNeue" size:14]]; + [self.resetSession setFont:TGSystemFont(14)]; [self.resetSession setTextColor:BLUE_UI_COLOR]; [self.resetSession sizeToFit]; @@ -68,16 +68,16 @@ - (void) redrawRow { NSRange range = [description appendString:[NSString stringWithFormat:@"%@ %@\n",item.authorization.app_name, item.authorization.app_version]]; - [description setFont:[NSFont fontWithName:@"HelveticaNeue-Medium" size:13] forRange:range]; + [description setFont:TGSystemMediumFont(13) forRange:range]; range = [description appendString:[NSString stringWithFormat:@"%@, %@ %@\n",item.authorization.device_model,item.authorization.platform,item.authorization.system_version]]; - [description setFont:[NSFont fontWithName:@"HelveticaNeue" size:12] forRange:range]; + [description setFont:TGSystemFont(12) forRange:range]; range = [description appendString:[NSString stringWithFormat:@"%@ (%@)",item.authorization.country, item.authorization.ip] withColor:GRAY_TEXT_COLOR]; - [description setFont:[NSFont fontWithName:@"HelveticaNeue" size:12] forRange:range]; + [description setFont:TGSystemFont(12) forRange:range]; NSMutableParagraphStyle *style = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; @@ -96,9 +96,9 @@ - (void) redrawRow { -(void)setFrameSize:(NSSize)newSize { [super setFrameSize:newSize]; - [self.resetSession setFrameOrigin:NSMakePoint( NSWidth(self.frame) - NSWidth(self.resetSession.frame) - 113, 18)]; + [self.resetSession setFrameOrigin:NSMakePoint( NSWidth(self.frame) - NSWidth(self.resetSession.frame) - 33, 18)]; - [self.textField setFrameSize:NSMakeSize(NSMinX(self.resetSession.frame) - 110, NSHeight(self.frame))]; + [self.textField setFrameSize:NSMakeSize(NSMinX(self.resetSession.frame) - 30, NSHeight(self.frame))]; } @@ -109,7 +109,7 @@ - (void)drawRect:(NSRect)dirtyRect [NSColorFromRGB(0xe0e0e0) setFill]; - NSRectFill(NSMakeRect(100, 0, NSWidth(self.frame) - 200, 1)); + NSRectFill(NSMakeRect(30, 0, NSWidth(self.frame) - 60, 1)); } diff --git a/TelegramTest/TGSessionsViewController.m b/TelegramTest/TGSessionsViewController.m index b6af2217..588ff91d 100644 --- a/TelegramTest/TGSessionsViewController.m +++ b/TelegramTest/TGSessionsViewController.m @@ -131,9 +131,7 @@ -(void)rebuild { [self.tableView removeAllItems:NO]; - GeneralSettingsBlockHeaderItem *selfHeader = [[GeneralSettingsBlockHeaderItem alloc] initWithObject:NSLocalizedString(@"AuthSessions.CurrentSession", nil)]; - - selfHeader.height = 62; + GeneralSettingsBlockHeaderItem *selfHeader = [[GeneralSettingsBlockHeaderItem alloc] initWithString:NSLocalizedString(@"AuthSessions.CurrentSession", nil) height:62 flipped:NO]; [self.tableView insert:selfHeader atIndex:self.tableView.count tableRedraw:NO]; @@ -142,12 +140,12 @@ -(void)rebuild { - GeneralSettingsRowItem *terminate = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(GeneralSettingsRowItem *item) { + GeneralSettingsRowItem *terminate = [[GeneralSettingsRowItem alloc] initWithType:SettingsRowItemTypeNext callback:^(TGGeneralRowItem *item) { [self terminateSessions]; - } description:NSLocalizedString(@"AuthSessions.TerminateOtherSessions", nil) height:42 stateback:^id(GeneralSettingsRowItem *item) { + } description:NSLocalizedString(@"AuthSessions.TerminateOtherSessions", nil) height:42 stateback:^id(TGGeneralRowItem *item) { return @([SettingsArchiver checkMaskedSetting:AutoGroupAudio]); }]; @@ -156,9 +154,8 @@ -(void)rebuild { if(self.authorizations.count > 0) { - GeneralSettingsBlockHeaderItem *otherHeader = [[GeneralSettingsBlockHeaderItem alloc] initWithObject:NSLocalizedString(@"AuthSessions.OtherSessions", nil)]; + GeneralSettingsBlockHeaderItem *otherHeader = [[GeneralSettingsBlockHeaderItem alloc] initWithString:NSLocalizedString(@"AuthSessions.OtherSessions", nil) height:62 flipped:NO]; - otherHeader.height = 62; [self.tableView insert:otherHeader atIndex:self.tableView.count tableRedraw:NO]; diff --git a/TelegramTest/TGSettingsTableView.h b/TelegramTest/TGSettingsTableView.h new file mode 100644 index 00000000..12434d24 --- /dev/null +++ b/TelegramTest/TGSettingsTableView.h @@ -0,0 +1,14 @@ +// +// TGSettingsTableView.h +// Telegram +// +// Created by keepcoder on 13.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TMTableView.h" +#import "GeneralSettingsRowView.h" +#import "GeneralSettingsBlockHeaderView.h" +@interface TGSettingsTableView : TMTableView + +@end diff --git a/TelegramTest/TGSettingsTableView.m b/TelegramTest/TGSettingsTableView.m new file mode 100644 index 00000000..e82395a9 --- /dev/null +++ b/TelegramTest/TGSettingsTableView.m @@ -0,0 +1,136 @@ +// +// TGSettingsTableView.m +// Telegram +// +// Created by keepcoder on 13.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TGSettingsTableView.h" +#import "TGGeneralRowItem.h" + +@interface TGSettingsTableView () + +@end + +@implementation TGSettingsTableView + +- (void)drawRect:(NSRect)dirtyRect { + [super drawRect:dirtyRect]; + + // Drawing code here. +} + + +- (void)setFrameSize:(NSSize)newSize { + + + + if([self inLiveResize]) { + NSRange visibleRows = [self rowsInRect:self.scrollView.contentView.bounds]; + if(visibleRows.length > 0) { + [NSAnimationContext beginGrouping]; + [[NSAnimationContext currentContext] setDuration:0]; + + NSMutableArray *array = [[NSMutableArray alloc] init]; + + NSInteger count = visibleRows.location + visibleRows.length; + for(NSInteger i = visibleRows.location; i < count; i++) { + + TGGeneralRowItem *item = (TGGeneralRowItem *)[self itemAtPosition:i]; + + if([item updateItemHeightWithWidth:newSize.width]) { + id view = [self viewAtColumn:0 row:i makeIfNecessary:NO]; + // if([view isKindOfClass:[MessageTableCellTextView class]]) { + if(view) + [array addObject:view]; + // } + } + } + + [self noteHeightOfRowsWithIndexesChanged:[NSIndexSet indexSetWithIndexesInRange:visibleRows]]; + + for(TGGeneralRowItem *cell in array) { + [cell redrawRow]; + } + + [NSAnimationContext endGrouping]; + } + + } else { + [self fixedResizeWithWidth:newSize.width]; + } + + [super setFrameSize:newSize]; +} + + + +- (void)fixedResizeWithWidth:(int)width { + + + [self.list enumerateObjectsUsingBlock:^(TGGeneralRowItem *item, NSUInteger idx, BOOL * _Nonnull stop) { + [item updateItemHeightWithWidth:width]; + }]; + +} +- (void)viewDidEndLiveResize { + + [self.list enumerateObjectsUsingBlock:^(TGGeneralRowItem *item, NSUInteger idx, BOOL * _Nonnull stop) { + [item updateItemHeightWithWidth:NSWidth(self.frame)]; + }]; + + [self reloadData]; + +} + +-(instancetype)initWithFrame:(NSRect)frameRect { + if(self = [super initWithFrame:frameRect]) { + self.tm_delegate = self; + } + + return self; +} + +- (CGFloat)rowHeight:(NSUInteger)row item:(TGGeneralRowItem *) item { + return item.height; +} + +- (BOOL)isGroupRow:(NSUInteger)row item:(TGGeneralRowItem *) item { + return NO; +} + +-(BOOL)addItem:(TGGeneralRowItem *)item tableRedraw:(BOOL)tableRedraw { + [item updateItemHeightWithWidth:NSWidth(self.frame)]; + return [super addItem:item tableRedraw:tableRedraw]; +} + +-(BOOL)insert:(NSArray *)array startIndex:(NSUInteger)startIndex tableRedraw:(BOOL)tableRedraw { + [array enumerateObjectsUsingBlock:^(TGGeneralRowItem *obj, NSUInteger idx, BOOL * _Nonnull stop) { + [obj updateItemHeightWithWidth:NSWidth(self.frame)]; + }]; + return [super insert:array startIndex:startIndex tableRedraw:tableRedraw]; +} + +-(BOOL)insert:(TGGeneralRowItem *)item atIndex:(NSUInteger)atIndex tableRedraw:(BOOL)tableRedraw { + [item updateItemHeightWithWidth:NSWidth(self.frame)]; + return [super insert:item atIndex:atIndex tableRedraw:tableRedraw]; +} + +- (TMRowView *)viewForRow:(NSUInteger)row item:(TGGeneralRowItem *) item { + return [self cacheViewForClass:[item viewClass] identifier:NSStringFromClass([item viewClass]) withSize:NSMakeSize(NSWidth(self.frame), [item height])]; +} + +- (void)selectionDidChange:(NSInteger)row item:(TGGeneralRowItem *) item { + +} + +- (BOOL)selectionWillChange:(NSInteger)row item:(TGGeneralRowItem *) item { + return NO; +} + +- (BOOL)isSelectable:(NSInteger)row item:(TGGeneralRowItem *) item { + return NO; +} + +@end diff --git a/TelegramTest/TGShareContactModalView.h b/TelegramTest/TGShareContactModalView.h new file mode 100644 index 00000000..ed0494ad --- /dev/null +++ b/TelegramTest/TGShareContactModalView.h @@ -0,0 +1,16 @@ +// +// TGShareContactModalView.h +// Telegram +// +// Created by keepcoder on 23.10.15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "TGModalView.h" + +@interface TGShareContactModalView : TGModalView +@property (nonatomic,weak) MessagesViewController *messagesViewController; + +@property (nonatomic,strong) TLUser *user; + +@end diff --git a/TelegramTest/TGShareContactModalView.m b/TelegramTest/TGShareContactModalView.m new file mode 100644 index 00000000..56572c71 --- /dev/null +++ b/TelegramTest/TGShareContactModalView.m @@ -0,0 +1,64 @@ +// +// TGShareContactModalView.m +// Telegram +// +// Created by keepcoder on 23.10.15. +// Copyright © 2015 keepcoder. All rights reserved. +// + +#import "TGShareContactModalView.h" +#import "SelectUsersTableView.h" +#import "MessageTableItem.h" + +@interface TGShareContactModalView () +@property (nonatomic,strong) SelectUsersTableView *tableView; +@end + +@implementation TGShareContactModalView + + +-(instancetype)initWithFrame:(NSRect)frameRect { + if(self = [super initWithFrame:frameRect]) { + [self setContainerFrameSize:NSMakeSize(300, 300)]; + + + [self initialize]; + } + + return self; +} + +-(void)initialize { + _tableView = [[SelectUsersTableView alloc] initWithFrame:NSMakeRect(0, 50, self.containerSize.width, self.containerSize.height - 50)]; + + _tableView.selectDelegate = self; + _tableView.selectLimit = 10; + + [self enableCancelAndOkButton]; + + [self addSubview:_tableView.containerView]; + + [_tableView readyConversations]; +} + +-(void)okAction { + + [_tableView.selectedItems enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + + TL_conversation *conversation = [obj isKindOfClass:[SelectUserItem class]] ? [[obj valueForKey:@"user"] dialog] : [[obj valueForKey:@"chat"] dialog]; + + [_messagesViewController shareContact:_user forConversation:conversation callback:nil]; + + }]; + + [self close:YES]; + +} + + +-(void)selectTableDidChangedItem:(id)item { + +} + + +@end diff --git a/TelegramTest/TGSharedLinkRowView.m b/TelegramTest/TGSharedLinkRowView.m index b0e12fa8..5416cb87 100644 --- a/TelegramTest/TGSharedLinkRowView.m +++ b/TelegramTest/TGSharedLinkRowView.m @@ -11,13 +11,25 @@ #import "TGWebpageContainer.h" #import "POPCGUtils.h" #import "TGEmbedModalView.h" +#import "TGSharedLinksTableView.h" @interface TGSharedLinkRowView () @property (nonatomic,strong) TGCTextView *textField; @property (nonatomic,strong) TMView *containerView; -@property (nonatomic,strong) TMTextField *linkField; +@property (nonatomic,strong) TMHyperlinkTextField *linkField; @property (nonatomic,strong) TGImageView *imageView; + +@property (nonatomic,assign,getter=isEditable,readonly) BOOL editable; + +@property (nonatomic,strong) BTRButton *selectButton; + +@property (nonatomic,strong) TMTextField *domainTextField; + +@property (nonatomic,strong) TMView *imageContainerView; + @end +#define s_lox 30 + @implementation TGSharedLinkRowView @@ -26,7 +38,8 @@ - (void)drawRect:(NSRect)dirtyRect { [DIALOG_BORDER_COLOR set]; - NSRectFill(NSMakeRect(12, 0, NSWidth(dirtyRect) - 24, 1)); + NSRectFill(NSMakeRect(72, 0, NSWidth(dirtyRect) - 24, 1)); + } -(instancetype)initWithFrame:(NSRect)frameRect { @@ -39,31 +52,28 @@ -(instancetype)initWithFrame:(NSRect)frameRect { _textField = [[TGCTextView alloc] initWithFrame:self.bounds]; - [_textField setEditable:YES]; + [_textField setEditable:NO]; [_containerView addSubview:_textField]; - - _linkField = [TMTextField defaultTextField]; + + _linkField = [TMHyperlinkTextField defaultTextField]; + [[_linkField cell] setLineBreakMode:NSLineBreakByTruncatingTail]; + [[_linkField cell] setTruncatesLastVisibleLine:YES]; [_linkField setFont:TGSystemFont(13)]; [_linkField setTextColor:LINK_COLOR]; [_linkField setFrameSize:NSMakeSize(0, 20)]; dispatch_block_t block = ^{ - open_link(_linkField.stringValue); + }; - [_linkField setClickBlock:^{ - - block(); - - }]; [_containerView addSubview:_linkField]; - _imageView = [[TGImageView alloc] initWithFrame:NSZeroRect]; + _imageView = [[TGImageView alloc] initWithFrame:NSMakeRect(0, 0, 50, 50)]; _imageView.cornerRadius = 4; @@ -88,55 +98,213 @@ -(instancetype)initWithFrame:(NSRect)frameRect { }; - [_imageView setTapBlock:^{ - embed(); - }]; - [self.containerView addSubview:_imageView]; + + self.imageContainerView = [[TMView alloc] initWithFrame:NSMakeRect(0, 0, 50, 50)]; + + [self.imageContainerView addSubview:_imageView]; + + + [self.containerView addSubview:self.imageContainerView]; + + _domainTextField = [TMTextField defaultTextField]; + + [_domainTextField setFont:TGSystemFont(20)]; + [_domainTextField setTextColor:[NSColor whiteColor]]; + + [_imageView addSubview:_domainTextField]; + + self.selectButton = [[BTRButton alloc] initWithFrame:NSMakeRect(-image_ComposeCheckActive().size.width, 0, image_ComposeCheckActive().size.width, image_ComposeCheckActive().size.height)]; + + [self.selectButton setBackgroundImage:image_ComposeCheck() forControlState:BTRControlStateNormal]; + [self.selectButton setBackgroundImage:image_ComposeCheck() forControlState:BTRControlStateHover]; + [self.selectButton setBackgroundImage:image_ComposeCheck() forControlState:BTRControlStateHighlighted]; + [self.selectButton setBackgroundImage:image_ComposeCheckActive() forControlState:BTRControlStateSelected]; + + [self.selectButton setUserInteractionEnabled:NO]; + + [self.selectButton setHidden:YES]; + [self.containerView addSubview:self.selectButton]; + } return self; } +static NSImage *sharedLinkCapImage() { + static NSImage *image = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + NSRect rect = NSMakeRect(0, 0, 50, 50); + image = [[NSImage alloc] initWithSize:rect.size]; + [image lockFocus]; + [NSColorFromRGB(0xf1f1f1) set]; + NSBezierPath *path = [NSBezierPath bezierPath]; + [path appendBezierPathWithRoundedRect:NSMakeRect(0, 0, rect.size.width, rect.size.height) xRadius:4 yRadius:4]; + [path fill]; + + [image unlockFocus]; + }); + return image; +} + -(void)setFrameSize:(NSSize)newSize { [super setFrameSize:newSize]; [_containerView setFrame:NSMakeRect(12, 0, newSize.width - 24, newSize.height)]; + [self.selectButton setCenteredYByView:self.containerView]; + + [_imageContainerView setFrameOrigin:NSMakePoint(self.isEditable ? s_lox : 0, NSHeight(self.containerView.frame) - 50 - 5)]; + + if(newSize.height < 80) + { + [_imageContainerView setCenteredYByView:_imageContainerView.superview]; + } } +-(void)mouseDown:(NSEvent *)theEvent { + if(self.isEditable) { + + TGDocumentsMediaTableView *table = (TGDocumentsMediaTableView *) self.item.table; + + [table setSelected:![table isSelectedItem:self.item] forItem:self.item]; + + [self setSelected:[table isSelectedItem:self.item]]; + } else { + if(((MessageTableItemText *)self.item).webpage != nil) { + open_link(_linkField.stringValue); + } + } +} + +-(NSString *)firstDomainCharacter { + + MessageTableItemText *item = (MessageTableItemText *)self.item; + + NSString *url; + + if(item.webpage) + url = item.webpage.webpage.url; + else + if(item.links.count > 0) + url = item.links[0]; + + if(url != nil) + { + + if(![url hasPrefix:@"http://"] && ![url hasPrefix:@"https://"] && ![url hasPrefix:@"ftp://"]) + return [[url substringToIndex:1] uppercaseString]; + + NSURLComponents *components = [[NSURLComponents alloc] initWithString:url]; + + return [[components.host substringToIndex:1] uppercaseString]; + } + + return @"L"; +} + + -(void)setItem:(MessageTableItemText *)item { [super setItem:item]; - [_textField setHidden:item.webpage == nil]; - [_imageView setHidden:item.webpage.imageObject == nil]; [_linkField setHidden:item.webpage == nil]; + + [_linkField setFrame:NSMakeRect(self.isEditable ? s_lox-2 + 60 : 60 , 5, NSWidth(_containerView.frame) - (self.isEditable ? s_lox + 60 : 65), 20)]; + + + + if(item.webpage) { [_textField setAttributedString:item.webpage.desc]; [_textField setFrameSize:item.webpage.descSize]; - [_textField setFrameOrigin:NSMakePoint(2, NSHeight(self.frame) - NSHeight(_textField.frame) - 5 )]; + [_textField setFrameOrigin:NSMakePoint(self.isEditable ? s_lox +60 : 62, NSHeight(self.frame) - NSHeight(_textField.frame) - 5 )]; + [_linkField setStringValue:item.webpage.webpage.url]; + [_imageView setObject:item.webpage.roundObject]; - [_linkField setStringValue:item.webpage.webpage.url]; + if(_textField.attributedString.string.length == 0) { + [_linkField setCenteredYByView:_linkField.superview]; + } + } else { + [_textField setAttributedString:item.allAttributedLinks]; + [_textField setFrameSize:item.allAttributedLinksSize]; - [_linkField setFrameOrigin:NSMakePoint(0, NSMinY(_textField.frame) - NSHeight(_linkField.frame))]; - [_linkField setFrameSize:NSMakeSize(NSWidth(_containerView.frame), 20)]; + [_textField setCenteredYByView:_textField.superview]; + [_textField setFrameOrigin:NSMakePoint(self.isEditable ? s_lox +60 : 62, NSMinY(_textField.frame))]; - [_imageView setObject:item.webpage.imageObject]; - [_imageView setFrame:NSMakeRect(NSWidth(self.containerView.frame) - 50, NSHeight(self.containerView.frame) - 50 - 5, 50, 50)]; } + if(!item.webpage.imageObject) + self.imageView.image = sharedLinkCapImage(); + + + [_domainTextField setHidden:item.webpage.imageObject != nil]; + + [_domainTextField setStringValue:[self firstDomainCharacter]]; + [_domainTextField sizeToFit]; + [_domainTextField setCenterByView:_imageView]; + } -(void)setEditable:(BOOL)editable animated:(BOOL)animated { + [self.selectButton setSelected:self.isSelected]; + + [_textField setDisableLinks:editable]; + + if(animated) { + + [self.selectButton setHidden:NO]; + + [self.selectButton setAlphaValue:1]; + + if(editable){ + [self.selectButton setAlphaValue:0]; + } + + [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) { + + [context setDuration:0.2]; + + + [[self.textField animator] setFrameOrigin:NSMakePoint(editable ? s_lox + 60 : 62, NSMinY(self.textField.frame))]; + [[self.imageContainerView animator] setFrameOrigin:NSMakePoint(editable ? s_lox : 0, NSMinY(self.imageContainerView.frame))]; + [[self.linkField animator] setFrame:NSMakeRect(editable ? s_lox-2 + 60 : 60 , NSMinY(self.linkField.frame), NSWidth(_containerView.frame) - (self.isEditable ? s_lox + 60 : 65), NSHeight(self.linkField.frame))]; + [[self.selectButton animator] setFrameOrigin:NSMakePoint(self.isEditable ? 0 : -NSWidth(self.selectButton.frame), NSMinY(self.selectButton.frame))]; + + [[self.selectButton animator] setAlphaValue:editable ? 1 : 0]; + + } completionHandler:^{ + [self setItem:self.item]; + }]; + + + + + } else { + [self setItem:self.item]; + } + +} + +-(BOOL)isEditable { + return [(TGSharedLinksTableView *)self.item.table isEditable]; +} + +-(void)setSelected:(BOOL)selected { + [self.selectButton setSelected:selected]; +} + +-(BOOL)isSelected { + return [(TGSharedLinksTableView *)self.item.table isSelectedItem:self.item]; } -(void)_didChangeBackgroundColorWithAnimation:(POPBasicAnimation *)anim toColor:(NSColor *)color { @@ -166,6 +334,7 @@ -(void)_didChangeBackgroundColorWithAnimation:(POPBasicAnimation *)anim toColor: animation.toValue = anim.toValue; animation.fromValue = anim.fromValue; animation.duration = anim.duration; + animation.removedOnCompletion = YES; [self.textField pop_addAnimation:animation forKey:@"background"]; } diff --git a/TelegramTest/TGSharedLinksTableView.m b/TelegramTest/TGSharedLinksTableView.m index 7fbdfea8..252d2f34 100644 --- a/TelegramTest/TGSharedLinksTableView.m +++ b/TelegramTest/TGSharedLinksTableView.m @@ -20,7 +20,7 @@ - (void)drawRect:(NSRect)dirtyRect { -(instancetype)initWithFrame:(NSRect)frameRect { if(self = [super initWithFrame:frameRect]) { - [Notification addObserver:self selector:@selector(didChangeUpdateWebpage:) name:UPDATE_WEB_PAGES]; + [Notification addObserver:self selector:@selector(didChangeUpdateWebpage:) name:UPDATE_WEB_PAGE_ITEMS]; } return self; @@ -32,6 +32,28 @@ -(void)dealloc { -(void)didChangeUpdateWebpage:(NSNotification *)notification { + NSArray *ids = notification.userInfo[KEY_MESSAGE_ID_LIST]; + + if(self.items.count <= 1) + return; + + NSArray *items = [self.items filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.message.n_id IN %@",ids]]; + + [items enumerateObjectsUsingBlock:^(MessageTableItemText *obj, NSUInteger idx, BOOL *stop) { + + [obj updateWebPage]; + + NSUInteger index = [self indexOfItem:obj]; + + if(index != NSNotFound) { + [self noteHeightOfRowsWithIndexesChanged:[NSIndexSet indexSetWithIndex:index]]; + + [self reloadDataForRowIndexes:[NSIndexSet indexSetWithIndex:index] columnIndexes:[NSIndexSet indexSetWithIndex:0]]; + } + + + }]; + } @@ -43,21 +65,30 @@ -(Class)historyFilter { } -(BOOL)acceptMessageItem:(MessageTableItem *)item { - return [item isKindOfClass:[MessageTableItemText class]] && ((MessageTableItemText *)item).webpage != nil; + return [item isKindOfClass:[MessageTableItemText class]]; } -(int)heightWithItem:(MessageTableItemText *)item { - return MAX(item.webpage.descSize.height+30, 60); + return item.webpage ? MAX(item.webpage.descSize.height+30, 60) : MAX(item.allAttributedLinksSize.height + 10, 60); } -(NSPredicate *)searchPredicateWithString:(NSString *)string { return [NSPredicate predicateWithBlock:^BOOL(MessageTableItemText *evaluatedObject, NSDictionary *bindings) { - return [evaluatedObject.webpage.webpage.title searchInStringByWordsSeparated:string] || [evaluatedObject.webpage.webpage.n_description searchInStringByWordsSeparated:string] || [evaluatedObject.webpage.webpage.site_name searchInStringByWordsSeparated:string]; + if(evaluatedObject.webpage) + { + return [evaluatedObject.webpage.webpage.title searchInStringByWordsSeparated:string] || [evaluatedObject.webpage.webpage.n_description searchInStringByWordsSeparated:string] || [evaluatedObject.webpage.webpage.site_name searchInStringByWordsSeparated:string]; + } + + return [evaluatedObject.allAttributedLinks.string containsString:string]; }]; } +-(id)remoteFilter { + return [TL_inputMessagesFilterUrl create]; +} + - (void)prepareItem:(MessageTableItemText *)item { // [item.webpage makeSize:NSWidth(self.scrollView)-24]; } diff --git a/TelegramTest/TGSharedMediaCap.m b/TelegramTest/TGSharedMediaCap.m index fbbe2f16..fbd303c3 100644 --- a/TelegramTest/TGSharedMediaCap.m +++ b/TelegramTest/TGSharedMediaCap.m @@ -54,7 +54,7 @@ -(instancetype)initWithFrame:(NSRect)frameRect cap:(NSImage *)cap text:(NSString [self.capTextField setStringValue:text]; - [self.capTextField setFont:[NSFont fontWithName:@"HelveticaNeue" size:14]]; + [self.capTextField setFont:TGSystemFont(14)]; [self.capTextField setTextColor:GRAY_TEXT_COLOR]; [self.capTextField sizeToFit]; @@ -73,12 +73,12 @@ -(instancetype)initWithFrame:(NSRect)frameRect cap:(NSImage *)cap text:(NSString -(void)setProgress:(BOOL)progress { _progress = progress; - [_progressIndicator setHidden:!progress]; + [_progressIndicator setHidden:YES]; - if(progress) - [_progressIndicator startAnimation:self]; - else - [_progressIndicator stopAnimation:self]; +// if(progress) +// [_progressIndicator startAnimation:self]; +// else +// [_progressIndicator stopAnimation:self]; [_capImageView setHidden:progress]; [_capTextField setHidden:progress]; diff --git a/TelegramTest/TGSplitView.m b/TelegramTest/TGSplitView.m index 62d55fd8..0dac194f 100644 --- a/TelegramTest/TGSplitView.m +++ b/TelegramTest/TGSplitView.m @@ -12,7 +12,7 @@ @interface TGSplitView () { NSMutableDictionary *_proportions; NSMutableDictionary *_startSize; - TGView *_containerView; + // TGView *self; NSMutableArray *_controllers; BOOL _isSingleLayout; NSMutableDictionary *_layoutProportions; @@ -32,8 +32,8 @@ -(instancetype)initWithFrame:(NSRect)frameRect { _startSize = [[NSMutableDictionary alloc] init]; _layoutProportions = [[NSMutableDictionary alloc] init]; _canChangeState = YES; - _containerView = [[TGView alloc] initWithFrame:self.bounds]; - [self addSubview:_containerView]; + // self = [[TGView alloc] initWithFrame:self.bounds]; + // [self addSubview:self]; _state = -1; @@ -52,7 +52,7 @@ -(void)addController:(TGViewController *)controller proportion:(struct TGSplitPr assert([NSThread isMainThread] && controller.view.superview == nil); - [_containerView addSubview:controller.view]; + [self addSubview:controller.view]; [_controllers addObject:controller]; @@ -72,29 +72,28 @@ -(void)update { -(void)setFrameSize:(NSSize)newSize { [super setFrameSize:newSize]; - [_containerView setFrameSize:newSize]; - struct TGSplitProportion singleLayout = {0,0}; - struct TGSplitProportion dualLayout = {0,0}; + struct TGSplitProportion singleLayout = {380,300+380}; + struct TGSplitProportion dualLayout = {300+380,FLT_MAX}; struct TGSplitProportion tripleLayout = {0,0}; - [_layoutProportions[@(TGSplitViewStateSingleLayout)] getValue:&singleLayout]; - [_layoutProportions[@(TGSplitViewStateDualLayout)] getValue:&dualLayout]; + // [_layoutProportions[@(TGSplitViewStateSingleLayout)] getValue:&singleLayout]; + // [_layoutProportions[@(TGSplitViewStateDualLayout)] getValue:&dualLayout]; [_layoutProportions[@(TGSplitViewStateTripleLayout)] getValue:&tripleLayout]; if(isAcceptLayout(singleLayout) && _canChangeState) { - if(_state != TGSplitViewStateSingleLayout && NSWidth(_containerView.frame) < singleLayout.max ) + if(_state != TGSplitViewStateSingleLayout && NSWidth(self.frame) < singleLayout.max ) self.state = TGSplitViewStateSingleLayout; if(isAcceptLayout(dualLayout)) { if(isAcceptLayout(tripleLayout)) { - if(_state != TGSplitViewStateDualLayout && NSWidth(_containerView.frame) > dualLayout.min && NSWidth(_containerView.frame) < tripleLayout.min) + if(_state != TGSplitViewStateDualLayout && NSWidth(self.frame) > dualLayout.min && NSWidth(self.frame) < tripleLayout.min) self.state = TGSplitViewStateDualLayout; else self.state = TGSplitViewStateTripleLayout; } else - if(_state != TGSplitViewStateDualLayout && NSWidth(_containerView.frame) > dualLayout.min) + if(_state != TGSplitViewStateDualLayout && NSWidth(self.frame) > dualLayout.min) self.state = TGSplitViewStateDualLayout; } } @@ -110,7 +109,7 @@ -(void)setFrameSize:(NSSize)newSize { NSSize startSize = [_startSize[obj.internalId] sizeValue]; - NSSize size = NSMakeSize(x, NSHeight(_containerView.frame)); + NSSize size = NSMakeSize(x, NSHeight(self.frame)); int min = startSize.width; @@ -120,14 +119,14 @@ -(void)setFrameSize:(NSSize)newSize { min = proportion.min; } else if(startSize.width > proportion.max) { - min = NSWidth(_containerView.frame) - x; + min = NSWidth(self.frame) - x; } if(idx == _controllers.count - 1) - min = NSWidth(_containerView.frame) - x; + min = NSWidth(self.frame) - x; - size = NSMakeSize(x + min > NSWidth(_containerView.frame) ? (NSWidth(_containerView.frame) - x) : min, NSHeight(_containerView.frame)); + size = NSMakeSize(x + min > NSWidth(self.frame) ? (NSWidth(self.frame) - x) : min, NSHeight(self.frame)); NSRect rect = NSMakeRect(x, 0, size.width, size.height); @@ -168,7 +167,7 @@ -(void)removeController:(TGViewController *)controller { assert([NSThread isMainThread]); if(idx != NSNotFound) { - [_containerView.subviews[idx] removeFromSuperview]; + [self.subviews[idx] removeFromSuperview]; [_controllers removeObjectAtIndex:idx]; [_startSize removeObjectForKey:controller.internalId]; [_proportions removeObjectForKey:controller.internalId]; @@ -177,7 +176,7 @@ -(void)removeController:(TGViewController *)controller { } -(void)removeAllControllers { - [_containerView removeAllSubviews]; + [self removeAllSubviews]; [_controllers removeAllObjects]; [_startSize removeAllObjects]; [_proportions removeAllObjects]; @@ -216,7 +215,7 @@ -(void)mouseDown:(NSEvent *)theEvent { _splitIdx = 0; _splitSuccess = NO; - [_containerView.subviews enumerateObjectsUsingBlock:^(TGView *obj, NSUInteger idx, BOOL *stop) { + [self.subviews enumerateObjectsUsingBlock:^(TGView *obj, NSUInteger idx, BOOL *stop) { if(fabs(_startPoint.x - NSMaxX(obj.frame)) <= 10) { diff --git a/TelegramTest/TGStickerPackEmojiController.h b/TelegramTest/TGStickerPackEmojiController.h index e2101961..14044bef 100644 --- a/TelegramTest/TGStickerPackEmojiController.h +++ b/TelegramTest/TGStickerPackEmojiController.h @@ -15,5 +15,6 @@ @property (nonatomic,strong,readonly) TGAllStickersTableView *stickers; -(void)reload; +-(void)removeAllItems; @end diff --git a/TelegramTest/TGStickerPackEmojiController.m b/TelegramTest/TGStickerPackEmojiController.m index 6fee5f34..eafc99c7 100644 --- a/TelegramTest/TGStickerPackEmojiController.m +++ b/TelegramTest/TGStickerPackEmojiController.m @@ -106,9 +106,16 @@ -(instancetype)initWithFrame:(NSRect)frameRect { _stickers = [[TGAllStickersTableView alloc] initWithFrame:NSMakeRect(0, 0, NSWidth(frameRect), NSHeight(frameRect) - 44)]; + + [_stickers setDidNeedReload:^{ + + [weakSelf reload:NO]; + + }]; + [self addSubview:_stickers.containerView]; - [self addScrollEvent]; + [self addScrollEvent]; } @@ -116,6 +123,8 @@ -(instancetype)initWithFrame:(NSRect)frameRect { } + + - (void) addScrollEvent { id clipView = [[_stickers enclosingScrollView] contentView]; [[NSNotificationCenter defaultCenter] addObserver:self @@ -152,11 +161,19 @@ -(void)scrollViewDocumentOffsetChangingNotificationHandler:(NSNotification *)not } - +-(void)removeAllItems { + [_stickers removeAllItems:NO]; + [_stickers reloadData]; +} -(void)reload { + [self reload:YES]; +} + +-(void)reload:(BOOL)reloadStickers { - [_stickers load:NO]; + if(reloadStickers) + [_stickers load:NO]; NSArray *stickers = [_stickers allStickers]; @@ -201,6 +218,10 @@ -(void)reload { [self drawWithStickers:sets]; + + [self.stickers scrollToBeginningOfDocument:nil]; + if(_packsContainerView.subviews.count > 0 && reloadStickers) + [self didSelected:_packsContainerView.subviews[0] scrollToPack:NO selectItem:YES]; } -(void)drawWithStickers:(NSArray *)stickers { @@ -214,7 +235,7 @@ -(void)drawWithStickers:(NSArray *)stickers { __block int x = 0; - float itemWidth = MAX(roundf(NSWidth(self.frame)/stickers.count),48); + float itemWidth = MAX(roundf(NSWidth(self.frame)/(stickers.count + 1)),48); [stickers enumerateObjectsUsingBlock:^(TLDocument *obj, NSUInteger idx, BOOL *stop) { @@ -259,6 +280,22 @@ -(void)drawWithStickers:(NSArray *)stickers { }]; + if(self.stickers.sets.count > 1) { + TGStickerPackButton *button = [[TGStickerPackButton alloc] initWithFrame:NSMakeRect(x, 0, itemWidth, 44)]; + + button.packId = -2; + button.delegate = self; + [button.imageView setContentMode:BTRViewContentModeCenter]; + button.imageView.image = image_StickerSettings(); + + [_packsContainerView addSubview:button]; + + x+=itemWidth; + } + + + + [_packsContainerView setFrameSize:NSMakeSize(x, NSHeight(_packsContainerView.frame))]; } @@ -272,6 +309,21 @@ -(void)selectItem:(TGStickerPackButton *)button { -(void)didSelected:(TGStickerPackButton *)button scrollToPack:(BOOL)scrollToPack selectItem:(BOOL)selectItem { + if(button.packId == -2) { + + if(selectItem) { + [self selectItem:button]; + } + + TGStickersSettingsViewController *settingViewController = [[TGStickersSettingsViewController alloc] initWithFrame:NSZeroRect]; + + [[EmojiViewController instance].messagesViewController.navigationViewController pushViewController:settingViewController animated:YES]; + + [[EmojiViewController instance] close]; + + return; + } + [self removeScrollEvent]; if(selectItem) { diff --git a/TelegramTest/TGStickerPackModalView.m b/TelegramTest/TGStickerPackModalView.m index 7f885161..0bce3c1d 100644 --- a/TelegramTest/TGStickerPackModalView.m +++ b/TelegramTest/TGStickerPackModalView.m @@ -219,24 +219,10 @@ -(void)setStickerPack:(TL_messages_stickerSet *)stickerPack { [_tableView showWithStickerPack:stickerPack]; - __block BOOL packIsset = NO; + __block BOOL packIsset = [EmojiViewController setWithId:stickerPack.set.n_id] != nil; - __block TLDocument *headerSticker; - - [[stickerPack documents] enumerateObjectsUsingBlock:^(TLDocument *obj, NSUInteger idx, BOOL *stop) { - - if(idx == 0) - headerSticker = obj; - - NSArray *filter = [[EmojiViewController allStickers] filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.n_id == %ld",obj.n_id]]; - - if(filter.count > 0) { - packIsset = YES; - *stop = YES; - } - - }]; + __block TLDocument *headerSticker = [stickerPack.documents firstObject]; NSUInteger dif = ceil((float)stickerPack.documents.count/5.0); @@ -269,6 +255,10 @@ -(void)setStickerPack:(TL_messages_stickerSet *)stickerPack { [_addButton setTitle:[NSString stringWithFormat:NSLocalizedString(@"StickerPack.AddStickerPack", nil),stickerPack.documents.count] forControlState:BTRControlStateNormal]; + _addButton.heightBugFix = 3; + + [_addButton setTitleFont:TGSystemBoldFont(14) forControlState:BTRControlStateNormal]; + [_addButton setBackgroundImage:greenBackgroundImage(NSMakeSize(130, 27)) forControlState:BTRControlStateNormal]; diff --git a/TelegramTest/TGStickersSettingsViewController.h b/TelegramTest/TGStickersSettingsViewController.h index 8a34bcd6..4ca8e0ad 100644 --- a/TelegramTest/TGStickersSettingsViewController.h +++ b/TelegramTest/TGStickersSettingsViewController.h @@ -7,7 +7,7 @@ // #import "TMViewController.h" - -@interface TGStickersSettingsViewController : TMViewController +#import "ComposeViewController.h" +@interface TGStickersSettingsViewController : ComposeViewController @end diff --git a/TelegramTest/TGStickersSettingsViewController.m b/TelegramTest/TGStickersSettingsViewController.m index 23558510..b4650e68 100644 --- a/TelegramTest/TGStickersSettingsViewController.m +++ b/TelegramTest/TGStickersSettingsViewController.m @@ -13,6 +13,8 @@ #import "EmojiViewController.h" #import "TGMessagesStickerImageObject.h" #import "TGStickerPackModalView.h" +#import "ComposeActionStickersBehavior.h" +#import "TGMovableTableView.h" @@ -28,13 +30,23 @@ @interface TGStickerPackRowItem : TMRowItem @interface TGStickerPackRowView : TMRowView @property (nonatomic,strong) TMTextField *titleField; @property (nonatomic,strong) TGImageView *imageView; -@property (nonatomic,strong) TMTextButton *removeButton; +@property (nonatomic,strong) TMView *imageContainerView; + +@property (nonatomic,strong) BTRButton *deletePack; +@property (nonatomic,strong) NSImageView *reorderPack; +@property (nonatomic,strong) BTRButton *disablePack; + + +@property (nonatomic,strong) TMView *separator; + +-(void)setEditable:(BOOL)editable animated:(BOOL)animated; + @property (nonatomic,weak) TGStickersSettingsViewController *controller; @end -@interface TGStickersSettingsViewController () -@property (nonatomic,strong) TMTableView *tableView; - +@interface TGStickersSettingsViewController () +@property (nonatomic,strong) TGMovableTableView *tableView; +@property (nonatomic,assign) BOOL needSaveOrder; -(void)removeStickerPack:(TGStickerPackRowItem *)item; @@ -102,33 +114,41 @@ @implementation TGStickerPackRowView -(instancetype)initWithFrame:(NSRect)frameRect { if (self = [super initWithFrame:frameRect]) { + + _titleField = [TMTextField defaultTextField]; - [[_titleField cell] setTruncatesLastVisibleLine:NO]; + [[_titleField cell] setTruncatesLastVisibleLine:YES]; [self addSubview:_titleField]; - _imageView = [[TGImageView alloc] initWithFrame:NSMakeRect(0, 0, 35, 35)]; - - [self addSubview:_imageView]; + _imageContainerView = [[TMView alloc] initWithFrame:NSMakeRect(0, 0, 35, 35)]; - _removeButton = [TMTextButton standartUserProfileButtonWithTitle:NSLocalizedString(@"Remove", nil)]; + [self addSubview:_imageContainerView]; - [_removeButton setFont:TGSystemFont(14)]; - [_removeButton setTextColor:BLUE_UI_COLOR]; + _imageView = [[TGImageView alloc] initWithFrame:NSMakeRect(0, 0, 35, 35)]; - [_removeButton sizeToFit]; + [_imageContainerView addSubview:_imageView]; weak(); - [_removeButton setTapBlock:^ { - + _deletePack = [[BTRButton alloc] initWithFrame:NSMakeRect(0, 0, image_ModernMenuDeleteIcon().size.width, image_ModernMenuDeleteIcon().size.height)]; + [_deletePack setImage:image_ModernMenuDeleteIcon() forControlState:BTRControlStateNormal]; + + [_deletePack addBlock:^(BTRControlEvents events) { [weakSelf.controller removeStickerPack:(TGStickerPackRowItem *)[weakSelf rowItem]]; - - }]; + } forControlEvents:BTRControlEventClick]; + + [self addSubview:_deletePack]; - [_removeButton setCenterByView:self]; - [self addSubview:_removeButton]; + _reorderPack = imageViewWithImage(image_AudioPlayerList()); + + [self addSubview:_reorderPack]; + + + _separator = [[TMView alloc] initWithFrame:NSMakeRect(30, 0, NSWidth(frameRect) - 60, DIALOG_BORDER_WIDTH)]; + _separator.backgroundColor = DIALOG_BORDER_COLOR; + [self addSubview:_separator]; } @@ -136,6 +156,19 @@ -(instancetype)initWithFrame:(NSRect)frameRect { } +-(void)mouseDown:(NSEvent *)theEvent { + + TGMovableTableView *tableView = ((TGMovableTableView *)[self rowItem].table); + + if([self mouse:[self convertPoint:[theEvent locationInWindow] fromView:nil] inRect:_reorderPack.frame] && [[self rowItem] isEditable]) { + [tableView startMoveItemAtIndex:[tableView indexOfObject:[self rowItem]]]; + } else { + if(![[self rowItem] isEditable]) { + [tableView.mdelegate selectionDidChange:[tableView indexOfObject:[self rowItem]] item:[self rowItem]]; + } + } +} + -(void)redrawRow { [super redrawRow]; @@ -147,30 +180,65 @@ -(void)redrawRow { [_titleField setCenterByView:self]; - - [_imageView setFrameSize:item.imageObject.imageSize]; _imageView.object = item.imageObject; + [_deletePack setHidden:(item.set.flags & (1 << 2)) == (1 << 2)]; - [_removeButton setHidden:(item.set.flags & (1 << 2)) == (1 << 2)]; } -(void)setFrameSize:(NSSize)newSize { [super setFrameSize:newSize]; - [_removeButton setFrameOrigin:NSMakePoint(newSize.width - 100 - NSWidth(_removeButton.frame), 17)]; - [_titleField setFrameOrigin:NSMakePoint(100, 8)]; - [_imageView setFrameOrigin:NSMakePoint( roundf((50 -NSWidth(_imageView.frame))/2) + 50, 5)]; + [_titleField setFrameOrigin:NSMakePoint(80, 8)]; + [_titleField setFrameSize:NSMakeSize(newSize.width - 140, NSHeight(_titleField.frame))]; + [_deletePack setCenteredYByView:_deletePack.superview]; + [_reorderPack setCenteredYByView:_deletePack.superview]; + [_imageContainerView setCenteredYByView:_imageContainerView.superview]; + [self updatePositionAnimated:NO]; + } --(void)drawRect:(NSRect)dirtyRect { +-(void)setEditable:(BOOL)editable animated:(BOOL)animated { - [DIALOG_BORDER_COLOR setFill]; + [self updatePositionAnimated:animated]; +} + + +-(void)updatePositionAnimated:(BOOL)animated { + + TMRowItem *item = [self rowItem]; + + id deleteView = animated ? [_deletePack animator] : _deletePack; + id titleView = animated ?[_titleField animator] : _titleField; + id imageView = animated ? [_imageContainerView animator] : _imageContainerView; + id separatorView = animated ? [_separator animator] : _separator; + id reoderView = animated ? [_reorderPack animator] : _reorderPack; + + int defImageX = roundf((30 -NSWidth(_imageContainerView.frame))/2) + 30; + + + int defTitleX = item.isEditable ? 80 + NSWidth(_deletePack.frame) - 2: 80-2; + + [deleteView setFrameOrigin:NSMakePoint(item.isEditable ? 10 : - NSWidth(_deletePack.frame), NSMinY(_deletePack.frame))]; + [titleView setFrameOrigin:NSMakePoint(defTitleX , NSMinY(_titleField.frame))]; + [imageView setFrameOrigin:NSMakePoint(item.isEditable ? defImageX + NSWidth(_deletePack.frame) : defImageX, NSMinY(_imageContainerView.frame))]; + + [_reorderPack setFrameOrigin:NSMakePoint(NSWidth(self.frame) - 30 - NSWidth(_reorderPack.frame), roundf((NSHeight(self.frame) - NSHeight(_reorderPack.frame))/2))]; - NSRectFill(NSMakeRect(100, 0, NSWidth(dirtyRect) - 200, DIALOG_BORDER_WIDTH)); + [reoderView setAlphaValue:item.isEditable ? 1 : 0]; + [deleteView setAlphaValue:item.isEditable ? 1 : 0]; + [separatorView setFrame:NSMakeRect(defTitleX, 0, NSWidth(self.frame) - defTitleX - 30, DIALOG_BORDER_WIDTH)]; +} + +-(void)drawRect:(NSRect)dirtyRect { + + [[NSColor whiteColor] set]; + NSRectFill(dirtyRect); + [_separator setHidden:self.dragInSuperView]; + } @end @@ -186,98 +254,163 @@ -(void)loadView { [self setCenterBarViewText:NSLocalizedString(@"Sticker.StickerSettings", nil)]; - _tableView = [[TMTableView alloc] initWithFrame:self.view.bounds]; + _tableView = [[TGMovableTableView alloc] initWithFrame:self.view.bounds]; + + [self.view addSubview:_tableView]; - [self.view addSubview:_tableView.containerView]; + _tableView.mdelegate = self; - _tableView.tm_delegate = self; +} + + +-(void)stickersNeedFullReload:(NSNotification *)notification { + [self reload]; +} + +-(void)stickersNeedReorder:(NSNotification *)notification { + + [self reload]; +} + +-(void)stickersNewPackAdded:(NSNotification *)notification { + TL_messages_stickerSet *set = notification.userInfo[KEY_STICKERSET]; + + TGStickerPackRowItem *item = [[TGStickerPackRowItem alloc] initWithObject:@{@"set":set.set,@"stickers":set.documents}]; + + [_tableView insertItem:item atIndex:0]; + +} + + + + +-(void)didUpdatedEditableState { + [super didUpdatedEditableState]; + + [_tableView enumerateAvailableRowViewsUsingBlock:^(__kindof TMRowView *rowView, TMRowItem *rowItem, NSInteger row) { + + TGStickerPackRowView *view = (TGStickerPackRowView *)rowView; + + [rowItem setEditable:self.action.isEditable]; + + [view setEditable:rowItem.isEditable animated:YES]; + + }]; + + if(!self.action.isEditable && _needSaveOrder) { + dispatch_after_seconds(0.2, ^{ + [self saveOrder]; + }); + + } +} + +-(void)saveOrder { + NSMutableArray *reoder = [NSMutableArray array]; + + [_tableView enumerateAvailableRowViewsUsingBlock:^(__kindof TMRowView *rowView, TMRowItem *rowItem, NSInteger row) { + + TGStickerPackRowItem *item = (TGStickerPackRowItem *)rowItem; + + [reoder addObject:@(item.set.n_id)]; + + }]; + + [Notification perform:STICKERS_REORDER data:@{KEY_ORDER:reoder}]; + + [RPCRequest sendRequest:[TLAPI_messages_reorderStickerSets createWithOrder:reoder] successHandler:^(id request, id response) { + + + } errorHandler:^(id request, RpcError *error) { + + + + }]; + + _needSaveOrder = NO; + } -(void)viewWillAppear:(BOOL)animated { + + [self setAction:[[ComposeAction alloc] initWithBehaviorClass:[ComposeActionStickersBehavior class]]]; + + [super viewWillAppear:animated]; - NSArray *stickers = [EmojiViewController allStickers]; + _needSaveOrder = NO; + [Notification addObserver:self selector:@selector(stickersNeedFullReload:) name:STICKERS_ALL_CHANGED]; + [Notification addObserver:self selector:@selector(stickersNeedReorder:) name:STICKERS_REORDER]; + [Notification addObserver:self selector:@selector(stickersNewPackAdded:) name:STICKERS_NEW_PACK]; - NSMutableDictionary *packs = [[NSMutableDictionary alloc] init]; + [self reload]; +} + + +-(void)viewWillDisappear:(BOOL)animated { + [super viewWillDisappear:animated]; + + [Notification removeObserver:self]; + + if(_needSaveOrder) { + [self saveOrder]; + } +} + +-(void)reload { + NSMutableArray *packSets = [NSMutableArray array]; NSArray *sets = [EmojiViewController allSets]; - [stickers enumerateObjectsUsingBlock:^(TL_document *obj, NSUInteger idx, BOOL *stop) { + + [sets enumerateObjectsUsingBlock:^(TL_stickerSet *set, NSUInteger setIdx, BOOL * _Nonnull setStop) { + NSDictionary *val = @{@"stickers":[EmojiViewController stickersWithId:set.n_id],@"set":set}; - if(obj.class == TL_document.class) { - - TL_documentAttributeSticker *attr = (TL_documentAttributeSticker *) [obj attributeWithClass:TL_documentAttributeSticker.class]; - - if(attr) { - NSMutableArray *p = [packs objectForKey:@(attr.stickerset.n_id)][@"stickers"]; - - if(!p) { - p = [[NSMutableArray alloc] init]; - - NSArray *f = [sets filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.n_id == %ld",attr.stickerset.n_id]]; - - id set; - - if(f.count == 1) - set = f[0]; - else - set = [TL_stickerSet createWithFlags:4 n_id:0 access_hash:0 title:@"Great Minds" short_name:@"" n_count:0 n_hash:0]; - - [packs setObject:@{@"stickers":p,@"set":set} forKey:@(attr.stickerset.n_id)]; - } - - [p addObject:obj]; - - } - - } + [packSets addObject:val]; }]; - [self reloadDataWithPacks:packs.allValues]; + + + [self reloadDataWithPacks:packSets]; } -(void)reloadDataWithPacks:(NSArray *)packs { - [_tableView removeAllItems:YES]; + [_tableView removeAllItems]; + + NSMutableArray *items = [[NSMutableArray alloc] init]; [packs enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { TGStickerPackRowItem *item = [[TGStickerPackRowItem alloc] initWithObject:obj]; - - [_tableView insert:item atIndex:_tableView.count tableRedraw:NO]; + item.editable = self.action.isEditable; + [items addObject:item]; }]; - GeneralSettingsBlockHeaderItem *description = [[GeneralSettingsBlockHeaderItem alloc] initWithObject:NSLocalizedString(@"Stickers.StickersSetDescription", nil)]; - - description.isFlipped = YES; - description.height = 150; - - [_tableView insert:description atIndex:_tableView.count tableRedraw:NO]; + [_tableView addItems:items]; - [_tableView reloadData]; } -(void)removeStickerPack:(TGStickerPackRowItem *)item { + + confirm(appName(), [NSString stringWithFormat:NSLocalizedString(@"Stickers.RemoveStickerAlert", nil),[item.pack[@"set"] title]], ^{ [self showModalProgress]; [RPCRequest sendRequest:[TLAPI_messages_uninstallStickerSet createWithStickerset:item.inputSet] successHandler:^(id request, id response) { - _tableView.defaultAnimation = NSTableViewAnimationEffectFade; - - [_tableView removeItem:item]; - _tableView.defaultAnimation = NSTableViewAnimationEffectNone; + [_tableView removeItemAtIndex:[_tableView indexOfObject:item] animated:YES]; [EmojiViewController reloadStickers]; @@ -292,6 +425,12 @@ -(void)removeStickerPack:(TGStickerPackRowItem *)item { } +-(void)tableViewDidChangeOrder { + + + _needSaveOrder = YES; +} + - (CGFloat)rowHeight:(NSUInteger)row item:(TMRowItem *) item { return [item isKindOfClass:[GeneralSettingsBlockHeaderItem class]] ? ((GeneralSettingsBlockHeaderItem *)item).height : 50; } @@ -303,10 +442,10 @@ - (BOOL)isGroupRow:(NSUInteger)row item:(TMRowItem *) item { - (TMRowView *)viewForRow:(NSUInteger)row item:(TMRowItem *) item { if([item isKindOfClass:[GeneralSettingsBlockHeaderItem class]]) { - return [self.tableView cacheViewForClass:[GeneralSettingsBlockHeaderView class] identifier:@"GeneralSettingsBlockHeaderView"]; + return [[GeneralSettingsBlockHeaderView alloc] initWithFrame:NSZeroRect]; } - TGStickerPackRowView *view = (TGStickerPackRowView *)[_tableView cacheViewForClass:[TGStickerPackRowView class] identifier:@"TGStickerPackRowView" withSize:NSMakeSize(NSWidth(self.view.frame), 42)]; + TGStickerPackRowView *view = [[TGStickerPackRowView alloc] initWithFrame:NSZeroRect]; view.controller = self; @@ -317,9 +456,7 @@ - (void)selectionDidChange:(NSInteger)row item:(TGStickerPackRowItem *) item { if([item isKindOfClass:[TGStickerPackRowItem class]]) { TGStickerPackModalView *modalView = [[TGStickerPackModalView alloc] init]; - - - + [modalView setStickerPack:[TL_messages_stickerSet createWithSet:item.pack[@"set"] packs:nil documents:[item.pack[@"stickers"] mutableCopy]]]; [modalView show:self.view.window animated:YES]; diff --git a/TelegramTest/TGSwipeRedView.m b/TelegramTest/TGSwipeRedView.m index b6d56000..4bfa857b 100644 --- a/TelegramTest/TGSwipeRedView.m +++ b/TelegramTest/TGSwipeRedView.m @@ -13,7 +13,7 @@ @implementation TGSwipeRedView - (id)initWithFrame:(NSRect)frameRect { self = [super initWithFrame:frameRect]; if(self) { - self.attributedString = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"Delete", nil) attributes:@{NSFontAttributeName: [NSFont fontWithName:@"HelveticaNeue" size:13], NSForegroundColorAttributeName: [NSColor whiteColor]}]; + self.attributedString = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"Delete", nil) attributes:@{NSFontAttributeName: TGSystemFont(13), NSForegroundColorAttributeName: [NSColor whiteColor]}]; self.size = [self.attributedString size]; [self setFrameSize:NSMakeSize(self.size.width + 36, self.bounds.size.height)]; diff --git a/TelegramTest/TGTLSerialization.mm b/TelegramTest/TGTLSerialization.mm index c60cb3cd..c0362401 100644 --- a/TelegramTest/TGTLSerialization.mm +++ b/TelegramTest/TGTLSerialization.mm @@ -127,7 +127,7 @@ - (MTRequestDatacenterAddressListParser)requestDatacenterAddressList:(int32_t)da - (NSUInteger)currentLayer { - return 32; + return 43; } @end \ No newline at end of file diff --git a/TelegramTest/TGUnreadMarkView.m b/TelegramTest/TGUnreadMarkView.m index 6c04be47..67ec75f2 100644 --- a/TelegramTest/TGUnreadMarkView.m +++ b/TelegramTest/TGUnreadMarkView.m @@ -14,7 +14,7 @@ @implementation TGUnreadMarkView static NSDictionary *dictionary; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - dictionary = @{NSFontAttributeName: [NSFont fontWithName:@"HelveticaNeue-Bold" size:11], NSForegroundColorAttributeName:NSColorFromRGB(0xfafafa)}; + dictionary = @{NSFontAttributeName: TGSystemBoldFont(11), NSForegroundColorAttributeName:NSColorFromRGB(0xfafafa)}; }); return dictionary; } diff --git a/TelegramTest/TGUpdateChannelContainer.h b/TelegramTest/TGUpdateChannelContainer.h new file mode 100644 index 00000000..62e6c4b1 --- /dev/null +++ b/TelegramTest/TGUpdateChannelContainer.h @@ -0,0 +1,20 @@ +// +// TGUpdateChannelContainer.h +// Telegram +// +// Created by keepcoder on 21.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import + +@interface TGUpdateChannelContainer : NSObject + +@property (nonatomic,assign,readonly) int pts; +@property (nonatomic,assign,readonly) int pts_count; +@property (nonatomic,assign,readonly) int channel_id; +@property (nonatomic,strong,readonly) id update; + +-(id)initWithPts:(int)pts pts_count:(int)pts_count channel_id:(int)channel_id update:(id)update; + +@end diff --git a/TelegramTest/TGUpdateChannelContainer.m b/TelegramTest/TGUpdateChannelContainer.m new file mode 100644 index 00000000..3e760934 --- /dev/null +++ b/TelegramTest/TGUpdateChannelContainer.m @@ -0,0 +1,24 @@ +// +// TGUpdateChannelContainer.m +// Telegram +// +// Created by keepcoder on 21.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TGUpdateChannelContainer.h" + +@implementation TGUpdateChannelContainer + +-(id)initWithPts:(int)pts pts_count:(int)pts_count channel_id:(int)channel_id update:(id)update { + if(self = [super init]) { + _pts = pts; + _pts_count = pts_count; + _channel_id = channel_id; + _update = update; + } + + return self; +} + +@end diff --git a/TelegramTest/TGUpdateChannels.h b/TelegramTest/TGUpdateChannels.h new file mode 100644 index 00000000..0a98d06b --- /dev/null +++ b/TelegramTest/TGUpdateChannels.h @@ -0,0 +1,21 @@ +// +// TGUpdateChannels.h +// Telegram +// +// Created by keepcoder on 20.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import + +@interface TGUpdateChannels : NSObject + +-(id)initWithQueue:(ASQueue *)queue; + + +-(void)addUpdate:(id)update; + + +-(void)failUpdateWithChannelId:(int)channel_id limit:(int)limit withCallback:(void (^)(id response, TGMessageHole *longHole))callback errorCallback:(void (^)(RpcError *error))errorCallback; + +@end diff --git a/TelegramTest/TGUpdateChannels.m b/TelegramTest/TGUpdateChannels.m new file mode 100644 index 00000000..78f11308 --- /dev/null +++ b/TelegramTest/TGUpdateChannels.m @@ -0,0 +1,642 @@ +// +// TGUpdateChannels.m +// Telegram +// +// Created by keepcoder on 20.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TGUpdateChannels.h" +#import "TGUpdateChannelContainer.h" +#import "TGTimer.h" +#import "TGForceChannelUpdate.h" +#import "TLPeer+Extensions.h" + + + +@interface TGUpdateChannels () +@property (nonatomic,strong) ASQueue *queue; +@property (nonatomic,strong) NSMutableDictionary *channelWaitingUpdates; +@property (nonatomic,strong) NSMutableDictionary *channelWaitingTimers; + +@property (nonatomic,strong) NSMutableDictionary *channelsInUpdating; + + +@end + +@implementation TGUpdateChannels + +-(id)initWithQueue:(ASQueue *)queue { + if(self = [super init]) { + _queue = queue; + _channelWaitingUpdates = [[NSMutableDictionary alloc] init]; + _channelWaitingTimers = [[NSMutableDictionary alloc] init]; + _channelsInUpdating = [[NSMutableDictionary alloc] init]; + } + + return self; +} + +-(int)ptsWithChannelId:(int)channel_id { + + return MAX([[[DialogsManager sharedManager] find:-channel_id] pts],1); +} + +-(TL_conversation *)conversationWithChannelId:(int)channel_id { + + TL_conversation *conversation = [[DialogsManager sharedManager] find:-channel_id]; + + if(!conversation) { + conversation = [[Storage manager] selectConversation:[TL_peerChannel createWithChannel_id:channel_id]]; + + if(conversation) { + [[DialogsManager sharedManager] add:@[conversation]]; + } + + + } + + + return conversation; + +} + + + +-(int)channelIdWithUpdate:(id)update { + + if([update isKindOfClass:[TL_updateNewChannelMessage class]]) { + return ((TL_updateNewChannelMessage *)update).message.to_id.channel_id; + } else if([update isKindOfClass:[TL_updateDeleteChannelMessages class]]) { + return [(TL_updateDeleteChannelMessages *)update channel_id]; + } + + return 0; +} + +/* + updateNewChannelMessage message:Message pts:int pts_count:int = Update; + updateReadChannelInbox peer:Peer max_id:int = Update; + */ + +-(void)addUpdate:(id)update { + + [_queue dispatchOnQueue:^{ + + + static NSArray *statefullUpdates; + static NSArray *statelessUpdates; + + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + + statefullUpdates = @[NSStringFromClass([TL_updateNewChannelMessage class]),NSStringFromClass([TL_updateDeleteChannelMessages class])]; + statelessUpdates = @[NSStringFromClass([TL_updateReadChannelInbox class]),NSStringFromClass([TL_updateChannelTooLong class]),NSStringFromClass([TL_updateChannelGroup class]),NSStringFromClass([TL_updateChannelMessageViews class]),NSStringFromClass([TL_updateChannel class])]; + }); + + if([statefullUpdates indexOfObject:[update className]] != NSNotFound) + { + + if(_channelsInUpdating[@([self channelIdWithUpdate:update])] == nil) { + [self addStatefullUpdate:[[TGUpdateChannelContainer alloc] initWithPts:[update pts] pts_count:[update pts_count] channel_id:[self channelIdWithUpdate:update] update:update]]; + } + + + } else if([statelessUpdates indexOfObject:[update className]] != NSNotFound) { + [self proccessStatelessUpdate:update]; + } else if([update isKindOfClass:[TGForceChannelUpdate class]]) { + [self proccessUpdate:[(TGForceChannelUpdate *)update update]]; + } + + + + }]; + +} + +-(void)addStatefullUpdate:(TGUpdateChannelContainer *)statefulMessage { + + if(statefulMessage.pts == 0 || [self ptsWithChannelId:statefulMessage.channel_id] + statefulMessage.pts_count == statefulMessage.pts ) + { + [self proccessStatefullUpdate:statefulMessage]; + + return; + } + + + [self addWaitingUpdate:statefulMessage]; + +} + + +-(void)addWaitingUpdate:(TGUpdateChannelContainer *)statefullMessage { + + NSMutableArray *updates = _channelWaitingUpdates[@(statefullMessage.channel_id)]; + + if(!updates) + { + updates = [[NSMutableArray alloc] init]; + _channelWaitingUpdates[@(statefullMessage.channel_id)] = updates; + } + + [updates addObject:statefullMessage]; + + + [updates sortUsingComparator:^NSComparisonResult(TGUpdateChannelContainer * obj1, TGUpdateChannelContainer * obj2) { + return obj1.pts < obj2.pts ? NSOrderedAscending : NSOrderedDescending; + }]; + + + NSMutableArray *success = [[NSMutableArray alloc] init]; + + [updates enumerateObjectsUsingBlock:^(TGUpdateChannelContainer *statefulMessage, NSUInteger idx, BOOL *stop) { + + if(statefulMessage.pts > 0 && [self ptsWithChannelId:statefulMessage.pts] + statefulMessage.pts_count == statefulMessage.pts ) + { + [success addObject:statefullMessage]; + + [self proccessStatefullUpdate:statefullMessage]; + } + + }]; + + + [updates removeObjectsInArray:success]; + + if(updates.count > 0) { + + TGTimer *timer = _channelWaitingTimers[@(statefullMessage.channel_id)]; + + if(timer) + { + [timer invalidate]; + [_channelWaitingTimers removeObjectForKey:@(statefullMessage.channel_id)]; + } + + timer = [[TGTimer alloc] initWithTimeout:2 repeat:NO completion:^{ + + [self failUpdateWithChannelId:statefullMessage.channel_id limit:50 withCallback:nil errorCallback:nil]; + + } queue:_queue.nativeQueue reservedObject:@(statefullMessage.channel_id)]; + + [timer start]; + } + +} + + +-(TGMessageGroupHole *)proccessUnimportantGroup:(NSArray *)messages { + + TL_localMessage *minMsg = [[Storage manager] lastMessageAroundMinId:[(TL_localMessage *)messages[0] channelMsgId] important:YES isTop:NO]; + + TL_localMessage *minUnimportantMsg = [messages firstObject]; + TL_localMessage *maxUnimportantMsg = [messages lastObject]; + + + int minId = minMsg ? minMsg.n_id : minUnimportantMsg.n_id - 1; + + TGMessageGroupHole *hole = [[[Storage manager] groupHoles:minUnimportantMsg.peer_id min:minId max:maxUnimportantMsg.n_id +1] lastObject]; + + if(hole == nil) + hole = [[TGMessageGroupHole alloc] initWithUniqueId:-rand_int() peer_id:minUnimportantMsg.peer_id min_id:minId max_id:maxUnimportantMsg.n_id+1 date:minUnimportantMsg.date-1 count:0]; + + hole.max_id = maxUnimportantMsg.n_id+1; + hole.messagesCount+= (int)messages.count; + + [hole save]; + + [[Storage manager] insertMessages:messages]; + + return hole; + +} + + +-(void)proccessHoleWithNewMessage:(NSArray *)messages { + + messages = [messages sortedArrayUsingDescriptors:@[[NSSortDescriptor sortDescriptorWithKey:@"self.n_id" ascending:YES]]]; + + NSMutableArray *unimporantMessages = [[NSMutableArray alloc] init]; + + + + NSMutableArray *groups = [[NSMutableArray alloc] init]; + + [messages enumerateObjectsUsingBlock:^(TL_localMessage *obj, NSUInteger idx, BOOL *stop) { + + if(![obj isImportantMessage]) + [unimporantMessages addObject:obj]; + + if([obj isImportantMessage] || idx == messages.count-1) { + + if([obj isImportantMessage]) { + [obj save:NO]; + } + + if(unimporantMessages.count > 0) { + TGMessageGroupHole *hole = [self proccessUnimportantGroup:[unimporantMessages copy]]; + [groups addObject:hole]; + [unimporantMessages removeAllObjects]; + } + + } + }]; + + [Notification performOnStageQueue:MESSAGE_LIST_UPDATE_TOP data:@{KEY_MESSAGE_LIST:messages}]; + + [groups enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + [Notification perform:UPDATE_MESSAGE_GROUP_HOLE data:@{KEY_GROUP_HOLE:obj}]; + }]; + +} + +-(void)proccessUpdate:(id)update { + if([update isKindOfClass:[TL_updateNewChannelMessage class]]) + { + + TL_localMessage *msg = [TL_localMessage convertReceivedMessage:[(TL_updateNewChannelMessage *)update message]]; + + if(![self conversationWithChannelId:abs(msg.peer_id)]) { + [self proccessUpdate:[TL_updateChannel createWithChannel_id:abs(msg.peer_id)]]; + return; + } + + + if(![msg isImportantMessage]) { + + TGMessageGroupHole *hole = [self proccessUnimportantGroup:@[msg]]; + + [Notification perform:UPDATE_MESSAGE_GROUP_HOLE data:@{KEY_GROUP_HOLE:hole}]; + + } + + + [MessagesManager addAndUpdateMessage:msg]; + + } else if( [update isKindOfClass:[TL_updateDeleteChannelMessages class]]) { + + NSMutableArray *channelMessages = [NSMutableArray array]; + + int peer_id = -[(TL_updateDeleteChannelMessages *)update channel_id]; + + + [[update messages] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + [channelMessages addObject:@(channelMsgId([obj intValue], peer_id))]; + }]; + + + [[DialogsManager sharedManager] deleteChannelMessags:channelMessages]; + + + [[update messages] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + + + TL_localMessage *topMsg = [[Storage manager] lastMessageAroundMinId:channelMsgId([obj intValue], peer_id) important:YES isTop:NO]; + + TL_localMessage *botMsg = [[Storage manager] lastMessageAroundMinId:channelMsgId([obj intValue], peer_id) important:YES isTop:YES]; + + int topMsgId = topMsg ? topMsg.n_id : [obj intValue]-1; + int botMsgId = botMsg ? botMsg.n_id : [obj intValue]+1; + + NSArray *groupHoles = [[Storage manager] groupHoles:peer_id min:topMsgId max:botMsgId]; + + if(groupHoles.count == 1) { + + TGMessageGroupHole *hole = [groupHoles firstObject]; + + if(hole.max_id > [obj intValue] && hole.min_id < [obj intValue]) + hole.messagesCount--; + else { + hole.min_id = topMsg.n_id; + } + + if(hole.messagesCount == 0) + [hole remove]; + else + [hole save]; + + [Notification perform:UPDATE_MESSAGE_GROUP_HOLE data:@{KEY_GROUP_HOLE:hole}]; + + } else if(groupHoles.count == 2) { + + TGMessageGroupHole *topHole = groupHoles[0]; + TGMessageGroupHole *botHole = groupHoles[1]; + + [botHole remove]; + + + topHole.max_id = botHole.max_id; + topHole.messagesCount += botHole.messagesCount; + [topHole save]; + + [Notification perform:UPDATE_MESSAGE_GROUP_HOLE data:@{KEY_GROUP_HOLE:topHole}]; + [Notification performOnStageQueue:MESSAGE_DELETE_EVENT data:@{KEY_DATA:@[@{KEY_PEER_ID:@(botHole.peer_id),KEY_MESSAGE_ID:@(botHole.uniqueId)}]}]; + + } + + }]; + + + } else if([update isKindOfClass:[TL_updateMessageID class]]) { + [[Storage manager] updateMessageId:[(TL_updateMessageID *)update random_id] msg_id:[(TL_updateMessageID *)update n_id]]; + [Notification performOnStageQueue:MESSAGE_UPDATE_MESSAGE_ID data:@{KEY_MESSAGE_ID:@([(TL_updateMessageID *)update n_id]),KEY_RANDOM_ID:@([(TL_updateMessageID *)update random_id])}]; + } else if([update isKindOfClass:[TL_updateReadChannelInbox class]]) { + + [[DialogsManager sharedManager] markChannelMessagesAsRead:[update channel_id] max_id:[(TL_updateReadChannelInbox *)update max_id]]; + + } else if([update isKindOfClass:[TL_updateChannelTooLong class]]) { + + [self failUpdateWithChannelId:[update channel_id] limit:50 withCallback:nil errorCallback:nil]; + + + } else if([update isKindOfClass:[TL_updateChannelMessageViews class]]) { + + TL_updateChannelMessageViews *views = (TL_updateChannelMessageViews *)update; + + [[Storage manager] updateMessageViews:views.views channelMsgId:channelMsgId(views.n_id, views.peer.peer_id)]; + + [Notification perform:UPDATE_MESSAGE_VIEWS data:@{KEY_DATA:@{@(views.n_id):@(views.views)},KEY_MESSAGE_ID_LIST:@[@(views.n_id)],KEY_PEER_ID:@(-views.channel_id)}]; + + } else if([update isKindOfClass:[TL_updateMessageID class]]) { + [[MTNetwork instance].updateService.proccessor addUpdate:update]; + } else if([update isKindOfClass:[TL_updateChannel class]]) { + + //TODO + // update channel interface. + + + TLChat *chat = [[ChatsManager sharedManager] find:[update channel_id]]; + + + if(!chat) + return; + + TL_conversation *channel = [self conversationWithChannelId:[update channel_id]]; + + BOOL addInviteMessage = channel == nil; + + + if(!channel) { + channel = [[DialogsManager sharedManager] createDialogForChannel:chat]; + + [[DialogsManager sharedManager] add:@[channel]]; + + channel.invisibleChannel = NO; + [channel save]; + + } + + + dispatch_block_t dispatch = ^{ + if(!chat.left && chat.type != TLChatTypeForbidden) { + + [[FullChatManager sharedManager] performLoad:chat.n_id callback:^(TLChatFull *fullChat) { + + if(fullChat.migrated_from_chat_id == 0) { + [RPCRequest sendRequest:[TLAPI_channels_getParticipant createWithChannel:chat.inputPeer user_id:[[UsersManager currentUser] inputUser]] successHandler:^(id request, TL_channels_channelParticipant *participant) { + + [SharedManager proccessGlobalResponse:participant]; + + if([participant.participant isKindOfClass:[TL_channelParticipantSelf class]]) { + TL_localMessage *msg = [TL_localMessageService createWithFlags:TGMENTIONMESSAGE n_id:0 from_id:[participant.participant inviter_id] to_id:channel.peer date:participant.participant.date action:([TL_messageActionChatAddUser createWithUsers:[@[@([UsersManager currentUserId])] mutableCopy]]) fakeId:[MessageSender getFakeMessageId] randomId:rand_long() dstate:DeliveryStateNormal]; + + channel.invisibleChannel = NO; + + [channel save]; + [MessagesManager addAndUpdateMessage:msg]; + + } + + + } errorHandler:^(id request, RpcError *error) { + + [self failUpdateWithChannelId:[update channel_id] limit:50 withCallback:nil errorCallback:nil]; + + }]; + + } else { + + [self failUpdateWithChannelId:[update channel_id] limit:50 withCallback:nil errorCallback:nil]; + } + + }]; + + } + + }; + + if(addInviteMessage) { + + _channelsInUpdating[@(channel.peer_id)] = [RPCRequest sendRequest:[TLAPI_updates_getChannelDifference createWithChannel:chat.inputPeer filter:[TL_channelMessagesFilterEmpty create] pts:1 limit:INT32_MAX] successHandler:^(id request, TL_updates_channelDifference *response) { + + channel.pts = response.pts; + channel.top_important_message = [response top_important_message]; + channel.last_message_date = channel.lastMessage.date; + + channel.last_marked_message = [response top_message]; + channel.last_marked_date = [[MTNetwork instance] getTime]; + + channel.read_inbox_max_id = [response read_inbox_max_id]; + channel.unread_count = [response unread_important_count]; + + if(!chat.isCreator) + dispatch(); + else + { + [TL_localMessage convertReceivedMessages:[response n_messages]]; + + [self proccessHoleWithNewMessage:[response n_messages]]; + } + + [_channelsInUpdating removeObjectForKey:@(channel.peer_id)]; + + [[DialogsManager sharedManager] notifyAfterUpdateConversation:channel]; + + } errorHandler:^(id request, RpcError *error) { + + [_channelsInUpdating removeObjectForKey:@(channel.peer_id)]; + }]; + } + + } + +} + + +-(void)proccessStatefullUpdate:(TGUpdateChannelContainer *)statefulMessage { + + [self proccessUpdate:statefulMessage.update]; + + if(statefulMessage.pts > 0) { + TL_conversation *conversation = [self conversationWithChannelId:statefulMessage.channel_id]; + + conversation.pts = [statefulMessage pts]; + + [conversation save]; + } + +} + + +-(void)proccessStatelessUpdate:(id)update { + + [self proccessUpdate:update]; + +} + + +-(void)failUpdateWithChannelId:(int)channel_id limit:(int)limit withCallback:(void (^)(id response, TGMessageHole *longHole))callback errorCallback:(void (^)(RpcError *error))errorCallback +{ + TL_channel *channel = [[ChatsManager sharedManager] find:channel_id]; + + TL_conversation *conversation = [self conversationWithChannelId:channel_id]; + + if(conversation) { + id request = _channelsInUpdating[@(channel_id)]; + + + if(request == nil) { + _channelsInUpdating[@(channel_id)] = [RPCRequest sendRequest:[TLAPI_updates_getChannelDifference createWithChannel:[TL_inputChannel createWithChannel_id:channel_id access_hash:channel.access_hash] filter:[TL_channelMessagesFilterEmpty create] pts:[self ptsWithChannelId:channel_id] limit:limit] successHandler:^(id request, id response) { + + + TGMessageHole *longHole; + + + if([response isKindOfClass:[TL_updates_channelDifferenceEmpty class]]) { + + + } else if([response isKindOfClass:[TL_updates_channelDifference class]]) { + + if(conversation.pts < [response pts]) { + + [[response other_updates] enumerateObjectsUsingBlock:^(TLUpdate *obj, NSUInteger idx, BOOL *stop) { + + obj.channel_id = channel_id; + + [self proccessUpdate:obj]; + + }]; + + conversation.pts = [response pts]; + + [conversation save]; + + [TL_localMessage convertReceivedMessages:[response n_messages]]; + + [self proccessHoleWithNewMessage:[response n_messages]]; + } + + + } else if([response isKindOfClass:[TL_updates_channelDifferenceTooLong class]]) { + + if(conversation.pts < [response pts]) { + __block TL_localMessage *topMsg; + __block TL_localMessage *importantMsg; + + [[response messages] enumerateObjectsUsingBlock:^(TLMessage *obj, NSUInteger idx, BOOL *stop) { + + TL_localMessage *c = [TL_localMessage convertReceivedMessage:obj]; + + if([response top_message] == c.n_id) + topMsg = c; + + if(!importantMsg || c.n_id < importantMsg.n_id) + importantMsg = c; + + }]; + + [[Storage manager] invalidateChannelMessagesWithPts:conversation.pts]; + + conversation.pts = [response pts]; + + conversation.top_message = [response top_message]; + conversation.lastMessage = importantMsg; + conversation.top_important_message = conversation.chat.isMegagroup ? [response top_message] : [response top_important_message]; + conversation.last_message_date = conversation.lastMessage.date; + + if(conversation.last_marked_message == 0) { + conversation.last_marked_message = conversation.chat.isMegagroup ? [response top_message] : [response top_important_message]; + conversation.last_marked_date = conversation.last_message_date; + } + + conversation.read_inbox_max_id = [response read_inbox_max_id]; + conversation.unread_count = conversation.chat.isMegagroup ? [response unread_count] : [response unread_important_count]; + + [conversation save]; + + [[DialogsManager sharedManager] add:@[conversation]]; + + [[DialogsManager sharedManager] notifyAfterUpdateConversation:conversation]; + + + + + + + // insert holes + { + int maxSyncedId = [[Storage manager] syncedMessageIdWithPeerId:conversation.peer_id important:NO latest:YES isChannel:YES]; + + if(importantMsg.n_id > maxSyncedId && maxSyncedId > 0) { + longHole = [[TGMessageHole alloc] initWithUniqueId:-rand_int() peer_id:importantMsg.peer_id min_id:maxSyncedId+1 max_id:importantMsg.n_id-1 date:0 count:0]; + + [longHole save]; + } + + + if(importantMsg.n_id != topMsg.n_id) { + TGMessageHole *nextHole = [[TGMessageHole alloc] initWithUniqueId:-rand_int() peer_id:importantMsg.peer_id min_id:importantMsg.n_id max_id:topMsg.n_id+1 date:0 count:0]; + + [nextHole save]; + + if(longHole == nil) + longHole = nextHole; + } + + } + } + + + + [SharedManager proccessGlobalResponse:response]; + } + + + if(callback != nil) + { + callback(response,longHole); + } + + + [_channelsInUpdating removeObjectForKey:@(channel_id)]; + + } errorHandler:^(id request, RpcError *error) { + + if(errorCallback != nil) + { + errorCallback(error); + } + + if([error.error_msg isEqualToString:@"CHANNEL_PRIVATE"]) { + + [self addUpdate:[TL_updateChannel createWithChannel_id:channel_id]]; + + } + + [_channelsInUpdating removeObjectForKey:@(channel_id)]; + + } timeout:0 queue:_queue.nativeQueue]; + } + + } else { + if(channel != nil) + [self addUpdate:[TL_updateChannel createWithChannel_id:channel_id]]; + } + + +} + + + + +@end diff --git a/TelegramTest/TGUpdateMessageService.m b/TelegramTest/TGUpdateMessageService.m index 467847ce..7a50fee4 100644 --- a/TelegramTest/TGUpdateMessageService.m +++ b/TelegramTest/TGUpdateMessageService.m @@ -151,9 +151,8 @@ - (void)mtProto:(MTProto *)__unused mtProto receivedParsedMessage:(id)incomingMe - if([incomingMessage isKindOfClass:[TL_messages_sentMessage class]] || - [incomingMessage isKindOfClass:[TL_gzip_packed class]] || - [incomingMessage isKindOfClass:[TL_messages_affectedHistory class]]) + if([incomingMessage isKindOfClass:[TL_gzip_packed class]] || + [incomingMessage isKindOfClass:[TL_messages_affectedMessages class]]) [self addMessageToQueueAndScheduleProcessing:incomingMessage]; } @@ -168,17 +167,15 @@ - (void)addMessageToQueueAndScheduleProcessing:(MTIncomingMessage *)message _scheduledMessageProcessing = true; int currentSessionToken = _sessionToken; - dispatch_async(_queue.nativeQueue, ^ - { - _scheduledMessageProcessing = false; - - if (currentSessionToken != _sessionToken) - return; - - NSArray *messages = [[NSArray alloc] initWithArray:_messagesToProcess]; - [_messagesToProcess removeAllObjects]; - [self processMessages:messages]; - }); + + _scheduledMessageProcessing = false; + + if (currentSessionToken != _sessionToken) + return; + + NSArray *messages = [[NSArray alloc] initWithArray:_messagesToProcess]; + [_messagesToProcess removeAllObjects]; + [self processMessages:messages]; } } diff --git a/TelegramTest/TGUserContainerRowItem.h b/TelegramTest/TGUserContainerRowItem.h new file mode 100644 index 00000000..da959e87 --- /dev/null +++ b/TelegramTest/TGUserContainerRowItem.h @@ -0,0 +1,25 @@ +// +// TGUserContainerRowItem.h +// Telegram +// +// Created by keepcoder on 16.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TGGeneralRowItem.h" + +@interface TGUserContainerRowItem : TGGeneralRowItem + + + +@property (nonatomic,strong,readonly) TLUser *user; + + +@property (nonatomic,assign) int avatarHeight; +@property (nonatomic,strong) NSString *status; + +@property (nonatomic,strong) dispatch_block_t stateCallback; + +-(id)initWithUser:(TLUser *)user; + +@end diff --git a/TelegramTest/TGUserContainerRowItem.m b/TelegramTest/TGUserContainerRowItem.m new file mode 100644 index 00000000..abe58900 --- /dev/null +++ b/TelegramTest/TGUserContainerRowItem.m @@ -0,0 +1,25 @@ +// +// TGUserContainerRowItem.m +// Telegram +// +// Created by keepcoder on 16.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TGUserContainerRowItem.h" + +@implementation TGUserContainerRowItem + + +-(id)initWithUser:(TLUser *)user { + if(self = [super init]) { + _user = user; + } + return self; +} + +-(Class)viewClass { + return NSClassFromString(@"TGUserContainerView"); +} + +@end diff --git a/TelegramTest/TGUserContainerView.h b/TelegramTest/TGUserContainerView.h new file mode 100644 index 00000000..008c1596 --- /dev/null +++ b/TelegramTest/TGUserContainerView.h @@ -0,0 +1,14 @@ +// +// TGUserContainerView.h +// Telegram +// +// Created by keepcoder on 16.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TMView.h" +@interface TGUserContainerView : TMRowView + +-(void)setEditable:(BOOL)editable animated:(BOOL)animated; + +@end diff --git a/TelegramTest/TGUserContainerView.m b/TelegramTest/TGUserContainerView.m new file mode 100644 index 00000000..75fce56e --- /dev/null +++ b/TelegramTest/TGUserContainerView.m @@ -0,0 +1,188 @@ +// +// TGUserContainerView.m +// Telegram +// +// Created by keepcoder on 16.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TGUserContainerView.h" +#import "TGUserContainerRowItem.h" +#import "ITSwitch.h" +@interface TGUserContainerView () + +@property (nonatomic,strong) TMView *avatarContainerView; + +@property (nonatomic,strong) TMAvatarImageView *avatarImageView; +@property (nonatomic,strong) TMStatusTextField *statusTextField; +@property (nonatomic,strong) TMNameTextField *nameTextField; + +@property (nonatomic,strong) ITSwitch *switchView; +@property (nonatomic,strong) NSImageView *selectImageView; + +@property (nonatomic,strong) TMView *separator; + +@property (nonatomic,strong) NSImageView *deleteMenuImageView; + +@end + +@implementation TGUserContainerView + +- (id)initWithFrame:(NSRect)frame { + self = [super initWithFrame:frame]; + if (self) { + + self.avatarImageView = [TMAvatarImageView standartMessageTableAvatar]; + + + _avatarContainerView = [[TMView alloc] initWithFrame:NSMakeRect(30, 0, NSWidth(_avatarImageView.frame), NSHeight(_avatarImageView.frame))]; + + [_avatarContainerView addSubview:_avatarImageView]; + + [self addSubview:_avatarContainerView]; + + self.nameTextField = [[TMNameTextField alloc] init]; + [self.nameTextField setSelector:@selector(chatInfoTitle)]; + + + self.statusTextField = [[TMStatusTextField alloc] init]; + [self.statusTextField setSelector:@selector(statusForGroupInfo)]; + [self addSubview:self.statusTextField]; + [self addSubview:self.nameTextField]; + [_statusTextField setFont:TGSystemFont(12)]; + [_statusTextField setTextColor:GRAY_TEXT_COLOR]; + + + _selectImageView = imageViewWithImage(image_UsernameCheck()); + _switchView = [[ITSwitch alloc] initWithFrame:NSMakeRect(0, 0, 36, 20)]; + + + [self addSubview:_selectImageView]; + [self addSubview:_switchView]; + + _separator = [[TMView alloc] initWithFrame:NSZeroRect]; + _separator.backgroundColor = DIALOG_BORDER_COLOR; + [self addSubview:_separator]; + + _deleteMenuImageView = imageViewWithImage(image_ModernMenuDeleteIcon()); + + [self addSubview:_deleteMenuImageView]; + } + return self; +} + +-(int)xOffset { + return [self rowItem].isEditable ? 40 + NSWidth(_deleteMenuImageView.frame) : 30; +} + +-(void)setEditable:(BOOL)editable animated:(BOOL)animated { + + [self updateFramesWithAnimation:animated]; + +} + +- (void)drawRect:(NSRect)dirtyRect { + [super drawRect:dirtyRect]; + +} + +-(TGUserContainerRowItem *)item { + return (TGUserContainerRowItem *)[self rowItem]; +} + +-(void)redrawRow { + TGUserContainerRowItem *item = (TGUserContainerRowItem *)[self rowItem]; + + [_switchView setHidden:item.type != SettingsRowItemTypeSwitch]; + [_selectImageView setHidden:item.type != SettingsRowItemTypeSelected]; + + + if(item.stateback) { + [_switchView setOn:[item.stateback(item) boolValue]]; + + [_switchView setHidden:item.type != SettingsRowItemTypeSwitch]; + + [_selectImageView setHidden:item.type != SettingsRowItemTypeSelected || ![item.stateback(item) boolValue]]; + } + + + [_switchView setCenteredYByView:self]; + [_selectImageView setCenteredYByView:self]; + + [self setUser:item.user]; +} + +-(void)mouseDown:(NSEvent *)theEvent { + TGUserContainerRowItem *item = (TGUserContainerRowItem *)[self rowItem]; + + if(item.stateCallback != nil) { + item.stateCallback(); + } else { + [super mouseDown:theEvent]; + } + +} + + +-(void)updateFramesWithAnimation:(BOOL)animated { + + + + id statusF = animated ? [_statusTextField animator] : _statusTextField; + id nameF = animated ? [_nameTextField animator] : _nameTextField; + + id avatarF = animated ? [_avatarContainerView animator] : _avatarContainerView; + id separatorF = animated ? [_separator animator] : _separator; + + id deleteF = animated ? [_deleteMenuImageView animator] : _deleteMenuImageView; + + [statusF setFrameOrigin:NSMakePoint(self.xOffset + NSWidth(_avatarContainerView.frame) + 10, NSHeight(self.frame)/2 - NSHeight(self.statusTextField.frame) )]; + [nameF setFrameOrigin:NSMakePoint(self.xOffset + NSWidth(_avatarContainerView.frame) + 10, NSHeight(self.frame)/2 )]; + + + [avatarF setFrameOrigin:NSMakePoint(self.xOffset, NSMinY(_avatarContainerView.frame))]; + + [_selectImageView setFrameOrigin:NSMakePoint(NSWidth(self.frame) - self.xOffset - 30, NSMinY(_selectImageView.frame))]; + [_switchView setFrameOrigin:NSMakePoint(NSWidth(self.frame) - self.xOffset - 30, NSMinY(_selectImageView.frame))]; + + [separatorF setFrame:NSMakeRect(self.xOffset + 10 + NSWidth(_avatarContainerView.frame), 0, NSWidth(self.frame) - self.xOffset - 30 - 10 - NSWidth(_avatarContainerView.frame), DIALOG_BORDER_WIDTH)]; + + [deleteF setFrameOrigin:NSMakePoint(self.item.isEditable ? 30 : - NSWidth(_deleteMenuImageView.frame), roundf((NSHeight(self.frame) - NSHeight(_deleteMenuImageView.frame))/2))]; + + [(NSView *)deleteF setAlphaValue:self.item.isEditable ? 1 : 0]; + + [_deleteMenuImageView setHidden:self.item.stateback == nil || ![self.item.stateback(self.item) boolValue]]; +} + +-(void)setFrameSize:(NSSize)newSize { + [super setFrameSize:newSize]; + + [self.nameTextField setFrameSize:NSMakeSize(NSWidth(self.frame) - NSMaxX(self.avatarImageView.frame) - 20, NSHeight(self.nameTextField.frame))]; + [self.statusTextField setFrameSize:NSMakeSize(NSWidth(self.frame) - NSMaxX(self.avatarImageView.frame) - 20, NSHeight(self.statusTextField.frame))]; + + [self.avatarContainerView setCenteredYByView:self]; + + [self updateFramesWithAnimation:NO]; + +} + + +-(void)setUser:(TLUser *)user { + [self.statusTextField setUser:user]; + [self.nameTextField setUser:user]; + [self.avatarImageView setUser:user]; + + TGUserContainerRowItem *item = (TGUserContainerRowItem *)[self rowItem]; + + if(item.status.length > 0) { + [_statusTextField setUser:nil]; + [_statusTextField setStringValue:item.status]; + } + + [self.statusTextField sizeToFit]; + [self.nameTextField sizeToFit]; + +} + + +@end diff --git a/TelegramTest/TGWebPageObject.h b/TelegramTest/TGWebPageObject.h index 2e526623..eca008ab 100644 --- a/TelegramTest/TGWebPageObject.h +++ b/TelegramTest/TGWebPageObject.h @@ -14,7 +14,7 @@ @property (nonatomic,assign,readonly) NSSize titleSize; @property (nonatomic,strong,readonly) TGImageObject *imageObject; - +@property (nonatomic,strong,readonly) TGImageObject *roundObject; @property (nonatomic,strong,readonly) NSAttributedString *desc; @property (nonatomic,assign,readonly) NSSize descSize; diff --git a/TelegramTest/TGWebPageObject.m b/TelegramTest/TGWebPageObject.m index 6a7af8d0..40fc03c8 100644 --- a/TelegramTest/TGWebPageObject.m +++ b/TelegramTest/TGWebPageObject.m @@ -13,7 +13,11 @@ #import "TGWebpageTWObject.h" #import "TGWebpageStandartObject.h" #import "TGWebpageArticle.h" +#import "TGWebpageGifObject.h" #import "NSAttributedString+Hyperlink.h" + +#import "TGArticleImageObject.h" + @implementation TGWebpageObject NSImage *placeholder() { @@ -50,9 +54,9 @@ -(id)initWithWebPage:(TLWebPage *)webpage { [author appendString:webpage.author withColor:DARK_BLACK]; - [author setFont:[NSFont fontWithName:@"HelveticaNeue-Medium" size:12.5] forRange:author.range]; + [author setFont:TGSystemMediumFont(13) forRange:author.range]; - [author addAttribute:NSParagraphStyleAttributeName value:style range:author.range]; + // [author addAttribute:NSParagraphStyleAttributeName value:style range:author.range]; _author = author; @@ -64,10 +68,8 @@ -(id)initWithWebPage:(TLWebPage *)webpage { if(webpage.title) { NSMutableAttributedString *title = [[NSMutableAttributedString alloc] init]; - - [title appendString:webpage.title withColor:[NSColor blackColor]]; - [title setFont:[NSFont fontWithName:@"HelveticaNeue-Medium" size:12.5] forRange:title.range]; + [title setFont:TGSystemMediumFont(13) forRange:title.range]; _title = title; } @@ -76,7 +78,7 @@ -(id)initWithWebPage:(TLWebPage *)webpage { // // NSMutableAttributedString *copy = [_title mutableCopy]; // -// [copy setFont:[NSFont fontWithName:@"HelveticaNeue-Medium" size:12.5] forRange:copy.range]; +// [copy setFont:TGSystemMediumFont(12.5) forRange:copy.range]; // [copy addAttribute:NSParagraphStyleAttributeName value:style range:copy.range]; // _author = copy; // @@ -85,10 +87,9 @@ -(id)initWithWebPage:(TLWebPage *)webpage { NSMutableAttributedString *siteName = [[NSMutableAttributedString alloc] init]; [siteName appendString:webpage.site_name ? webpage.site_name : @"Link Preview" withColor:GRAY_TEXT_COLOR]; - - [siteName setFont:[NSFont fontWithName:@"HelveticaNeue-Medium" size:12.5] forRange:siteName.range]; - [siteName addAttribute:NSParagraphStyleAttributeName value:style range:siteName.range]; - + + [siteName setFont:TGSystemMediumFont(13) forRange:siteName.range]; + // [siteName addAttribute:NSParagraphStyleAttributeName value:style range:siteName.range]; _siteName = siteName; @@ -98,7 +99,7 @@ -(id)initWithWebPage:(TLWebPage *)webpage { NSMutableAttributedString *desc = [[NSMutableAttributedString alloc] init]; [desc appendString:webpage.n_description withColor:[NSColor blackColor]]; - [desc setFont:[NSFont fontWithName:@"HelveticaNeue" size:12.5] forRange:desc.range]; + [desc setFont:TGSystemFont(13) forRange:desc.range]; NSMutableParagraphStyle *style = [NSMutableParagraphStyle new]; style.lineBreakMode = NSLineBreakByWordWrapping; @@ -113,7 +114,7 @@ -(id)initWithWebPage:(TLWebPage *)webpage { NSMutableAttributedString *title = [[NSMutableAttributedString alloc] init]; [title appendString:[NSString stringWithFormat:@"%@\n",t] withColor:[NSColor blackColor]]; - [title setFont:[NSFont fontWithName:@"HelveticaNeue-Medium" size:12.5] forRange:title.range]; + [title setFont:TGSystemMediumFont(13) forRange:title.range]; [desc insertAttributedString:title atIndex:0]; } @@ -146,6 +147,11 @@ -(id)initWithWebPage:(TLWebPage *)webpage { _imageObject.imageSize = imageSize; + + + _roundObject = [[TGArticleImageObject alloc] initWithLocation:photoSize.location placeHolder:placeholder() sourceId:0 size:photoSize.size]; + + _roundObject.imageSize = NSMakeSize(60, 60); } @@ -181,7 +187,9 @@ -(void)makeSize:(int)width { } - +-(void)dealloc { + +} -(Class)webpageContainer { return NSClassFromString(@"TGWebpageContainer"); @@ -218,11 +226,16 @@ +(id)objectForWebpage:(TLWebPage *)webpage { - if([webpage.type isEqualToString:@"article"] || [webpage.type isEqualToString:@"app"] || [webpage.type isEqualToString:@"document"]) + if([webpage.type isEqualToString:@"article"] || [webpage.type isEqualToString:@"app"]) { return [[TGWebpageArticle alloc] initWithWebPage:webpage]; } + if([webpage.type isEqualToString:@"document"]) { + if([webpage.document.mime_type isEqualToString:@"image/gif"]) + return [[TGWebpageGifObject alloc] initWithWebPage:webpage]; + } + return [[TGWebpageStandartObject alloc] initWithWebPage:webpage]; return nil; diff --git a/TelegramTest/TGWebpageArticle.m b/TelegramTest/TGWebpageArticle.m index f2333279..66ad3de4 100644 --- a/TelegramTest/TGWebpageArticle.m +++ b/TelegramTest/TGWebpageArticle.m @@ -14,7 +14,7 @@ @implementation TGWebpageArticle @synthesize imageSize = _imageSize; @synthesize author = _author; @synthesize imageObject = _imageObject; - +@synthesize descSize = _descSize; -(id)initWithWebPage:(TLWebPage *)webpage { @@ -47,15 +47,20 @@ -(void)makeSize:(int)width { _size = [super size]; - if(self.imageObject) { + // if(self.imageObject) { _imageSize = strongsize(self.imageObject.imageSize,60); - - _size.height = [self.desc coreTextSizeForTextFieldForWidth:width - 67 withPaths:@[[NSValue valueWithRect:NSMakeRect(0, 300, _size.width - 77, 60)],[NSValue valueWithRect:NSMakeRect(0, 0, _size.width -7, 300)]]].height; - - - _size.height = MAX(_size.height, 60); - } + + _descSize = [self.desc coreTextSizeForTextFieldForWidth: width-67]; + +// _size.height = [self.desc coreTextSizeForTextFieldForWidth:width - 67 withPaths:@[[NSValue valueWithRect:NSMakeRect(0, 300, _size.width - 77, 60)],[NSValue valueWithRect:NSMakeRect(0, 0, _size.width -7, 300)]]].height; +// + _size.width = _descSize.width + _imageSize.width + 100; + _size.height = _descSize.width > 200 ? _descSize.height : _descSize.height + _imageSize.height + 10; + + + _size.height = MAX(_size.height, _imageSize.height); + // } } diff --git a/TelegramTest/TGWebpageArticleContainer.m b/TelegramTest/TGWebpageArticleContainer.m index d1ded9db..645197b8 100644 --- a/TelegramTest/TGWebpageArticleContainer.m +++ b/TelegramTest/TGWebpageArticleContainer.m @@ -18,15 +18,16 @@ - (void)drawRect:(NSRect)dirtyRect { -(void)setWebpage:(TGWebpageObject *)webpage { [super setWebpage:webpage]; + - [self.imageView setFrame:NSMakeRect(webpage.desc.length > 0 ? (NSWidth(self.frame) - 67) : [self textX], 0, webpage.imageSize.width, webpage.imageSize.height)]; + [self.imageView setFrame:NSMakeRect(webpage.descSize.width > 200 ? (webpage.descSize.width + 5) : [self textX], webpage.descSize.width > 200 ? 0 : webpage.descSize.height + 5, webpage.imageSize.width, webpage.imageSize.height)]; if(webpage.imageObject) { - [self.descriptionField setDrawRects:@[[NSValue valueWithRect:NSMakeRect(0, webpage.size.height - 60, webpage.size.width - 77, 60)],[NSValue valueWithRect:NSMakeRect(0, 0, webpage.size.width - 7, webpage.size.height - 60)]]]; + //[self.descriptionField setDrawRects:@[[NSValue valueWithRect:NSMakeRect(0, webpage.size.height - 60, webpage.size.width - 77, 60)],[NSValue valueWithRect:NSMakeRect(0, 0, webpage.size.width - 7, webpage.size.height - 60)]]]; - [self.descriptionField setFrame:NSMakeRect([self textX], 0, webpage.size.width - 7 , webpage.size.height )]; + [self.descriptionField setFrame:NSMakeRect([self textX], 0, webpage.descSize.width , webpage.size.height )]; } else { [self.descriptionField setFrame:NSMakeRect([self textX], 0, webpage.descSize.width , webpage.descSize.height )]; } diff --git a/TelegramTest/TGWebpageAttach.m b/TelegramTest/TGWebpageAttach.m index ae939f45..74ac52c7 100644 --- a/TelegramTest/TGWebpageAttach.m +++ b/TelegramTest/TGWebpageAttach.m @@ -38,7 +38,7 @@ -(id)initWithFrame:(NSRect)frameRect webpage:(TLWebPage *)webpage link:(NSString _stateField = [TMTextField defaultTextField]; - [_titleField setFont:[NSFont fontWithName:@"HelveticaNeue" size:13]]; + [_titleField setFont:TGSystemFont(13)]; [_titleField setTextColor:LINK_COLOR]; @@ -46,7 +46,7 @@ -(id)initWithFrame:(NSRect)frameRect webpage:(TLWebPage *)webpage link:(NSString [_titleField setFrameOrigin:NSMakePoint(5, NSHeight(frameRect) - 13)]; - [_stateField setFont:[NSFont fontWithName:@"HelveticaNeue" size:13]]; + [_stateField setFont:TGSystemFont(13)]; @@ -135,7 +135,10 @@ -(void)updateLayout { desc = _webpage.n_description; if(!desc) desc = _webpage.author; - + if(!desc && _webpage.document) + desc = NSLocalizedString(@"Document", nil); + if(!desc) + desc = _webpage.url; [_stateField setTextColor:GRAY_TEXT_COLOR]; } @@ -154,6 +157,7 @@ -(void)updateLayout { } -(void)dealloc { + //assert([NSThread isMainThread]); remove_global_dispatcher(_internalId); [Notification removeObserver:self]; } diff --git a/TelegramTest/TGWebpageContainer.m b/TelegramTest/TGWebpageContainer.m index 884eb67c..046378c6 100644 --- a/TelegramTest/TGWebpageContainer.m +++ b/TelegramTest/TGWebpageContainer.m @@ -70,8 +70,8 @@ -(instancetype)initWithFrame:(NSRect)frameRect { [self addSubview:_imageView]; _siteName = [TMTextField defaultTextField]; - - + [[_siteName cell] setTruncatesLastVisibleLine:YES]; + [[_author cell] setTruncatesLastVisibleLine:YES]; [self.siteName setFrameOrigin:NSMakePoint(5, -6)]; [self.author setFrameOrigin:NSMakePoint(5, 10)]; @@ -177,7 +177,7 @@ -(NSSize)containerSize { -(int)maxTextWidth { - int width = self.containerSize.width; + int width = self.containerSize.width - 60; if([self.webpage.webpage.type isEqualToString:@"profile"]) { width = width - 75; diff --git a/TelegramTest/TGWebpageGifContainer.h b/TelegramTest/TGWebpageGifContainer.h new file mode 100644 index 00000000..f9b071cb --- /dev/null +++ b/TelegramTest/TGWebpageGifContainer.h @@ -0,0 +1,16 @@ +// +// TGWebpageGifContainer.h +// Telegram +// +// Created by keepcoder on 20.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TGWebpageContainer.h" + +@interface TGWebpageGifContainer : TGWebpageContainer + + + + +@end diff --git a/TelegramTest/TGWebpageGifContainer.m b/TelegramTest/TGWebpageGifContainer.m new file mode 100644 index 00000000..2be923d3 --- /dev/null +++ b/TelegramTest/TGWebpageGifContainer.m @@ -0,0 +1,205 @@ +// +// TGWebpageGifContainer.m +// Telegram +// +// Created by keepcoder on 20.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TGWebpageGifContainer.h" +#import "TGWebpageGifObject.h" +#import "TGModernAnimatedImagePlayer.h" + +@interface TGWebpageGifContainer () +@property (nonatomic,strong) TGModernAnimatedImagePlayer *animatedPlayer; +@property (nonatomic,strong) NSImageView *playImage; +@end + +@implementation TGWebpageGifContainer + +@synthesize loaderView = _loaderView; + + +static NSImage *gifPlayImage() { + static NSImage *image = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + NSRect rect = NSMakeRect(0, 0, 48, 48); + image = [[NSImage alloc] initWithSize:rect.size]; + [image lockFocus]; + [NSColorFromRGBWithAlpha(0x000000, 0.5) set]; + NSBezierPath *path = [NSBezierPath bezierPath]; + [path appendBezierPathWithRoundedRect:NSMakeRect(0, 0, rect.size.width, rect.size.height) xRadius:rect.size.width/2 yRadius:rect.size.height/2]; + [path fill]; + + [image_PlayIconWhite() drawInRect:NSMakeRect(roundf((48 - image_PlayIconWhite().size.width)/2) + 2, roundf((48 - image_PlayIconWhite().size.height)/2) , image_PlayIconWhite().size.width, image_PlayIconWhite().size.height) fromRect:NSZeroRect operation:NSCompositeHighlight fraction:1]; + [image unlockFocus]; + }); + return image;//image_VideoPlay(); +} + +-(instancetype)initWithFrame:(NSRect)frameRect { + if(self = [super initWithFrame:frameRect]) { + + self.playImage = imageViewWithImage(gifPlayImage()); + + [self.imageView addSubview:self.playImage]; + + [self.playImage setCenterByView:self.imageView]; + + } + + return self; +} + +-(void)setWebpage:(TGWebpageGifObject *)webpage { + + [super setWebpage:webpage]; + + + [self.descriptionField setFrame:NSMakeRect([self textX], 0, webpage.descSize.width , webpage.descSize.height )]; + + [self.descriptionField setAttributedString:webpage.desc]; + + + [self.imageView setFrame:NSMakeRect(0, webpage.size.height - webpage.imageSize.height, webpage.imageSize.width, webpage.imageSize.height)]; + + [self.playImage setCenterByView:self.imageView]; + +} + + +-(void)showPhoto { + [self playAnimation]; +} + + +- (void)playAnimation { + + TGWebpageGifObject *item = (TGWebpageGifObject *)self.webpage; + + if([item isset]) { + + weak(); + + if(!self.animatedPlayer) { + self.animatedPlayer = [[TGModernAnimatedImagePlayer alloc] initWithSize:self.imageView.frame.size path:item.path]; + [self.animatedPlayer setFrameReady:^(NSImage *image) { + weakSelf.imageView.image = image; + }]; + + [self.playImage setHidden:YES]; + + [self.animatedPlayer play]; + + } else { + [self animationDidStop:nil finished:YES]; + } + } else { + [self startDownload:YES]; + } + +} + +- (void)animationDidStart:(CAAnimation *)theAnimation { + +} + +- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag { + + [self.animatedPlayer stop]; + self.animatedPlayer = nil; + + TGWebpageGifObject *item = (TGWebpageGifObject *)self.webpage; + + self.imageView.object = item.imageObject; + [self.playImage setHidden:NO]; + +} + + +- (void)startDownload:(BOOL)cancel { + + TGWebpageGifObject *item = (TGWebpageGifObject *)self.webpage; + + [item startDownload:cancel force:YES]; + + [self updateDownloadState]; +} + + +-(void)updateDownloadState { + + weak(); + + TGWebpageGifObject *item = (TGWebpageGifObject *)self.webpage; + + if(item.downloadItem) { + + + [item.downloadListener setCompleteHandler:^(DownloadItem * item) { + + [[ASQueue mainQueue] dispatchOnQueue:^{ + + [weakSelf downloadProgressHandler:item]; + + dispatch_after_seconds(0.2, ^{ + weakSelf.item.downloadItem = nil; + [self updateState:0]; + }); + }]; + + }]; + + [item.downloadListener setProgressHandler:^(DownloadItem * item) { + + [ASQueue dispatchOnMainQueue:^{ + [weakSelf downloadProgressHandler:item]; + }]; + }]; + + [self updateState:TMLoaderViewStateDownloading]; + + } + +} + +-(void)updateState:(TMLoaderViewState)state { + + TGWebpageGifObject *item = (TGWebpageGifObject *)self.webpage; + + + [self.playImage setHidden:item.downloadItem != nil && item.downloadItem.downloadState != DownloadStateCompleted]; + + if(!item.isset && item.downloadItem && item.downloadItem.downloadState != DownloadStateCompleted) { + [self.loaderView removeFromSuperview]; + + _loaderView = [[TMLoaderView alloc] initWithFrame:NSMakeRect(0, 0, 40, 40)]; + + [self.loaderView setStyle:TMCircularProgressDarkStyle]; + + + [self.imageView addSubview:self.loaderView]; + [self.loaderView setCenterByView:self.imageView]; + + [self.loaderView setState:state]; + + [self.loaderView setProgress:item.downloadItem.progress animated:NO]; + + if(self.loaderView.currentProgress > 0) { + [self.loaderView setProgress:self.loaderView.currentProgress animated:YES]; + } + + + + } else { + [self.loaderView removeFromSuperview]; + } + +} + +-(void)downloadProgressHandler:(DownloadItem *)item { + [self.loaderView setProgress:item.progress animated:YES]; +} + +@end diff --git a/TelegramTest/TGWebpageGifObject.h b/TelegramTest/TGWebpageGifObject.h new file mode 100644 index 00000000..669765e3 --- /dev/null +++ b/TelegramTest/TGWebpageGifObject.h @@ -0,0 +1,20 @@ +// +// TGWebpageGifObject.h +// Telegram +// +// Created by keepcoder on 20.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "ComposeViewController.h" +#import "TGWebpageObject.h" +@interface TGWebpageGifObject : TGWebpageObject + + +@property (nonatomic,strong,readonly) DownloadEventListener *downloadListener; +@property (nonatomic,strong,readonly) DownloadItem *downloadItem; + +- (void)startDownload:(BOOL)cancel force:(BOOL)force; +-(NSString *)path; +-(BOOL)isset; +@end diff --git a/TelegramTest/TGWebpageGifObject.m b/TelegramTest/TGWebpageGifObject.m new file mode 100644 index 00000000..183072f7 --- /dev/null +++ b/TelegramTest/TGWebpageGifObject.m @@ -0,0 +1,70 @@ +// +// TGWebpageGifObject.m +// Telegram +// +// Created by keepcoder on 20.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TGWebpageGifObject.h" +#import "DownloadCacheDocumentItem.h" +@interface TGWebpageGifObject () + +@end + +@implementation TGWebpageGifObject + +@synthesize size = _size; +@synthesize imageObject = _imageObject; +@synthesize imageSize = _imageSize; +-(id)initWithWebPage:(TLWebPage *)webpage { + if(self = [super initWithWebPage:webpage]) { + + _imageObject = [[TGImageObject alloc] initWithLocation:webpage.document.thumb.location placeHolder:nil sourceId:0 size:webpage.document.thumb.size]; + _imageObject.imageSize = NSMakeSize(roundf(webpage.document.thumb.w * (320 / webpage.document.thumb.w)), roundf(webpage.document.thumb.h * (320 / webpage.document.thumb.h))); + + + } + + return self; +} + +- (void)startDownload:(BOOL)cancel force:(BOOL)force { + + if(!_downloadItem) { + _downloadItem = [[DownloadCacheDocumentItem alloc] initWithObject:self.webpage.document]; + _downloadListener = [[DownloadEventListener alloc] init]; + + [_downloadItem addEvent:_downloadListener]; + + } + + if((self.downloadItem.downloadState == DownloadStateCanceled || self.downloadItem.downloadState == DownloadStateWaitingStart) && force) + [self.downloadItem start]; + +} + +-(void)makeSize:(int)width { + [super makeSize:width]; + + _imageSize = strongsize(_imageObject.imageSize, MIN(320, width - 67)); + + _size = _imageSize; + _size.width+=20; + +} + +- (BOOL)isset { + return isPathExists([self path]) && [FileUtils checkNormalizedSize:[self path] checksize:self.webpage.document.size]; +} + +-(NSString *)path { + return self.webpage.document.path_with_cache; +} + + +-(Class)webpageContainer { + return NSClassFromString(@"TGWebpageGifContainer"); +} + +@end diff --git a/TelegramTest/TLApi.h b/TelegramTest/TLApi.h index 7ed68256..82cfb204 100644 --- a/TelegramTest/TLApi.h +++ b/TelegramTest/TLApi.h @@ -2,7 +2,7 @@ // TLApi.h // Telegram // -// Auto created by Mikhail Filimonov on 24.07.15. +// Auto created by Mikhail Filimonov on 27.11.15. // Copyright (c) 2013 Telegram for OS X. All rights reserved. // @@ -149,6 +149,13 @@ +(TLAPI_account_getWallPapers*)create; @end +@interface TLAPI_account_reportPeer : TLApiObject +@property (nonatomic, strong) TLInputPeer* peer; +@property (nonatomic, strong) TLReportReason* reason; + ++(TLAPI_account_reportPeer*)createWithPeer:(TLInputPeer*)peer reason:(TLReportReason*)reason; +@end + @interface TLAPI_users_getUsers : TLApiObject @property (nonatomic, strong) NSMutableArray* n_id; @@ -236,23 +243,28 @@ @end @interface TLAPI_messages_getDialogs : TLApiObject -@property int offset; -@property int max_id; +@property int offset_date; +@property int offset_id; +@property (nonatomic, strong) TLInputPeer* offset_peer; @property int limit; -+(TLAPI_messages_getDialogs*)createWithOffset:(int)offset max_id:(int)max_id limit:(int)limit; ++(TLAPI_messages_getDialogs*)createWithOffset_date:(int)offset_date offset_id:(int)offset_id offset_peer:(TLInputPeer*)offset_peer limit:(int)limit; @end @interface TLAPI_messages_getHistory : TLApiObject @property (nonatomic, strong) TLInputPeer* peer; -@property int offset; -@property int max_id; +@property int offset_id; +@property int add_offset; @property int limit; +@property int max_id; +@property int min_id; -+(TLAPI_messages_getHistory*)createWithPeer:(TLInputPeer*)peer offset:(int)offset max_id:(int)max_id limit:(int)limit; ++(TLAPI_messages_getHistory*)createWithPeer:(TLInputPeer*)peer offset_id:(int)offset_id add_offset:(int)add_offset limit:(int)limit max_id:(int)max_id min_id:(int)min_id; @end @interface TLAPI_messages_search : TLApiObject +@property int flags; +@property (nonatomic,assign,readonly) BOOL isImportant_only; @property (nonatomic, strong) TLInputPeer* peer; @property (nonatomic, strong) NSString* q; @property (nonatomic, strong) TLMessagesFilter* filter; @@ -262,22 +274,21 @@ @property int max_id; @property int limit; -+(TLAPI_messages_search*)createWithPeer:(TLInputPeer*)peer q:(NSString*)q filter:(TLMessagesFilter*)filter min_date:(int)min_date max_date:(int)max_date offset:(int)offset max_id:(int)max_id limit:(int)limit; ++(TLAPI_messages_search*)createWithFlags:(int)flags peer:(TLInputPeer*)peer q:(NSString*)q filter:(TLMessagesFilter*)filter min_date:(int)min_date max_date:(int)max_date offset:(int)offset max_id:(int)max_id limit:(int)limit; @end @interface TLAPI_messages_readHistory : TLApiObject @property (nonatomic, strong) TLInputPeer* peer; @property int max_id; -@property int offset; -+(TLAPI_messages_readHistory*)createWithPeer:(TLInputPeer*)peer max_id:(int)max_id offset:(int)offset; ++(TLAPI_messages_readHistory*)createWithPeer:(TLInputPeer*)peer max_id:(int)max_id; @end @interface TLAPI_messages_deleteHistory : TLApiObject @property (nonatomic, strong) TLInputPeer* peer; -@property int offset; +@property int max_id; -+(TLAPI_messages_deleteHistory*)createWithPeer:(TLInputPeer*)peer offset:(int)offset; ++(TLAPI_messages_deleteHistory*)createWithPeer:(TLInputPeer*)peer max_id:(int)max_id; @end @interface TLAPI_messages_deleteMessages : TLApiObject @@ -301,32 +312,45 @@ @interface TLAPI_messages_sendMessage : TLApiObject @property int flags; +@property (nonatomic,assign,readonly) BOOL isNo_webpage; +@property (nonatomic,assign,readonly) BOOL isBroadcast; @property (nonatomic, strong) TLInputPeer* peer; @property int reply_to_msg_id; @property (nonatomic, strong) NSString* message; @property long random_id; @property (nonatomic, strong) TLReplyMarkup* reply_markup; +@property (nonatomic, strong) NSMutableArray* entities; -+(TLAPI_messages_sendMessage*)createWithFlags:(int)flags peer:(TLInputPeer*)peer reply_to_msg_id:(int)reply_to_msg_id message:(NSString*)message random_id:(long)random_id reply_markup:(TLReplyMarkup*)reply_markup; ++(TLAPI_messages_sendMessage*)createWithFlags:(int)flags peer:(TLInputPeer*)peer reply_to_msg_id:(int)reply_to_msg_id message:(NSString*)message random_id:(long)random_id reply_markup:(TLReplyMarkup*)reply_markup entities:(NSMutableArray*)entities; @end @interface TLAPI_messages_sendMedia : TLApiObject @property int flags; +@property (nonatomic,assign,readonly) BOOL isBroadcast; @property (nonatomic, strong) TLInputPeer* peer; @property int reply_to_msg_id; @property (nonatomic, strong) TLInputMedia* media; @property long random_id; @property (nonatomic, strong) TLReplyMarkup* reply_markup; -+(TLAPI_messages_sendMedia*)createWithFlags:(int)flags peer:(TLInputPeer*)peer reply_to_msg_id:(int)reply_to_msg_id media:(TLInputMedia*)media random_id:(long)random_id reply_markup:(TLReplyMarkup*)reply_markup; ++(TLAPI_messages_sendMedia*)createWithFlags:(int)flags peer:(TLInputPeer*)peer reply_to_msg_id:(int)reply_to_msg_id media:(TLInputMedia*)media random_id:(long)random_id reply_markup:(TLReplyMarkup*)reply_markup; @end @interface TLAPI_messages_forwardMessages : TLApiObject -@property (nonatomic, strong) TLInputPeer* peer; +@property int flags; +@property (nonatomic,assign,readonly) BOOL isBroadcast; +@property (nonatomic, strong) TLInputPeer* from_peer; @property (nonatomic, strong) NSMutableArray* n_id; @property (nonatomic, strong) NSMutableArray* random_id; +@property (nonatomic, strong) TLInputPeer* to_peer; -+(TLAPI_messages_forwardMessages*)createWithPeer:(TLInputPeer*)peer n_id:(NSMutableArray*)n_id random_id:(NSMutableArray*)random_id; ++(TLAPI_messages_forwardMessages*)createWithFlags:(int)flags from_peer:(TLInputPeer*)from_peer n_id:(NSMutableArray*)n_id random_id:(NSMutableArray*)random_id to_peer:(TLInputPeer*)to_peer; +@end + +@interface TLAPI_messages_reportSpam : TLApiObject +@property (nonatomic, strong) TLInputPeer* peer; + ++(TLAPI_messages_reportSpam*)createWithPeer:(TLInputPeer*)peer; @end @interface TLAPI_messages_getChats : TLApiObject @@ -465,10 +489,10 @@ @interface TLAPI_photos_getUserPhotos : TLApiObject @property (nonatomic, strong) TLInputUser* user_id; @property int offset; -@property int max_id; +@property long max_id; @property int limit; -+(TLAPI_photos_getUserPhotos*)createWithUser_id:(TLInputUser*)user_id offset:(int)offset max_id:(int)max_id limit:(int)limit; ++(TLAPI_photos_getUserPhotos*)createWithUser_id:(TLInputUser*)user_id offset:(int)offset max_id:(long)max_id limit:(int)limit; @end @interface TLAPI_messages_forwardMessage : TLApiObject @@ -488,102 +512,6 @@ +(TLAPI_messages_sendBroadcast*)createWithContacts:(NSMutableArray*)contacts random_id:(NSMutableArray*)random_id message:(NSString*)message media:(TLInputMedia*)media; @end -@interface TLAPI_geochats_getLocated : TLApiObject -@property (nonatomic, strong) TLInputGeoPoint* geo_point; -@property int radius; -@property int limit; - -+(TLAPI_geochats_getLocated*)createWithGeo_point:(TLInputGeoPoint*)geo_point radius:(int)radius limit:(int)limit; -@end - -@interface TLAPI_geochats_getRecents : TLApiObject -@property int offset; -@property int limit; - -+(TLAPI_geochats_getRecents*)createWithOffset:(int)offset limit:(int)limit; -@end - -@interface TLAPI_geochats_checkin : TLApiObject -@property (nonatomic, strong) TLInputGeoChat* peer; - -+(TLAPI_geochats_checkin*)createWithPeer:(TLInputGeoChat*)peer; -@end - -@interface TLAPI_geochats_getFullChat : TLApiObject -@property (nonatomic, strong) TLInputGeoChat* peer; - -+(TLAPI_geochats_getFullChat*)createWithPeer:(TLInputGeoChat*)peer; -@end - -@interface TLAPI_geochats_editChatTitle : TLApiObject -@property (nonatomic, strong) TLInputGeoChat* peer; -@property (nonatomic, strong) NSString* title; -@property (nonatomic, strong) NSString* address; - -+(TLAPI_geochats_editChatTitle*)createWithPeer:(TLInputGeoChat*)peer title:(NSString*)title address:(NSString*)address; -@end - -@interface TLAPI_geochats_editChatPhoto : TLApiObject -@property (nonatomic, strong) TLInputGeoChat* peer; -@property (nonatomic, strong) TLInputChatPhoto* photo; - -+(TLAPI_geochats_editChatPhoto*)createWithPeer:(TLInputGeoChat*)peer photo:(TLInputChatPhoto*)photo; -@end - -@interface TLAPI_geochats_search : TLApiObject -@property (nonatomic, strong) TLInputGeoChat* peer; -@property (nonatomic, strong) NSString* q; -@property (nonatomic, strong) TLMessagesFilter* filter; -@property int min_date; -@property int max_date; -@property int offset; -@property int max_id; -@property int limit; - -+(TLAPI_geochats_search*)createWithPeer:(TLInputGeoChat*)peer q:(NSString*)q filter:(TLMessagesFilter*)filter min_date:(int)min_date max_date:(int)max_date offset:(int)offset max_id:(int)max_id limit:(int)limit; -@end - -@interface TLAPI_geochats_getHistory : TLApiObject -@property (nonatomic, strong) TLInputGeoChat* peer; -@property int offset; -@property int max_id; -@property int limit; - -+(TLAPI_geochats_getHistory*)createWithPeer:(TLInputGeoChat*)peer offset:(int)offset max_id:(int)max_id limit:(int)limit; -@end - -@interface TLAPI_geochats_setTyping : TLApiObject -@property (nonatomic, strong) TLInputGeoChat* peer; -@property Boolean typing; - -+(TLAPI_geochats_setTyping*)createWithPeer:(TLInputGeoChat*)peer typing:(Boolean)typing; -@end - -@interface TLAPI_geochats_sendMessage : TLApiObject -@property (nonatomic, strong) TLInputGeoChat* peer; -@property (nonatomic, strong) NSString* message; -@property long random_id; - -+(TLAPI_geochats_sendMessage*)createWithPeer:(TLInputGeoChat*)peer message:(NSString*)message random_id:(long)random_id; -@end - -@interface TLAPI_geochats_sendMedia : TLApiObject -@property (nonatomic, strong) TLInputGeoChat* peer; -@property (nonatomic, strong) TLInputMedia* media; -@property long random_id; - -+(TLAPI_geochats_sendMedia*)createWithPeer:(TLInputGeoChat*)peer media:(TLInputMedia*)media random_id:(long)random_id; -@end - -@interface TLAPI_geochats_createGeoChat : TLApiObject -@property (nonatomic, strong) NSString* title; -@property (nonatomic, strong) TLInputGeoPoint* geo_point; -@property (nonatomic, strong) NSString* address; -@property (nonatomic, strong) NSString* venue; - -+(TLAPI_geochats_createGeoChat*)createWithTitle:(NSString*)title geo_point:(TLInputGeoPoint*)geo_point address:(NSString*)address venue:(NSString*)venue; -@end - @interface TLAPI_messages_getDhConfig : TLApiObject @property int version; @property int random_length; @@ -764,9 +692,9 @@ @end @interface TLAPI_messages_getAllStickers : TLApiObject -@property (nonatomic, strong) NSString* n_hash; +@property int n_hash; -+(TLAPI_messages_getAllStickers*)createWithN_hash:(NSString*)n_hash; ++(TLAPI_messages_getAllStickers*)createWithN_hash:(int)n_hash; @end @interface TLAPI_account_updateDeviceLocked : TLApiObject @@ -878,10 +806,260 @@ @interface TLAPI_messages_startBot : TLApiObject @property (nonatomic, strong) TLInputUser* bot; -@property int chat_id; +@property (nonatomic, strong) TLInputPeer* peer; @property long random_id; @property (nonatomic, strong) NSString* start_param; -+(TLAPI_messages_startBot*)createWithBot:(TLInputUser*)bot chat_id:(int)chat_id random_id:(long)random_id start_param:(NSString*)start_param; ++(TLAPI_messages_startBot*)createWithBot:(TLInputUser*)bot peer:(TLInputPeer*)peer random_id:(long)random_id start_param:(NSString*)start_param; +@end + +@interface TLAPI_help_getAppChangelog : TLApiObject +@property (nonatomic, strong) NSString* device_model; +@property (nonatomic, strong) NSString* system_version; +@property (nonatomic, strong) NSString* app_version; +@property (nonatomic, strong) NSString* lang_code; + ++(TLAPI_help_getAppChangelog*)createWithDevice_model:(NSString*)device_model system_version:(NSString*)system_version app_version:(NSString*)app_version lang_code:(NSString*)lang_code; +@end + +@interface TLAPI_messages_getMessagesViews : TLApiObject +@property (nonatomic, strong) TLInputPeer* peer; +@property (nonatomic, strong) NSMutableArray* n_id; +@property Boolean increment; + ++(TLAPI_messages_getMessagesViews*)createWithPeer:(TLInputPeer*)peer n_id:(NSMutableArray*)n_id increment:(Boolean)increment; +@end + +@interface TLAPI_channels_getDialogs : TLApiObject +@property int offset; +@property int limit; + ++(TLAPI_channels_getDialogs*)createWithOffset:(int)offset limit:(int)limit; +@end + +@interface TLAPI_channels_getImportantHistory : TLApiObject +@property (nonatomic, strong) TLInputChannel* channel; +@property int offset_id; +@property int add_offset; +@property int limit; +@property int max_id; +@property int min_id; + ++(TLAPI_channels_getImportantHistory*)createWithChannel:(TLInputChannel*)channel offset_id:(int)offset_id add_offset:(int)add_offset limit:(int)limit max_id:(int)max_id min_id:(int)min_id; +@end + +@interface TLAPI_channels_readHistory : TLApiObject +@property (nonatomic, strong) TLInputChannel* channel; +@property int max_id; + ++(TLAPI_channels_readHistory*)createWithChannel:(TLInputChannel*)channel max_id:(int)max_id; +@end + +@interface TLAPI_channels_deleteMessages : TLApiObject +@property (nonatomic, strong) TLInputChannel* channel; +@property (nonatomic, strong) NSMutableArray* n_id; + ++(TLAPI_channels_deleteMessages*)createWithChannel:(TLInputChannel*)channel n_id:(NSMutableArray*)n_id; +@end + +@interface TLAPI_channels_deleteUserHistory : TLApiObject +@property (nonatomic, strong) TLInputChannel* channel; +@property (nonatomic, strong) TLInputUser* user_id; + ++(TLAPI_channels_deleteUserHistory*)createWithChannel:(TLInputChannel*)channel user_id:(TLInputUser*)user_id; +@end + +@interface TLAPI_channels_reportSpam : TLApiObject +@property (nonatomic, strong) TLInputChannel* channel; +@property (nonatomic, strong) TLInputUser* user_id; +@property (nonatomic, strong) NSMutableArray* n_id; + ++(TLAPI_channels_reportSpam*)createWithChannel:(TLInputChannel*)channel user_id:(TLInputUser*)user_id n_id:(NSMutableArray*)n_id; +@end + +@interface TLAPI_channels_getMessages : TLApiObject +@property (nonatomic, strong) TLInputChannel* channel; +@property (nonatomic, strong) NSMutableArray* n_id; + ++(TLAPI_channels_getMessages*)createWithChannel:(TLInputChannel*)channel n_id:(NSMutableArray*)n_id; +@end + +@interface TLAPI_channels_getParticipants : TLApiObject +@property (nonatomic, strong) TLInputChannel* channel; +@property (nonatomic, strong) TLChannelParticipantsFilter* filter; +@property int offset; +@property int limit; + ++(TLAPI_channels_getParticipants*)createWithChannel:(TLInputChannel*)channel filter:(TLChannelParticipantsFilter*)filter offset:(int)offset limit:(int)limit; +@end + +@interface TLAPI_channels_getParticipant : TLApiObject +@property (nonatomic, strong) TLInputChannel* channel; +@property (nonatomic, strong) TLInputUser* user_id; + ++(TLAPI_channels_getParticipant*)createWithChannel:(TLInputChannel*)channel user_id:(TLInputUser*)user_id; +@end + +@interface TLAPI_channels_getChannels : TLApiObject +@property (nonatomic, strong) NSMutableArray* n_id; + ++(TLAPI_channels_getChannels*)createWithN_id:(NSMutableArray*)n_id; +@end + +@interface TLAPI_channels_getFullChannel : TLApiObject +@property (nonatomic, strong) TLInputChannel* channel; + ++(TLAPI_channels_getFullChannel*)createWithChannel:(TLInputChannel*)channel; +@end + +@interface TLAPI_channels_createChannel : TLApiObject +@property int flags; +@property (nonatomic,assign,readonly) BOOL isBroadcast; +@property (nonatomic,assign,readonly) BOOL isMegagroup; +@property (nonatomic, strong) NSString* title; +@property (nonatomic, strong) NSString* about; + ++(TLAPI_channels_createChannel*)createWithFlags:(int)flags title:(NSString*)title about:(NSString*)about; +@end + +@interface TLAPI_channels_editAbout : TLApiObject +@property (nonatomic, strong) TLInputChannel* channel; +@property (nonatomic, strong) NSString* about; + ++(TLAPI_channels_editAbout*)createWithChannel:(TLInputChannel*)channel about:(NSString*)about; +@end + +@interface TLAPI_channels_editAdmin : TLApiObject +@property (nonatomic, strong) TLInputChannel* channel; +@property (nonatomic, strong) TLInputUser* user_id; +@property (nonatomic, strong) TLChannelParticipantRole* role; + ++(TLAPI_channels_editAdmin*)createWithChannel:(TLInputChannel*)channel user_id:(TLInputUser*)user_id role:(TLChannelParticipantRole*)role; +@end + +@interface TLAPI_channels_editTitle : TLApiObject +@property (nonatomic, strong) TLInputChannel* channel; +@property (nonatomic, strong) NSString* title; + ++(TLAPI_channels_editTitle*)createWithChannel:(TLInputChannel*)channel title:(NSString*)title; +@end + +@interface TLAPI_channels_editPhoto : TLApiObject +@property (nonatomic, strong) TLInputChannel* channel; +@property (nonatomic, strong) TLInputChatPhoto* photo; + ++(TLAPI_channels_editPhoto*)createWithChannel:(TLInputChannel*)channel photo:(TLInputChatPhoto*)photo; +@end + +@interface TLAPI_channels_toggleComments : TLApiObject +@property (nonatomic, strong) TLInputChannel* channel; +@property Boolean enabled; + ++(TLAPI_channels_toggleComments*)createWithChannel:(TLInputChannel*)channel enabled:(Boolean)enabled; +@end + +@interface TLAPI_channels_checkUsername : TLApiObject +@property (nonatomic, strong) TLInputChannel* channel; +@property (nonatomic, strong) NSString* username; + ++(TLAPI_channels_checkUsername*)createWithChannel:(TLInputChannel*)channel username:(NSString*)username; +@end + +@interface TLAPI_channels_updateUsername : TLApiObject +@property (nonatomic, strong) TLInputChannel* channel; +@property (nonatomic, strong) NSString* username; + ++(TLAPI_channels_updateUsername*)createWithChannel:(TLInputChannel*)channel username:(NSString*)username; +@end + +@interface TLAPI_channels_joinChannel : TLApiObject +@property (nonatomic, strong) TLInputChannel* channel; + ++(TLAPI_channels_joinChannel*)createWithChannel:(TLInputChannel*)channel; +@end + +@interface TLAPI_channels_leaveChannel : TLApiObject +@property (nonatomic, strong) TLInputChannel* channel; + ++(TLAPI_channels_leaveChannel*)createWithChannel:(TLInputChannel*)channel; +@end + +@interface TLAPI_channels_inviteToChannel : TLApiObject +@property (nonatomic, strong) TLInputChannel* channel; +@property (nonatomic, strong) NSMutableArray* users; + ++(TLAPI_channels_inviteToChannel*)createWithChannel:(TLInputChannel*)channel users:(NSMutableArray*)users; +@end + +@interface TLAPI_channels_kickFromChannel : TLApiObject +@property (nonatomic, strong) TLInputChannel* channel; +@property (nonatomic, strong) TLInputUser* user_id; +@property Boolean kicked; + ++(TLAPI_channels_kickFromChannel*)createWithChannel:(TLInputChannel*)channel user_id:(TLInputUser*)user_id kicked:(Boolean)kicked; +@end + +@interface TLAPI_channels_exportInvite : TLApiObject +@property (nonatomic, strong) TLInputChannel* channel; + ++(TLAPI_channels_exportInvite*)createWithChannel:(TLInputChannel*)channel; +@end + +@interface TLAPI_channels_deleteChannel : TLApiObject +@property (nonatomic, strong) TLInputChannel* channel; + ++(TLAPI_channels_deleteChannel*)createWithChannel:(TLInputChannel*)channel; +@end + +@interface TLAPI_updates_getChannelDifference : TLApiObject +@property (nonatomic, strong) TLInputChannel* channel; +@property (nonatomic, strong) TLChannelMessagesFilter* filter; +@property int pts; +@property int limit; + ++(TLAPI_updates_getChannelDifference*)createWithChannel:(TLInputChannel*)channel filter:(TLChannelMessagesFilter*)filter pts:(int)pts limit:(int)limit; +@end + +@interface TLAPI_messages_toggleChatAdmins : TLApiObject +@property int chat_id; +@property Boolean enabled; + ++(TLAPI_messages_toggleChatAdmins*)createWithChat_id:(int)chat_id enabled:(Boolean)enabled; +@end + +@interface TLAPI_messages_editChatAdmin : TLApiObject +@property int chat_id; +@property (nonatomic, strong) TLInputUser* user_id; +@property Boolean is_admin; + ++(TLAPI_messages_editChatAdmin*)createWithChat_id:(int)chat_id user_id:(TLInputUser*)user_id is_admin:(Boolean)is_admin; +@end + +@interface TLAPI_messages_migrateChat : TLApiObject +@property int chat_id; + ++(TLAPI_messages_migrateChat*)createWithChat_id:(int)chat_id; +@end + +@interface TLAPI_messages_searchGlobal : TLApiObject +@property (nonatomic, strong) NSString* q; +@property int offset_date; +@property (nonatomic, strong) TLInputPeer* offset_peer; +@property int offset_id; +@property int limit; + ++(TLAPI_messages_searchGlobal*)createWithQ:(NSString*)q offset_date:(int)offset_date offset_peer:(TLInputPeer*)offset_peer offset_id:(int)offset_id limit:(int)limit; +@end + +@interface TLAPI_help_getTermsOfService : TLApiObject +@property (nonatomic, strong) NSString* lang_code; + ++(TLAPI_help_getTermsOfService*)createWithLang_code:(NSString*)lang_code; +@end + +@interface TLAPI_messages_reorderStickerSets : TLApiObject +@property (nonatomic, strong) NSMutableArray* order; + ++(TLAPI_messages_reorderStickerSets*)createWithOrder:(NSMutableArray*)order; @end diff --git a/TelegramTest/TLApi.m b/TelegramTest/TLApi.m index 67369774..67b54bfd 100644 --- a/TelegramTest/TLApi.m +++ b/TelegramTest/TLApi.m @@ -2,7 +2,7 @@ // TLApi.m // Telegram // -// Auto created by Mikhail Filimonov on 24.07.15.. +// Auto created by Mikhail Filimonov on 27.11.15.. // Copyright (c) 2013 Telegram for OS X. All rights reserved. // @@ -318,6 +318,21 @@ - (NSData*)getData { } @end +@implementation TLAPI_account_reportPeer ++(TLAPI_account_reportPeer*)createWithPeer:(TLInputPeer*)peer reason:(TLReportReason*)reason { + TLAPI_account_reportPeer* obj = [[TLAPI_account_reportPeer alloc] init]; + obj.peer = peer; + obj.reason = reason; + return obj; +} +- (NSData*)getData { + SerializedData* stream = [ClassStore streamWithConstuctor:-1374118561]; + [ClassStore TLSerialize:self.peer stream:stream]; + [ClassStore TLSerialize:self.reason stream:stream]; + return [stream getOutput]; +} +@end + @implementation TLAPI_users_getUsers +(TLAPI_users_getUsers*)createWithN_id:(NSMutableArray*)n_id { TLAPI_users_getUsers* obj = [[TLAPI_users_getUsers alloc] init]; @@ -556,45 +571,53 @@ - (NSData*)getData { @end @implementation TLAPI_messages_getDialogs -+(TLAPI_messages_getDialogs*)createWithOffset:(int)offset max_id:(int)max_id limit:(int)limit { ++(TLAPI_messages_getDialogs*)createWithOffset_date:(int)offset_date offset_id:(int)offset_id offset_peer:(TLInputPeer*)offset_peer limit:(int)limit { TLAPI_messages_getDialogs* obj = [[TLAPI_messages_getDialogs alloc] init]; - obj.offset = offset; - obj.max_id = max_id; + obj.offset_date = offset_date; + obj.offset_id = offset_id; + obj.offset_peer = offset_peer; obj.limit = limit; return obj; } - (NSData*)getData { - SerializedData* stream = [ClassStore streamWithConstuctor:-321970698]; - [stream writeInt:self.offset]; - [stream writeInt:self.max_id]; + SerializedData* stream = [ClassStore streamWithConstuctor:1799878989]; + [stream writeInt:self.offset_date]; + [stream writeInt:self.offset_id]; + [ClassStore TLSerialize:self.offset_peer stream:stream]; [stream writeInt:self.limit]; return [stream getOutput]; } @end @implementation TLAPI_messages_getHistory -+(TLAPI_messages_getHistory*)createWithPeer:(TLInputPeer*)peer offset:(int)offset max_id:(int)max_id limit:(int)limit { ++(TLAPI_messages_getHistory*)createWithPeer:(TLInputPeer*)peer offset_id:(int)offset_id add_offset:(int)add_offset limit:(int)limit max_id:(int)max_id min_id:(int)min_id { TLAPI_messages_getHistory* obj = [[TLAPI_messages_getHistory alloc] init]; obj.peer = peer; - obj.offset = offset; - obj.max_id = max_id; + obj.offset_id = offset_id; + obj.add_offset = add_offset; obj.limit = limit; + obj.max_id = max_id; + obj.min_id = min_id; return obj; } - (NSData*)getData { - SerializedData* stream = [ClassStore streamWithConstuctor:-1834885329]; + SerializedData* stream = [ClassStore streamWithConstuctor:-1970355494]; [ClassStore TLSerialize:self.peer stream:stream]; - [stream writeInt:self.offset]; - [stream writeInt:self.max_id]; + [stream writeInt:self.offset_id]; + [stream writeInt:self.add_offset]; [stream writeInt:self.limit]; + [stream writeInt:self.max_id]; + [stream writeInt:self.min_id]; return [stream getOutput]; } @end @implementation TLAPI_messages_search -+(TLAPI_messages_search*)createWithPeer:(TLInputPeer*)peer q:(NSString*)q filter:(TLMessagesFilter*)filter min_date:(int)min_date max_date:(int)max_date offset:(int)offset max_id:(int)max_id limit:(int)limit { ++(TLAPI_messages_search*)createWithFlags:(int)flags peer:(TLInputPeer*)peer q:(NSString*)q filter:(TLMessagesFilter*)filter min_date:(int)min_date max_date:(int)max_date offset:(int)offset max_id:(int)max_id limit:(int)limit { TLAPI_messages_search* obj = [[TLAPI_messages_search alloc] init]; - obj.peer = peer; + obj.flags = flags; + + obj.peer = peer; obj.q = q; obj.filter = filter; obj.min_date = min_date; @@ -605,7 +628,9 @@ +(TLAPI_messages_search*)createWithPeer:(TLInputPeer*)peer q:(NSString*)q filter return obj; } - (NSData*)getData { - SerializedData* stream = [ClassStore streamWithConstuctor:132772523]; + SerializedData* stream = [ClassStore streamWithConstuctor:-732523960]; + [stream writeInt:self.flags]; + [ClassStore TLSerialize:self.peer stream:stream]; [stream writeString:self.q]; [ClassStore TLSerialize:self.filter stream:stream]; @@ -619,33 +644,31 @@ - (NSData*)getData { @end @implementation TLAPI_messages_readHistory -+(TLAPI_messages_readHistory*)createWithPeer:(TLInputPeer*)peer max_id:(int)max_id offset:(int)offset { ++(TLAPI_messages_readHistory*)createWithPeer:(TLInputPeer*)peer max_id:(int)max_id { TLAPI_messages_readHistory* obj = [[TLAPI_messages_readHistory alloc] init]; obj.peer = peer; obj.max_id = max_id; - obj.offset = offset; return obj; } - (NSData*)getData { - SerializedData* stream = [ClassStore streamWithConstuctor:-1336990448]; + SerializedData* stream = [ClassStore streamWithConstuctor:238054714]; [ClassStore TLSerialize:self.peer stream:stream]; [stream writeInt:self.max_id]; - [stream writeInt:self.offset]; return [stream getOutput]; } @end @implementation TLAPI_messages_deleteHistory -+(TLAPI_messages_deleteHistory*)createWithPeer:(TLInputPeer*)peer offset:(int)offset { ++(TLAPI_messages_deleteHistory*)createWithPeer:(TLInputPeer*)peer max_id:(int)max_id { TLAPI_messages_deleteHistory* obj = [[TLAPI_messages_deleteHistory alloc] init]; obj.peer = peer; - obj.offset = offset; + obj.max_id = max_id; return obj; } - (NSData*)getData { - SerializedData* stream = [ClassStore streamWithConstuctor:-185009311]; + SerializedData* stream = [ClassStore streamWithConstuctor:-1212072999]; [ClassStore TLSerialize:self.peer stream:stream]; - [stream writeInt:self.offset]; + [stream writeInt:self.max_id]; return [stream getOutput]; } @end @@ -704,32 +727,48 @@ - (NSData*)getData { @end @implementation TLAPI_messages_sendMessage -+(TLAPI_messages_sendMessage*)createWithFlags:(int)flags peer:(TLInputPeer*)peer reply_to_msg_id:(int)reply_to_msg_id message:(NSString*)message random_id:(long)random_id reply_markup:(TLReplyMarkup*)reply_markup { ++(TLAPI_messages_sendMessage*)createWithFlags:(int)flags peer:(TLInputPeer*)peer reply_to_msg_id:(int)reply_to_msg_id message:(NSString*)message random_id:(long)random_id reply_markup:(TLReplyMarkup*)reply_markup entities:(NSMutableArray*)entities { TLAPI_messages_sendMessage* obj = [[TLAPI_messages_sendMessage alloc] init]; obj.flags = flags; + + obj.peer = peer; obj.reply_to_msg_id = reply_to_msg_id; obj.message = message; obj.random_id = random_id; obj.reply_markup = reply_markup; + obj.entities = entities; return obj; } - (NSData*)getData { - SerializedData* stream = [ClassStore streamWithConstuctor:-61479243]; + SerializedData* stream = [ClassStore streamWithConstuctor:-91733382]; [stream writeInt:self.flags]; + + [ClassStore TLSerialize:self.peer stream:stream]; - if(self.flags & (1 << 0)) [stream writeInt:self.reply_to_msg_id]; + if(self.flags & (1 << 0)) {[stream writeInt:self.reply_to_msg_id];} [stream writeString:self.message]; [stream writeLong:self.random_id]; - if(self.flags & (1 << 2)) [ClassStore TLSerialize:self.reply_markup stream:stream]; + if(self.flags & (1 << 2)) {[ClassStore TLSerialize:self.reply_markup stream:stream];} + if(self.flags & (1 << 3)) {//Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.entities count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLMessageEntity* obj = [self.entities objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + }} return [stream getOutput]; } @end @implementation TLAPI_messages_sendMedia -+(TLAPI_messages_sendMedia*)createWithFlags:(int)flags peer:(TLInputPeer*)peer reply_to_msg_id:(int)reply_to_msg_id media:(TLInputMedia*)media random_id:(long)random_id reply_markup:(TLReplyMarkup*)reply_markup { ++(TLAPI_messages_sendMedia*)createWithFlags:(int)flags peer:(TLInputPeer*)peer reply_to_msg_id:(int)reply_to_msg_id media:(TLInputMedia*)media random_id:(long)random_id reply_markup:(TLReplyMarkup*)reply_markup { TLAPI_messages_sendMedia* obj = [[TLAPI_messages_sendMedia alloc] init]; obj.flags = flags; + obj.peer = peer; obj.reply_to_msg_id = reply_to_msg_id; obj.media = media; @@ -740,26 +779,32 @@ +(TLAPI_messages_sendMedia*)createWithFlags:(int)flags peer:(TLInputPeer*)peer r - (NSData*)getData { SerializedData* stream = [ClassStore streamWithConstuctor:-923703407]; [stream writeInt:self.flags]; + [ClassStore TLSerialize:self.peer stream:stream]; - if(self.flags & (1 << 0)) [stream writeInt:self.reply_to_msg_id]; + if(self.flags & (1 << 0)) {[stream writeInt:self.reply_to_msg_id];} [ClassStore TLSerialize:self.media stream:stream]; [stream writeLong:self.random_id]; - if(self.flags & (1 << 2)) [ClassStore TLSerialize:self.reply_markup stream:stream]; + if(self.flags & (1 << 2)) {[ClassStore TLSerialize:self.reply_markup stream:stream];} return [stream getOutput]; } @end @implementation TLAPI_messages_forwardMessages -+(TLAPI_messages_forwardMessages*)createWithPeer:(TLInputPeer*)peer n_id:(NSMutableArray*)n_id random_id:(NSMutableArray*)random_id { ++(TLAPI_messages_forwardMessages*)createWithFlags:(int)flags from_peer:(TLInputPeer*)from_peer n_id:(NSMutableArray*)n_id random_id:(NSMutableArray*)random_id to_peer:(TLInputPeer*)to_peer { TLAPI_messages_forwardMessages* obj = [[TLAPI_messages_forwardMessages alloc] init]; - obj.peer = peer; + obj.flags = flags; + + obj.from_peer = from_peer; obj.n_id = n_id; obj.random_id = random_id; + obj.to_peer = to_peer; return obj; } - (NSData*)getData { - SerializedData* stream = [ClassStore streamWithConstuctor:1440838285]; - [ClassStore TLSerialize:self.peer stream:stream]; + SerializedData* stream = [ClassStore streamWithConstuctor:1888354709]; + [stream writeInt:self.flags]; + + [ClassStore TLSerialize:self.from_peer stream:stream]; //Serialize ShortVector [stream writeInt:0x1cb5c415]; { @@ -786,6 +831,20 @@ - (NSData*)getData { break; } } + [ClassStore TLSerialize:self.to_peer stream:stream]; + return [stream getOutput]; +} +@end + +@implementation TLAPI_messages_reportSpam ++(TLAPI_messages_reportSpam*)createWithPeer:(TLInputPeer*)peer { + TLAPI_messages_reportSpam* obj = [[TLAPI_messages_reportSpam alloc] init]; + obj.peer = peer; + return obj; +} +- (NSData*)getData { + SerializedData* stream = [ClassStore streamWithConstuctor:-820669733]; + [ClassStore TLSerialize:self.peer stream:stream]; return [stream getOutput]; } @end @@ -1115,7 +1174,7 @@ - (NSData*)getData { @end @implementation TLAPI_photos_getUserPhotos -+(TLAPI_photos_getUserPhotos*)createWithUser_id:(TLInputUser*)user_id offset:(int)offset max_id:(int)max_id limit:(int)limit { ++(TLAPI_photos_getUserPhotos*)createWithUser_id:(TLInputUser*)user_id offset:(int)offset max_id:(long)max_id limit:(int)limit { TLAPI_photos_getUserPhotos* obj = [[TLAPI_photos_getUserPhotos alloc] init]; obj.user_id = user_id; obj.offset = offset; @@ -1124,10 +1183,10 @@ +(TLAPI_photos_getUserPhotos*)createWithUser_id:(TLInputUser*)user_id offset:(in return obj; } - (NSData*)getData { - SerializedData* stream = [ClassStore streamWithConstuctor:-1209117380]; + SerializedData* stream = [ClassStore streamWithConstuctor:-1848823128]; [ClassStore TLSerialize:self.user_id stream:stream]; [stream writeInt:self.offset]; - [stream writeInt:self.max_id]; + [stream writeLong:self.max_id]; [stream writeInt:self.limit]; return [stream getOutput]; } @@ -1190,210 +1249,6 @@ - (NSData*)getData { } @end -@implementation TLAPI_geochats_getLocated -+(TLAPI_geochats_getLocated*)createWithGeo_point:(TLInputGeoPoint*)geo_point radius:(int)radius limit:(int)limit { - TLAPI_geochats_getLocated* obj = [[TLAPI_geochats_getLocated alloc] init]; - obj.geo_point = geo_point; - obj.radius = radius; - obj.limit = limit; - return obj; -} -- (NSData*)getData { - SerializedData* stream = [ClassStore streamWithConstuctor:2132356495]; - [ClassStore TLSerialize:self.geo_point stream:stream]; - [stream writeInt:self.radius]; - [stream writeInt:self.limit]; - return [stream getOutput]; -} -@end - -@implementation TLAPI_geochats_getRecents -+(TLAPI_geochats_getRecents*)createWithOffset:(int)offset limit:(int)limit { - TLAPI_geochats_getRecents* obj = [[TLAPI_geochats_getRecents alloc] init]; - obj.offset = offset; - obj.limit = limit; - return obj; -} -- (NSData*)getData { - SerializedData* stream = [ClassStore streamWithConstuctor:-515735953]; - [stream writeInt:self.offset]; - [stream writeInt:self.limit]; - return [stream getOutput]; -} -@end - -@implementation TLAPI_geochats_checkin -+(TLAPI_geochats_checkin*)createWithPeer:(TLInputGeoChat*)peer { - TLAPI_geochats_checkin* obj = [[TLAPI_geochats_checkin alloc] init]; - obj.peer = peer; - return obj; -} -- (NSData*)getData { - SerializedData* stream = [ClassStore streamWithConstuctor:1437853947]; - [ClassStore TLSerialize:self.peer stream:stream]; - return [stream getOutput]; -} -@end - -@implementation TLAPI_geochats_getFullChat -+(TLAPI_geochats_getFullChat*)createWithPeer:(TLInputGeoChat*)peer { - TLAPI_geochats_getFullChat* obj = [[TLAPI_geochats_getFullChat alloc] init]; - obj.peer = peer; - return obj; -} -- (NSData*)getData { - SerializedData* stream = [ClassStore streamWithConstuctor:1730338159]; - [ClassStore TLSerialize:self.peer stream:stream]; - return [stream getOutput]; -} -@end - -@implementation TLAPI_geochats_editChatTitle -+(TLAPI_geochats_editChatTitle*)createWithPeer:(TLInputGeoChat*)peer title:(NSString*)title address:(NSString*)address { - TLAPI_geochats_editChatTitle* obj = [[TLAPI_geochats_editChatTitle alloc] init]; - obj.peer = peer; - obj.title = title; - obj.address = address; - return obj; -} -- (NSData*)getData { - SerializedData* stream = [ClassStore streamWithConstuctor:1284383347]; - [ClassStore TLSerialize:self.peer stream:stream]; - [stream writeString:self.title]; - [stream writeString:self.address]; - return [stream getOutput]; -} -@end - -@implementation TLAPI_geochats_editChatPhoto -+(TLAPI_geochats_editChatPhoto*)createWithPeer:(TLInputGeoChat*)peer photo:(TLInputChatPhoto*)photo { - TLAPI_geochats_editChatPhoto* obj = [[TLAPI_geochats_editChatPhoto alloc] init]; - obj.peer = peer; - obj.photo = photo; - return obj; -} -- (NSData*)getData { - SerializedData* stream = [ClassStore streamWithConstuctor:903355029]; - [ClassStore TLSerialize:self.peer stream:stream]; - [ClassStore TLSerialize:self.photo stream:stream]; - return [stream getOutput]; -} -@end - -@implementation TLAPI_geochats_search -+(TLAPI_geochats_search*)createWithPeer:(TLInputGeoChat*)peer q:(NSString*)q filter:(TLMessagesFilter*)filter min_date:(int)min_date max_date:(int)max_date offset:(int)offset max_id:(int)max_id limit:(int)limit { - TLAPI_geochats_search* obj = [[TLAPI_geochats_search alloc] init]; - obj.peer = peer; - obj.q = q; - obj.filter = filter; - obj.min_date = min_date; - obj.max_date = max_date; - obj.offset = offset; - obj.max_id = max_id; - obj.limit = limit; - return obj; -} -- (NSData*)getData { - SerializedData* stream = [ClassStore streamWithConstuctor:-808598451]; - [ClassStore TLSerialize:self.peer stream:stream]; - [stream writeString:self.q]; - [ClassStore TLSerialize:self.filter stream:stream]; - [stream writeInt:self.min_date]; - [stream writeInt:self.max_date]; - [stream writeInt:self.offset]; - [stream writeInt:self.max_id]; - [stream writeInt:self.limit]; - return [stream getOutput]; -} -@end - -@implementation TLAPI_geochats_getHistory -+(TLAPI_geochats_getHistory*)createWithPeer:(TLInputGeoChat*)peer offset:(int)offset max_id:(int)max_id limit:(int)limit { - TLAPI_geochats_getHistory* obj = [[TLAPI_geochats_getHistory alloc] init]; - obj.peer = peer; - obj.offset = offset; - obj.max_id = max_id; - obj.limit = limit; - return obj; -} -- (NSData*)getData { - SerializedData* stream = [ClassStore streamWithConstuctor:-1254131096]; - [ClassStore TLSerialize:self.peer stream:stream]; - [stream writeInt:self.offset]; - [stream writeInt:self.max_id]; - [stream writeInt:self.limit]; - return [stream getOutput]; -} -@end - -@implementation TLAPI_geochats_setTyping -+(TLAPI_geochats_setTyping*)createWithPeer:(TLInputGeoChat*)peer typing:(Boolean)typing { - TLAPI_geochats_setTyping* obj = [[TLAPI_geochats_setTyping alloc] init]; - obj.peer = peer; - obj.typing = typing; - return obj; -} -- (NSData*)getData { - SerializedData* stream = [ClassStore streamWithConstuctor:146319145]; - [ClassStore TLSerialize:self.peer stream:stream]; - [stream writeBool:self.typing]; - return [stream getOutput]; -} -@end - -@implementation TLAPI_geochats_sendMessage -+(TLAPI_geochats_sendMessage*)createWithPeer:(TLInputGeoChat*)peer message:(NSString*)message random_id:(long)random_id { - TLAPI_geochats_sendMessage* obj = [[TLAPI_geochats_sendMessage alloc] init]; - obj.peer = peer; - obj.message = message; - obj.random_id = random_id; - return obj; -} -- (NSData*)getData { - SerializedData* stream = [ClassStore streamWithConstuctor:102432836]; - [ClassStore TLSerialize:self.peer stream:stream]; - [stream writeString:self.message]; - [stream writeLong:self.random_id]; - return [stream getOutput]; -} -@end - -@implementation TLAPI_geochats_sendMedia -+(TLAPI_geochats_sendMedia*)createWithPeer:(TLInputGeoChat*)peer media:(TLInputMedia*)media random_id:(long)random_id { - TLAPI_geochats_sendMedia* obj = [[TLAPI_geochats_sendMedia alloc] init]; - obj.peer = peer; - obj.media = media; - obj.random_id = random_id; - return obj; -} -- (NSData*)getData { - SerializedData* stream = [ClassStore streamWithConstuctor:-1192173825]; - [ClassStore TLSerialize:self.peer stream:stream]; - [ClassStore TLSerialize:self.media stream:stream]; - [stream writeLong:self.random_id]; - return [stream getOutput]; -} -@end - -@implementation TLAPI_geochats_createGeoChat -+(TLAPI_geochats_createGeoChat*)createWithTitle:(NSString*)title geo_point:(TLInputGeoPoint*)geo_point address:(NSString*)address venue:(NSString*)venue { - TLAPI_geochats_createGeoChat* obj = [[TLAPI_geochats_createGeoChat alloc] init]; - obj.title = title; - obj.geo_point = geo_point; - obj.address = address; - obj.venue = venue; - return obj; -} -- (NSData*)getData { - SerializedData* stream = [ClassStore streamWithConstuctor:235482646]; - [stream writeString:self.title]; - [ClassStore TLSerialize:self.geo_point stream:stream]; - [stream writeString:self.address]; - [stream writeString:self.venue]; - return [stream getOutput]; -} -@end - @implementation TLAPI_messages_getDhConfig +(TLAPI_messages_getDhConfig*)createWithVersion:(int)version random_length:(int)random_length { TLAPI_messages_getDhConfig* obj = [[TLAPI_messages_getDhConfig alloc] init]; @@ -1748,7 +1603,7 @@ +(TLAPI_contacts_resolveUsername*)createWithUsername:(NSString*)username { return obj; } - (NSData*)getData { - SerializedData* stream = [ClassStore streamWithConstuctor:200282908]; + SerializedData* stream = [ClassStore streamWithConstuctor:-113456221]; [stream writeString:self.username]; return [stream getOutput]; } @@ -1800,14 +1655,14 @@ - (NSData*)getData { @end @implementation TLAPI_messages_getAllStickers -+(TLAPI_messages_getAllStickers*)createWithN_hash:(NSString*)n_hash { ++(TLAPI_messages_getAllStickers*)createWithN_hash:(int)n_hash { TLAPI_messages_getAllStickers* obj = [[TLAPI_messages_getAllStickers alloc] init]; obj.n_hash = n_hash; return obj; } - (NSData*)getData { - SerializedData* stream = [ClassStore streamWithConstuctor:-1438922648]; - [stream writeString:self.n_hash]; + SerializedData* stream = [ClassStore streamWithConstuctor:479598769]; + [stream writeInt:self.n_hash]; return [stream getOutput]; } @end @@ -2044,20 +1899,632 @@ - (NSData*)getData { @end @implementation TLAPI_messages_startBot -+(TLAPI_messages_startBot*)createWithBot:(TLInputUser*)bot chat_id:(int)chat_id random_id:(long)random_id start_param:(NSString*)start_param { ++(TLAPI_messages_startBot*)createWithBot:(TLInputUser*)bot peer:(TLInputPeer*)peer random_id:(long)random_id start_param:(NSString*)start_param { TLAPI_messages_startBot* obj = [[TLAPI_messages_startBot alloc] init]; obj.bot = bot; - obj.chat_id = chat_id; + obj.peer = peer; obj.random_id = random_id; obj.start_param = start_param; return obj; } - (NSData*)getData { - SerializedData* stream = [ClassStore streamWithConstuctor:457052156]; + SerializedData* stream = [ClassStore streamWithConstuctor:-421563528]; [ClassStore TLSerialize:self.bot stream:stream]; - [stream writeInt:self.chat_id]; + [ClassStore TLSerialize:self.peer stream:stream]; [stream writeLong:self.random_id]; [stream writeString:self.start_param]; return [stream getOutput]; } +@end + +@implementation TLAPI_help_getAppChangelog ++(TLAPI_help_getAppChangelog*)createWithDevice_model:(NSString*)device_model system_version:(NSString*)system_version app_version:(NSString*)app_version lang_code:(NSString*)lang_code { + TLAPI_help_getAppChangelog* obj = [[TLAPI_help_getAppChangelog alloc] init]; + obj.device_model = device_model; + obj.system_version = system_version; + obj.app_version = app_version; + obj.lang_code = lang_code; + return obj; +} +- (NSData*)getData { + SerializedData* stream = [ClassStore streamWithConstuctor:1537966002]; + [stream writeString:self.device_model]; + [stream writeString:self.system_version]; + [stream writeString:self.app_version]; + [stream writeString:self.lang_code]; + return [stream getOutput]; +} +@end + +@implementation TLAPI_messages_getMessagesViews ++(TLAPI_messages_getMessagesViews*)createWithPeer:(TLInputPeer*)peer n_id:(NSMutableArray*)n_id increment:(Boolean)increment { + TLAPI_messages_getMessagesViews* obj = [[TLAPI_messages_getMessagesViews alloc] init]; + obj.peer = peer; + obj.n_id = n_id; + obj.increment = increment; + return obj; +} +- (NSData*)getData { + SerializedData* stream = [ClassStore streamWithConstuctor:-993483427]; + [ClassStore TLSerialize:self.peer stream:stream]; + //Serialize ShortVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.n_id count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + if([self.n_id count] > i) { + NSNumber* obj = [self.n_id objectAtIndex:i]; + [stream writeInt:[obj intValue]]; + } else + break; + } + } + [stream writeBool:self.increment]; + return [stream getOutput]; +} +@end + +@implementation TLAPI_channels_getDialogs ++(TLAPI_channels_getDialogs*)createWithOffset:(int)offset limit:(int)limit { + TLAPI_channels_getDialogs* obj = [[TLAPI_channels_getDialogs alloc] init]; + obj.offset = offset; + obj.limit = limit; + return obj; +} +- (NSData*)getData { + SerializedData* stream = [ClassStore streamWithConstuctor:-1445735863]; + [stream writeInt:self.offset]; + [stream writeInt:self.limit]; + return [stream getOutput]; +} +@end + +@implementation TLAPI_channels_getImportantHistory ++(TLAPI_channels_getImportantHistory*)createWithChannel:(TLInputChannel*)channel offset_id:(int)offset_id add_offset:(int)add_offset limit:(int)limit max_id:(int)max_id min_id:(int)min_id { + TLAPI_channels_getImportantHistory* obj = [[TLAPI_channels_getImportantHistory alloc] init]; + obj.channel = channel; + obj.offset_id = offset_id; + obj.add_offset = add_offset; + obj.limit = limit; + obj.max_id = max_id; + obj.min_id = min_id; + return obj; +} +- (NSData*)getData { + SerializedData* stream = [ClassStore streamWithConstuctor:-575067701]; + [ClassStore TLSerialize:self.channel stream:stream]; + [stream writeInt:self.offset_id]; + [stream writeInt:self.add_offset]; + [stream writeInt:self.limit]; + [stream writeInt:self.max_id]; + [stream writeInt:self.min_id]; + return [stream getOutput]; +} +@end + +@implementation TLAPI_channels_readHistory ++(TLAPI_channels_readHistory*)createWithChannel:(TLInputChannel*)channel max_id:(int)max_id { + TLAPI_channels_readHistory* obj = [[TLAPI_channels_readHistory alloc] init]; + obj.channel = channel; + obj.max_id = max_id; + return obj; +} +- (NSData*)getData { + SerializedData* stream = [ClassStore streamWithConstuctor:-871347913]; + [ClassStore TLSerialize:self.channel stream:stream]; + [stream writeInt:self.max_id]; + return [stream getOutput]; +} +@end + +@implementation TLAPI_channels_deleteMessages ++(TLAPI_channels_deleteMessages*)createWithChannel:(TLInputChannel*)channel n_id:(NSMutableArray*)n_id { + TLAPI_channels_deleteMessages* obj = [[TLAPI_channels_deleteMessages alloc] init]; + obj.channel = channel; + obj.n_id = n_id; + return obj; +} +- (NSData*)getData { + SerializedData* stream = [ClassStore streamWithConstuctor:-2067661490]; + [ClassStore TLSerialize:self.channel stream:stream]; + //Serialize ShortVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.n_id count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + if([self.n_id count] > i) { + NSNumber* obj = [self.n_id objectAtIndex:i]; + [stream writeInt:[obj intValue]]; + } else + break; + } + } + return [stream getOutput]; +} +@end + +@implementation TLAPI_channels_deleteUserHistory ++(TLAPI_channels_deleteUserHistory*)createWithChannel:(TLInputChannel*)channel user_id:(TLInputUser*)user_id { + TLAPI_channels_deleteUserHistory* obj = [[TLAPI_channels_deleteUserHistory alloc] init]; + obj.channel = channel; + obj.user_id = user_id; + return obj; +} +- (NSData*)getData { + SerializedData* stream = [ClassStore streamWithConstuctor:-787622117]; + [ClassStore TLSerialize:self.channel stream:stream]; + [ClassStore TLSerialize:self.user_id stream:stream]; + return [stream getOutput]; +} +@end + +@implementation TLAPI_channels_reportSpam ++(TLAPI_channels_reportSpam*)createWithChannel:(TLInputChannel*)channel user_id:(TLInputUser*)user_id n_id:(NSMutableArray*)n_id { + TLAPI_channels_reportSpam* obj = [[TLAPI_channels_reportSpam alloc] init]; + obj.channel = channel; + obj.user_id = user_id; + obj.n_id = n_id; + return obj; +} +- (NSData*)getData { + SerializedData* stream = [ClassStore streamWithConstuctor:-32999408]; + [ClassStore TLSerialize:self.channel stream:stream]; + [ClassStore TLSerialize:self.user_id stream:stream]; + //Serialize ShortVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.n_id count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + if([self.n_id count] > i) { + NSNumber* obj = [self.n_id objectAtIndex:i]; + [stream writeInt:[obj intValue]]; + } else + break; + } + } + return [stream getOutput]; +} +@end + +@implementation TLAPI_channels_getMessages ++(TLAPI_channels_getMessages*)createWithChannel:(TLInputChannel*)channel n_id:(NSMutableArray*)n_id { + TLAPI_channels_getMessages* obj = [[TLAPI_channels_getMessages alloc] init]; + obj.channel = channel; + obj.n_id = n_id; + return obj; +} +- (NSData*)getData { + SerializedData* stream = [ClassStore streamWithConstuctor:-1814580409]; + [ClassStore TLSerialize:self.channel stream:stream]; + //Serialize ShortVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.n_id count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + if([self.n_id count] > i) { + NSNumber* obj = [self.n_id objectAtIndex:i]; + [stream writeInt:[obj intValue]]; + } else + break; + } + } + return [stream getOutput]; +} +@end + +@implementation TLAPI_channels_getParticipants ++(TLAPI_channels_getParticipants*)createWithChannel:(TLInputChannel*)channel filter:(TLChannelParticipantsFilter*)filter offset:(int)offset limit:(int)limit { + TLAPI_channels_getParticipants* obj = [[TLAPI_channels_getParticipants alloc] init]; + obj.channel = channel; + obj.filter = filter; + obj.offset = offset; + obj.limit = limit; + return obj; +} +- (NSData*)getData { + SerializedData* stream = [ClassStore streamWithConstuctor:618237842]; + [ClassStore TLSerialize:self.channel stream:stream]; + [ClassStore TLSerialize:self.filter stream:stream]; + [stream writeInt:self.offset]; + [stream writeInt:self.limit]; + return [stream getOutput]; +} +@end + +@implementation TLAPI_channels_getParticipant ++(TLAPI_channels_getParticipant*)createWithChannel:(TLInputChannel*)channel user_id:(TLInputUser*)user_id { + TLAPI_channels_getParticipant* obj = [[TLAPI_channels_getParticipant alloc] init]; + obj.channel = channel; + obj.user_id = user_id; + return obj; +} +- (NSData*)getData { + SerializedData* stream = [ClassStore streamWithConstuctor:1416484774]; + [ClassStore TLSerialize:self.channel stream:stream]; + [ClassStore TLSerialize:self.user_id stream:stream]; + return [stream getOutput]; +} +@end + +@implementation TLAPI_channels_getChannels ++(TLAPI_channels_getChannels*)createWithN_id:(NSMutableArray*)n_id { + TLAPI_channels_getChannels* obj = [[TLAPI_channels_getChannels alloc] init]; + obj.n_id = n_id; + return obj; +} +- (NSData*)getData { + SerializedData* stream = [ClassStore streamWithConstuctor:176122811]; + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.n_id count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLInputChannel* obj = [self.n_id objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + return [stream getOutput]; +} +@end + +@implementation TLAPI_channels_getFullChannel ++(TLAPI_channels_getFullChannel*)createWithChannel:(TLInputChannel*)channel { + TLAPI_channels_getFullChannel* obj = [[TLAPI_channels_getFullChannel alloc] init]; + obj.channel = channel; + return obj; +} +- (NSData*)getData { + SerializedData* stream = [ClassStore streamWithConstuctor:141781513]; + [ClassStore TLSerialize:self.channel stream:stream]; + return [stream getOutput]; +} +@end + +@implementation TLAPI_channels_createChannel ++(TLAPI_channels_createChannel*)createWithFlags:(int)flags title:(NSString*)title about:(NSString*)about { + TLAPI_channels_createChannel* obj = [[TLAPI_channels_createChannel alloc] init]; + obj.flags = flags; + + + obj.title = title; + obj.about = about; + return obj; +} +- (NSData*)getData { + SerializedData* stream = [ClassStore streamWithConstuctor:-192332417]; + [stream writeInt:self.flags]; + + + [stream writeString:self.title]; + [stream writeString:self.about]; + return [stream getOutput]; +} +@end + +@implementation TLAPI_channels_editAbout ++(TLAPI_channels_editAbout*)createWithChannel:(TLInputChannel*)channel about:(NSString*)about { + TLAPI_channels_editAbout* obj = [[TLAPI_channels_editAbout alloc] init]; + obj.channel = channel; + obj.about = about; + return obj; +} +- (NSData*)getData { + SerializedData* stream = [ClassStore streamWithConstuctor:333610782]; + [ClassStore TLSerialize:self.channel stream:stream]; + [stream writeString:self.about]; + return [stream getOutput]; +} +@end + +@implementation TLAPI_channels_editAdmin ++(TLAPI_channels_editAdmin*)createWithChannel:(TLInputChannel*)channel user_id:(TLInputUser*)user_id role:(TLChannelParticipantRole*)role { + TLAPI_channels_editAdmin* obj = [[TLAPI_channels_editAdmin alloc] init]; + obj.channel = channel; + obj.user_id = user_id; + obj.role = role; + return obj; +} +- (NSData*)getData { + SerializedData* stream = [ClassStore streamWithConstuctor:-344583728]; + [ClassStore TLSerialize:self.channel stream:stream]; + [ClassStore TLSerialize:self.user_id stream:stream]; + [ClassStore TLSerialize:self.role stream:stream]; + return [stream getOutput]; +} +@end + +@implementation TLAPI_channels_editTitle ++(TLAPI_channels_editTitle*)createWithChannel:(TLInputChannel*)channel title:(NSString*)title { + TLAPI_channels_editTitle* obj = [[TLAPI_channels_editTitle alloc] init]; + obj.channel = channel; + obj.title = title; + return obj; +} +- (NSData*)getData { + SerializedData* stream = [ClassStore streamWithConstuctor:1450044624]; + [ClassStore TLSerialize:self.channel stream:stream]; + [stream writeString:self.title]; + return [stream getOutput]; +} +@end + +@implementation TLAPI_channels_editPhoto ++(TLAPI_channels_editPhoto*)createWithChannel:(TLInputChannel*)channel photo:(TLInputChatPhoto*)photo { + TLAPI_channels_editPhoto* obj = [[TLAPI_channels_editPhoto alloc] init]; + obj.channel = channel; + obj.photo = photo; + return obj; +} +- (NSData*)getData { + SerializedData* stream = [ClassStore streamWithConstuctor:-248621111]; + [ClassStore TLSerialize:self.channel stream:stream]; + [ClassStore TLSerialize:self.photo stream:stream]; + return [stream getOutput]; +} +@end + +@implementation TLAPI_channels_toggleComments ++(TLAPI_channels_toggleComments*)createWithChannel:(TLInputChannel*)channel enabled:(Boolean)enabled { + TLAPI_channels_toggleComments* obj = [[TLAPI_channels_toggleComments alloc] init]; + obj.channel = channel; + obj.enabled = enabled; + return obj; +} +- (NSData*)getData { + SerializedData* stream = [ClassStore streamWithConstuctor:-1432183160]; + [ClassStore TLSerialize:self.channel stream:stream]; + [stream writeBool:self.enabled]; + return [stream getOutput]; +} +@end + +@implementation TLAPI_channels_checkUsername ++(TLAPI_channels_checkUsername*)createWithChannel:(TLInputChannel*)channel username:(NSString*)username { + TLAPI_channels_checkUsername* obj = [[TLAPI_channels_checkUsername alloc] init]; + obj.channel = channel; + obj.username = username; + return obj; +} +- (NSData*)getData { + SerializedData* stream = [ClassStore streamWithConstuctor:283557164]; + [ClassStore TLSerialize:self.channel stream:stream]; + [stream writeString:self.username]; + return [stream getOutput]; +} +@end + +@implementation TLAPI_channels_updateUsername ++(TLAPI_channels_updateUsername*)createWithChannel:(TLInputChannel*)channel username:(NSString*)username { + TLAPI_channels_updateUsername* obj = [[TLAPI_channels_updateUsername alloc] init]; + obj.channel = channel; + obj.username = username; + return obj; +} +- (NSData*)getData { + SerializedData* stream = [ClassStore streamWithConstuctor:890549214]; + [ClassStore TLSerialize:self.channel stream:stream]; + [stream writeString:self.username]; + return [stream getOutput]; +} +@end + +@implementation TLAPI_channels_joinChannel ++(TLAPI_channels_joinChannel*)createWithChannel:(TLInputChannel*)channel { + TLAPI_channels_joinChannel* obj = [[TLAPI_channels_joinChannel alloc] init]; + obj.channel = channel; + return obj; +} +- (NSData*)getData { + SerializedData* stream = [ClassStore streamWithConstuctor:615851205]; + [ClassStore TLSerialize:self.channel stream:stream]; + return [stream getOutput]; +} +@end + +@implementation TLAPI_channels_leaveChannel ++(TLAPI_channels_leaveChannel*)createWithChannel:(TLInputChannel*)channel { + TLAPI_channels_leaveChannel* obj = [[TLAPI_channels_leaveChannel alloc] init]; + obj.channel = channel; + return obj; +} +- (NSData*)getData { + SerializedData* stream = [ClassStore streamWithConstuctor:-130635115]; + [ClassStore TLSerialize:self.channel stream:stream]; + return [stream getOutput]; +} +@end + +@implementation TLAPI_channels_inviteToChannel ++(TLAPI_channels_inviteToChannel*)createWithChannel:(TLInputChannel*)channel users:(NSMutableArray*)users { + TLAPI_channels_inviteToChannel* obj = [[TLAPI_channels_inviteToChannel alloc] init]; + obj.channel = channel; + obj.users = users; + return obj; +} +- (NSData*)getData { + SerializedData* stream = [ClassStore streamWithConstuctor:429865580]; + [ClassStore TLSerialize:self.channel stream:stream]; + //Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.users count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLInputUser* obj = [self.users objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + } + return [stream getOutput]; +} +@end + +@implementation TLAPI_channels_kickFromChannel ++(TLAPI_channels_kickFromChannel*)createWithChannel:(TLInputChannel*)channel user_id:(TLInputUser*)user_id kicked:(Boolean)kicked { + TLAPI_channels_kickFromChannel* obj = [[TLAPI_channels_kickFromChannel alloc] init]; + obj.channel = channel; + obj.user_id = user_id; + obj.kicked = kicked; + return obj; +} +- (NSData*)getData { + SerializedData* stream = [ClassStore streamWithConstuctor:-1502421484]; + [ClassStore TLSerialize:self.channel stream:stream]; + [ClassStore TLSerialize:self.user_id stream:stream]; + [stream writeBool:self.kicked]; + return [stream getOutput]; +} +@end + +@implementation TLAPI_channels_exportInvite ++(TLAPI_channels_exportInvite*)createWithChannel:(TLInputChannel*)channel { + TLAPI_channels_exportInvite* obj = [[TLAPI_channels_exportInvite alloc] init]; + obj.channel = channel; + return obj; +} +- (NSData*)getData { + SerializedData* stream = [ClassStore streamWithConstuctor:-950663035]; + [ClassStore TLSerialize:self.channel stream:stream]; + return [stream getOutput]; +} +@end + +@implementation TLAPI_channels_deleteChannel ++(TLAPI_channels_deleteChannel*)createWithChannel:(TLInputChannel*)channel { + TLAPI_channels_deleteChannel* obj = [[TLAPI_channels_deleteChannel alloc] init]; + obj.channel = channel; + return obj; +} +- (NSData*)getData { + SerializedData* stream = [ClassStore streamWithConstuctor:-1072619549]; + [ClassStore TLSerialize:self.channel stream:stream]; + return [stream getOutput]; +} +@end + +@implementation TLAPI_updates_getChannelDifference ++(TLAPI_updates_getChannelDifference*)createWithChannel:(TLInputChannel*)channel filter:(TLChannelMessagesFilter*)filter pts:(int)pts limit:(int)limit { + TLAPI_updates_getChannelDifference* obj = [[TLAPI_updates_getChannelDifference alloc] init]; + obj.channel = channel; + obj.filter = filter; + obj.pts = pts; + obj.limit = limit; + return obj; +} +- (NSData*)getData { + SerializedData* stream = [ClassStore streamWithConstuctor:-1154295872]; + [ClassStore TLSerialize:self.channel stream:stream]; + [ClassStore TLSerialize:self.filter stream:stream]; + [stream writeInt:self.pts]; + [stream writeInt:self.limit]; + return [stream getOutput]; +} +@end + +@implementation TLAPI_messages_toggleChatAdmins ++(TLAPI_messages_toggleChatAdmins*)createWithChat_id:(int)chat_id enabled:(Boolean)enabled { + TLAPI_messages_toggleChatAdmins* obj = [[TLAPI_messages_toggleChatAdmins alloc] init]; + obj.chat_id = chat_id; + obj.enabled = enabled; + return obj; +} +- (NSData*)getData { + SerializedData* stream = [ClassStore streamWithConstuctor:-326379039]; + [stream writeInt:self.chat_id]; + [stream writeBool:self.enabled]; + return [stream getOutput]; +} +@end + +@implementation TLAPI_messages_editChatAdmin ++(TLAPI_messages_editChatAdmin*)createWithChat_id:(int)chat_id user_id:(TLInputUser*)user_id is_admin:(Boolean)is_admin { + TLAPI_messages_editChatAdmin* obj = [[TLAPI_messages_editChatAdmin alloc] init]; + obj.chat_id = chat_id; + obj.user_id = user_id; + obj.is_admin = is_admin; + return obj; +} +- (NSData*)getData { + SerializedData* stream = [ClassStore streamWithConstuctor:-1444503762]; + [stream writeInt:self.chat_id]; + [ClassStore TLSerialize:self.user_id stream:stream]; + [stream writeBool:self.is_admin]; + return [stream getOutput]; +} +@end + +@implementation TLAPI_messages_migrateChat ++(TLAPI_messages_migrateChat*)createWithChat_id:(int)chat_id { + TLAPI_messages_migrateChat* obj = [[TLAPI_messages_migrateChat alloc] init]; + obj.chat_id = chat_id; + return obj; +} +- (NSData*)getData { + SerializedData* stream = [ClassStore streamWithConstuctor:363051235]; + [stream writeInt:self.chat_id]; + return [stream getOutput]; +} +@end + +@implementation TLAPI_messages_searchGlobal ++(TLAPI_messages_searchGlobal*)createWithQ:(NSString*)q offset_date:(int)offset_date offset_peer:(TLInputPeer*)offset_peer offset_id:(int)offset_id limit:(int)limit { + TLAPI_messages_searchGlobal* obj = [[TLAPI_messages_searchGlobal alloc] init]; + obj.q = q; + obj.offset_date = offset_date; + obj.offset_peer = offset_peer; + obj.offset_id = offset_id; + obj.limit = limit; + return obj; +} +- (NSData*)getData { + SerializedData* stream = [ClassStore streamWithConstuctor:-1640190800]; + [stream writeString:self.q]; + [stream writeInt:self.offset_date]; + [ClassStore TLSerialize:self.offset_peer stream:stream]; + [stream writeInt:self.offset_id]; + [stream writeInt:self.limit]; + return [stream getOutput]; +} +@end + +@implementation TLAPI_help_getTermsOfService ++(TLAPI_help_getTermsOfService*)createWithLang_code:(NSString*)lang_code { + TLAPI_help_getTermsOfService* obj = [[TLAPI_help_getTermsOfService alloc] init]; + obj.lang_code = lang_code; + return obj; +} +- (NSData*)getData { + SerializedData* stream = [ClassStore streamWithConstuctor:936873859]; + [stream writeString:self.lang_code]; + return [stream getOutput]; +} +@end + +@implementation TLAPI_messages_reorderStickerSets ++(TLAPI_messages_reorderStickerSets*)createWithOrder:(NSMutableArray*)order { + TLAPI_messages_reorderStickerSets* obj = [[TLAPI_messages_reorderStickerSets alloc] init]; + obj.order = order; + return obj; +} +- (NSData*)getData { + SerializedData* stream = [ClassStore streamWithConstuctor:-1613775824]; + //Serialize ShortVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.order count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + if([self.order count] > i) { + NSNumber* obj = [self.order objectAtIndex:i]; + [stream writeLong:[obj longValue]]; + } else + break; + } + } + return [stream getOutput]; +} @end \ No newline at end of file diff --git a/TelegramTest/TLChatCategory.h b/TelegramTest/TLChatCategory.h index 8c4adc69..416c9417 100644 --- a/TelegramTest/TLChatCategory.h +++ b/TelegramTest/TLChatCategory.h @@ -16,6 +16,9 @@ typedef enum { TLChatTypeEmpty } TLChatType; + +- (NSSize)dialogTitleSize; + - (NSAttributedString *)dialogTitle; - (NSAttributedString *)titleForMessage; - (NSAttributedString *)titleForChatInfo; @@ -26,8 +29,18 @@ typedef enum { -(TL_conversation *)dialog; -(TLChatFull *)chatFull; - - (NSAttributedString *)statusAttributedString; - (NSAttributedString *)statusForMessagesHeaderView; - (NSAttributedString *)statusForSearchTableView; + +-(BOOL)left; + + +-(BOOL)isManager; +-(BOOL)isChannel; +-(id)inputPeer; +-(NSString *)usernameLink; + + + @end diff --git a/TelegramTest/TLChatCategory.m b/TelegramTest/TLChatCategory.m index d7ff3977..b107868f 100644 --- a/TelegramTest/TLChatCategory.m +++ b/TelegramTest/TLChatCategory.m @@ -7,7 +7,7 @@ // #import "TLChatCategory.h" - +#import "NSNumber+NumberFormatter.h" @implementation TLChat (Category) DYNAMIC_PROPERTY(DType); @@ -25,16 +25,17 @@ -(TL_conversation *)dialog { TL_conversation *dialog = [self getDDialog]; if(!dialog) { - dialog = [[DialogsManager sharedManager] findByChatId:self.n_id]; + dialog = [[DialogsManager sharedManager] findByChatId:self.n_id]; [self setDDialog:dialog]; } if(!dialog) { - dialog = [[Storage manager] selectConversation:[TL_peerChat createWithChat_id:self.n_id]]; + dialog = [[Storage manager] selectConversation:self.peer]; - if(!dialog) + if(!dialog) { dialog = [[DialogsManager sharedManager] createDialogForChat:self]; - else + + } else [[DialogsManager sharedManager] add:@[dialog]]; [self setDDialog:dialog]; @@ -44,8 +45,19 @@ -(TL_conversation *)dialog { } +DYNAMIC_PROPERTY(ChatFull); + -(TLChatFull *)chatFull { - return [[FullChatManager sharedManager] find:self.n_id]; + + TLChatFull *chatFull = [self getChatFull]; + + if(!chatFull) + { + chatFull = [[FullChatManager sharedManager] find:self.n_id]; + [self setChatFull:chatFull]; + } + + return chatFull; } - (void) setType:(TLChatType)type { @@ -56,7 +68,7 @@ - (void) setType:(TLChatType)type { - (TLChatType)rebuildType { int type; - if([self isKindOfClass:[TL_chatForbidden class]]) + if([self isKindOfClass:[TL_chatForbidden class]] || [self isKindOfClass:[TL_channelForbidden class]]) type = TLChatTypeForbidden; else if([self isKindOfClass:[TL_chatEmpty class]]) type = TLChatTypeEmpty; @@ -72,14 +84,32 @@ - (TLChatType)rebuildType { - (NSAttributedString *) dialogTitle { NSMutableAttributedString *dialogTitleAttributedString = [[NSMutableAttributedString alloc] init]; - + +// if([self isChannel]) { +// [dialogTitleAttributedString appendAttributedString:[NSAttributedString attributedStringWithAttachment:chatIconAttachment()]]; +// [dialogTitleAttributedString setSelectionAttachment:chatIconSelectedAttachment() forAttachment:chatIconAttachment()]; +// } +// + [dialogTitleAttributedString appendString:self.cropTitle withColor:NSColorFromRGB(0x333333)]; [dialogTitleAttributedString setSelectionColor:NSColorFromRGB(0xffffff) forColor:NSColorFromRGB(0x333333)]; - [dialogTitleAttributedString setFont:[NSFont fontWithName:@"HelveticaNeue" size:14] forRange:dialogTitleAttributedString.range]; + [dialogTitleAttributedString setFont:TGSystemFont(14) forRange:dialogTitleAttributedString.range]; + +// if([self isChannel] && [self isVerify]) { +// [dialogTitleAttributedString appendAttributedString:[NSAttributedString attributedStringWithAttachment:channelVerifyAttachment()]]; +// [dialogTitleAttributedString setSelectionAttachment:channelVerifySelectedAttachment() forAttachment:channelVerifyAttachment()]; +// } +// [self setDIALOGTITLE:dialogTitleAttributedString]; return [self getDIALOGTITLE]; + +} + + +- (NSSize)dialogTitleSize { + return [[self dialogTitle] sizeForTextFieldForWidth:INT32_MAX]; } DYNAMIC_PROPERTY(TITLEFORMESSAGE); @@ -88,7 +118,7 @@ - (NSAttributedString *) titleForMessage { NSMutableAttributedString *dialogTitleAttributedString = [[NSMutableAttributedString alloc] init]; [dialogTitleAttributedString appendString:self.cropTitle withColor:NSColorFromRGB(0x222222)]; - [dialogTitleAttributedString setFont:[NSFont fontWithName:@"HelveticaNeue" size:14] forRange:dialogTitleAttributedString.range]; + [dialogTitleAttributedString setFont:TGSystemFont(14) forRange:dialogTitleAttributedString.range]; NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init]; [style setAlignment:NSCenterTextAlignment]; @@ -129,12 +159,57 @@ - (NSAttributedString *)statusAttributedString { return instance; } +static NSTextAttachment *channelVerifyAttachment() { + static NSTextAttachment *instance; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + instance = [NSMutableAttributedString textAttachmentByImage:[image_Verify() imageWithInsets:NSEdgeInsetsMake(0, 0, 0, 0)]]; + }); + return instance; +} + +static NSTextAttachment *channelVerifySelectedAttachment() { + static NSTextAttachment *instance; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + instance = [NSMutableAttributedString textAttachmentByImage:[image_VerifyWhite() imageWithInsets:NSEdgeInsetsMake(0, 0, 0, 0)]]; + }); + return instance; +} + - (NSAttributedString *)statusForSearchTableView { NSMutableAttributedString *str; if(!str) { str = [[NSMutableAttributedString alloc] init]; + + if([self isChannel]) + { + + [str appendString:self.isMegagroup ? NSLocalizedString(@"Conversation.GroupTitle", nil) : NSLocalizedString(@"Conversation.ChannelTitle", nil) withColor:NSColorFromRGB(0xa9a9a9)]; + +// TLChatFull *fullChat = [[FullChatManager sharedManager] find:self.n_id]; +// +// if(fullChat.participants_count > 0) { +// +// NSString *count = fullChat.participants_count > 10000 ? [NSString stringWithFormat:@"%@ %@",[@(fullChat.participants_count) prettyNumber],NSLocalizedString(@"Conversation.Members", nil)] : [NSString stringWithFormat:@"%d %@", fullChat.participants_count, fullChat.participants_count > 1 ? NSLocalizedString(@"Conversation.Members", nil) : NSLocalizedString(@"Conversation.Member", nil)]; +// +// [str appendString:count withColor:NSColorFromRGB(0xa9a9a9)]; +// } else { +// [str appendString:NSLocalizedString(@"Conversation.ChannelTitle", nil) withColor:NSColorFromRGB(0xa9a9a9)]; +// } +// + [str setSelectionColor:NSColorFromRGB(0xffffff) forColor:BLUE_UI_COLOR]; + [str setSelectionColor:NSColorFromRGB(0xfffffe) forColor:NSColorFromRGB(0xa9a9a9)]; + [str setFont:TGSystemFont(13) forRange:str.range]; + + return str; + } + + + + [str appendString:[NSString stringWithFormat:@"%d %@", self.participants_count, self.participants_count > 1 ? NSLocalizedString(@"Conversation.Members", nil) : NSLocalizedString(@"Conversation.Member", nil)] withColor:NSColorFromRGB(0x9b9b9b)]; @@ -146,13 +221,32 @@ - (NSAttributedString *)statusForSearchTableView { [str setSelectionColor:NSColorFromRGB(0xffffff) forColor:BLUE_UI_COLOR]; [str setSelectionColor:NSColorFromRGB(0xfffffe) forColor:NSColorFromRGB(0x9b9b9b)]; - [str setFont:[NSFont fontWithName:@"HelveticaNeue" size:13] forRange:str.range]; + [str setFont:TGSystemFont(13) forRange:str.range]; } return str; } - (NSAttributedString *)statusForMessagesHeaderView { + + + + NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] init]; + + if([self isChannel]) + { + + TLChatFull *fullChat = [[FullChatManager sharedManager] find:self.n_id]; + + if(fullChat.participants_count > 0) { + [attributedString appendString:[NSString stringWithFormat:@"%d %@", fullChat.participants_count, fullChat.participants_count > 1 ? NSLocalizedString(@"Conversation.Members", nil) : NSLocalizedString(@"Conversation.Member", nil)] withColor:NSColorFromRGB(0xa9a9a9)]; + } else { + [attributedString appendString:self.isMegagroup ? NSLocalizedString(@"Conversation.GroupTitle", nil) : NSLocalizedString(@"Conversation.ChannelTitle", nil) withColor:NSColorFromRGB(0xa9a9a9)]; + } + + return attributedString; + } + [attributedString appendString:[NSString stringWithFormat:@"%d %@", self.participants_count, self.participants_count > 1 ? NSLocalizedString(@"Conversation.Members", nil) : NSLocalizedString(@"Conversation.Member", nil)] withColor:NSColorFromRGB(0xa9a9a9)]; int online = [[FullChatManager sharedManager] getOnlineCount:self.n_id]; @@ -162,7 +256,7 @@ - (NSAttributedString *)statusForMessagesHeaderView { } - [attributedString setFont:[NSFont fontWithName:@"HelveticaNeue" size:12] forRange:attributedString.range]; + [attributedString setFont:TGSystemFont(12) forRange:attributedString.range]; NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; [paragraphStyle setAlignment:2]; @@ -172,4 +266,50 @@ - (NSAttributedString *)statusForMessagesHeaderView { return attributedString; } +-(id)inputPeer { + return [self isKindOfClass:[TL_channel class]] || [self isKindOfClass:[TL_channelForbidden class]] ? [TL_inputChannel createWithChannel_id:self.n_id access_hash:self.access_hash] : ([self isKindOfClass:[TL_peerSecret class]] ? [TL_inputEncryptedChat createWithChat_id:self.n_id access_hash:self.access_hash] : nil); +} + + + +-(TLPeer *)peer { + return [self isKindOfClass:[TL_channel class]] ? [TL_peerChannel createWithChannel_id:self.n_id] : [TL_peerChat createWithChat_id:self.n_id]; +} + + + + + +-(BOOL)left { + return self.flags & (1 << 2); +} + +-(BOOL)isKicked { + return self.flags & (1 << 1); +} + + +-(BOOL)isModerator { + return self.flags & (1 << 4); +} + +-(BOOL)isVerify { + return self.flags & (1 << 7); +} + + +-(BOOL)isChannel { + return [self isKindOfClass:[TL_channel class]] || [self isKindOfClass:[TL_channelForbidden class]]; +} + +-(BOOL)isManager { + return [self isAdmin] || [self isEditor] || [self isModerator] || [self isCreator]; +} + +-(NSString *)usernameLink { + return self.username.length > 0 ? [NSString stringWithFormat:@"https://telegram.me/%@",self.username] : @""; +} + + + @end diff --git a/TelegramTest/TLChatFullCategory.h b/TelegramTest/TLChatFullCategory.h index 707ae620..3bdb2c12 100644 --- a/TelegramTest/TLChatFullCategory.h +++ b/TelegramTest/TLChatFullCategory.h @@ -15,4 +15,5 @@ - (int)lastUpdateTime; - (void)setLastUpdateTime:(int)lastUpdateTime; -(TL_conversation *)conversation; +-(TLChat *)chat; @end diff --git a/TelegramTest/TLChatFullCategory.m b/TelegramTest/TLChatFullCategory.m index e65efeee..ec220df9 100644 --- a/TelegramTest/TLChatFullCategory.m +++ b/TelegramTest/TLChatFullCategory.m @@ -40,4 +40,13 @@ - (TL_conversation *)conversation { return [self getConversation]; } +DYNAMIC_PROPERTY(Chat); + +-(TLChat *)chat { + if(![self getChat]) { + [self setChat:[[ChatsManager sharedManager] find:self.n_id]]; + } + return [self getChat]; +} + @end diff --git a/TelegramTest/TLClassStore.m b/TelegramTest/TLClassStore.m index 042d3b27..e23bae79 100644 --- a/TelegramTest/TLClassStore.m +++ b/TelegramTest/TLClassStore.m @@ -7,8 +7,10 @@ // #import "TLClassStore.h" - - +#import "TL_localMessage_old32.h" +#import "TL_localMessage_old34.h" +#import "TL_conversation_old34.h" +#import "TL_localMessageService_old34.h" @implementation TLClassStore @@ -26,19 +28,26 @@ +(void)initialize { [self.cs_classes setObject:[TL_messageActionEncryptedChat class] forKey:[NSNumber numberWithInt:1]]; [self.cs_classes setObject:[TL_peerSecret class] forKey:[NSNumber numberWithInt:2]]; - [self.cs_classes setObject:[TL_localMessage class] forKey:[NSNumber numberWithInt:3]]; + [self.cs_classes setObject:[TL_localMessage_old32 class] forKey:[NSNumber numberWithInt:3]]; [self.cs_classes setObject:[TL_destructMessage class] forKey:[NSNumber numberWithInt:4]]; - [self.cs_classes setObject:[TL_conversation class] forKey:[NSNumber numberWithInt:5]]; + [self.cs_classes setObject:[TL_conversation_old34 class] forKey:[NSNumber numberWithInt:5]]; [self.cs_classes setObject:[TL_outDocument class] forKey:[NSNumber numberWithInt:6]]; - [self.cs_classes setObject:[TL_localMessageService class] forKey:[NSNumber numberWithInt:8]]; + [self.cs_classes setObject:[TL_localMessageService_old34 class] forKey:[NSNumber numberWithInt:8]]; [self.cs_classes setObject:[TL_peerBroadcast class] forKey:[NSNumber numberWithInt:9]]; [self.cs_classes setObject:[TL_broadcast class] forKey:[NSNumber numberWithInt:10]]; [self.cs_classes setObject:[TL_messageActionSetMessageTTL class] forKey:[NSNumber numberWithInt:11]]; [self.cs_classes setObject:[TL_secretServiceMessage class] forKey:[NSNumber numberWithInt:12]]; [self.cs_classes setObject:[TL_messageActionBotDescription class] forKey:[NSNumber numberWithInt:13]]; + [self.cs_classes setObject:[TL_localMessage_old34 class] forKey:[NSNumber numberWithInt:14]]; + [self.cs_classes setObject:[TL_localMessage class] forKey:[NSNumber numberWithInt:15]]; + + [self.cs_classes setObject:[TL_conversation class] forKey:[NSNumber numberWithInt:16]]; + + [self.cs_classes setObject:[TL_localEmptyMessage class] forKey:[NSNumber numberWithInt:17]]; + [self.cs_classes setObject:[TL_localMessageService class] forKey:[NSNumber numberWithInt:18]]; for(NSNumber* number in [self.cs_classes allKeys]) { [self.cs_constuctors setObject:number forKey:[self.cs_classes objectForKey:number]]; diff --git a/TelegramTest/TLContactCategory.m b/TelegramTest/TLContactCategory.m index 5ae9798a..0fd7928e 100644 --- a/TelegramTest/TLContactCategory.m +++ b/TelegramTest/TLContactCategory.m @@ -10,8 +10,19 @@ @implementation TLContact (Category) +DYNAMIC_PROPERTY(dUser); + - (TLUser *)user { - return [[UsersManager sharedManager] find:self.user_id]; + + TLUser *u = [self getdUser]; + + if(!u) + { + u = [[UsersManager sharedManager] find:self.user_id]; + [self setdUser:u]; + } + + return u; } @end diff --git a/TelegramTest/TLDocument+Extension.h b/TelegramTest/TLDocument+Extension.h index 27119d21..dd017431 100644 --- a/TelegramTest/TLDocument+Extension.h +++ b/TelegramTest/TLDocument+Extension.h @@ -12,6 +12,7 @@ -(int)duration; -(NSString *)file_name; +-(NSString *)path_with_cache; -(BOOL)isSticker; -(TLDocumentAttribute *)attributeWithClass:(Class)className; -(NSSize)imageSize; diff --git a/TelegramTest/TLDocument+Extension.m b/TelegramTest/TLDocument+Extension.m index 0966250c..3acf450f 100644 --- a/TelegramTest/TLDocument+Extension.m +++ b/TelegramTest/TLDocument+Extension.m @@ -38,7 +38,9 @@ -(int)duration { return 0; } - +-(NSString *)path_with_cache { + return [NSString stringWithFormat:@"%@/%ld.doc",[FileUtils path],self.n_id]; +} -(TLDocumentAttribute *)attributeWithClass:(Class)className { diff --git a/TelegramTest/TLEncryptedChatCategory.h b/TelegramTest/TLEncryptedChatCategory.h index 18699965..6d374070 100644 --- a/TelegramTest/TLEncryptedChatCategory.h +++ b/TelegramTest/TLEncryptedChatCategory.h @@ -12,4 +12,6 @@ - (EncryptedParams *)encryptedParams; - (TL_conversation *)dialog; + +-(NSString *)username; @end diff --git a/TelegramTest/TLEncryptedChatCategory.m b/TelegramTest/TLEncryptedChatCategory.m index 3148ec9b..6ecba387 100644 --- a/TelegramTest/TLEncryptedChatCategory.m +++ b/TelegramTest/TLEncryptedChatCategory.m @@ -18,4 +18,8 @@ - (TL_conversation *)dialog { return [[DialogsManager sharedManager] find:self.n_id]; } +-(NSString *)username { + return @""; +} + @end diff --git a/TelegramTest/TLPeer+Extensions.h b/TelegramTest/TLPeer+Extensions.h index d9312d09..a123b6b3 100644 --- a/TelegramTest/TLPeer+Extensions.h +++ b/TelegramTest/TLPeer+Extensions.h @@ -13,6 +13,7 @@ -(BOOL)isChat; +(TLPeer *)peerForId:(int)peer_id; -(TLPeer *)peerOut; +-(TLInputPeer *)inputPeer; -(BOOL)isSecret; -(BOOL)isBroadcast; @end diff --git a/TelegramTest/TLPeer+Extensions.m b/TelegramTest/TLPeer+Extensions.m index e6c3aa63..4930b4b0 100644 --- a/TelegramTest/TLPeer+Extensions.m +++ b/TelegramTest/TLPeer+Extensions.m @@ -11,11 +11,11 @@ @implementation TLPeer (Extensions) - (int)peer_id { - return self.chat_id != 0 ? ([self isSecret] || ([self isBroadcast]) ? self.chat_id : -self.chat_id) : self.user_id; + return self.chat_id != 0 ? ([self isSecret] || ([self isBroadcast]) ? self.chat_id : -self.chat_id) : (self.channel_id != 0 ? -self.channel_id : self.user_id); } - (BOOL)isChat { - return self.chat_id != 0; + return self.chat_id != 0 || self.channel_id != 0; } - (BOOL)isSecret { @@ -30,17 +30,38 @@ - (BOOL)isBroadcast { -(TLPeer *)peerOut { - if(self.chat_id == 0) + if(self.chat_id == 0 && self.channel_id == 0) return [TL_peerUser createWithUser_id:self.user_id]; else if([self isSecret] || [self isBroadcast]) return self; - return [TL_peerChat createWithChat_id:self.chat_id]; + + if(self.chat_id != 0) + return [TL_peerChat createWithChat_id:self.chat_id]; + else if(self.channel_id != 0) + return [TL_peerChannel createWithChannel_id:self.channel_id]; + + + return nil; +} + +-(TLInputPeer *)inputPeer { + if(self.chat_id == 0 && self.channel_id == 0) + return [TL_inputPeerUser createWithUser_id:self.user_id access_hash:[[[UsersManager sharedManager] find:self.user_id] access_hash]]; + else if(![self isBroadcast]) { + + TLChat *chat = [[ChatsManager sharedManager] find:self.chat_id == 0 ? self.channel_id : self.chat_id]; + + if([self isKindOfClass:[TL_peerChannel class]]) { + return [TL_inputPeerChannel createWithChannel_id:self.channel_id access_hash:chat.access_hash]; + } else if([self isKindOfClass:[TL_peerChat class]]) { + return [TL_inputPeerChat createWithChat_id:self.chat_id]; + } + } + + + return nil; } -+(TLPeer *)peerForId:(int)peer_id { - if(peer_id < 0) - return [TL_peerChat createWithChat_id:-peer_id]; - return [TL_peerUser createWithUser_id:peer_id]; -}; + @end diff --git a/TelegramTest/TLUserCategory.h b/TelegramTest/TLUserCategory.h index cee69955..596dc259 100644 --- a/TelegramTest/TLUserCategory.h +++ b/TelegramTest/TLUserCategory.h @@ -38,6 +38,9 @@ typedef enum { - (NSString *)phoneWithFormat; - (NSAttributedString *)dialogTitle; + +- (NSSize)dialogTitleSize; +- (NSSize)dialogEncryptedTitleSize; - (NSAttributedString *)dialogTitleEncrypted; - (NSAttributedString *)chatInfoTitle; @@ -65,7 +68,6 @@ typedef enum { - (NSString *)dialogFullName; - (TLInputPeer *)inputPeer; - (TLInputUser *)inputUser; -- (NSString *)shortLastSeen; - (NSString *)lastSeen; - (int)lastSeenTime; - (TL_conversation *)dialog; diff --git a/TelegramTest/TLUserCategory.m b/TelegramTest/TLUserCategory.m index d8ac3f72..160a9961 100644 --- a/TelegramTest/TLUserCategory.m +++ b/TelegramTest/TLUserCategory.m @@ -89,6 +89,8 @@ - (TLUserType)rebuildType { [self setType:type]; + [self rebuildNames]; + return type; } @@ -99,10 +101,6 @@ - (BOOL)isOnline { return [[MTNetwork instance] getTime] < self.status.lastSeenTime; } --(BOOL)isBot { - return (self.flags & TGUSERFLAGBOT) == TGUSERFLAGBOT; -} - DYNAMIC_PROPERTY(FULLUPDATETIME) -(BOOL)needFullUpdate { @@ -171,15 +169,14 @@ - (int)lastSeenUpdate { - (void)setLastSeenUpdate:(int)seenUpdate { [self setSEEN_UPDATE:@(seenUpdate)]; } -/* - Names - */ - - +-(NSColor *)colorByNameOrPhone { + return NSColorFromRGB(0x333333); +} - (void) rebuildNames { + if(!self.last_name) self.last_name = @""; @@ -188,114 +185,20 @@ - (void) rebuildNames { //Fullname - NSString *fullName = [[[[NSString stringWithFormat:@"%@ %@", self.first_name, self.last_name] trim] singleLine] htmlentities]; - NSString *fullNameFull = fullName; - if(fullName.length > 30) - fullName = [fullName substringToIndex:30]; - - [self setDFullName:fullName]; - - - NSString *fullNameOrPhone = fullName; - - NSColor *colorByNameOrPhone; - if(self.type == TLUserTypeRequest) { - fullNameOrPhone = self.phoneWithFormat; - colorByNameOrPhone = BLUE_UI_COLOR; - } else if(self.type == TLUserTypeForeign || self.type == TLUserTypeDeleted || self.type == TLUserTypeEmpty) { - colorByNameOrPhone = BLUE_UI_COLOR; - } else if(self.type == TLUserTypeSelf) { - colorByNameOrPhone = BLUE_UI_COLOR; - } else { - colorByNameOrPhone = NSColorFromRGB(0x333333); - } - - colorByNameOrPhone = NSColorFromRGB(0x333333); - - //Dialogs - NSMutableAttributedString *dialogTitleAttributedString = [[NSMutableAttributedString alloc] init]; - - [dialogTitleAttributedString appendString:fullName withColor:colorByNameOrPhone]; - [dialogTitleAttributedString setSelectionColor:NSColorFromRGB(0xffffff) forColor:NSColorFromRGB(0x333333)]; - [dialogTitleAttributedString setSelectionColor:NSColorFromRGB(0xfffffe) forColor:BLUE_UI_COLOR]; - - - - [dialogTitleAttributedString setFont:[NSFont fontWithName:@"HelveticaNeue" size:14] forRange:dialogTitleAttributedString.range]; - [self setDIALOGTITLE:dialogTitleAttributedString]; - - NSMutableAttributedString *dialogEncryptedTitleAttributedString = [[NSMutableAttributedString alloc] init]; - [dialogEncryptedTitleAttributedString appendAttributedString:[NSAttributedString attributedStringWithAttachment:encryptedIconAttachment()]]; - [dialogEncryptedTitleAttributedString setSelectionAttachment:encryptedIconSelectedAttachment() forAttachment:encryptedIconAttachment()]; - - [dialogEncryptedTitleAttributedString appendString:fullNameOrPhone withColor:DARK_GREEN]; - [dialogEncryptedTitleAttributedString setSelectionColor:NSColorFromRGB(0xffffff) forColor:DARK_GREEN]; - [dialogEncryptedTitleAttributedString setFont:[NSFont fontWithName:@"HelveticaNeue" size:14] forRange:dialogEncryptedTitleAttributedString.range]; - [self setDIALOGTITLEENCRYPTED:dialogEncryptedTitleAttributedString]; - - - NSMutableAttributedString *chatInfoTitleAttributedString = [[NSMutableAttributedString alloc] init]; - - [chatInfoTitleAttributedString appendString:fullName withColor:DARK_BLACK]; - [chatInfoTitleAttributedString setSelectionColor:NSColorFromRGB(0xffffff) forColor:DARK_BLACK]; - - [chatInfoTitleAttributedString setFont:[NSFont fontWithName:@"HelveticaNeue" size:12.5] forRange:chatInfoTitleAttributedString.range]; - [self setCHATINFOTITLE:chatInfoTitleAttributedString]; - - - NSMutableAttributedString *userNameTitle = [[NSMutableAttributedString alloc] init]; - - [userNameTitle appendString:[NSString stringWithFormat:@"%@%@",self.username.length > 0 ? @"@" : @"",self.username] withColor:GRAY_TEXT_COLOR]; - [userNameTitle setSelectionColor:NSColorFromRGB(0xffffff) forColor:GRAY_TEXT_COLOR]; - - [userNameTitle setFont:[NSFont fontWithName:@"HelveticaNeue" size:14] forRange:userNameTitle.range]; - [self setUserNameTitle:userNameTitle]; - - - NSMutableAttributedString *userNameProfileTitle = [[NSMutableAttributedString alloc] init]; - [userNameProfileTitle appendString:[NSString stringWithFormat:@"@%@",self.username] withColor:NSColorFromRGB(0x333333)]; - [userNameProfileTitle setSelectionColor:NSColorFromRGB(0xffffff) forColor:NSColorFromRGB(0x333333)]; - [userNameProfileTitle setFont:[NSFont fontWithName:@"HelveticaNeue-Light" size:14] forRange:userNameProfileTitle.range]; - [self setUserNameProfileTitle:userNameProfileTitle]; + [self setDFullName:nil]; + [self setDIALOGTITLE:nil]; + [self setDIALOGTITLEENCRYPTED:nil]; + [self setCHATINFOTITLE:nil]; + [self setUserNameProfileTitle:nil]; + [self setUserNameSearchTitle:nil]; + [self setTITLE_FOR_MESSAGE:nil]; + [self setENCRYPTED_TITLE_FOR_MESSAGE:nil]; + [self setUserNameTitle:nil]; - - NSMutableAttributedString *userNameSearchTitle = [[NSMutableAttributedString alloc] init]; - - [userNameSearchTitle appendString:[NSString stringWithFormat:@"@%@",self.username] withColor:BLUE_UI_COLOR]; - [userNameSearchTitle setSelectionColor:NSColorFromRGB(0xffffff) forColor:BLUE_UI_COLOR]; - - - [userNameSearchTitle setFont:[NSFont fontWithName:@"HelveticaNeue" size:13] forRange:userNameSearchTitle.range]; - [self setUserNameSearchTitle:userNameSearchTitle]; - - //Message Tite - - NSMutableAttributedString *titleForMessageAttributedString = [[NSMutableAttributedString alloc] init]; - [titleForMessageAttributedString appendString:fullNameOrPhone withColor:NSColorFromRGB(0x222222)]; - [titleForMessageAttributedString setFont:[NSFont fontWithName:@"HelveticaNeue" size:14] forRange:titleForMessageAttributedString.range]; - - NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init]; - [style setAlignment:NSCenterTextAlignment]; - [titleForMessageAttributedString addAttribute:NSParagraphStyleAttributeName value:style range:titleForMessageAttributedString.range]; - [self setTITLE_FOR_MESSAGE:titleForMessageAttributedString]; - - - NSMutableAttributedString *profileAttributedString = [[NSMutableAttributedString alloc] init]; - [profileAttributedString appendString:fullNameOrPhone withColor:NSColorFromRGB(0x222222)]; - [profileAttributedString setFont:[NSFont fontWithName:@"HelveticaNeue" size:15] forRange:profileAttributedString.range]; - [profileAttributedString setAlignment:NSLeftTextAlignment range:profileAttributedString.range]; - [self setProfileTitle:profileAttributedString]; - - NSMutableAttributedString *encryptedTitleForMessageAttributedString = [[NSMutableAttributedString alloc] init]; - [encryptedTitleForMessageAttributedString appendAttributedString:[NSAttributedString attributedStringWithAttachment:encryptedIconAttachmentBlack()]]; - [encryptedTitleForMessageAttributedString appendString:fullNameFull withColor:DARK_BLACK]; - [encryptedTitleForMessageAttributedString setFont:[NSFont fontWithName:@"HelveticaNeue" size:14] forRange:encryptedTitleForMessageAttributedString.range]; - [encryptedTitleForMessageAttributedString addAttribute:NSParagraphStyleAttributeName value:style range:encryptedTitleForMessageAttributedString.range]; - [self setENCRYPTED_TITLE_FOR_MESSAGE:encryptedTitleForMessageAttributedString]; } static NSTextAttachment *encryptedIconAttachment() { @@ -338,31 +241,138 @@ - (void) rebuildNames { DYNAMIC_PROPERTY(ProfileTitle); - (NSAttributedString *)dialogTitle { + + id title = [self getDIALOGTITLE]; + + if(!title) { + NSMutableAttributedString *dialogTitleAttributedString = [[NSMutableAttributedString alloc] init]; + + [dialogTitleAttributedString appendString:self.fullName withColor:[self colorByNameOrPhone]]; + [dialogTitleAttributedString setSelectionColor:NSColorFromRGB(0xffffff) forColor:NSColorFromRGB(0x333333)]; + [dialogTitleAttributedString setSelectionColor:NSColorFromRGB(0xfffffe) forColor:BLUE_UI_COLOR]; + + [dialogTitleAttributedString setFont:TGSystemFont(14) forRange:dialogTitleAttributedString.range]; + [self setDIALOGTITLE:dialogTitleAttributedString]; + } + return [self getDIALOGTITLE]; } +- (NSSize)dialogTitleSize { + return [[self dialogTitle] sizeForTextFieldForWidth:INT32_MAX]; +} + + +- (NSSize)dialogEncryptedTitleSize { + return [[self dialogTitleEncrypted] sizeForTextFieldForWidth:INT32_MAX]; +} + - (NSAttributedString *)profileTitle { + + id title = [self getProfileTitle]; + + if(!title) { + NSMutableAttributedString *profileAttributedString = [[NSMutableAttributedString alloc] init]; + [profileAttributedString appendString:self.fullName withColor:NSColorFromRGB(0x222222)]; + [profileAttributedString setFont:TGSystemFont(15) forRange:profileAttributedString.range]; + [profileAttributedString setAlignment:NSLeftTextAlignment range:profileAttributedString.range]; + [self setProfileTitle:profileAttributedString]; + } + return [self getProfileTitle]; } - (NSAttributedString *)dialogTitleEncrypted { + + id title = [self getDIALOGTITLEENCRYPTED]; + + if(!title) { + NSMutableAttributedString *dialogEncryptedTitleAttributedString = [[NSMutableAttributedString alloc] init]; + [dialogEncryptedTitleAttributedString appendAttributedString:[NSAttributedString attributedStringWithAttachment:encryptedIconAttachment()]]; + [dialogEncryptedTitleAttributedString setSelectionAttachment:encryptedIconSelectedAttachment() forAttachment:encryptedIconAttachment()]; + + [dialogEncryptedTitleAttributedString appendString:self.fullName withColor:DARK_GREEN]; + [dialogEncryptedTitleAttributedString setSelectionColor:NSColorFromRGB(0xffffff) forColor:DARK_GREEN]; + [dialogEncryptedTitleAttributedString setFont:TGSystemFont(14) forRange:dialogEncryptedTitleAttributedString.range]; + [self setDIALOGTITLEENCRYPTED:dialogEncryptedTitleAttributedString]; + } + + return [self getDIALOGTITLEENCRYPTED]; } - (NSAttributedString *)chatInfoTitle { + + id title = [self getCHATINFOTITLE]; + + if(!title) { + NSMutableAttributedString *chatInfoTitleAttributedString = [[NSMutableAttributedString alloc] init]; + + [chatInfoTitleAttributedString appendString:self.fullName withColor:DARK_BLACK]; + [chatInfoTitleAttributedString setSelectionColor:NSColorFromRGB(0xffffff) forColor:DARK_BLACK]; + + [chatInfoTitleAttributedString setFont:TGSystemFont(12.5) forRange:chatInfoTitleAttributedString.range]; + [self setCHATINFOTITLE:chatInfoTitleAttributedString]; + } + + return [self getCHATINFOTITLE]; } - (NSAttributedString *)userNameTitle { + + + id title = [self getUserNameTitle]; + + if(!title) { + NSMutableAttributedString *userNameTitle = [[NSMutableAttributedString alloc] init]; + + [userNameTitle appendString:[NSString stringWithFormat:@"%@%@",self.username.length > 0 ? @"@" : @"",self.username.length > 0 ? self.username : @""] withColor:GRAY_TEXT_COLOR]; + [userNameTitle setSelectionColor:NSColorFromRGB(0xffffff) forColor:GRAY_TEXT_COLOR]; + + [userNameTitle setFont:TGSystemFont(14) forRange:userNameTitle.range]; + [self setUserNameTitle:userNameTitle]; + } + return [self getUserNameTitle]; } - (NSAttributedString *)userNameProfileTitle { + + id title = [self getUserNameProfileTitle]; + + if(!title) { + NSMutableAttributedString *userNameProfileTitle = [[NSMutableAttributedString alloc] init]; + + [userNameProfileTitle appendString:[NSString stringWithFormat:@"@%@",self.username] withColor:NSColorFromRGB(0x333333)]; + [userNameProfileTitle setSelectionColor:NSColorFromRGB(0xffffff) forColor:NSColorFromRGB(0x333333)]; + + + [userNameProfileTitle setFont:TGSystemLightFont(14) forRange:userNameProfileTitle.range]; + [self setUserNameProfileTitle:userNameProfileTitle]; + + } + + return [self getUserNameProfileTitle]; } - (NSAttributedString *)userNameSearchTitle { + + id title = [self userNameSearchTitle]; + + if(!title) { + NSMutableAttributedString *userNameSearchTitle = [[NSMutableAttributedString alloc] init]; + + [userNameSearchTitle appendString:[NSString stringWithFormat:@"@%@",self.username] withColor:BLUE_UI_COLOR]; + [userNameSearchTitle setSelectionColor:NSColorFromRGB(0xffffff) forColor:BLUE_UI_COLOR]; + + + [userNameSearchTitle setFont:TGSystemFont(13) forRange:userNameSearchTitle.range]; + [self setUserNameSearchTitle:userNameSearchTitle]; + } + return [self getUserNameSearchTitle]; } @@ -370,19 +380,68 @@ - (NSAttributedString *)userNameSearchTitle { DYNAMIC_PROPERTY(ENCRYPTED_TITLE_FOR_MESSAGE); - (NSAttributedString *) titleForMessage { + + id title = [self getTITLE_FOR_MESSAGE]; + + if(!title) { + NSMutableAttributedString *titleForMessageAttributedString = [[NSMutableAttributedString alloc] init]; + [titleForMessageAttributedString appendString:self.fullName withColor:NSColorFromRGB(0x222222)]; + [titleForMessageAttributedString setFont:TGSystemFont(14) forRange:titleForMessageAttributedString.range]; + + NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init]; + [style setAlignment:NSCenterTextAlignment]; + [titleForMessageAttributedString addAttribute:NSParagraphStyleAttributeName value:style range:titleForMessageAttributedString.range]; + [self setTITLE_FOR_MESSAGE:titleForMessageAttributedString]; + } + return [self getTITLE_FOR_MESSAGE]; } - (NSAttributedString *) encryptedTitleForMessage { + + + id title = [self getENCRYPTED_TITLE_FOR_MESSAGE]; + + if(!title) { + + NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init]; + [style setAlignment:NSCenterTextAlignment]; + + NSMutableAttributedString *encryptedTitleForMessageAttributedString = [[NSMutableAttributedString alloc] init]; + [encryptedTitleForMessageAttributedString appendAttributedString:[NSAttributedString attributedStringWithAttachment:encryptedIconAttachmentBlack()]]; + [encryptedTitleForMessageAttributedString appendString:self.fullName withColor:DARK_BLACK]; + [encryptedTitleForMessageAttributedString setFont:TGSystemFont(14) forRange:encryptedTitleForMessageAttributedString.range]; + [encryptedTitleForMessageAttributedString addAttribute:NSParagraphStyleAttributeName value:style range:encryptedTitleForMessageAttributedString.range]; + [self setENCRYPTED_TITLE_FOR_MESSAGE:encryptedTitleForMessageAttributedString]; + } + return [self getENCRYPTED_TITLE_FOR_MESSAGE]; } - - DYNAMIC_PROPERTY(DFullName); - (NSString *)fullName { + + NSString *fullName = [self getDFullName]; + + if(!fullName) { + + if(!self.first_name) + self.first_name = @""; + + if(!self.last_name) + self.last_name = @""; + + NSString *fullName = [[[[NSString stringWithFormat:@"%@%@%@", self.first_name,self.first_name.length > 0 ? @" " : @"", self.last_name] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] singleLine] htmlentities]; + if(fullName.length > 30) + fullName = [fullName substringToIndex:30]; + + + [self setDFullName:fullName]; + + } + return [self getDFullName]; } @@ -428,7 +487,7 @@ - (NSAttributedString *)statusForMessagesHeaderView { range = [str appendString:string withColor:NSColorFromRGB(0xa9a9a9)]; } - [str setFont:[NSFont fontWithName:@"HelveticaNeue" size:12] forRange:range]; + [str setFont:TGSystemFont(12) forRange:range]; // [self setSTATUS_MESSAGES_HEADER_VIEW:str]; } @@ -450,7 +509,7 @@ - (NSAttributedString *)statusForUserInfoView { range = [str appendString:string withColor:NSColorFromRGB(0xa1a1a1)]; } - [str setFont:[NSFont fontWithName:@"Helvetica-Light" size:12.5] forRange:range]; + [str setFont:TGSystemLightFont(12.5) forRange:range]; } return str; } @@ -469,7 +528,7 @@ - (NSAttributedString *)statusForSearchTableView { [str setSelectionColor:NSColorFromRGB(0xffffff) forColor:BLUE_UI_COLOR]; [str setSelectionColor:NSColorFromRGB(0xfffffe) forColor:NSColorFromRGB(0x9b9b9b)]; - [str setFont:[NSFont fontWithName:@"HelveticaNeue" size:13] forRange:range]; + [str setFont:TGSystemFont(13) forRange:range]; } return str; } @@ -499,7 +558,7 @@ - (NSAttributedString *)statusForGroupInfo { range = [str appendString:string withColor:GRAY_TEXT_COLOR]; } - [str setFont:[NSFont fontWithName:@"HelveticaNeue" size:12.5f] forRange:range]; + [str setFont:TGSystemFont(12.5f) forRange:range]; } return str; } @@ -518,7 +577,7 @@ - (NSAttributedString *)statusForProfile { range = [str appendString:string withColor:GRAY_TEXT_COLOR]; } - [str setFont:[NSFont fontWithName:@"HelveticaNeue-Light" size:14] forRange:range]; + [str setFont:TGSystemLightFont(14) forRange:range]; [str setAlignment:NSLeftTextAlignment range:range]; } @@ -560,24 +619,8 @@ - (TL_conversation *)dialog { - (TLInputUser *)inputUser { + return [TL_inputUser createWithUser_id:self.n_id access_hash:self.access_hash]; - - switch (self.type) { - case TLUserTypeContact: - return [TL_inputUserContact createWithUser_id:self.n_id]; - case TLUserTypeDeleted: - return [TL_inputUserEmpty create]; - case TLUserTypeEmpty: - return [TL_inputUserEmpty create]; - case TLUserTypeForeign: - return [TL_inputUserForeign createWithUser_id:self.n_id access_hash:self.access_hash]; - case TLUserTypeRequest: - return [TL_inputUserForeign createWithUser_id:self.n_id access_hash:self.access_hash]; - case TLUserTypeSelf: - return [TL_inputUserSelf create]; - default: - return [TL_inputUserEmpty create]; - } } -(id)copy { @@ -608,10 +651,8 @@ -(BOOL)isEqual:(id)object { } -(TLInputPeer *)inputPeer { - if([self isKindOfClass:[TL_userContact class]]) { - return [TL_inputPeerContact createWithUser_id:self.n_id]; - } - return [TL_inputPeerForeign createWithUser_id:self.n_id access_hash:self.access_hash]; + + return [TL_inputPeerUser createWithUser_id:self.n_id access_hash:self.access_hash]; } - (TL_contact *)contact { diff --git a/TelegramTest/TL_broadcast.m b/TelegramTest/TL_broadcast.m index 79ac6287..16e995ce 100644 --- a/TelegramTest/TL_broadcast.m +++ b/TelegramTest/TL_broadcast.m @@ -128,7 +128,7 @@ - (NSAttributedString *) dialogTitle { [dialogTitleAttributedString appendString:title withColor:NSColorFromRGB(0x333333)]; [dialogTitleAttributedString setSelectionColor:NSColorFromRGB(0xffffff) forColor:NSColorFromRGB(0x333333)]; - [dialogTitleAttributedString setFont:[NSFont fontWithName:@"HelveticaNeue" size:14] forRange:dialogTitleAttributedString.range]; + [dialogTitleAttributedString setFont:TGSystemFont(14) forRange:dialogTitleAttributedString.range]; [self setDIALOGTITLE:dialogTitleAttributedString]; @@ -149,7 +149,7 @@ - (NSAttributedString *) titleForMessage { NSMutableAttributedString *dialogTitleAttributedString = [[NSMutableAttributedString alloc] init]; [dialogTitleAttributedString appendString:title withColor:NSColorFromRGB(0x222222)]; - [dialogTitleAttributedString setFont:[NSFont fontWithName:@"HelveticaNeue" size:14] forRange:dialogTitleAttributedString.range]; + [dialogTitleAttributedString setFont:TGSystemFont(14) forRange:dialogTitleAttributedString.range]; NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init]; [style setAlignment:NSCenterTextAlignment]; @@ -235,7 +235,7 @@ - (NSAttributedString *)statusForMessagesHeaderView { - [attributedString setFont:[NSFont fontWithName:@"HelveticaNeue" size:12] forRange:attributedString.range]; + [attributedString setFont:TGSystemFont(12) forRange:attributedString.range]; NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; [paragraphStyle setAlignment:2]; diff --git a/TelegramTest/TL_channelConversation.h b/TelegramTest/TL_channelConversation.h new file mode 100644 index 00000000..26fe7b12 --- /dev/null +++ b/TelegramTest/TL_channelConversation.h @@ -0,0 +1,13 @@ +// +// TL_channelConversation.h +// Telegram +// +// Created by keepcoder on 21.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "MTProto.h" + +@interface TL_channelConversation : TL_dialogChannel + +@end diff --git a/TelegramTest/TL_channelConversation.m b/TelegramTest/TL_channelConversation.m new file mode 100644 index 00000000..209f9c5f --- /dev/null +++ b/TelegramTest/TL_channelConversation.m @@ -0,0 +1,13 @@ +// +// TL_channelConversation.m +// Telegram +// +// Created by keepcoder on 21.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TL_channelConversation.h" + +@implementation TL_channelConversation + +@end diff --git a/TelegramTest/TL_conversation.h b/TelegramTest/TL_conversation.h index 565f4973..982e8b24 100644 --- a/TelegramTest/TL_conversation.h +++ b/TelegramTest/TL_conversation.h @@ -38,10 +38,16 @@ typedef enum { @property (nonatomic) DeliveryState dstate; @property (nonatomic) int sync_message_id; +-(int)universalTopMessage; + + +@property (nonatomic,assign,getter=isInvisibleChannel) BOOL invisibleChannel; @property (nonatomic,strong) TL_localMessage *lastMessage; -+ (TL_conversation *)createWithPeer:(TLPeer *)peer top_message:(int)top_message unread_count:(int)unread_count last_message_date:(int)last_message_date notify_settings:(TLPeerNotifySettings *)notify_settings last_marked_message:(int)last_marked_message top_message_fake:(int)top_message_fake last_marked_date:(int)last_marked_date sync_message_id:(int)sync_message_id; ++ (TL_conversation *)createWithPeer:(TLPeer *)peer top_message:(int)top_message unread_count:(int)unread_count last_message_date:(int)last_message_date notify_settings:(TLPeerNotifySettings *)notify_settings last_marked_message:(int)last_marked_message top_message_fake:(int)top_message_fake last_marked_date:(int)last_marked_date sync_message_id:(int)sync_message_id read_inbox_max_id:(int)read_inbox_max_id unread_important_count:(int)unread_important_count lastMessage:(TL_localMessage *)lastMessage; + ++ (TL_conversation *)createWithPeer:(TLPeer *)peer top_message:(int)top_message unread_count:(int)unread_count last_message_date:(int)last_message_date notify_settings:(TLPeerNotifySettings *)notify_settings last_marked_message:(int)last_marked_message top_message_fake:(int)top_message_fake last_marked_date:(int)last_marked_date sync_message_id:(int)sync_message_id read_inbox_max_id:(int)read_inbox_max_id unread_important_count:(int)unread_important_count lastMessage:(TL_localMessage *)lastMessage pts:(int)pts isInvisibleChannel:(BOOL)invisibleChannel top_important_message:(int)top_important_message; - (void)save; - (BOOL) isAddToList; @@ -63,7 +69,8 @@ typedef enum { DialogTypeUser = 0, DialogTypeChat = 1, DialogTypeSecretChat = 2, - DialogTypeBroadcast = 3 + DialogTypeBroadcast = 3, + DialogTypeChannel = 4 } DialogType; -(id)inputPeer; @@ -80,7 +87,15 @@ typedef enum { - (NSUInteger)cacheHash; - (NSString *)cacheKey; +-(BOOL)canEditConversation; +-(long)channel_top_message_id; +-(long)channel_top_important_message_id; - (DialogType) type; +-(BOOL)isVerified; + +//channel methods +-(BOOL)canSendChannelMessageAsAdmin; +-(BOOL)canSendChannelMessageAsUser; @end diff --git a/TelegramTest/TL_conversation.m b/TelegramTest/TL_conversation.m index 5f0bdd50..58adb519 100644 --- a/TelegramTest/TL_conversation.m +++ b/TelegramTest/TL_conversation.m @@ -9,15 +9,16 @@ #import "TL_conversation.h" #import "TLPeer+Extensions.h" #import "TGPasslock.h" - +#import "TL_localMessage.h" @interface TL_conversation () @property (nonatomic,strong,readonly) TLUser *p_user; @property (nonatomic,strong,readonly) TLChat *p_chat; @end + @implementation TL_conversation -+(TL_conversation *)createWithPeer:(TLPeer *)peer top_message:(int)top_message unread_count:(int)unread_count last_message_date:(int)last_message_date notify_settings:(TLPeerNotifySettings *)notify_settings last_marked_message:(int)last_marked_message top_message_fake:(int)top_message_fake last_marked_date:(int)last_marked_date sync_message_id:(int)sync_message_id { ++(TL_conversation *)createWithPeer:(TLPeer *)peer top_message:(int)top_message unread_count:(int)unread_count last_message_date:(int)last_message_date notify_settings:(TLPeerNotifySettings *)notify_settings last_marked_message:(int)last_marked_message top_message_fake:(int)top_message_fake last_marked_date:(int)last_marked_date sync_message_id:(int)sync_message_id read_inbox_max_id:(int)read_inbox_max_id unread_important_count:(int)unread_important_count lastMessage:(TL_localMessage *)lastMessage { TL_conversation *dialog = [[TL_conversation alloc] init]; dialog.peer = peer; dialog.top_message = top_message; @@ -30,15 +31,31 @@ +(TL_conversation *)createWithPeer:(TLPeer *)peer top_message:(int)top_message u dialog.last_real_message_date = last_message_date; dialog.dstate = DeliveryStateNormal; dialog.sync_message_id = sync_message_id; - dialog.lastMessage = [[MessagesManager sharedManager] find:top_message]; + dialog.lastMessage = lastMessage; + + + dialog.read_inbox_max_id = read_inbox_max_id; + dialog.unread_important_count = unread_important_count; return dialog; } + ++ (TL_conversation *)createWithPeer:(TLPeer *)peer top_message:(int)top_message unread_count:(int)unread_count last_message_date:(int)last_message_date notify_settings:(TLPeerNotifySettings *)notify_settings last_marked_message:(int)last_marked_message top_message_fake:(int)top_message_fake last_marked_date:(int)last_marked_date sync_message_id:(int)sync_message_id read_inbox_max_id:(int)read_inbox_max_id unread_important_count:(int)unread_important_count lastMessage:(TL_localMessage *)lastMessage pts:(int)pts isInvisibleChannel:(BOOL)isInvisibleChannel top_important_message:(int)top_important_message { + + TL_conversation *conversation = [self createWithPeer:peer top_message:top_message unread_count:unread_count last_message_date:last_message_date notify_settings:notify_settings last_marked_message:last_marked_message top_message_fake:top_message_fake last_marked_date:last_marked_date sync_message_id:sync_message_id read_inbox_max_id:read_inbox_max_id unread_important_count:unread_important_count lastMessage:lastMessage]; + + conversation.pts = pts; + conversation.invisibleChannel = isInvisibleChannel; + conversation.top_important_message = top_important_message; + return conversation; + +} + -(void)serialize:(SerializedData*)stream { [TLClassStore TLSerialize:self.peer stream:stream]; - [stream writeInt:self.top_message]; - [stream writeInt:self.unread_count]; + [stream writeInt:self.top_message]; + [stream writeInt:self.unread_count]; [stream writeInt:self.last_message_date]; [TLClassStore TLSerialize:self.notify_settings stream:stream]; [stream writeInt:self.last_marked_message]; @@ -46,19 +63,23 @@ -(void)serialize:(SerializedData*)stream { [stream writeInt:self.last_marked_date]; [stream writeInt:self.last_real_message_date]; [stream writeInt:self.sync_message_id]; - + [stream writeInt:self.read_inbox_max_id]; + [stream writeInt:self.unread_important_count]; + } -(void)unserialize:(SerializedData*)stream { self.peer = [TLClassStore TLDeserialize:stream]; self.top_message = [stream readInt]; - self.unread_count = [stream readInt]; - self.last_message_date = [stream readInt]; + self.unread_count = [stream readInt]; + self.last_message_date = [stream readInt]; self.notify_settings = [TLClassStore TLDeserialize:stream]; self.last_marked_message = [stream readInt]; self.top_message_fake = [stream readInt]; self.last_marked_date = [stream readInt]; self.last_real_message_date = [stream readInt]; self.sync_message_id = [stream readInt]; + self.read_inbox_max_id = [stream readInt]; + self.unread_important_count = [stream readInt]; } -(void)setLast_message_date:(int)last_message_date { @@ -66,7 +87,9 @@ -(void)setLast_message_date:(int)last_message_date { self->_last_real_message_date = last_message_date; } - +-(void)setLastMessage:(TL_localMessage *)lastMessage { + _lastMessage = lastMessage; +} -(BOOL)canSendMessage { @@ -78,19 +101,34 @@ -(BOOL)canSendMessage { } if(self.type == DialogTypeChat) { - return !(self.chat.type != TLChatTypeNormal || self.chat.left); + return !(self.chat.type != TLChatTypeNormal || self.chat.left || self.chat.isDeactivated); } if(self.type == DialogTypeUser && self.user.isBot) return !self.user.isBot || !self.user.isBlocked; + if(self.type == DialogTypeChannel) + return ((!self.chat.isBroadcast && !self.isInvisibleChannel) || self.chat.isCreator || self.chat.isEditor) && !self.chat.isKicked && !self.chat.left && self.chat.type == TLChatTypeNormal; + + if(self.type == DialogTypeUser) + return !self.user.isBlocked; + return YES; } +-(BOOL)isInvisibleChannel { + + return _invisibleChannel; +} + - (TL_broadcast *)broadcast { return [[BroadcastManager sharedManager] find:self.peer.peer_id]; } +-(int)universalTopMessage { + return (self.type == DialogTypeChannel ? self.top_important_message : self.top_message); +} + -(NSString *)blockedText { if(self.type == DialogTypeSecretChat) { EncryptedParams *params = [EncryptedParams findAndCreate:self.peer.peer_id]; @@ -108,8 +146,30 @@ -(NSString *)blockedText { } - if(self.type == DialogTypeChat) { - if(self.chat.type == TLChatTypeForbidden) { + if(self.type == DialogTypeChat || self.type == DialogTypeChannel) { + + if(self.type == DialogTypeChannel) { + + if(self.isInvisibleChannel) { + return NSLocalizedString(@"Conversation.Action.JoinToChannel", nil); + } + + if(self.chat.isKicked || self.chat.left || self.chat.type == TLChatTypeForbidden) { + return NSLocalizedString(@"Conversation.DeleteAndExit", nil); + } + + if(self.chat.isBroadcast) { + return self.isMute ? NSLocalizedString(@"Unmute", nil) : NSLocalizedString(@"Mute", nil); + } + + + } + + if(self.chat.isDeactivated) { + return NSLocalizedString(@"Conversation.Action.ChatDeactivated", nil); + } + + if(self.chat.isKicked || self.chat.type == TLChatTypeForbidden) { return NSLocalizedString(@"Conversation.Action.YouKickedGroup", nil); } @@ -118,13 +178,16 @@ -(NSString *)blockedText { return NSLocalizedString(@"Conversation.Action.YouLeftGroup", nil); } + + } + if(self.type == DialogTypeUser) { if(self.user.isBlocked) { if(self.user.isBot) return NSLocalizedString(@"RestartBot", nil); - return NSLocalizedString(@"User.Blocked", nil); + return NSLocalizedString(@"User.Unlock", nil); } } @@ -132,16 +195,31 @@ -(NSString *)blockedText { return NSLocalizedString(@"Bot.Start", nil); } + - (void)save { if(self.top_message && self.fake) self.fake = NO; - [[Storage manager] updateDialog:self]; + [[Storage manager] insertDialogs:@[self]]; } -(void)dealloc { } +-(int)unread_count { + if(super.unread_count > 1000000) { + + if(self.top_message < TGMINFAKEID) { + return MAX(self.top_message - self.last_marked_message,0); + } + + return 100; + + } + + return super.unread_count; +} + -(void)setUnread_count:(int)unread_count { @@ -161,10 +239,19 @@ - (BOOL)isMute { - (BOOL) isAddToList { if(self.type == DialogTypeSecretChat) return YES; - - return self.last_message_date > 0 && !self.fake; + + return !self.isInvisibleChannel && self.last_message_date > 0 && !self.fake && (!self.chat.isDeactivated); } +//-(BOOL)isInvisibleChannel { +// if(self.type == DialogTypeChannel) { +// return _invisibleChannel || [self.chat left]; +// } +// +// return _invisibleChannel; +//} + + - (void)mute:(dispatch_block_t)completeHandler until:(int)until { [self _changeMute:until completeHandler:completeHandler]; } @@ -183,25 +270,36 @@ - (void)_changeMute:(int)until completeHandler:(dispatch_block_t)completeHandler id request = [TLAPI_account_updateNotifySettings createWithPeer:[TL_inputNotifyPeer createWithPeer:[self inputPeer]] settings:[TL_inputPeerNotifySettings createWithMute_until:mute_until sound:self.notify_settings.sound ? self.notify_settings.sound : @"" show_previews:self.notify_settings.show_previews events_mask:self.notify_settings.events_mask]]; - [RPCRequest sendRequest:request successHandler:^(RPCRequest *request, id response) { - if([response isKindOfClass:[TL_boolTrue class]]) { - - self.notify_settings = [TL_peerNotifySettings createWithMute_until:mute_until sound:self.notify_settings.sound show_previews:self.notify_settings.show_previews events_mask:self.notify_settings.events_mask]; - [self updateNotifySettings:self.notify_settings]; - - } + + dispatch_block_t successBlock = ^{ + self.notify_settings = [TL_peerNotifySettings createWithMute_until:mute_until sound:self.notify_settings.sound show_previews:self.notify_settings.show_previews events_mask:self.notify_settings.events_mask]; + [self updateNotifySettings:self.notify_settings]; if(completeHandler) completeHandler(); - } errorHandler:^(RPCRequest *request, RpcError *error) { - if(completeHandler) - completeHandler(); - }]; + [MessagesManager updateUnreadBadge]; + + }; + + if(self.type != DialogTypeSecretChat && self.type != DialogTypeBroadcast) { + [RPCRequest sendRequest:request successHandler:^(RPCRequest *request, id response) { + + successBlock(); + + } errorHandler:^(RPCRequest *request, RpcError *error) { + if(completeHandler) + completeHandler(); + }]; + } else { + successBlock(); + } + + } - (void)muteOrUnmute:(dispatch_block_t)completeHandler until:(int)until { - [self mute:completeHandler until:until]; + [self mute:completeHandler until:self.isMute ? 0 : 365*24*60*60]; } -(int)peer_id { @@ -220,10 +318,9 @@ - (void)updateNotifySettings:(TLPeerNotifySettings *)notify_settings { -(id)inputPeer { id input; if(self.peer.chat_id != 0) { - // if([self.peer isKindOfClass:[TL_peerSecret class]]) { - // TLEncryptedChat *chat = [[ChatsManager sharedManager] find:self.peer.chat_id]; - //} input = [TL_inputPeerChat createWithChat_id:self.peer.chat_id]; + } else if([self.peer isKindOfClass:[TL_peerChannel class]]) { + return [TL_inputPeerChannel createWithChannel_id:self.peer.channel_id access_hash:self.chat.access_hash]; } else { TLUser *user = [[UsersManager sharedManager] find:self.peer.user_id]; input = [user inputPeer]; @@ -235,7 +332,6 @@ -(id)inputPeer { -(void)setUnreadCount:(int)unread_count { self.unread_count = unread_count < 0 ? 0 : unread_count; - } -(void)addUnread { @@ -268,16 +364,18 @@ - (DialogType) type { return [typeNumber intValue]; } else { DialogType type = DialogTypeUser; - if(self.peer.chat_id) { - if(self.peer.class == [TL_peerChat class]) - type = DialogTypeChat; - else if(self.peer.class == [TL_peerSecret class]) - type = DialogTypeSecretChat; - else - type = DialogTypeBroadcast; - - - } + + if(self.peer.class == [TL_peerUser class]) + type = DialogTypeUser; + else if(self.peer.class == [TL_peerChat class]) + type = DialogTypeChat; + else if(self.peer.class == [TL_peerSecret class]) + type = DialogTypeSecretChat; + else if(self.peer.class == [TL_peerChannel class]) + type = DialogTypeChannel; + else if(self.peer.class == [TL_peerBroadcast class]) + type = DialogTypeBroadcast; + objc_setAssociatedObject(self, kType, [NSNumber numberWithInt:type], OBJC_ASSOCIATION_RETAIN_NONATOMIC); return type; @@ -296,8 +394,8 @@ - (NSString *)cacheKey { - (TLChat *) chat { - if(!_p_chat && self.peer.chat_id != 0) { - _p_chat = [[ChatsManager sharedManager] find:self.peer.chat_id]; + if(!_p_chat && (self.peer.chat_id != 0 || self.peer.channel_id != 0)) { + _p_chat = [[ChatsManager sharedManager] find:self.peer.chat_id == 0 ? self.peer.channel_id : self.peer.chat_id]; } return _p_chat; } @@ -306,6 +404,17 @@ - (TLChatFull *)fullChat { return [[FullChatManager sharedManager] find:[self chat].n_id]; } +-(long)channel_top_message_id { + return channelMsgId(self.top_message,self.peer_id); +} + +-(long)channel_top_important_message_id { + return channelMsgId(self.top_important_message,self.peer_id); +} + +-(BOOL)isVerified { + return self.type == DialogTypeChannel ? self.chat.isVerified : self.type == DialogTypeUser ? self.user.isVerified : NO; +} - (TL_encryptedChat *) encryptedChat { return (TL_encryptedChat *)[self chat]; @@ -328,5 +437,19 @@ - (TLUser *) user { return _p_user; } +-(BOOL)canEditConversation { + return YES; +} + + +-(BOOL)canSendChannelMessageAsAdmin { + return self.type == DialogTypeChannel && !self.chat.isMegagroup && (self.chat.isAdmin || self.chat.isEditor); +} + +-(BOOL)canSendChannelMessageAsUser { + return self.type == DialogTypeChannel && (self.chat.isMegagroup || ((self.chat.isAdmin && !self.chat.isBroadcast) || !self.chat.isBroadcast)); +} + + @end diff --git a/TelegramTest/TL_conversation_old34.h b/TelegramTest/TL_conversation_old34.h new file mode 100644 index 00000000..6df17abe --- /dev/null +++ b/TelegramTest/TL_conversation_old34.h @@ -0,0 +1,13 @@ +// +// TL_conversation_old34.h +// Telegram +// +// Created by keepcoder on 24.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TL_conversation.h" + +@interface TL_conversation_old34 : TL_conversation + +@end diff --git a/TelegramTest/TL_conversation_old34.m b/TelegramTest/TL_conversation_old34.m new file mode 100644 index 00000000..66ce907f --- /dev/null +++ b/TelegramTest/TL_conversation_old34.m @@ -0,0 +1,41 @@ +// +// TL_conversation_old34.m +// Telegram +// +// Created by keepcoder on 24.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TL_conversation_old34.h" + +@implementation TL_conversation_old34 + + + +-(void)serialize:(SerializedData*)stream { + [TLClassStore TLSerialize:self.peer stream:stream]; + [stream writeInt:self.top_message]; + [stream writeInt:self.unread_count]; + [stream writeInt:self.last_message_date]; + [TLClassStore TLSerialize:self.notify_settings stream:stream]; + [stream writeInt:self.last_marked_message]; + [stream writeInt:self.top_message_fake]; + [stream writeInt:self.last_marked_date]; + [stream writeInt:self.last_real_message_date]; + [stream writeInt:self.sync_message_id]; + +} +-(void)unserialize:(SerializedData*)stream { + self.peer = [TLClassStore TLDeserialize:stream]; + self.top_message = [stream readInt]; + self.unread_count = [stream readInt]; + self.last_message_date = [stream readInt]; + self.notify_settings = [TLClassStore TLDeserialize:stream]; + self.last_marked_message = [stream readInt]; + self.top_message_fake = [stream readInt]; + self.last_marked_date = [stream readInt]; + self.last_real_message_date = [stream readInt]; + self.sync_message_id = [stream readInt]; +} + +@end diff --git a/TelegramTest/TL_localEmptyMessage.h b/TelegramTest/TL_localEmptyMessage.h new file mode 100644 index 00000000..dab4e5f6 --- /dev/null +++ b/TelegramTest/TL_localEmptyMessage.h @@ -0,0 +1,16 @@ +// +// TL_localEmptyMessage.h +// Telegram +// +// Created by keepcoder on 16.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TLObject.h" + +@interface TL_localEmptyMessage : TL_localMessage + + ++(TL_localEmptyMessage *)createWithN_Id:(int)n_id to_id:(TLPeer *)peer; + +@end diff --git a/TelegramTest/TL_localEmptyMessage.m b/TelegramTest/TL_localEmptyMessage.m new file mode 100644 index 00000000..bb8e1855 --- /dev/null +++ b/TelegramTest/TL_localEmptyMessage.m @@ -0,0 +1,31 @@ +// +// TL_localEmptyMessage.m +// Telegram +// +// Created by keepcoder on 16.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TL_localEmptyMessage.h" + +@implementation TL_localEmptyMessage + ++(TL_localEmptyMessage *)createWithN_Id:(int)n_id to_id:(TLPeer *)peer { + TL_localEmptyMessage *empty = [[TL_localEmptyMessage alloc] init]; + empty.n_id = n_id; + empty.to_id = peer; + return empty; +} + + +-(void)serialize:(SerializedData *)stream { + [stream writeInt:self.n_id]; + [TLClassStore TLSerialize:self.to_id stream:stream]; +} + +-(void)unserialize:(SerializedData *)stream { + self.n_id = [stream readInt]; + self.to_id = [TLClassStore TLDeserialize:stream]; +} + +@end diff --git a/TelegramTest/TL_localMessage.h b/TelegramTest/TL_localMessage.h index a57765c0..3063afc3 100644 --- a/TelegramTest/TL_localMessage.h +++ b/TelegramTest/TL_localMessage.h @@ -8,6 +8,8 @@ #import "MTProto.h" #import "TL_conversation.h" +#import "TGMessageHole.h" +#import "TGMessageGroupHole.h" @interface TL_localMessage : TL_message typedef enum { @@ -16,32 +18,47 @@ typedef enum { MessageOutStateError = 2 } MessageOutState; -+(TL_localMessage *)createWithN_id:(int)n_id flags:(int)flags from_id:(int)from_id to_id:(TLPeer *)to_id fwd_from_id:(int)fwd_from_id fwd_date:(int)fwd_date reply_to_msg_id:(int)reply_to_msg_id date:(int)date message:(NSString *)message media:(TLMessageMedia *)media fakeId:(int)fakeId randomId:(long)randomId reply_markup:(TLReplyMarkup *)reply_markup state:(DeliveryState)state; ++(TL_localMessage *)createWithN_id:(int)n_id flags:(int)flags from_id:(int)from_id to_id:(TLPeer *)to_id fwd_from_id:(TLPeer *)fwd_from_id fwd_date:(int)fwd_date reply_to_msg_id:(int)reply_to_msg_id date:(int)date message:(NSString *)message media:(TLMessageMedia *)media fakeId:(int)fakeId randomId:(long)randomId reply_markup:(TLReplyMarkup *)reply_markup entities:(NSMutableArray *)entities views:(int)views isViewed:(BOOL)isViewed state:(DeliveryState)state; + ++(TL_localMessage *)createWithN_id:(int)n_id flags:(int)flags from_id:(int)from_id to_id:(TLPeer *)to_id fwd_from_id:(TLPeer *)fwd_from_id fwd_date:(int)fwd_date reply_to_msg_id:(int)reply_to_msg_id date:(int)date message:(NSString *)message media:(TLMessageMedia *)media fakeId:(int)fakeId randomId:(long)randomId reply_markup:(TLReplyMarkup *)reply_markup entities:(NSMutableArray *)entities views:(int)views state:(DeliveryState)state pts:(int)pts isViewed:(BOOL)isViewed; + + @property (nonatomic,assign) int fakeId; @property (nonatomic,assign) long randomId; +@property (nonatomic,assign) int pts; @property (nonatomic,assign) DeliveryState dstate; +@property (nonatomic,assign) int fwd_from_id_old; +@property (nonatomic,assign,getter=isViewed) BOOL viewed; @property (nonatomic,copy) dispatch_block_t didChangedDeliveryState; +@property (nonatomic,assign,getter=isInvalidate) BOOL invalidate; +@property (nonatomic,strong) TGMessageHole *hole; -(NSUserNotification *)userNotification; @property (nonatomic, strong) TL_localMessage *replyMessage; -(void)save:(BOOL)updateConversation; +-(void)saveViews; +(TL_localMessage *)convertReceivedMessage:(TLMessage *)msg; +(void)convertReceivedMessages:(NSMutableArray *)messages; - +-(long)channelMsgId; +long channelMsgId(int msg_id, int peer_id); -(int)peer_id; -(TLPeer *)peer; - - +-(TLChat *)chat; +-(BOOL)isImportantMessage; +-(BOOL)isChannelMessage; -(BOOL)n_out; -(BOOL)unread; -(BOOL)readedContent; -(BOOL)isMentioned; + +-(id)fwdObject; + - (TL_conversation *)conversation; -(int)filterType; diff --git a/TelegramTest/TL_localMessage.m b/TelegramTest/TL_localMessage.m index c4636b27..3e4699c6 100644 --- a/TelegramTest/TL_localMessage.m +++ b/TelegramTest/TL_localMessage.m @@ -9,15 +9,18 @@ #import "TL_localMessage.h" #import "TL_localMessageService.h" #import "HistoryFilter.h" - +#import "NSString+FindURLs.h" @interface TL_localMessage () @property (nonatomic,strong) NSUserNotification *notification; +@property (nonatomic,assign) int type; +@property (nonatomic,strong,readonly) TLChat *p_chat; +@property (nonatomic,weak) TLUser *fUser; @end @implementation TL_localMessage -+(TL_localMessage *)createWithN_id:(int)n_id flags:(int)flags from_id:(int)from_id to_id:(TLPeer *)to_id fwd_from_id:(int)fwd_from_id fwd_date:(int)fwd_date reply_to_msg_id:(int)reply_to_msg_id date:(int)date message:(NSString *)message media:(TLMessageMedia *)media fakeId:(int)fakeId randomId:(long)randomId reply_markup:(TLReplyMarkup *)reply_markup state:(DeliveryState)state { ++(TL_localMessage *)createWithN_id:(int)n_id flags:(int)flags from_id:(int)from_id to_id:(TLPeer *)to_id fwd_from_id:(TLPeer *)fwd_from_id fwd_date:(int)fwd_date reply_to_msg_id:(int)reply_to_msg_id date:(int)date message:(NSString *)message media:(TLMessageMedia *)media fakeId:(int)fakeId randomId:(long)randomId reply_markup:(TLReplyMarkup *)reply_markup entities:(NSMutableArray *)entities views:(int)views isViewed:(BOOL)isViewed state:(DeliveryState)state { TL_localMessage *msg = [[TL_localMessage alloc] init]; msg.flags = flags; @@ -34,9 +37,26 @@ +(TL_localMessage *)createWithN_id:(int)n_id flags:(int)flags from_id:(int)from_ msg.fakeId = fakeId; msg.randomId = randomId; msg.reply_markup = reply_markup; + msg.entities = entities; + msg.views = views; + msg.viewed = isViewed; + return msg; +} + + ++(TL_localMessage *)createWithN_id:(int)n_id flags:(int)flags from_id:(int)from_id to_id:(TLPeer *)to_id fwd_from_id:(TLPeer *)fwd_from_id fwd_date:(int)fwd_date reply_to_msg_id:(int)reply_to_msg_id date:(int)date message:(NSString *)message media:(TLMessageMedia *)media fakeId:(int)fakeId randomId:(long)randomId reply_markup:(TLReplyMarkup *)reply_markup entities:(NSMutableArray *)entities views:(int)views state:(DeliveryState)state pts:(int)pts isViewed:(BOOL)isViewed { + + TL_localMessage *msg = [self createWithN_id:n_id flags:flags from_id:from_id to_id:to_id fwd_from_id:fwd_from_id fwd_date:fwd_date reply_to_msg_id:reply_to_msg_id date:date message:message media:media fakeId:fakeId randomId:randomId reply_markup:reply_markup entities:entities views:views isViewed:isViewed state:state]; + + msg.pts = pts; + return msg; + + } + + -(id)init { if(self = [super init]) { _dstate = DeliveryStateNormal; @@ -54,20 +74,12 @@ -(TL_localMessage *)replyMessage { if(!_replyMessage) { - _replyMessage = [[MessagesManager sharedManager] supportMessage:self.reply_to_msg_id]; + _replyMessage = [MessagesManager supportMessage:self.reply_to_msg_id peer_id:self.peer_id]; - if(!_replyMessage) + if(_replyMessage) { - _replyMessage = [[MessagesManager sharedManager] find:self.reply_to_msg_id]; - - if(!_replyMessage) - _replyMessage = [[Storage manager] messageById:self.reply_to_msg_id]; - - if(_replyMessage) - { - [[Storage manager] addSupportMessages:@[_replyMessage]]; - [[MessagesManager sharedManager] addSupportMessages:@[_replyMessage]]; - } + [[Storage manager] addSupportMessages:@[_replyMessage]]; + [MessagesManager addSupportMessages:@[_replyMessage]]; } } @@ -81,11 +93,19 @@ -(TL_localMessage *)replyMessage { -(TLUser *)fromUser { - return [[UsersManager sharedManager] find:self.from_id]; + + if(_fUser != nil) + return _fUser; + else { + if(self.from_id != 0) + _fUser = [[UsersManager sharedManager] find:self.from_id];; + } + + return _fUser; } -(TLUser *)fromFwdUser { - return [[UsersManager sharedManager] find:self.fwd_from_id]; + return [[UsersManager sharedManager] find:self.fwd_from_id.user_id]; } -(void)setDstate:(DeliveryState)dstate { @@ -100,14 +120,19 @@ +(TL_localMessage *)convertReceivedMessage:(TLMessage *)message { TL_localMessage *msg; + if([message isKindOfClass:[TL_messageService class]]) { - msg = [TL_localMessageService createWithN_id:message.n_id flags:message.flags from_id:message.from_id to_id:message.to_id date:message.date action:message.action fakeId:[MessageSender getFakeMessageId] randomId:rand_long() dstate:DeliveryStateNormal]; + msg = [TL_localMessageService createWithFlags:message.flags n_id:message.n_id from_id:message.from_id to_id:message.to_id date:message.date action:message.action fakeId:[MessageSender getFakeMessageId] randomId:rand_long() dstate:DeliveryStateNormal]; } else if(![message isKindOfClass:[TL_messageEmpty class]]) { - msg = [TL_localMessage createWithN_id:message.n_id flags:message.flags from_id:message.from_id to_id:message.to_id fwd_from_id:message.fwd_from_id fwd_date:message.fwd_date reply_to_msg_id:message.reply_to_msg_id date:message.date message:message.message media:message.media fakeId:[MessageSender getFakeMessageId] randomId:rand_long() reply_markup:message.reply_markup state:DeliveryStateNormal]; + msg = [TL_localMessage createWithN_id:message.n_id flags:message.flags from_id:message.from_id to_id:message.to_id fwd_from_id:message.fwd_from_id fwd_date:message.fwd_date reply_to_msg_id:message.reply_to_msg_id date:message.date message:message.message media:message.media fakeId:[MessageSender getFakeMessageId] randomId:rand_long() reply_markup:message.reply_markup entities:message.entities views:message.views isViewed:NO state:DeliveryStateNormal]; + } else { return (TL_localMessage *) message; } + if(msg.from_id > 0) + msg.fUser = [[UsersManager sharedManager] find:msg.from_id]; + return msg; } @@ -119,49 +144,97 @@ +(void)convertReceivedMessages:(NSMutableArray *)messages { } } + - (void)save:(BOOL)updateConversation { - [[Storage manager] insertMessage:self completeHandler:nil]; - [[MessagesManager sharedManager] TGsetMessage:self]; + [[Storage manager] insertMessages:@[self]]; if(updateConversation && (self.n_id != self.conversation.top_message || [self isKindOfClass:[TL_destructMessage class]])) { [[DialogsManager sharedManager] updateTop:self needUpdate:YES update_real_date:NO]; } } +-(void)saveViews { + [[Storage manager] updateChannelMessageViews:self.channelMsgId views:self.views]; +} + -(void)serialize:(SerializedData*)stream { [stream writeInt:self.flags]; - [stream writeInt:self.n_id]; - [stream writeInt:self.from_id]; - [TLClassStore TLSerialize:self.to_id stream:stream]; - if(self.flags & (1 << 2)) [stream writeInt:self.fwd_from_id]; + [stream writeInt:self.n_id]; + if(self.flags & (1 << 8)) {[stream writeInt:self.from_id];} + [TLClassStore TLSerialize:self.to_id stream:stream]; + if(self.flags & (1 << 2)) {[ClassStore TLSerialize:self.fwd_from_id stream:stream];} if(self.flags & (1 << 2)) [stream writeInt:self.fwd_date]; if(self.flags & (1 << 3)) [stream writeInt:self.reply_to_msg_id]; - [stream writeInt:self.date]; - [stream writeString:self.message]; - [TLClassStore TLSerialize:self.media stream:stream]; + [stream writeInt:self.date]; + [stream writeString:self.message]; + if(self.flags & (1 << 9)) {[ClassStore TLSerialize:self.media stream:stream];} [stream writeInt:self.fakeId]; [stream writeInt:self.dstate]; [stream writeLong:self.randomId]; if(self.flags & (1 << 6)) [ClassStore TLSerialize:self.reply_markup stream:stream]; + if(self.flags & (1 << 7)) {//Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.entities count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLMessageEntity* obj = [self.entities objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + }} + + if(self.flags & (1 << 10)) {[stream writeInt:self.views];} + + + } -(void)unserialize:(SerializedData*)stream { self.flags = [stream readInt]; - self.n_id = [stream readInt]; - self.from_id = [stream readInt]; - self.to_id = [TLClassStore TLDeserialize:stream]; - if(self.flags & (1 << 2)) self.fwd_from_id = [stream readInt]; + self.n_id = [stream readInt]; + if(self.flags & (1 << 8)) {self.from_id = [stream readInt];} + self.to_id = [TLClassStore TLDeserialize:stream]; + if(self.flags & (1 << 2)) {self.fwd_from_id = [ClassStore TLDeserialize:stream];} if(self.flags & (1 << 2)) self.fwd_date = [stream readInt]; if(self.flags & (1 << 3)) self.reply_to_msg_id = [stream readInt]; - self.date = [stream readInt]; + self.date = [stream readInt]; self.message = [stream readString]; - self.media = [TLClassStore TLDeserialize:stream]; + if(self.flags & (1 << 9)) {self.media = [ClassStore TLDeserialize:stream];} self.fakeId = [stream readInt]; self.dstate = [stream readInt]; self.randomId = [stream readLong]; if(self.flags & (1 << 6)) self.reply_markup = [ClassStore TLDeserialize:stream]; + if(self.flags & (1 << 7)) {//UNS FullVector + [stream readInt]; + { + if(!self.entities) + self.entities = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLMessageEntity* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLMessageEntity class]]) + [self.entities addObject:obj]; + else + break; + } + }} + + + if(self.flags & (1 << 10)) {self.views = [stream readInt];} + } + + +-(TLPeer *)fwd_from_id { + if(self.class != [TL_localMessage class]) { + return self.fwd_from_id_old != 0 ? [TL_peerUser createWithUser_id:self.fwd_from_id_old] : nil; + } + + return [super fwd_from_id]; +} + + -(int)peer_id { int peer_id; if([self.to_id chat_id] != 0) { @@ -170,7 +243,9 @@ -(int)peer_id { else peer_id = -self.to_id.chat_id; } - else + else if(self.to_id.channel_id != 0) { + peer_id = -self.to_id.channel_id; + } else if([self n_out]) peer_id = self.to_id.user_id; else @@ -180,7 +255,7 @@ -(int)peer_id { -(TLPeer *)peer { - if([self.to_id chat_id] != 0) + if([self.to_id chat_id] != 0 || self.to_id.channel_id != 0) return self.to_id; else { if([self n_out]) @@ -191,6 +266,14 @@ -(TLPeer *)peer { } } +- (TLChat *) chat { + + if(!_p_chat && (self.peer.chat_id != 0 || self.peer.channel_id != 0)) { + _p_chat = [[ChatsManager sharedManager] find:self.peer.chat_id == 0 ? self.peer.channel_id : self.peer.chat_id]; + } + return _p_chat; +} + -(id)initWithCoder:(NSCoder *)aDecoder { if((self = [TLClassStore deserialize:[aDecoder decodeObjectForKey:@"data"]])) { @@ -209,8 +292,16 @@ -(BOOL)n_out { } +-(BOOL)isImportantMessage { + return self.isChannelMessage && ((self.flags & 2) || (self.flags & 16) || (self.flags & 256) == 0); +} + +-(BOOL)isChannelMessage { + return [self.to_id isKindOfClass:[TL_peerChannel class]]; +} + -(BOOL)unread { - return self.flags & TGUNREADMESSAGE; + return self.isChannelMessage ? self.n_out || self.n_id > TGMINFAKEID ? NO : (self.conversation.read_inbox_max_id < self.n_id || self.conversation.read_inbox_max_id > TGMINFAKEID) : self.flags & TGUNREADMESSAGE; } -(BOOL)readedContent { @@ -221,22 +312,6 @@ -(BOOL)isMentioned { return self.flags & TGMENTIONMESSAGE; } --(void)setFlags:(int)flags { - - int of = self.flags; - - BOOL o = [self unread]; - - [super setFlags:flags]; - - BOOL n = [self unread]; - - if(of != -1 && o && o != n && [self userNotification]) { - [[NSUserNotificationCenter defaultUserNotificationCenter] removeDeliveredNotification:[self userNotification]]; - _notification = nil; - } - -} DYNAMIC_PROPERTY(DDialog); @@ -246,64 +321,72 @@ - (TL_conversation *)conversation { __block TL_conversation *dialog; dialog = [self getDDialog]; + + if(!dialog) { + dialog = [[DialogsManager sharedManager] find:self.peer_id]; + [self setDDialog:dialog]; + } + + if(!dialog) { + if(!dialog) + dialog = [[DialogsManager sharedManager] createDialogForMessage:self]; + else + [[DialogsManager sharedManager] add:@[dialog]]; - if(!dialog) { - dialog = [[DialogsManager sharedManager] find:self.peer_id]; - [self setDDialog:dialog]; - } - - if(!dialog) { - dialog = [[Storage manager] selectConversation:self.peer]; - - if(!dialog) - dialog = [[DialogsManager sharedManager] createDialogForMessage:self]; - else - [[DialogsManager sharedManager] add:@[dialog]]; - - [self setDDialog:dialog]; - } - + [self setDDialog:dialog]; + } + return dialog; } -(int)filterType { - int mask = HistoryFilterNone; - - if([self.media isKindOfClass:[TL_messageMediaEmpty class]]) { - mask|=HistoryFilterText; - } - - if([self.media isKindOfClass:[TL_messageMediaAudio class]]) { - mask|=HistoryFilterAudio; - } - - if([self.media isKindOfClass:[TL_messageMediaDocument class]]) { - TL_documentAttributeAudio *attr = (TL_documentAttributeAudio *)[self.media.document attributeWithClass:[TL_documentAttributeAudio class]]; - if(attr != nil || [self.media.document.mime_type hasPrefix:@"audio/"]) { - mask|=HistoryFilterAudioDocument; + if(_type == 0) + { + int mask = [self.to_id isKindOfClass:[TL_peerChannel class]] ? HistoryFilterChannelMessage : HistoryFilterNone; + + if([self isImportantMessage]) + mask|=HistoryFilterImportantChannelMessage; + + if([self.media isKindOfClass:[TL_messageMediaEmpty class]] || self.media == nil) { + mask|=HistoryFilterText; } - mask|=HistoryFilterDocuments; - } - - if([self.media isKindOfClass:[TL_messageMediaVideo class]]) { - mask|=HistoryFilterVideo; - } - - if([self.media isKindOfClass:[TL_messageMediaContact class]]) { - mask|=HistoryFilterContact; - } - - if([self.media isKindOfClass:[TL_messageMediaPhoto class]]) { - mask|=HistoryFilterPhoto; - } - - if([self.media isKindOfClass:[TL_messageMediaWebPage class]]) { - mask|=HistoryFilterSharedLink; + if([self.media isKindOfClass:[TL_messageMediaAudio class]]) { + mask|=HistoryFilterAudio; + } + + if([self.media isKindOfClass:[TL_messageMediaDocument class]]) { + TL_documentAttributeAudio *attr = (TL_documentAttributeAudio *)[self.media.document attributeWithClass:[TL_documentAttributeAudio class]]; + if(attr != nil || [self.media.document.mime_type hasPrefix:@"audio/"]) { + mask|=HistoryFilterAudioDocument; + } + + mask|=HistoryFilterDocuments; + } + + if([self.media isKindOfClass:[TL_messageMediaVideo class]]) { + mask|=HistoryFilterVideo; + } + + if([self.media isKindOfClass:[TL_messageMediaContact class]]) { + mask|=HistoryFilterContact; + } + + if([self.media isKindOfClass:[TL_messageMediaPhoto class]]) { + mask|=HistoryFilterPhoto; + } + + NSArray *entities = [self.entities filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.class = %@",[TL_messageEntityUrl class]]]; + + if([self.media.webpage isKindOfClass:[TL_webPage class]] || entities.count > 0) { + mask|=HistoryFilterSharedLink; + } + + _type = mask; } - return mask; + return _type; } @@ -330,8 +413,66 @@ -(NSUserNotification *)userNotification { } +-(void)setMedia:(TLMessageMedia*)media +{ + [super setMedia:media]; + + if(self.media == nil) { self.flags&= ~ (1 << 9) ;} else { self.flags|= (1 << 9); } +} + +-(void)setFrom_id:(int)from_id +{ + [super setFrom_id:from_id]; + + if(self.from_id == 0) { self.flags&= ~ (1 << 8) ;} else { self.flags|= (1 << 8); } +} + + +-(void)setEntities:(NSMutableArray*)entities +{ + [super setEntities:entities]; + + if(self.entities == nil) { self.flags&= ~ (1 << 7) ;} else { self.flags|= (1 << 7); } +} + +-(long)channelMsgId { + return self.isChannelMessage ? channelMsgId(self.n_id,self.peer_id) : self.n_id; +} + + +long channelMsgId(int msg_id, int peer_id) { + NSMutableData *data = [NSMutableData data]; + int msgId = msg_id; + int channelId = peer_id; + + msg_id = NSSwapHostIntToBig(msg_id); + + + + [data appendBytes:&msgId length:4]; + [data appendBytes:&channelId length:4]; + + long converted; + + [data getBytes:&converted length:8]; + + return converted; + +} + +-(id)fwdObject { + if([self.fwd_from_id isKindOfClass:[TL_peerUser class]]) { + return [[UsersManager sharedManager] find:self.fwd_from_id.user_id]; + } else + return [[ChatsManager sharedManager] find:self.fwd_from_id.chat_id != 0 ? self.fwd_from_id.chat_id : self.fwd_from_id.channel_id]; +} + -(id)copy { - return [TL_localMessage createWithN_id:self.n_id flags:self.flags from_id:self.from_id to_id:self.to_id fwd_from_id:self.fwd_from_id fwd_date:self.fwd_date reply_to_msg_id:self.reply_to_msg_id date:self.date message:self.message media:self.media fakeId:self.fakeId randomId:self.randomId reply_markup:self.reply_markup state:self.dstate]; + return [TL_localMessage createWithN_id:self.n_id flags:self.flags from_id:self.from_id to_id:self.to_id fwd_from_id:self.fwd_from_id fwd_date:self.fwd_date reply_to_msg_id:self.reply_to_msg_id date:self.date message:self.message media:self.media fakeId:self.fakeId randomId:self.randomId reply_markup:self.reply_markup entities:self.entities views:self.views state:self.dstate pts:self.pts isViewed:self.isViewed]; +} + +-(void)dealloc { + } diff --git a/TelegramTest/TL_localMessageService.h b/TelegramTest/TL_localMessageService.h index 424ea7a6..7f3400ac 100644 --- a/TelegramTest/TL_localMessageService.h +++ b/TelegramTest/TL_localMessageService.h @@ -9,5 +9,10 @@ #import "TL_localMessage.h" @interface TL_localMessageService : TL_localMessage -+ (TL_localMessageService *)createWithN_id:(int)n_id flags:(int)flags from_id:(int)from_id to_id:(TLPeer *)to_id date:(int)date action:(TLMessageAction *)action fakeId:(int)fakeId randomId:(long)randomId dstate:(DeliveryState)dstate; + ++(TL_localMessageService*)createWithFlags:(int)flags n_id:(int)n_id from_id:(int)from_id to_id:(TLPeer*)to_id date:(int)date action:(TLMessageAction*)action fakeId:(int)fakeId randomId:(long)randomId dstate:(DeliveryState)dstate; + + ++(TL_localMessageService *)createWithHole:(TGMessageHole *)hole; + @end diff --git a/TelegramTest/TL_localMessageService.m b/TelegramTest/TL_localMessageService.m index 6b94efa3..afe84df7 100644 --- a/TelegramTest/TL_localMessageService.m +++ b/TelegramTest/TL_localMessageService.m @@ -9,7 +9,8 @@ #import "TL_localMessageService.h" @implementation TL_localMessageService -+ (TL_localMessageService *)createWithN_id:(int)n_id flags:(int)flags from_id:(int)from_id to_id:(TLPeer *)to_id date:(int)date action:(TLMessageAction *)action fakeId:(int)fakeId randomId:(long)randomId dstate:(DeliveryState)dstate { ++(TL_localMessageService*)createWithFlags:(int)flags n_id:(int)n_id from_id:(int)from_id to_id:(TLPeer*)to_id date:(int)date action:(TLMessageAction*)action fakeId:(int)fakeId randomId:(long)randomId dstate:(DeliveryState)dstate { + TL_localMessageService *msg = [[TL_localMessageService alloc] init]; msg.flags = flags; msg.n_id = n_id == 0 ? fakeId : n_id; @@ -20,32 +21,60 @@ + (TL_localMessageService *)createWithN_id:(int)n_id flags:(int)flags from_id:(i msg.dstate = dstate; msg.fakeId = fakeId; msg.randomId = randomId; + return msg; + +} + + ++(TL_localMessageService *)createWithHole:(TGMessageHole *)hole { + + TL_localMessageService *service = [TL_localMessageService createWithFlags:16 n_id:hole.uniqueId from_id:0 to_id:[TL_peerChannel createWithChannel_id:-hole.peer_id] date:hole.date action:[TL_messageActionEmpty create] fakeId:0 randomId:rand_long() dstate:DeliveryStateNormal]; + + service.hole = hole; + + return service; } -(void)serialize:(SerializedData*)stream { [stream writeInt:self.flags]; - [stream writeInt:self.n_id]; - [stream writeInt:self.from_id]; - [TLClassStore TLSerialize:self.to_id stream:stream]; - [stream writeInt:self.date]; - [TLClassStore TLSerialize:self.action stream:stream]; + [stream writeInt:self.n_id]; + if(self.flags & (1 << 8)) {[stream writeInt:self.from_id];} + [ClassStore TLSerialize:self.to_id stream:stream]; + [stream writeInt:self.date]; + [ClassStore TLSerialize:self.action stream:stream]; + [stream writeLong:self.randomId]; [stream writeInt:self.fakeId]; [stream writeInt:self.dstate]; + } -(void)unserialize:(SerializedData*)stream { self.flags = [stream readInt]; - self.n_id = [stream readInt]; - self.from_id = [stream readInt]; - self.to_id = [TLClassStore TLDeserialize:stream]; - self.date = [stream readInt]; - self.action = [TLClassStore TLDeserialize:stream]; + self.n_id = [stream readInt]; + if(self.flags & (1 << 8)) {self.from_id = [stream readInt];} + self.to_id = [ClassStore TLDeserialize:stream]; + self.date = [stream readInt]; + self.action = [ClassStore TLDeserialize:stream]; + self.randomId = [stream readLong]; self.fakeId = [stream readInt]; self.dstate = [stream readInt]; } --(id)copy { - return [TL_localMessageService createWithN_id:self.n_id flags:self.flags from_id:self.from_id to_id:self.to_id date:self.date action:self.action fakeId:self.fakeId randomId:self.randomId dstate:self.dstate]; +-(TL_localMessageService *)copy { + + TL_localMessageService *objc = [[TL_localMessageService alloc] init]; + + objc.flags = self.flags; + objc.n_id = self.n_id; + objc.from_id = self.from_id; + objc.to_id = [self.to_id copy]; + objc.date = self.date; + objc.action = [self.action copy]; + objc.fakeId = self.fakeId; + objc.dstate = self.dstate; + objc.randomId = self.randomId; + return objc; } + @end diff --git a/TelegramTest/TL_localMessageService_old34.h b/TelegramTest/TL_localMessageService_old34.h new file mode 100644 index 00000000..67de72fc --- /dev/null +++ b/TelegramTest/TL_localMessageService_old34.h @@ -0,0 +1,13 @@ +// +// TL_localMessageService_old34.h +// Telegram +// +// Created by keepcoder on 18.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TL_localMessage_old34.h" + +@interface TL_localMessageService_old34 : TL_localMessage_old34 + +@end diff --git a/TelegramTest/TL_localMessageService_old34.m b/TelegramTest/TL_localMessageService_old34.m new file mode 100644 index 00000000..94f0f1f3 --- /dev/null +++ b/TelegramTest/TL_localMessageService_old34.m @@ -0,0 +1,51 @@ +// +// TL_localMessageService_old34.m +// Telegram +// +// Created by keepcoder on 18.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TL_localMessageService_old34.h" + +@implementation TL_localMessageService_old34 ++ (TL_localMessageService *)createWithN_id:(int)n_id flags:(int)flags from_id:(int)from_id to_id:(TLPeer *)to_id date:(int)date action:(TLMessageAction *)action fakeId:(int)fakeId randomId:(long)randomId dstate:(DeliveryState)dstate { + TL_localMessageService *msg = [[TL_localMessageService alloc] init]; + msg.flags = flags; + msg.n_id = n_id == 0 ? fakeId : n_id; + msg.from_id = from_id; + msg.to_id = to_id; + msg.date = date; + msg.action = action; + msg.dstate = dstate; + msg.fakeId = fakeId; + msg.randomId = randomId; + return msg; +} + + +-(void)serialize:(SerializedData*)stream { + [stream writeInt:self.flags]; + [stream writeInt:self.n_id]; + [stream writeInt:self.from_id]; + [TLClassStore TLSerialize:self.to_id stream:stream]; + [stream writeInt:self.date]; + [TLClassStore TLSerialize:self.action stream:stream]; + [stream writeInt:self.fakeId]; + [stream writeInt:self.dstate]; +} +-(void)unserialize:(SerializedData*)stream { + self.flags = [stream readInt]; + self.n_id = [stream readInt]; + self.from_id = [stream readInt]; + self.to_id = [TLClassStore TLDeserialize:stream]; + self.date = [stream readInt]; + self.action = [TLClassStore TLDeserialize:stream]; + self.fakeId = [stream readInt]; + self.dstate = [stream readInt]; +} + +-(id)copy { + return [TL_localMessageService_old34 createWithN_id:self.n_id flags:self.flags from_id:self.from_id to_id:self.to_id date:self.date action:self.action fakeId:self.fakeId randomId:self.randomId dstate:self.dstate]; +} +@end diff --git a/TelegramTest/TL_localMessage_old32.h b/TelegramTest/TL_localMessage_old32.h new file mode 100644 index 00000000..9fef182f --- /dev/null +++ b/TelegramTest/TL_localMessage_old32.h @@ -0,0 +1,13 @@ +// +// TL_localMessage_old32.h +// Telegram +// +// Created by keepcoder on 13.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TL_localMessage.h" + +@interface TL_localMessage_old32 : TL_localMessage + +@end diff --git a/TelegramTest/TL_localMessage_old32.m b/TelegramTest/TL_localMessage_old32.m new file mode 100644 index 00000000..87d7c98d --- /dev/null +++ b/TelegramTest/TL_localMessage_old32.m @@ -0,0 +1,50 @@ +// +// TL_localMessage_old32.m +// Telegram +// +// Created by keepcoder on 13.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TL_localMessage_old32.h" + +@implementation TL_localMessage_old32 + + +-(void)serialize:(SerializedData*)stream { + [stream writeInt:self.flags]; + [stream writeInt:self.n_id]; + [stream writeInt:self.from_id]; + [TLClassStore TLSerialize:self.to_id stream:stream]; + if(self.flags & (1 << 2)) [stream writeInt:self.fwd_from_id_old]; + if(self.flags & (1 << 2)) [stream writeInt:self.fwd_date]; + if(self.flags & (1 << 3)) [stream writeInt:self.reply_to_msg_id]; + [stream writeInt:self.date]; + [stream writeString:self.message]; + [TLClassStore TLSerialize:self.media stream:stream]; + [stream writeInt:self.fakeId]; + [stream writeInt:self.dstate]; + [stream writeLong:self.randomId]; + if(self.flags & (1 << 6)) + [ClassStore TLSerialize:self.reply_markup stream:stream]; +} +-(void)unserialize:(SerializedData*)stream { + self.flags = [stream readInt]; + self.n_id = [stream readInt]; + self.from_id = [stream readInt]; + self.to_id = [TLClassStore TLDeserialize:stream]; + if(self.flags & (1 << 2)) self.fwd_from_id_old = [stream readInt]; + if(self.flags & (1 << 2)) self.fwd_date = [stream readInt]; + if(self.flags & (1 << 3)) self.reply_to_msg_id = [stream readInt]; + self.date = [stream readInt]; + self.message = [stream readString]; + self.media = [TLClassStore TLDeserialize:stream]; + self.fakeId = [stream readInt]; + self.dstate = [stream readInt]; + self.randomId = [stream readLong]; + if(self.flags & (1 << 6)) + self.reply_markup = [ClassStore TLDeserialize:stream]; +} + + +@end diff --git a/TelegramTest/TL_localMessage_old34.h b/TelegramTest/TL_localMessage_old34.h new file mode 100644 index 00000000..3f282666 --- /dev/null +++ b/TelegramTest/TL_localMessage_old34.h @@ -0,0 +1,13 @@ +// +// TL_localMessage_old34.h +// Telegram +// +// Created by keepcoder on 21.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TL_localMessage.h" + +@interface TL_localMessage_old34 : TL_localMessage + +@end diff --git a/TelegramTest/TL_localMessage_old34.m b/TelegramTest/TL_localMessage_old34.m new file mode 100644 index 00000000..23081daf --- /dev/null +++ b/TelegramTest/TL_localMessage_old34.m @@ -0,0 +1,70 @@ +// +// TL_localMessage_old34.m +// Telegram +// +// Created by keepcoder on 21.08.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "TL_localMessage_old34.h" + +@implementation TL_localMessage_old34 +-(void)serialize:(SerializedData*)stream { + [stream writeInt:self.flags]; + [stream writeInt:self.n_id]; + [stream writeInt:self.from_id]; + [TLClassStore TLSerialize:self.to_id stream:stream]; + if(self.flags & (1 << 2)) [stream writeInt:self.fwd_from_id_old]; + if(self.flags & (1 << 2)) [stream writeInt:self.fwd_date]; + if(self.flags & (1 << 3)) [stream writeInt:self.reply_to_msg_id]; + [stream writeInt:self.date]; + [stream writeString:self.message]; + [TLClassStore TLSerialize:self.media stream:stream]; + [stream writeInt:self.fakeId]; + [stream writeInt:self.dstate]; + [stream writeLong:self.randomId]; + if(self.flags & (1 << 6)) + [ClassStore TLSerialize:self.reply_markup stream:stream]; + if(self.flags & (1 << 7)) {//Serialize FullVector + [stream writeInt:0x1cb5c415]; + { + NSInteger tl_count = [self.entities count]; + [stream writeInt:(int)tl_count]; + for(int i = 0; i < (int)tl_count; i++) { + TLMessageEntity* obj = [self.entities objectAtIndex:i]; + [ClassStore TLSerialize:obj stream:stream]; + } + }} +} +-(void)unserialize:(SerializedData*)stream { + self.flags = [stream readInt]; + self.n_id = [stream readInt]; + self.from_id = [stream readInt]; + self.to_id = [TLClassStore TLDeserialize:stream]; + if(self.flags & (1 << 2)) self.fwd_from_id_old = [stream readInt]; + if(self.flags & (1 << 2)) self.fwd_date = [stream readInt]; + if(self.flags & (1 << 3)) self.reply_to_msg_id = [stream readInt]; + self.date = [stream readInt]; + self.message = [stream readString]; + self.media = [TLClassStore TLDeserialize:stream]; + self.fakeId = [stream readInt]; + self.dstate = [stream readInt]; + self.randomId = [stream readLong]; + if(self.flags & (1 << 6)) + self.reply_markup = [ClassStore TLDeserialize:stream]; + if(self.flags & (1 << 7)) {//UNS FullVector + [stream readInt]; + { + if(!self.entities) + self.entities = [[NSMutableArray alloc] init]; + int count = [stream readInt]; + for(int i = 0; i < count; i++) { + TLMessageEntity* obj = [ClassStore TLDeserialize:stream]; + if(obj != nil && [obj isKindOfClass:[TLMessageEntity class]]) + [self.entities addObject:obj]; + else + break; + } + }} +} +@end diff --git a/TelegramTest/TL_messageActionEncryptedChat.m b/TelegramTest/TL_messageActionEncryptedChat.m index b746628b..f59cac89 100644 --- a/TelegramTest/TL_messageActionEncryptedChat.m +++ b/TelegramTest/TL_messageActionEncryptedChat.m @@ -20,4 +20,13 @@ -(void)serialize:(SerializedData*)stream { -(void)unserialize:(SerializedData*)stream { self.title = [stream readString]; } + +-(id)copy { + TL_messageActionEncryptedChat* obj = [[TL_messageActionEncryptedChat alloc] init]; + + obj.title = self.title; + + return obj; +} + @end diff --git a/TelegramTest/TMAttributedString.h b/TelegramTest/TMAttributedString.h index ac807000..36381e50 100644 --- a/TelegramTest/TMAttributedString.h +++ b/TelegramTest/TMAttributedString.h @@ -20,6 +20,7 @@ - (NSRange)appendString:(NSString *)string; - (NSRange)appendString:(NSString *)string withColor:(NSColor*)color; - (void)setFont:(NSFont *)font forRange:(NSRange)range; +- (void)setCTFont:(NSFont *)font forRange:(NSRange)range; - (void)setLink:(NSString *)link forRange:(NSRange)range; - (void)setLink:(NSString *)link withColor:(NSColor *)color forRange:(NSRange)range; diff --git a/TelegramTest/TMAttributedString.m b/TelegramTest/TMAttributedString.m index 3e710193..efcd7340 100644 --- a/TelegramTest/TMAttributedString.m +++ b/TelegramTest/TMAttributedString.m @@ -135,6 +135,10 @@ - (void)setFont:(NSFont *)font forRange:(NSRange)range { [self addAttribute:NSFontAttributeName value:font range:range]; } +- (void)setCTFont:(NSFont *)font forRange:(NSRange)range { + [self addAttribute:(NSString *)kCTFontAttributeName value:CFBridgingRelease(CTFontCreateWithFontDescriptor((__bridge CTFontDescriptorRef)[font fontDescriptor], 0.0f, NULL)) range:range]; +} + - (void)setLink:(NSString *)link forRange:(NSRange)range { [self setLink:link withColor:nil forRange:range]; } diff --git a/TelegramTest/TMAvatarImageView.h b/TelegramTest/TMAvatarImageView.h index e23e72c6..94ce9b2f 100644 --- a/TelegramTest/TMAvatarImageView.h +++ b/TelegramTest/TMAvatarImageView.h @@ -36,10 +36,11 @@ typedef void (^TapTMAvatarImageView)(void); @property (nonatomic, strong) TapTMAvatarImageView tapBlock; + (instancetype)standartTableAvatar; ++ (instancetype)standartHintAvatar; + (instancetype)standartUserInfoAvatar; + (instancetype)standartMessageTableAvatar; + (instancetype)standartNewConversationTableAvatar; - ++ (instancetype)standartInfoAvatar; + (NSImage *)generateTextAvatar:(int)colorMask size:(NSSize)size text:(NSString *)text type:(TMAvatarType)type font:(NSFont *)font offsetY:(int)offset; +(int)colorMask:(NSObject *)object; diff --git a/TelegramTest/TMAvatarImageView.m b/TelegramTest/TMAvatarImageView.m index 6b2bda33..1bcef771 100644 --- a/TelegramTest/TMAvatarImageView.m +++ b/TelegramTest/TMAvatarImageView.m @@ -15,7 +15,6 @@ #define INIT_HASH_CHEKER() __block NSUInteger hash = self.currentHash; #define HASH_CHECK() if(self.currentHash != hash) return; #import -#import #import "ImageUtils.h" #import "TGCache.h" #import "TMAvaImageObject.h" @@ -90,29 +89,44 @@ + (NSImage *) placeholderImageBySize:(NSSize)size andColor:(NSColor *)color { + (instancetype)standartTableAvatar { TMAvatarImageView *avatarImageView = [[self alloc] initWithFrame:NSMakeRect(10, roundf((66 - 50) / 2.0), 50, 50)]; avatarImageView.placeholder = [TMAvatarImageView placeholderImageBySize:avatarImageView.frame.size andColor:NSColorFromRGB(0xfafafa)]; - [avatarImageView setFont:[NSFont fontWithName:@"HelveticaNeue-Light" size:18]]; + [avatarImageView setFont:TGSystemLightFont(18)]; return avatarImageView; } + (instancetype)standartNewConversationTableAvatar { TMAvatarImageView *avatarImageView = [[self alloc] initWithFrame:NSMakeRect(10, roundf((60 - 44) / 2.0), 44, 44)]; avatarImageView.placeholder = [TMAvatarImageView placeholderImageBySize:avatarImageView.frame.size andColor:NSColorFromRGB(0xfafafa)]; - [avatarImageView setFont:[NSFont fontWithName:@"HelveticaNeue-Light" size:18]]; + [avatarImageView setFont:TGSystemLightFont(18)]; return avatarImageView; } + (instancetype)standartMessageTableAvatar { TMAvatarImageView *avatarImageView = [[self alloc] initWithFrame:NSMakeRect(0, 0, 36, 36)]; avatarImageView.placeholder = [TMAvatarImageView placeholderImageBySize:avatarImageView.frame.size andColor:NSColorFromRGB(0xfafafa)]; - [avatarImageView setFont:[NSFont fontWithName:@"HelveticaNeue" size:14]]; - [avatarImageView setOffsetTextY:2]; + [avatarImageView setFont:TGSystemFont(14)]; + [avatarImageView setOffsetTextY:0]; + return avatarImageView; +} + ++ (instancetype)standartHintAvatar { + TMAvatarImageView *avatarImageView = [[self alloc] initWithFrame:NSMakeRect(0, 0, 30, 30)]; + avatarImageView.placeholder = [TMAvatarImageView placeholderImageBySize:avatarImageView.frame.size andColor:NSColorFromRGB(0xfafafa)]; + [avatarImageView setFont:TGSystemFont(14)]; + [avatarImageView setOffsetTextY:0]; return avatarImageView; } + (instancetype) standartUserInfoAvatar { TMAvatarImageView *avatarImageView = [[self alloc] initWithFrame:NSMakeRect(0, 0, 130, 130)]; avatarImageView.placeholder = [TMAvatarImageView placeholderImageBySize:avatarImageView.frame.size andColor:NSColorFromRGB(0xfafafa)]; - [avatarImageView setFont:[NSFont fontWithName:@"HelveticaNeue-Light" size:30]]; + [avatarImageView setFont:TGSystemLightFont(30)]; + return avatarImageView; +} + ++ (instancetype) standartInfoAvatar { + TMAvatarImageView *avatarImageView = [[self alloc] initWithFrame:NSMakeRect(0, 0, 70, 70)]; + avatarImageView.placeholder = [TMAvatarImageView placeholderImageBySize:avatarImageView.frame.size andColor:NSColorFromRGB(0xfafafa)]; + [avatarImageView setFont:TGSystemLightFont(18)]; return avatarImageView; } @@ -163,7 +177,7 @@ - (void) initialize { [Notification addObserver:self selector:@selector(notificationChatChange:) name:CHAT_UPDATE_PHOTO]; [Notification addObserver:self selector:@selector(notificationChatChange:) name:CHAT_UPDATE_TITLE]; - self.font = [NSFont fontWithName:@"HelveticaNeue" size:12]; + self.font = TGSystemFont(12); self.isNeedPlaceholder = YES; static dispatch_once_t onceToken; @@ -239,9 +253,10 @@ - (void) setUser:(TLUser *)user { } - (void) setUser:(TLUser *)user animated:(BOOL)animated { - if(self.user.n_id == user.n_id) + if(self.user.n_id == user.n_id && [[self.fileLocation cacheKey] isEqualToString:user.photo.photo_small.cacheKey]) return; + self->_chat = nil; self->_user = user; self->_text = nil; @@ -298,7 +313,7 @@ -(void)updateWithConversation:(TL_conversation *)conversation { case DialogTypeBroadcast: [self setBroadcast:conversation.broadcast]; break; - case DialogTypeChat: + case DialogTypeChat: case DialogTypeChannel: [self setChat:conversation.chat]; break; case DialogTypeSecretChat: case DialogTypeUser: @@ -347,7 +362,6 @@ - (void) rebuild:(BOOL)animated { [self removeAnimationForKey:@"contents"]; - if(self.type == TMAvatarTypeUser && self.user.n_id == 777000 && self.bounds.size.width == 50.0f) { self.image = image_TelegramNotifications(); self.image.size = NSMakeSize(50.0f, 50.0f); @@ -363,8 +377,6 @@ - (void) rebuild:(BOOL)animated { __block NSString *key = [NSString stringWithFormat:@"%lu:%@",self.currentHash,NSStringFromSize(self.bounds.size)]; - - NSImage *image = [TGCache cachedImage:key group:@[AVACACHE]]; if(image) { if(animated) @@ -374,7 +386,6 @@ - (void) rebuild:(BOOL)animated { return; } - self.image = self.placeholder; if(self.fileLocation) { @@ -383,10 +394,8 @@ - (void) rebuild:(BOOL)animated { } else { - int colorMask = [TMAvatarImageView colorMask:self.type == TMAvatarTypeChat ? self.chat : (self.type == TMAvatarTypeBroadcast ? self.broadcast : self.user)]; - __block NSString *text = self->_text; [ASQueue dispatchOnStageQueue:^{ @@ -434,7 +443,13 @@ +(NSString *)text:(NSObject *)object { lastName = [lastName stringByReplacingOccurrencesOfString:obj withString:@""]; }]; - text = [NSString stringWithFormat:@"%C%C", (unichar)([firstName length] ? [firstName characterAtIndex:0] : 0), (unichar)([lastName length] ? [lastName characterAtIndex:0] : 0)]; + if(firstName.length == 0) { + text = [NSString stringWithFormat:@"%C",(unichar)([lastName length] ? [lastName characterAtIndex:0] : 0)]; + } else { + text = [NSString stringWithFormat:@"%C%C", (unichar)([firstName length] ? [firstName characterAtIndex:0] : 0), (unichar)([lastName length] ? [lastName characterAtIndex:0] : 0)]; + } + + } } else if([object isKindOfClass:[TLChat class]]) { @@ -516,24 +531,14 @@ + (NSImage *)generateTextAvatar:(int)colorMask size:(NSSize)size text:(NSString NSImage *image = [[NSImage alloc] initWithSize:size]; [image lockFocus]; - - - - - - - TGTwoColors twoColors; - twoColors = colors[colorMask % (sizeof(colors) / sizeof(colors[0]))]; if(colorMask != -1) { CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort]; - - CGColorRef colors[2] = { CGColorRetain(NSColorFromRGB(twoColors.bottom).CGColor), CGColorRetain(NSColorFromRGB(twoColors.top).CGColor) @@ -560,6 +565,8 @@ + (NSImage *)generateTextAvatar:(int)colorMask size:(NSSize)size text:(NSString NSColor *color = [NSColor whiteColor]; __block NSString *textResult = [text uppercaseString]; + + NSArray *emoji = [textResult getEmojiFromString:NO]; @@ -584,7 +591,9 @@ + (NSImage *)generateTextAvatar:(int)colorMask size:(NSSize)size text:(NSString NSDictionary *attributes = @{NSFontAttributeName: font, NSForegroundColorAttributeName: color}; NSSize textSize = [textResult sizeWithAttributes:attributes]; - [textResult drawAtPoint: NSMakePoint(roundf( (size.width- textSize.width) * 0.5 ),roundf( (size.height - textSize.height) * 0.5 + offset) )withAttributes: attributes]; + + textSize.height-=4; + [textResult drawAtPoint: NSMakePoint(roundf( (size.width- textSize.width) * 0.5 ),roundf( (size.height - textSize.height) * 0.5 + offset) ) withAttributes: attributes]; } else { static NSImage *smallAvatar; diff --git a/TelegramTest/TMBackButton.h b/TelegramTest/TMBackButton.h index 209ab460..eb39e861 100644 --- a/TelegramTest/TMBackButton.h +++ b/TelegramTest/TMBackButton.h @@ -18,7 +18,7 @@ typedef enum { -(void)setTarget:(id)target selector:(SEL)selector; -@property (nonatomic,strong) TMViewController *controller; +@property (nonatomic,weak) TMViewController *controller; @property (nonatomic,strong) TMTextField *field; - (id)initWithFrame:(NSRect)frame string:(NSString *)string; diff --git a/TelegramTest/TMBackButton.m b/TelegramTest/TMBackButton.m index 2d7bd178..bcef883e 100644 --- a/TelegramTest/TMBackButton.m +++ b/TelegramTest/TMBackButton.m @@ -42,7 +42,7 @@ - (id)initWithFrame:(NSRect)frame string:(NSString *)string { [self.field setBordered:NO]; [self.field setStringValue:string]; - [self.field setFont:[NSFont fontWithName:@"HelveticaNeue" size:14]]; + [self.field setFont:TGSystemFont(14)]; [self.field setFrameOrigin:NSMakePoint(0, 0)]; @@ -89,20 +89,27 @@ -(void)mouseDown:(NSEvent *)theEvent { -(void)updateBackButton { - if((self.controller.navigationViewController.viewControllerStack.count > 2 || [[Telegram mainViewController] isSingleLayout]) && ![[Telegram rightViewController] isModalViewActive]) { - [self.field setStringValue:[NSString stringWithFormat:@" %@", NSLocalizedString(@"Compose.Back",nil)]]; - } else if([[Telegram rightViewController] isModalViewActive]) { - [self.field setStringValue:NSLocalizedString(@"Cancel", nil)]; + if(self.controller.navigationViewController == ((TelegramWindow *)[NSApp mainWindow]).navigationController) { + if((self.controller.navigationViewController.viewControllerStack.count > 2 || [[Telegram mainViewController] isSingleLayout]) && ![[Telegram rightViewController] isModalViewActive]) { + [self.field setStringValue:[NSString stringWithFormat:@" %@", NSLocalizedString(@"Compose.Back",nil)]]; + } else if([[Telegram rightViewController] isModalViewActive]) { + [self.field setStringValue:NSLocalizedString(@"Cancel", nil)]; + } else { + [self.field setStringValue:NSLocalizedString(@"Close", nil)]; + } + + [self.imageView setHidden:(self.controller.navigationViewController.viewControllerStack.count <= 2 && ![Telegram isSingleLayout]) || [[Telegram rightViewController] isModalViewActive]]; + + + [self.backUnreadMarkView setHidden:!([self.controller.navigationViewController.currentController isKindOfClass:[MessagesViewController class]] && [[Telegram mainViewController] isSingleLayout])]; } else { - [self.field setStringValue:NSLocalizedString(@"Close", nil)]; + [self.field setStringValue:[NSString stringWithFormat:@" %@", NSLocalizedString(@"Compose.Back",nil)]]; + [self.imageView setHidden:NO]; + [self.backUnreadMarkView setHidden:YES]; } + - [self.imageView setHidden:(self.controller.navigationViewController.viewControllerStack.count <= 2 && ![Telegram isSingleLayout]) || [[Telegram rightViewController] isModalViewActive]]; - - - [self.backUnreadMarkView setHidden:!([self.controller.navigationViewController.currentController isKindOfClass:[MessagesViewController class]] && [[Telegram mainViewController] isSingleLayout])]; - - + [self.field sizeToFit]; @@ -132,7 +139,7 @@ -(void)draw { } - (void)click { - [[Telegram rightViewController] navigationGoBack]; + [self.controller.navigationViewController goBackWithAnimation:YES]; } diff --git a/TelegramTest/TMBlueAddButtonView.m b/TelegramTest/TMBlueAddButtonView.m index 8e05d416..b47240e0 100644 --- a/TelegramTest/TMBlueAddButtonView.m +++ b/TelegramTest/TMBlueAddButtonView.m @@ -40,7 +40,7 @@ - (id)initWithFrame:(NSRect)frame self.textLayer = [TMTextLayer layer]; self.textLayer.contentsScale = self.containerView.layer.contentsScale; - self.textLayer.textFont = [NSFont fontWithName:@"HelveticaNeue" size:13]; + self.textLayer.textFont = TGSystemFont(13); [self.containerView.layer addSublayer:self.textLayer]; diff --git a/TelegramTest/TMBottomScrollView.m b/TelegramTest/TMBottomScrollView.m index f5904914..e7ff97f7 100644 --- a/TelegramTest/TMBottomScrollView.m +++ b/TelegramTest/TMBottomScrollView.m @@ -47,7 +47,7 @@ - (void)setMessagesCount:(int)messagesCount { self->_messagesCount = messagesCount; if(messagesCount) { - self.messagesCountAttributedString = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:NSLocalizedString(messagesCount == 1 ? @"Messages.scrollToBottomNewMessage" : @"Messages.scrollToBottomNewMessages", nil), messagesCount] attributes:@{NSFontAttributeName: [NSFont fontWithName:@"HelveticaNeue" size:14], NSForegroundColorAttributeName: BLUE_UI_COLOR}]; + self.messagesCountAttributedString = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:NSLocalizedString(messagesCount == 1 ? @"Messages.scrollToBottomNewMessage" : @"Messages.scrollToBottomNewMessages", nil), messagesCount] attributes:@{NSFontAttributeName: TGSystemFont(14), NSForegroundColorAttributeName: BLUE_UI_COLOR}]; } else { self.messagesCountAttributedString = nil; } diff --git a/TelegramTest/TMCircularProgress.m b/TelegramTest/TMCircularProgress.m index 8dad48d6..be86e255 100644 --- a/TelegramTest/TMCircularProgress.m +++ b/TelegramTest/TMCircularProgress.m @@ -125,8 +125,13 @@ float ease(float t, float b, float c, float d) { - (void)drawRect:(NSRect)dirtyRect { - if(self.isHidden) + if(self.isHidden || self.window == nil) { + [self pop_removeAllAnimations]; + [_timer invalidate]; + _timer = nil; return; + } + [super drawRect:dirtyRect]; @@ -257,6 +262,8 @@ -(void)setProgress:(float)currentProgress animated:(BOOL)animated { }]; + animation.repeatForever = NO; + animation.fromValue = @(_currentAcceptProgress); animation.toValue = @(_currentProgress); @@ -304,45 +311,13 @@ -(void)setProgress:(float)currentProgress animated:(BOOL)animated { rotate.duration = 2; + rotate.removedOnCompletion = YES; rotate.repeatForever = YES; - [self pop_addAnimation:rotate forKey:@"rotate"]; } - - - - -// if(!self.timer) { -// self.timer = [[TGTimer alloc] initWithTimeout:1.f/fps repeat:YES completion:^{ -// -// if(_currentAcceptProgress < _currentProgress) { -// float summ = (_currentProgress - _currentAcceptProgress)/(fps*duration); -// if(summ < step) -// summ = step; -// _currentAcceptProgress+= summ; -// -// } -// -// if(_currentAcceptProgress == max) { -// _currentAcceptProgress = min; -// } -// -// rotateAngel+= 360/fps; -// -// if(rotateAngel > 360) -// rotateAngel = 0; -// -// [LoopingUtils runOnMainQueueAsync:^{ -// [self setNeedsDisplay:YES]; -// }]; -// -// } queue:[[ASQueue globalQueue] nativeQueue]]; -// -// [self.timer start]; -// } - + } diff --git a/TelegramTest/TMCollectionPageController.h b/TelegramTest/TMCollectionPageController.h index bce0f9ba..f478fd7a 100644 --- a/TelegramTest/TMCollectionPageController.h +++ b/TelegramTest/TMCollectionPageController.h @@ -20,11 +20,14 @@ -(void)showAllMedia; -(void)showFiles; +-(void)showSharedLinks; -(void)checkCap; -@property (nonatomic,assign) BOOL isEditable; +-(void)setIsEditable:(BOOL)isEditable animated:(BOOL)animated; -- (void)setSectedMessagesCount:(NSUInteger)count; +@property (nonatomic,assign,readonly) BOOL isEditable; + +- (void)setSectedMessagesCount:(NSUInteger)count enable:(BOOL)enable; -(BOOL)isSelectedItem:(PhotoCollectionImageObject *)item; -(void)setSelected:(BOOL)selected forItem:(PhotoCollectionImageObject *)item; diff --git a/TelegramTest/TMCollectionPageController.m b/TelegramTest/TMCollectionPageController.m index c83b39c0..61cbfe41 100644 --- a/TelegramTest/TMCollectionPageController.m +++ b/TelegramTest/TMCollectionPageController.m @@ -19,7 +19,7 @@ #import "DownloadVideoItem.h" #import "TGSharedMediaCap.h" #import "TGSharedLinksTableView.h" - +#import "TGAudioPlayerWindow.h" @interface TMCollectionPageController () @property (nonatomic,strong) PhotoCollectionTableView *photoCollection; @property (nonatomic,strong) NSMutableArray *items; @@ -85,20 +85,21 @@ -(id)initWithFrame:(NSRect)frame { -(void)loadView { - weakify(); + weak(); + // [super loadView]; [TGCache setMemoryLimit:100*1024*1024 group:PCCACHE]; - self.view = [[TMCollectionPageView alloc] initWithFrame:self.frameInit]; + self.view = [[TMCollectionPageView alloc] initWithFrame:NSZeroRect]; [self setTitle:NSLocalizedString(@"Conversation.Filter.Photos", nil)]; [self.centerTextField setClickBlock:^{ - TMMenuPopover *menuPopover = [[TMMenuPopover alloc] initWithMenu:[strongSelf filterMenu]]; + TMMenuPopover *menuPopover = [[TMMenuPopover alloc] initWithMenu:[weakSelf filterMenu]]; - [menuPopover showRelativeToRect:strongSelf.centerNavigationBarView.bounds ofView:strongSelf.centerNavigationBarView preferredEdge:CGRectMinYEdge]; + [menuPopover showRelativeToRect:weakSelf.centerNavigationBarView.bounds ofView:weakSelf.centerNavigationBarView preferredEdge:CGRectMinYEdge]; }]; @@ -109,7 +110,9 @@ -(void)loadView { self.behavior = [[TGPVMediaBehavior alloc] init]; _photoCollection = [[PhotoCollectionTableView alloc] initWithFrame:self.view.bounds]; - + + _photoCollection.viewController = self; + [_photoCollection setFrame:self.view.bounds]; _photoCollection.tm_delegate = self; @@ -120,7 +123,7 @@ -(void)loadView { [selectRightButton setTapBlock:^ { - strongSelf.isEditable = !strongSelf.isEditable; + [weakSelf setIsEditable:!weakSelf.isEditable animated:YES]; }]; @@ -140,12 +143,22 @@ -(void)loadView { self.documentsTableView = [[TGDocumentsMediaTableView alloc] initWithFrame:self.frameInit]; - + self.documentsTableView.collectionViewController = self; [self.view addSubview:self.documentsTableView.containerView]; [self.documentsTableView.containerView setHidden:YES]; + + self.sharedLinksTableView = [[TGSharedLinksTableView alloc] initWithFrame:self.frameInit]; + self.sharedLinksTableView.collectionViewController = self; + + [self.view addSubview:self.sharedLinksTableView.containerView]; + + [self.sharedLinksTableView.containerView setHidden:YES]; + + + self.mediaCap = [[TGSharedMediaCap alloc] initWithFrame:self.view.bounds cap:image_SadAttach() text:NSLocalizedString(@"SharedMedia.NoSharedMedia", nil)]; @@ -160,12 +173,7 @@ -(void)loadView { - self.sharedLinksTableView = [[TGSharedLinksTableView alloc] initWithFrame:self.frameInit]; - - - [self.view addSubview:self.sharedLinksTableView.containerView]; - - [self.sharedLinksTableView.containerView setHidden:YES]; + } @@ -178,7 +186,7 @@ -(void)setTitle:(NSString *)title { } --(void)setIsEditable:(BOOL)isEditable { +-(void)setIsEditable:(BOOL)isEditable animated:(BOOL)animated { _isEditable = isEditable; TMTextButton *btn = (TMTextButton *)self.rightNavigationBarView; @@ -191,16 +199,20 @@ -(void)setIsEditable:(BOOL)isEditable { self.selectedItems = [[NSMutableArray alloc] init]; - [self.documentsTableView setEditable:isEditable animated:YES]; - [self.sharedLinksTableView setEditable:isEditable animated:YES]; - [self reloadData]; + [self.documentsTableView setEditable:isEditable animated:animated]; + [self.sharedLinksTableView setEditable:isEditable animated:animated]; + [self.photoCollection reloadData]; + + [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) { + [context setDuration:animated ? 0.2 : 0]; + [[self.actionsView animator] setFrameOrigin:NSMakePoint(0, isEditable ? 0 : - NSHeight(self.actionsView.frame))]; - [[self.photoCollection.containerView animator] setFrame:NSMakeRect(0, _isEditable ? NSHeight(self.actionsView.frame) : 0, NSWidth([Telegram rightViewController].view.frame), NSHeight([Telegram rightViewController].view.frame) - 48 - (_isEditable ? NSHeight(self.actionsView.frame) : 0))]; - [[self.documentsTableView.containerView animator] setFrame:NSMakeRect(0, _isEditable ? NSHeight(self.actionsView.frame) : 0, NSWidth([Telegram rightViewController].view.frame), NSHeight([Telegram rightViewController].view.frame) - 48 - (_isEditable ? NSHeight(self.actionsView.frame) : 0))]; - [[self.sharedLinksTableView.containerView animator] setFrame:NSMakeRect(0, _isEditable ? NSHeight(self.actionsView.frame) : 0, NSWidth([Telegram rightViewController].view.frame), NSHeight([Telegram rightViewController].view.frame) - 48 - (_isEditable ? NSHeight(self.actionsView.frame) : 0))]; + [[self.photoCollection.containerView animator] setFrame:NSMakeRect(0, _isEditable ? NSHeight(self.actionsView.frame) : 0, NSWidth(self.navigationViewController.view.frame), NSHeight(self.navigationViewController.view.frame) - 48 - (_isEditable ? NSHeight(self.actionsView.frame) : 0))]; + [[self.documentsTableView.containerView animator] setFrame:NSMakeRect(0, _isEditable ? NSHeight(self.actionsView.frame) : 0, NSWidth(self.navigationViewController.view.frame), NSHeight(self.navigationViewController.view.frame) - 48 - (_isEditable ? NSHeight(self.actionsView.frame) : 0))]; + [[self.sharedLinksTableView.containerView animator] setFrame:NSMakeRect(0, _isEditable ? NSHeight(self.actionsView.frame) : 0, NSWidth(self.navigationViewController.view.frame), NSHeight(self.navigationViewController.view.frame) - 48 - (_isEditable ? NSHeight(self.actionsView.frame) : 0))]; } completionHandler:^{ @@ -219,22 +231,24 @@ -(void)setIsEditable:(BOOL)isEditable { -(void)didDeleteMessages:(NSNotification *)notification { - NSArray *ids = notification.userInfo[KEY_MESSAGE_ID_LIST]; + NSArray *peer_update_data = notification.userInfo[KEY_DATA]; NSMutableArray *items_to_delete = [[NSMutableArray alloc] init]; - [ids enumerateObjectsUsingBlock:^(NSNumber *msg_id, NSUInteger idx, BOOL *stop) { - - [self.items enumerateObjectsUsingBlock:^(PhotoCollectionImageObject *obj, NSUInteger idx, BOOL *stop) { + [peer_update_data enumerateObjectsUsingBlock:^(NSDictionary *data, NSUInteger idx, BOOL *stop) { + + if(self.conversation.peer_id == [data[KEY_PEER_ID] intValue]) { + [self.items enumerateObjectsUsingBlock:^(PhotoCollectionImageObject *obj, NSUInteger idx, BOOL *stop) { - if(obj.previewObject.msg_id == [msg_id intValue]) { + if(obj.previewObject.msg_id == [data[KEY_MESSAGE_ID] intValue]) { - [items_to_delete addObject:obj]; + [items_to_delete addObject:obj]; - *stop = YES; - } + *stop = YES; + } - }]; + }]; + } }]; @@ -369,10 +383,9 @@ -(void)showFiles { [self.photoCollection.containerView setHidden:YES]; [self.sharedLinksTableView.containerView setHidden:YES]; - [self.documentsTableView setConversation:self.conversation]; [self setTitle:NSLocalizedString(@"Conversation.Filter.Files", nil)]; [self checkCap]; - [self setIsEditable:NO]; + [self setIsEditable:NO animated:NO]; } -(void)showSharedLinks { @@ -380,11 +393,9 @@ -(void)showSharedLinks { [self.photoCollection.containerView setHidden:YES]; [self.documentsTableView.containerView setHidden:YES]; - - [self.sharedLinksTableView setConversation:self.conversation]; [self setTitle:NSLocalizedString(@"Conversation.Filter.SharedLinks", nil)]; [self checkCap]; - [self setIsEditable:NO]; + [self setIsEditable:NO animated:NO]; } -(void)showAllMedia { @@ -394,10 +405,15 @@ -(void)showAllMedia { [self setTitle:NSLocalizedString(@"Profile.SharedMedia", nil)]; [self checkCap]; - [self setIsEditable:NO]; + [self setIsEditable:NO animated:NO]; } + + -(void)setConversation:(TL_conversation *)conversation { + + + self->_conversation = conversation; self.isProgress = YES; @@ -405,16 +421,16 @@ -(void)setConversation:(TL_conversation *)conversation { self.selectedItems = [[NSMutableArray alloc] init]; - self.isEditable = NO; - [self setSectedMessagesCount:0]; + + [self setSectedMessagesCount:0 enable:NO]; [self view]; - [self showAllMedia]; + [self.documentsTableView setConversation:conversation]; - + [self.sharedLinksTableView setConversation:conversation]; [self.items removeAllObjects]; @@ -422,7 +438,7 @@ -(void)setConversation:(TL_conversation *)conversation { self.locked = NO; - self.behavior = [[TGPVMediaBehavior alloc] init]; + self.behavior = [[TGPVMediaBehavior alloc] initWithConversation:_conversation commonItem:nil]; self.behavior.conversation = conversation; @@ -461,14 +477,19 @@ -(void)setConversation:(TL_conversation *)conversation { -(void)setSelected:(BOOL)selected forItem:(MessageTableItem *)item { - if(selected) { [_selectedItems addObject:item]; } else { [_selectedItems removeObject:item]; } - [self setSectedMessagesCount:self.selectedItems.count]; + NSMutableArray *messages = [NSMutableArray array]; + + [_selectedItems enumerateObjectsUsingBlock:^(MessageTableItem *obj, NSUInteger idx, BOOL * _Nonnull stop) { + [messages addObject:obj.message]; + }]; + + [self setSectedMessagesCount:self.selectedItems.count enable:[MessagesViewController canDeleteMessages:messages inConversation:_conversation]]; } -(BOOL)isSelectedItem:(PhotoCollectionImageObject *)item { @@ -486,7 +507,7 @@ -(NSAttributedString *)stringForSharedMedia:(NSString *)mediaString { [string appendString:mediaString withColor:BLUE_UI_COLOR]; - [string setFont:[NSFont fontWithName:@"HelveticaNeue" size:14] forRange:NSMakeRange(0, string.length)]; + [string setFont:TGSystemFont(14) forRange:NSMakeRange(0, string.length)]; [string appendAttributedString:[NSAttributedString attributedStringWithAttachment:[NSMutableAttributedString textAttachmentByImage:[image_HeaderDropdownArrow() imageWithInsets:NSEdgeInsetsMake(0, 5, 1, 4)]]]]; @@ -524,7 +545,8 @@ -(void)loadRemote { self.locked = YES; [self.behavior load:[[[self.items lastObject] previewObject] msg_id] next:YES limit:100 callback:^(NSArray *previewObjects) { - [[ASQueue mainQueue] dispatchOnQueue:^{ + + [ASQueue dispatchOnMainQueue:^{ if(previewObjects.count > 0) { NSArray *converted = [self convertItems:previewObjects]; @@ -534,8 +556,15 @@ -(void)loadRemote { } self.locked = NO; + + if(self.items.count < 20 && [self.behavior.controller filterWithNext:YES].nextState != ChatHistoryStateFull) { + [self loadRemote]; + } + + }]; + }]; } @@ -663,10 +692,15 @@ -(void)addNextItems:(NSArray *)items { } -(void)checkCap { - if([self.photoCollection.containerView isHidden]) { + if(![self.documentsTableView.containerView isHidden]) { [self.mediaCap setHidden:![self.documentsTableView isNeedCap]]; [self.mediaCap updateCap:image_NoFiles() text:NSLocalizedString(@"SharedMedia.NoFiles", nil)]; [self.mediaCap setProgress:self.documentsTableView.isProgress]; + } else if(![self.sharedLinksTableView.containerView isHidden]) { + [self.mediaCap setHidden:![self.sharedLinksTableView isNeedCap]]; + [self.mediaCap updateCap:image_NoSharedLinks() text:NSLocalizedString(@"SharedMedia.NoSharedLinks", nil)]; + [self.mediaCap setProgress:self.sharedLinksTableView.isProgress]; + } else { [self.mediaCap setHidden:self.photoCollection.count != 0]; [self.mediaCap updateCap:image_SadAttach() text:NSLocalizedString(@"SharedMedia.NoSharedMedia", nil)]; @@ -738,6 +772,11 @@ -(NSMenu *)filterMenu { [self showSharedLinks]; }]]; + + [filterMenu addItem:[NSMenuItem menuItemWithTitle:NSLocalizedString(@"Modern.SharedMedia.Audio",nil) withBlock:^(id sender) { + [TGAudioPlayerWindow show:_conversation playerState:TGAudioPlayerWindowStatePlayList]; + }]]; + // [filterMenu addItem:[NSMenuItem menuItemWithTitle:NSLocalizedString(@"Conversation.Filter.Audio",nil) withBlock:^(id sender) { // [[Telegram rightViewController] showByDialog:self.conversation withJump:0 historyFilter:[AudioHistoryFilter class] sender:self]; // }]]; @@ -755,11 +794,30 @@ -(void)viewDidDisappear:(BOOL)animated { [self.photoCollection removeAllItems:NO]; [self.photoCollection reloadData]; + + [TGCache removeAllCachedImages:@[PCCACHE]]; + + [self.documentsTableView setConversation:nil]; + [self.sharedLinksTableView setConversation:nil]; + + [_behavior drop]; + _behavior = nil; } +-(void)viewWillDisappear:(BOOL)animated { + [super viewWillDisappear:animated]; + +} + + -(void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; + + + [self setIsEditable:NO animated:NO]; + + [Notification addObserver:self selector:@selector(didReceivedMedia:) name:MEDIA_RECEIVE]; [Notification addObserver:self selector:@selector(didDeleteMessages:) name:MESSAGE_DELETE_EVENT]; } @@ -770,9 +828,9 @@ - (TMView *)actionsView { if(self->_actionsView) return self->_actionsView; - weakify(); + weak(); - self->_actionsView = [[TMView alloc] initWithFrame:NSMakeRect(0, 0, strongSelf.view.bounds.size.width, 58)]; + self->_actionsView = [[TMView alloc] initWithFrame:NSMakeRect(0, 0, weakSelf.view.bounds.size.width, 58)]; [self.actionsView setWantsLayer:YES]; [self.actionsView setAutoresizesSubviews:YES]; [self.actionsView setAutoresizingMask:NSViewWidthSizable]; @@ -786,33 +844,39 @@ - (TMView *)actionsView { [self.deleteButton setAutoresizingMask:NSViewMaxXMargin ]; [self.deleteButton setTapBlock:^{ - [[Telegram rightViewController].messagesViewController setState:MessagesViewControllerStateNone]; - [[Telegram rightViewController].messagesViewController unSelectAll:NO]; + [weakSelf.messagesViewController setState:MessagesViewControllerStateNone]; + [weakSelf.messagesViewController unSelectAll:NO]; - if(![strongSelf.documentsTableView.containerView isHidden]) { + if(![weakSelf.documentsTableView.containerView isHidden]) { - [strongSelf.documentsTableView.selectedItems enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + [weakSelf.documentsTableView.selectedItems enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - [[Telegram rightViewController].messagesViewController setSelectedMessage:obj selected:YES]; + [weakSelf.messagesViewController setSelectedMessage:obj selected:YES]; }]; + } if(![weakSelf.sharedLinksTableView.containerView isHidden]) { + + [weakSelf.sharedLinksTableView.selectedItems enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + + [weakSelf.navigationViewController.messagesViewController setSelectedMessage:obj selected:YES]; + }]; } else { - [strongSelf.selectedItems enumerateObjectsUsingBlock:^(PhotoCollectionImageObject *obj, NSUInteger idx, BOOL *stop) { + [weakSelf.selectedItems enumerateObjectsUsingBlock:^(PhotoCollectionImageObject *obj, NSUInteger idx, BOOL *stop) { MessageTableItem *item = [MessageTableItem messageItemFromObject:obj.previewObject.media]; - [[Telegram rightViewController].messagesViewController setSelectedMessage:item selected:YES]; + [weakSelf.navigationViewController.messagesViewController setSelectedMessage:item selected:YES]; }]; } [[Telegram rightViewController].messagesViewController deleteSelectedMessages]; - strongSelf.isEditable = NO; + [weakSelf setIsEditable:NO animated:YES]; }]; self.deleteButton.disableColor = NSColorFromRGB(0xa1a1a1); @@ -821,7 +885,7 @@ - (TMView *)actionsView { self.messagesSelectedCount = [TMTextButton standartUserProfileNavigationButtonWithTitle:@""]; self.messagesSelectedCount.textColor = DARK_BLACK; - self.messagesSelectedCount.font = [NSFont fontWithName:@"HelveticaNeue" size:14]; + self.messagesSelectedCount.font = TGSystemFont(14); [self.messagesSelectedCount setAutoresizingMask:NSViewMinXMargin | NSViewMaxXMargin]; [self.actionsView addSubview:self.messagesSelectedCount]; @@ -833,38 +897,45 @@ - (TMView *)actionsView { [self.forwardButton setTapBlock:^{ - [[Telegram rightViewController].messagesViewController setState:MessagesViewControllerStateNone]; - [[Telegram rightViewController].messagesViewController unSelectAll:NO]; + [weakSelf.messagesViewController setState:MessagesViewControllerStateNone]; + [weakSelf.messagesViewController unSelectAll:NO]; NSUInteger count = 0; - if(![strongSelf.documentsTableView.containerView isHidden]) { + if(![weakSelf.documentsTableView.containerView isHidden]) { - count = strongSelf.documentsTableView.selectedItems.count; + count = weakSelf.documentsTableView.selectedItems.count; - [strongSelf.documentsTableView.selectedItems enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + [weakSelf.documentsTableView.selectedItems enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - [[Telegram rightViewController].messagesViewController setSelectedMessage:obj selected:YES]; + [weakSelf.messagesViewController setSelectedMessage:obj selected:YES]; }]; + } if(![weakSelf.sharedLinksTableView.containerView isHidden]) { + count = weakSelf.sharedLinksTableView.selectedItems.count; + + [weakSelf.sharedLinksTableView.selectedItems enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + + [weakSelf.messagesViewController setSelectedMessage:obj selected:YES]; + }]; } else { - count = strongSelf.selectedItems.count; + count = weakSelf.selectedItems.count; - [strongSelf.selectedItems enumerateObjectsUsingBlock:^(PhotoCollectionImageObject *obj, NSUInteger idx, BOOL *stop) { + [weakSelf.selectedItems enumerateObjectsUsingBlock:^(PhotoCollectionImageObject *obj, NSUInteger idx, BOOL *stop) { MessageTableItem *item = [MessageTableItem messageItemFromObject:obj.previewObject.media]; - [[Telegram rightViewController].messagesViewController setSelectedMessage:item selected:YES]; + [weakSelf.messagesViewController setSelectedMessage:item selected:YES]; }]; } - [[Telegram rightViewController] showForwardMessagesModalView:strongSelf.conversation messagesCount:count]; + [weakSelf.messagesViewController showForwardMessagesModalView]; - strongSelf.isEditable = NO; + [weakSelf setIsEditable:NO animated:YES]; }]; @@ -872,11 +943,11 @@ - (TMView *)actionsView { [GRAY_BORDER_COLOR set]; - NSRectFill(NSMakeRect(0, NSHeight(strongSelf.actionsView.frame) - 1, NSWidth(strongSelf.actionsView.frame), 1)); + NSRectFill(NSMakeRect(0, NSHeight(weakSelf.actionsView.frame) - 1, NSWidth(weakSelf.actionsView.frame), 1)); - [strongSelf.forwardButton setFrameOrigin:NSMakePoint(strongSelf.actionsView.bounds.size.width - strongSelf.forwardButton.bounds.size.width - 22, roundf((strongSelf.actionsView.bounds.size.height - strongSelf.deleteButton.bounds.size.height) / 2))]; - [strongSelf.deleteButton setFrameOrigin:NSMakePoint(30, roundf((strongSelf.actionsView.bounds.size.height - strongSelf.deleteButton.bounds.size.height) / 2) )]; - [strongSelf.messagesSelectedCount setCenterByView:strongSelf.actionsView]; + [weakSelf.forwardButton setFrameOrigin:NSMakePoint(weakSelf.actionsView.bounds.size.width - weakSelf.forwardButton.bounds.size.width - 22, roundf((weakSelf.actionsView.bounds.size.height - weakSelf.deleteButton.bounds.size.height) / 2))]; + [weakSelf.deleteButton setFrameOrigin:NSMakePoint(30, roundf((weakSelf.actionsView.bounds.size.height - weakSelf.deleteButton.bounds.size.height) / 2) )]; + [weakSelf.messagesSelectedCount setCenterByView:weakSelf.actionsView]; }]; @@ -887,7 +958,7 @@ - (TMView *)actionsView { return self.actionsView; } -- (void)setSectedMessagesCount:(NSUInteger)count { +- (void)setSectedMessagesCount:(NSUInteger)count enable:(BOOL)enable { if(count == 0) { [self.messagesSelectedCount setHidden:YES]; @@ -895,8 +966,8 @@ - (void)setSectedMessagesCount:(NSUInteger)count { [self.deleteButton setDisable:YES]; return; } else { - [self.deleteButton setDisable:NO]; [self.forwardButton setDisable:NO]; + [self.deleteButton setDisable:!enable]; } [self.messagesSelectedCount setHidden:NO]; diff --git a/TelegramTest/TMElements.h b/TelegramTest/TMElements.h index b7cb4aeb..1832c461 100644 --- a/TelegramTest/TMElements.h +++ b/TelegramTest/TMElements.h @@ -38,7 +38,6 @@ #import "TMNameTextField.h" #import "Butter.h" #import "TMTextField.h" -#import "TMGLGif.h" #import "TMTextButton.h" #import "TMSimpleTabViewController.h" #import "TMNavigationController.h" diff --git a/TelegramTest/TMGLGif.h b/TelegramTest/TMGLGif.h deleted file mode 100644 index abf80a81..00000000 --- a/TelegramTest/TMGLGif.h +++ /dev/null @@ -1,35 +0,0 @@ -// -// TMGLGif.h -// Telegram P-Edition -// -// Created by Dmitry Kondratyev on 2/12/14. -// Copyright (c) 2014 keepcoder. All rights reserved. -// - -#import - -#import -#import - -@interface TMGLGif : NSObject { - int num_frames; - NSSize size; - GLuint* gif_frames; - float* frame_times; - - int current_frame; - float time_duration; -} - -- (id)initWithImage:(NSImage *)image; - -- (int)numFrames; -- (NSSize)size; - -- (void)drawFrame:(int)frame_number at:(NSPoint)position; -- (void)drawAt:(NSPoint)position; -- (void)animate:(float)dt; - -+ (void)gifDrawingMode; - -@end \ No newline at end of file diff --git a/TelegramTest/TMGLGif.m b/TelegramTest/TMGLGif.m deleted file mode 100644 index f55c75fe..00000000 --- a/TelegramTest/TMGLGif.m +++ /dev/null @@ -1,138 +0,0 @@ -// -// TMGLGif.m -// Telegram P-Edition -// -// Created by Dmitry Kondratyev on 2/12/14. -// Copyright (c) 2014 keepcoder. All rights reserved. -// - -#import "TMGLGif.h" - -@implementation TMGLGif - -- (id)initWithImage:(NSImage *)img -{ - int i; - NSUInteger samplesPerPixel; - - self = [super init]; - - if(img == NULL) { - MTLog(@"Unable to load image named: %@", img); - return NULL; - } - - NSBitmapImageRep *rep = [[img representations] objectAtIndex:0]; - num_frames = [[rep valueForProperty:NSImageFrameCount] intValue]; - - size = NSMakeSize([rep pixelsWide], [rep pixelsHigh]); - gif_frames = (GLuint*)malloc(num_frames*sizeof(GLuint)); - frame_times = (float*)malloc(num_frames*sizeof(float)); - - for(i = 0; i < num_frames; i++) { - [rep setProperty:NSImageCurrentFrame withValue:[NSNumber numberWithInt:i]]; - frame_times[i] = [[rep valueForProperty:NSImageCurrentFrameDuration] floatValue]; - - samplesPerPixel = [rep samplesPerPixel]; - - if(![rep isPlanar] && (samplesPerPixel == 4 || samplesPerPixel == 3)) { - glGenTextures(1, &gif_frames[i]); - glBindTexture(GL_TEXTURE_RECTANGLE_EXT, gif_frames[i]); - glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - - - glTexImage2D(GL_TEXTURE_RECTANGLE_EXT, - 0, - samplesPerPixel == 4 ? GL_RGBA8 : GL_RGB8, - (int)[rep pixelsWide], - (int)[rep pixelsHigh], - 0, - samplesPerPixel == 4 ? GL_BGRA_EXT : GL_RGB, -#ifdef __BIG_ENDIAN__ - GL_UNSIGNED_INT_8_8_8_8_REV, -#else - GL_UNSIGNED_INT_8_8_8_8, -#endif - [rep bitmapData]); - } - else { - MTLog(@"-textureFromView: Unsupported bitmap data format: isPlanar:%d, samplesPerPixel:%ld, bitsPerPixel:%ld, bytesPerRow:%ld, bytesPerPlane:%ld", - [rep isPlanar], - (long)[rep samplesPerPixel], - (long) - (long)[rep bitsPerPixel], - [rep bytesPerRow], - (long)[rep bytesPerPlane]); - - return NULL; - } - } - - current_frame = 0; - time_duration = 0; - - return self; -} - -- (void)dealloc -{ - free(gif_frames); - free(frame_times); - -} - -- (int)numFrames -{ - return num_frames; -} - -- (NSSize)size -{ - return size; -} - -- (void)drawFrame:(int)frame_number at:(NSPoint)position -{ - glBindTexture (GL_TEXTURE_RECTANGLE_EXT, gif_frames[frame_number]); - - glBegin(GL_QUADS); - glTexCoord2f(0, 0); - glVertex2f(position.x, position.y); - - glTexCoord2f(size.width, 0); - glVertex2f(size.width+position.x, position.y); - - glTexCoord2f(size.width, size.height); - glVertex2f(size.width+position.x, size.height+position.y); - - glTexCoord2f(0, size.height); - glVertex2f(position.x, size.height+position.y); - glEnd(); -} - -- (void)drawAt:(NSPoint)position -{ - [self drawFrame:current_frame at:position]; -} - -- (void)animate:(float)dt -{ - time_duration += dt*0.1; - - while(time_duration > frame_times[current_frame]) { - time_duration -= frame_times[current_frame]; - current_frame++; - - if(current_frame >= num_frames) - current_frame = 0; - } -} - -+ (void)gifDrawingMode -{ - glEnable(GL_TEXTURE_RECTANGLE_EXT); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); -} - -@end \ No newline at end of file diff --git a/TelegramTest/TMGifImageView.h b/TelegramTest/TMGifImageView.h deleted file mode 100644 index 8db2d851..00000000 --- a/TelegramTest/TMGifImageView.h +++ /dev/null @@ -1,19 +0,0 @@ -// -// TMGifImageView.h -// Messenger for Telegram -// -// Created by Dmitry Kondratyev on 3/15/14. -// Copyright (c) 2014 keepcoder. All rights reserved. -// - -#import -#import - -@interface TMGifImageView : IKImageView - -@property (nonatomic) int roundRadius; - -- (void)setImage:(NSImage *)image isRounded:(BOOL)isRounded; -- (void)startAnimation; - -@end diff --git a/TelegramTest/TMGifImageView.m b/TelegramTest/TMGifImageView.m deleted file mode 100644 index 77fa3303..00000000 --- a/TelegramTest/TMGifImageView.m +++ /dev/null @@ -1,150 +0,0 @@ -// -// TMGifImageView.m -// Messenger for Telegram -// -// Created by Dmitry Kondratyev on 3/15/14. -// Copyright (c) 2014 keepcoder. All rights reserved. -// - -#import "TMGifImageView.h" -#import "ImageUtils.h" - -@interface TMGifImageView() -@property (nonatomic, strong) NSImage *image; -@property (nonatomic, strong) CAKeyframeAnimation *keyFrameAnimation; -@end - -@implementation TMGifImageView - - -- (void)setImage:(NSImage *)image isRounded:(BOOL)isRounded { - [self standartSet]; - - if(self.image == image) - return; - - self.image = image; - - CGImageSourceRef asource = CGImageSourceCreateWithData((__bridge CFDataRef)[image TIFFRepresentation], NULL); - if(asource == NULL) { - return ELog(@"asource null"); - } - - CFDictionaryRef dictRef = CGImageSourceCopyPropertiesAtIndex(asource, 0, nil); - CGImageRef maskRef = CGImageSourceCreateImageAtIndex(asource, 0, NULL); - - CFRelease(asource); - if(dictRef == NULL || maskRef == NULL) { - if(dictRef) - CFRelease(dictRef); - - if(maskRef) - CGImageRelease(maskRef); - - return ELog(@"dict or maskRef null"); - } - -// if(!isRounded) - { - CGImageRelease(maskRef); - image = [ImageUtils roundCorners:image size:NSMakeSize(self.roundRadius, self.roundRadius)]; - CGImageSourceRef asource = CGImageSourceCreateWithData((__bridge CFDataRef)[image TIFFRepresentation], NULL); - if(asource == NULL) { - CFRelease(dictRef); - return ELog(@"asource null"); - } - maskRef = CGImageSourceCreateImageAtIndex(asource, 0, NULL); - CFRelease(asource); - } - - [super setImage:maskRef imageProperties:(__bridge NSDictionary*)dictRef]; - CGImageRelease(maskRef); - CFRelease(dictRef); -} - -- (void)standartSet { - [self setAutoresizes:YES]; - -// if ([self overlayForType:IKOverlayTypeImage] == nil) -// [self setOverlay:[CALayer layer] forType:IKOverlayTypeImage]; - - [[self overlayForType:IKOverlayTypeImage] removeAllAnimations]; - - [self setBackgroundColor:[NSColor clearColor]]; -} - - -- (id)init { - self = [super init]; - if(self) { - [self standartSet]; - } - return self; -} - -- (void)startAnimation { -// if(self.keyFrameAnimation) { -// CALayer *layer = [self overlayForType:IKOverlayTypeImage]; -// [layer removeAllAnimations]; -// [layer addAnimation:self.keyFrameAnimation forKey:@"contents"]; -// return; -// } - - - [[self overlayForType:IKOverlayTypeImage] removeAllAnimations]; - - NSImage *image = self.image; - NSArray * reps = [image representations]; - for (NSImageRep * rep in reps) { - if ([rep isKindOfClass:[NSBitmapImageRep class]] == NO) - continue; - - NSBitmapImageRep *bitmapRep = (NSBitmapImageRep *)rep; - - int numFrame = [[bitmapRep valueForProperty:NSImageFrameCount] intValue]; - if (numFrame == 0) - break; - - CAKeyframeAnimation * animation = [CAKeyframeAnimation animationWithKeyPath:@"contents"]; - NSMutableArray * values = [NSMutableArray array]; - - float animationDuration = 0.0f; - for (int i = 0; i < numFrame; ++i) { - [bitmapRep setProperty:NSImageCurrentFrame withValue:[NSNumber numberWithInt:i]]; - - if ([[bitmapRep valueForProperty:NSImageCurrentFrameDuration] floatValue] <= 0.000001f) - [bitmapRep setProperty:NSImageCurrentFrameDuration withValue:[NSNumber numberWithFloat:1.0f / 20.0f]]; - - [values addObject:(id)[bitmapRep CGImage]]; - animationDuration += [[bitmapRep valueForProperty:NSImageCurrentFrameDuration] floatValue]; - } - - [animation setValues:values]; - [animation setCalculationMode:@"discrete"]; - [animation setDuration:animationDuration]; - [animation setRepeatCount:HUGE_VAL]; - [animation setDelegate:self.superview]; - -// self.keyFrameAnimation = animation; - - CALayer * layer = [self overlayForType:IKOverlayTypeImage]; - if(!layer) { - layer = [CALayer layer]; - [layer setCornerRadius:self.roundRadius * 2]; - [layer setMasksToBounds:YES]; - [self setOverlay:layer forType:IKOverlayTypeImage]; - } - - [layer addAnimation:animation forKey:@"contents"]; - - break; - } - -} - -- (void)mouseDown:(NSEvent *)theEvent { - - [[self overlayForType:IKOverlayTypeImage] removeAllAnimations]; -} - -@end diff --git a/TelegramTest/TMGrowingTextView.h b/TelegramTest/TMGrowingTextView.h index 97382a5b..2b8bafab 100644 --- a/TelegramTest/TMGrowingTextView.h +++ b/TelegramTest/TMGrowingTextView.h @@ -40,6 +40,9 @@ typedef enum { @property (nonatomic,assign) int maxHeight; @property (nonatomic,assign) int minHeight; + +@property (nonatomic,assign) BOOL disabledBorder; + //@property (nonatomic) int maxLines; @property (nonatomic, strong) id growingDelegate; @property (nonatomic, strong) NSImage *backgroundImage; diff --git a/TelegramTest/TMGrowingTextView.m b/TelegramTest/TMGrowingTextView.m index fe5440f3..ce5c2809 100644 --- a/TelegramTest/TMGrowingTextView.m +++ b/TelegramTest/TMGrowingTextView.m @@ -79,6 +79,7 @@ - (void)controlTextDidChange:(NSNotification *)obj { - (void)textDidChange:(NSNotification *)notification { + if(_limit > 0 && self.string.length > _limit) { [self setString:[self.string substringWithRange:NSMakeRange(0, _limit)]]; @@ -89,9 +90,7 @@ - (void)textDidChange:(NSNotification *)notification { - [self detectAndAddLinks:URLFindTypeHashtags | URLFindTypeLinks | URLFindTypeMentions]; - - self.font = [NSFont fontWithName:@"HelveticaNeue" size:[SettingsArchiver checkMaskedSetting:BigFontSetting] ? 15 : 13]; + self.font = TGSystemFont([SettingsArchiver checkMaskedSetting:BigFontSetting] ? 15 : 13); // NSUInteger numberOfLines, index, numberOfGlyphs = [self.layoutManager numberOfGlyphs]; @@ -233,7 +232,7 @@ - (void)initialize { self.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable; self.autoresizesSubviews = YES; self.delegate = self; - self.font = [NSFont fontWithName:@"HelveticaNeue" size:15]; + self.font = TGSystemFont(15); self.insertionPointColor = NSColorFromRGB(0x0f92dd); @@ -245,14 +244,19 @@ - (void)initialize { weakify(); self.containerView = [[TMView alloc] initWithFrame:self.bounds]; [self.containerView setDrawBlock:^{ - NSRect rect = NSMakeRect(1, 1, strongSelf.containerView.bounds.size.width - 2, strongSelf.containerView.bounds.size.height - 2); - NSBezierPath *circlePath = [NSBezierPath bezierPath]; - [circlePath appendBezierPathWithRoundedRect:rect xRadius:3 yRadius:3]; - [NSColorFromRGB(0xdedede) setStroke]; - [circlePath setLineWidth:IS_RETINA ? 2 : 1]; - [circlePath stroke]; - [[NSColor whiteColor] setFill]; - [circlePath fill]; + + if(!strongSelf.disabledBorder) { + NSRect rect = NSMakeRect(1, 1, strongSelf.containerView.bounds.size.width - 2, strongSelf.containerView.bounds.size.height - 2); + NSBezierPath *circlePath = [NSBezierPath bezierPath]; + [circlePath appendBezierPathWithRoundedRect:rect xRadius:3 yRadius:3]; + [NSColorFromRGB(0xdedede) setStroke]; + [circlePath setLineWidth:IS_RETINA ? 2 : 1]; + [circlePath stroke]; + [[NSColor whiteColor] setFill]; + [circlePath fill]; + + } + [strongSelf.scrollView setFrame:NSMakeRect(2, 2, strongSelf.containerView.bounds.size.width - 4, strongSelf.containerView.bounds.size.height - 4)]; @@ -350,7 +354,7 @@ - (void)setFrameOrigin:(NSPoint)newOriginN { } - (void)setPlaceholderString:(NSString *)placeHodlder { - self.placeholderTextAttributedString = [[NSAttributedString alloc] initWithString:placeHodlder attributes:@{NSForegroundColorAttributeName: NSColorFromRGB(0xc8c8c8), NSFontAttributeName: [NSFont fontWithName:@"HelveticaNeue" size:[SettingsArchiver checkMaskedSetting:BigFontSetting] ? 15 : 13]}]; + self.placeholderTextAttributedString = [[NSAttributedString alloc] initWithString:placeHodlder attributes:@{NSForegroundColorAttributeName: NSColorFromRGB(0xc8c8c8), NSFontAttributeName: TGSystemFont([SettingsArchiver checkMaskedSetting:BigFontSetting] ? 15 : 13)}]; } @@ -361,10 +365,10 @@ - (void) drawRect:(NSRect)dirtyRect { [super drawRect:dirtyRect]; - if ([[self string] isEqualToString:@""] ) { + if (self.string.length == 0) { if(self.placeholderTextAttributedString) { - [self.placeholderTextAttributedString drawAtPoint:NSMakePoint(6, 4)]; + [self.placeholderTextAttributedString drawAtPoint:NSMakePoint(6, NSAppKitVersionNumber > NSAppKitVersionNumber10_10_Max ? 6 : 4)]; } } } diff --git a/TelegramTest/TMInAppLinks.h b/TelegramTest/TMInAppLinks.h index 950365bb..ebfeaf0d 100644 --- a/TelegramTest/TMInAppLinks.h +++ b/TelegramTest/TMInAppLinks.h @@ -12,6 +12,8 @@ + (NSString *) userProfile:(int)user_id; ++ (NSString *)peerProfile:(TLPeer*)peer; + + (void) parseUrlAndDo:(NSString *)url; @end diff --git a/TelegramTest/TMInAppLinks.m b/TelegramTest/TMInAppLinks.m index f4fbcff9..929597bd 100644 --- a/TelegramTest/TMInAppLinks.m +++ b/TelegramTest/TMInAppLinks.m @@ -8,13 +8,18 @@ #import "TMInAppLinks.h" #import "Telegram.h" - +#import "TLPeer+Extensions.h" +#import "TGHeadChatPanel.h" @implementation TMInAppLinks + (NSString *) userProfile:(int)user_id { return [NSString stringWithFormat:@"USER_PROFILE:%d", user_id]; } ++ (NSString *)peerProfile:(TLPeer*)peer { + return [NSString stringWithFormat:@"openWithPeer:%@:%d",peer.className,peer.peer_id]; +} + + (void) parseUrlAndDo:(NSString *)url { NSArray *params = [url componentsSeparatedByString:@":"]; if(params.count) { @@ -22,10 +27,16 @@ + (void) parseUrlAndDo:(NSString *)url { if([action isEqualToString:@"USER_PROFILE"]) { int user_id = [[params objectAtIndex:1] intValue]; - [[Telegram sharedInstance] showUserInfoWithUserId:user_id conversation:[[[UsersManager sharedManager] find:user_id] dialog] sender:self]; + TL_conversation *conversation = [[[UsersManager sharedManager] find:user_id] dialog]; + + [appWindow().navigationController showInfoPage:conversation]; + + return; } } + + open_link(url); } @end diff --git a/TelegramTest/TMLoaderView.m b/TelegramTest/TMLoaderView.m index 56bb8eaf..201c26bd 100644 --- a/TelegramTest/TMLoaderView.m +++ b/TelegramTest/TMLoaderView.m @@ -21,8 +21,11 @@ @implementation TMLoaderView - (void)drawRect:(NSRect)dirtyRect { - if(self.isHidden) + if(self.isHidden || !self.window) { + [self pop_removeAllAnimations]; return; + } + if(self.style == TMCircularProgressDarkStyle) { diff --git a/TelegramTest/TMMediaController.mm b/TelegramTest/TMMediaController.mm index fa23a0d3..7b74434f 100644 --- a/TelegramTest/TMMediaController.mm +++ b/TelegramTest/TMMediaController.mm @@ -250,55 +250,57 @@ - (void)rightMouseDown:(NSEvent *)theEvent { if(controller.class == TMMediaController.class) { [menu addItem:[NSMenuItem separatorItem]]; - [menu addItem:[NSMenuItem menuItemWithTitle:NSLocalizedString(@"MediaPreview.Forward", nil) withBlock:^(id sender) { - // [controller.panel performSelector:@selector(selectPreviousItem) withObject:nil]; - - id previewItem = controller.currentItem; - - TL_localMessage *msg = previewItem.previewObject.media; - - [[Telegram rightViewController] showByDialog:msg.conversation sender:controller]; - [[Telegram rightViewController].messagesViewController setState:MessagesViewControllerStateNone]; - [[Telegram rightViewController].messagesViewController unSelectAll:NO]; - - MessageTableItem *item = [MessageTableItem messageItemFromObject:previewItem.previewObject.media]; - - [[Telegram rightViewController].messagesViewController setSelectedMessage:item selected:YES]; - - - [[Telegram rightViewController] showForwardMessagesModalView:[Telegram rightViewController].messagesViewController.conversation messagesCount:1]; - - [[TMMediaController controller] close]; - - - }]]; - [menu addItem:[NSMenuItem menuItemWithTitle:NSLocalizedString(@"MediaPreview.Delete", nil) withBlock:^(id sender) { - id previewItem = controller.currentItem; - - TL_localMessage *msg = previewItem.previewObject.media; - - [[Telegram rightViewController] showByDialog:msg.conversation sender:controller]; - - [[Telegram rightViewController].messagesViewController setState:MessagesViewControllerStateNone]; - [[Telegram rightViewController].messagesViewController unSelectAll:NO]; - - MessageTableItem *item = [MessageTableItem messageItemFromObject:previewItem.previewObject.media]; - [[Telegram rightViewController].messagesViewController setSelectedMessage:item selected:YES]; - - [[Telegram rightViewController].messagesViewController deleteSelectedMessages]; - - [[TMMediaController controller] deleteItem:previewItem]; - - }]]; - - [menu addItem:[NSMenuItem menuItemWithTitle:NSLocalizedString(@"MediaPreview.GoToMessage", nil) withBlock:^(id sender) { - id previewItem = controller.currentItem; - - TL_localMessage *msg = previewItem.previewObject.media; - - [[Telegram rightViewController] showByDialog:msg.conversation withJump:msg.n_id historyFilter:[HistoryFilter class] sender:controller]; - - }]]; +// [menu addItem:[NSMenuItem menuItemWithTitle:NSLocalizedString(@"MediaPreview.Forward", nil) withBlock:^(id sender) { +// // [controller.panel performSelector:@selector(selectPreviousItem) withObject:nil]; +// +// id previewItem = controller.currentItem; +// +// TL_localMessage *msg = previewItem.previewObject.media; +// +// +// +// [[Telegram rightViewController] showByDialog:msg.conversation sender:controller]; +// [[Telegram rightViewController].messagesViewController setState:MessagesViewControllerStateNone]; +// [[Telegram rightViewController].messagesViewController unSelectAll:NO]; +// +// MessageTableItem *item = [MessageTableItem messageItemFromObject:previewItem.previewObject.media]; +// +// [[Telegram rightViewController].messagesViewController setSelectedMessage:item selected:YES]; +// +// +// [[Telegram rightViewController] showForwardMessagesModalView:[Telegram rightViewController].messagesViewController.conversation messagesCount:1]; +// +// [[TMMediaController controller] close]; +// +// +// }]]; +// [menu addItem:[NSMenuItem menuItemWithTitle:NSLocalizedString(@"MediaPreview.Delete", nil) withBlock:^(id sender) { +// id previewItem = controller.currentItem; +// +// TL_localMessage *msg = previewItem.previewObject.media; +// +// [[Telegram rightViewController] showByDialog:msg.conversation sender:controller]; +// +// [[Telegram rightViewController].messagesViewController setState:MessagesViewControllerStateNone]; +// [[Telegram rightViewController].messagesViewController unSelectAll:NO]; +// +// MessageTableItem *item = [MessageTableItem messageItemFromObject:previewItem.previewObject.media]; +// [[Telegram rightViewController].messagesViewController setSelectedMessage:item selected:YES]; +// +// [[Telegram rightViewController].messagesViewController deleteSelectedMessages]; +// +// [[TMMediaController controller] deleteItem:previewItem]; +// +// }]]; +// +// [menu addItem:[NSMenuItem menuItemWithTitle:NSLocalizedString(@"MediaPreview.GoToMessage", nil) withBlock:^(id sender) { +// id previewItem = controller.currentItem; +// +// TL_localMessage *msg = previewItem.previewObject.media; +// +// [[Telegram rightViewController] showByDialog:msg.conversation withJump:msg.n_id historyFilter:[HistoryFilter class] sender:controller]; +// +// }]]; } @@ -625,7 +627,7 @@ -(void)prepare:(TL_conversation *)object completionHandler:(dispatch_block_t)co if(completionHandler) completionHandler(); - } max_id:0 peer_id:_dialog.peer_id next:YES limit:10000]; + } max_id:0 filterMask:HistoryFilterPhoto peer:_dialog.peer next:YES limit:10000]; } else if(_dialog) { self->items = [self media:_dialog.peer.peer_id]; if(completionHandler) completionHandler(); diff --git a/TelegramTest/TMMenuController.h b/TelegramTest/TMMenuController.h index 84149dff..2336f2f9 100644 --- a/TelegramTest/TMMenuController.h +++ b/TelegramTest/TMMenuController.h @@ -13,7 +13,6 @@ @property (nonatomic,strong,readonly) id selectedItem; -@property (nonatomic, weak) TMMenuPopover *popover; @property (nonatomic, strong) NSMenu *menuController; - (id)initWithMenu:(NSMenu *)menu; - (void)close; @@ -21,4 +20,7 @@ -(void)selectNext; -(void)selectPrev; -(void)performSelected; + +-(TMMenuPopover *)popover; + @end diff --git a/TelegramTest/TMMenuController.m b/TelegramTest/TMMenuController.m index 03b39917..557c1913 100644 --- a/TelegramTest/TMMenuController.m +++ b/TelegramTest/TMMenuController.m @@ -107,6 +107,7 @@ -(void)dealloc { [_item removeObserver:self forKeyPath:@"image"]; } + - (void)click { [self.controller close]; @@ -232,6 +233,8 @@ - (void)loadView { } [_documentView setFrameSize:NSMakeSize(NSWidth(_documentView.frame), h)]; + + [_scrollView.clipView scrollToPoint:NSMakePoint(0, h)]; } -(void)selectNext { diff --git a/TelegramTest/TMMenuPopover.m b/TelegramTest/TMMenuPopover.m index 303d6780..e50b9e8c 100644 --- a/TelegramTest/TMMenuPopover.m +++ b/TelegramTest/TMMenuPopover.m @@ -318,10 +318,10 @@ - (void)showRelativeToRect:(CGRect)positioningRect ofView:(NSView *)positioningV if (shouldClose) { - // id mouseDownView = [((AppDelegate *)[NSApp delegate]).window.contentView hitTest:event.locationInWindow]; - // if(mouseDownView != self.positioningView) { + id mouseDownView = [appWindow().contentView hitTest:event.locationInWindow]; + if(mouseDownView != self.positioningView) { [strongSelf close]; - // } + } } }; diff --git a/TelegramTest/TMModalView.m b/TelegramTest/TMModalView.m index f3292775..494764e7 100644 --- a/TelegramTest/TMModalView.m +++ b/TelegramTest/TMModalView.m @@ -44,10 +44,10 @@ - (void)setHeaderTitle:(NSString *)titleString text:(NSString *)text { NSMutableAttributedString *sharingContactAttributedString = [[NSMutableAttributedString alloc] init]; [sharingContactAttributedString appendString:titleString withColor:NSColorFromRGB(0x222222)]; [sharingContactAttributedString appendString:@"\n"]; - [sharingContactAttributedString setFont:[NSFont fontWithName:@"HelveticaNeue-Light" size:22] forRange:sharingContactAttributedString.range]; + [sharingContactAttributedString setFont:TGSystemLightFont(22) forRange:sharingContactAttributedString.range]; NSRange range = [sharingContactAttributedString appendString:text withColor:NSColorFromRGB(0x9b9b9b)]; - [sharingContactAttributedString setFont:[NSFont fontWithName:@"HelveticaNeue" size:13] forRange:range]; + [sharingContactAttributedString setFont:TGSystemFont(13) forRange:range]; NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; [paragraphStyle setAlignment:NSCenterTextAlignment]; diff --git a/TelegramTest/TMNameTextField.m b/TelegramTest/TMNameTextField.m index 4d622cf6..25210932 100644 --- a/TelegramTest/TMNameTextField.m +++ b/TelegramTest/TMNameTextField.m @@ -146,10 +146,11 @@ -(void)setBroadcast:(TL_broadcast *)broadcast { -(void)updateWithConversation:(TL_conversation *)conversation { switch (conversation.type) { + case DialogTypeBroadcast: [self setBroadcast:conversation.broadcast]; break; - case DialogTypeChat: + case DialogTypeChat: case DialogTypeChannel: [self setChat:conversation.chat]; break; case DialogTypeSecretChat: diff --git a/TelegramTest/TMNavigationController.h b/TelegramTest/TMNavigationController.h index 87ca4f5f..e3a229df 100644 --- a/TelegramTest/TMNavigationController.h +++ b/TelegramTest/TMNavigationController.h @@ -24,6 +24,8 @@ #import "TMNavigationBar.h" #import "ConnectionStatusViewControllerView.h" +@class MessagesViewController; + @protocol TMNavagationDelegate -(void)willChangedController:(TMViewController *)controller; @@ -57,10 +59,22 @@ typedef enum { @property (nonatomic, readonly) BOOL isLocked; +@property (nonatomic,weak) MessagesViewController *messagesViewController; + +-(void)gotoViewController:(TMViewController *)controller; +-(void)gotoViewController:(TMViewController *)controller animated:(BOOL)animated; +-(void)gotoViewController:(TMViewController *)controller back:(BOOL)back; +-(void)gotoViewController:(TMViewController *)controller back:(BOOL)back animated:(BOOL)animated; -(void)addDelegate:(id)delegate; -(void)removeDelegate:(id)delegate; - (void)pushViewController:(TMViewController *)viewController animated:(BOOL)animated; - (void)goBackWithAnimation:(BOOL)animated; - (void)clear; + +-(void)gotoEmptyController; + +-(void)showInfoPage:(TL_conversation *)conversation; +-(void)showMessagesViewController:(TL_conversation *)conversation; +-(void)showMessagesViewController:(TL_conversation *)conversation withMessage:(TL_localMessage *)message; @end diff --git a/TelegramTest/TMNavigationController.m b/TelegramTest/TMNavigationController.m index a14b2068..19a19521 100644 --- a/TelegramTest/TMNavigationController.m +++ b/TelegramTest/TMNavigationController.m @@ -1,16 +1,3 @@ -// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE -// Version 2, December 2004 -// -// Copyright (C) 2013 Ilija Tovilo -// -// Everyone is permitted to copy and distribute verbatim or modified -// copies of this license document, and changing it is allowed as long -// as the name is changed. -// -// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE -// TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION -// -// 0. You just DO WHAT THE FUCK YOU WANT TO. // // ITNavigationView.m @@ -25,6 +12,12 @@ #import "HackUtils.h" #import "TGAnimationBlockDelegate.h" #import "NotSelectedDialogsViewController.h" + + +#import "TGModernChannelInfoViewController.h" +#import "TGModernChatInfoViewController.h" +#import "TGModernUserViewController.h" + #define kDefaultAnimationDuration 0.1 #define kSlowAnimationMultiplier 4 #define kDefaultTimingFunction [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn] @@ -87,9 +80,7 @@ - (void) loadView { self.containerView.layer.backgroundColor = [NSColor clearColor].CGColor; [self.view addSubview:self.containerView]; - - int connectingHeight = navigationOffset-navigationHeight; - + // [self.containerView addSubview:_connectionController]; @@ -144,7 +135,6 @@ - (void)pushViewController:(TMViewController *)viewController animated:(BOOL)ani return; - if([self.viewControllerStack indexOfObject:viewController] == NSNotFound) { [self.viewControllerStack addObject:viewController]; @@ -229,6 +219,10 @@ - (void)pop_animationDidStart:(POPAnimation *)anim { [view.layer setOpacity:1]; } +-(void)setCurrentController:(TMViewController *)currentController { + _currentController = currentController; +} + - (void)setCurrentViewController:(TMViewController *)newViewController withAnimation:(BOOL)animationFlag { @@ -281,7 +275,7 @@ - (void)setCurrentViewController:(TMViewController *)newViewController withAnima self.currentController = newViewController; - + // Make view resize properly newView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable; @@ -320,6 +314,8 @@ - (void)setCurrentViewController:(TMViewController *)newViewController withAnima if (!isAnimate) { // Add the new view + if(oldViewController && oldViewController != newViewController && [self.viewControllerStack indexOfObject:oldViewController] == NSNotFound) + [oldViewController _didStackRemoved]; [oldView removeFromSuperview]; [newView removeFromSuperview]; @@ -417,7 +413,8 @@ - (void)setCurrentViewController:(TMViewController *)newViewController withAnima if(two > 0) return; - + if(oldViewController && oldViewController != newViewController && [self.viewControllerStack indexOfObject:oldViewController] == NSNotFound) + [oldViewController _didStackRemoved]; _isLocked = NO; @@ -510,6 +507,7 @@ - (void)setCurrentViewController:(TMViewController *)newViewController withAnima } + } @@ -574,7 +572,127 @@ - (NSImage *)imageOfView:(NSView *)view { return [[NSImage alloc] initWithCGImage:[rep CGImage] size:view.bounds.size]; } +-(void)gotoViewController:(TMViewController *)controller { + [self gotoViewController:controller back:YES]; +} +-(void)gotoViewController:(TMViewController *)controller back:(BOOL)back { + + + [self gotoViewController:controller back:back animated:YES]; + +} + +-(void)gotoViewController:(TMViewController *)controller animated:(BOOL)animated { + [self gotoViewController:controller back:YES animated:animated]; +} + +-(void)gotoViewController:(TMViewController *)controller back:(BOOL)back animated:(BOOL)animated { + + if(self.currentController == controller) + return; + + NSArray *stack = self.viewControllerStack; + + __block NSUInteger idx = NSNotFound; + + [stack enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger index, BOOL * _Nonnull stop) { + if([obj isKindOfClass:[controller class]]) { + idx = index; + *stop = YES; + } + }]; + + if(idx != NSNotFound) { + if(!back) { + self.viewControllerStack = [[stack subarrayWithRange:NSMakeRange(0, MAX(0,idx-1))] mutableCopy]; + + [self pushViewController:controller animated:animated]; + } else { + self.viewControllerStack =[[stack subarrayWithRange:NSMakeRange(0, MIN(idx,stack.count ))] mutableCopy]; + + [self pushViewController:controller animated:animated]; + } + } else { + if(self.viewControllerStack.count > 0) + [self.viewControllerStack removeObjectsInRange:NSMakeRange(1, self.viewControllerStack.count - 1)]; + + [self pushViewController:controller animated:animated && ![self.currentController isKindOfClass:[NotSelectedDialogsViewController class]]]; + } + +} + +-(void)showInfoPage:(TL_conversation *)conversation { + + TMViewController *infoViewController; + + switch (conversation.type) { + case DialogTypeChat: + + infoViewController = [[TGModernChatInfoViewController alloc] initWithFrame:NSZeroRect]; + + [(TGModernChatInfoViewController *)infoViewController setChat:conversation.chat]; + + break; + + case DialogTypeSecretChat: + + infoViewController = [[TGModernUserViewController alloc] initWithFrame:NSZeroRect]; + + + [(TGModernUserViewController *)infoViewController setUser:conversation.encryptedChat.peerUser conversation:conversation]; + + break; + + case DialogTypeUser: { + infoViewController = [[TGModernUserViewController alloc] initWithFrame:NSZeroRect]; + + + [(TGModernUserViewController *)infoViewController setUser:conversation.user conversation:conversation]; + break; + } + + case DialogTypeBroadcast: + infoViewController = [[BroadcastInfoViewController alloc] initWithFrame:NSZeroRect]; + + [(BroadcastInfoViewController *)infoViewController setBroadcast:conversation.broadcast]; + case DialogTypeChannel: + + + if(conversation.chat.type == TLChatTypeForbidden) + return; + + infoViewController = [[TGModernChannelInfoViewController alloc] initWithFrame:NSZeroRect]; + + [(TGModernChannelInfoViewController *)infoViewController setChat:conversation.chat]; + + default: + break; + } + + [self pushViewController:infoViewController animated:YES]; + +} + +-(void)gotoEmptyController { + [self.viewControllerStack subarrayWithRange:NSMakeRange(1, self.viewControllerStack.count - 1)]; + + [self goBackWithAnimation:YES]; +} + +-(void)showMessagesViewController:(TL_conversation *)conversation { + [self.messagesViewController setCurrentConversation:conversation]; + + [self gotoViewController:self.messagesViewController]; +} + +-(void)showMessagesViewController:(TL_conversation *)conversation withMessage:(TL_localMessage *)message { + + [self.messagesViewController setCurrentConversation:conversation withMessageJump:message]; + + [self gotoViewController:self.messagesViewController]; +} + @end diff --git a/TelegramTest/TMProgressModalView.h b/TelegramTest/TMProgressModalView.h index c90b4f79..7e3533a6 100644 --- a/TelegramTest/TMProgressModalView.h +++ b/TelegramTest/TMProgressModalView.h @@ -13,4 +13,6 @@ -(void)successAction; -(void)progressAction; +-(void)setDescription:(NSString *)description; + @end diff --git a/TelegramTest/TMProgressModalView.m b/TelegramTest/TMProgressModalView.m index a93cc29f..60b2d6eb 100644 --- a/TelegramTest/TMProgressModalView.m +++ b/TelegramTest/TMProgressModalView.m @@ -13,11 +13,21 @@ @interface TMProgressModalView () @property (nonatomic,strong) TMView *progressContainer; @property (nonatomic,strong) ITProgressIndicator *progressIndicator; @property (nonatomic,strong) NSImageView *successImageView; + +@property (nonatomic,strong) NSString *n_description; + +@property (nonatomic,strong) TMTextField *textField; + + @end @implementation TMProgressModalView - +-(void)setDescription:(NSString *)description { + _n_description = description; + + [self update]; +} - (id)initWithFrame:(NSRect)frame { @@ -71,12 +81,63 @@ - (id)initWithFrame:(NSRect)frame _successImageView.autoresizingMask = self.progressIndicator.autoresizingMask = self.progressContainer.autoresizingMask = NSViewMinXMargin | NSViewMaxXMargin | NSViewMinYMargin | NSViewMaxYMargin; + self.textField = [TMTextField defaultTextField]; + + [self addSubview:self.textField]; + [_textField setHidden:YES]; + [self progressAction]; + + } return self; } +-(void)update { + + [_textField setHidden:_n_description.length == 0]; + + if(_n_description.length > 0) { + NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] init]; + + [attr appendString:_n_description withColor:[NSColor whiteColor]]; + [attr setFont:TGSystemFont(13) forRange:attr.range]; + [attr setAlignment:NSCenterTextAlignment range:attr.range]; + + NSSize size = [attr sizeForTextFieldForWidth:300]; + + [_textField setAttributedStringValue:attr]; + + [_textField setFrameSize:size]; + + [_progressContainer setFrameSize:NSMakeSize(MAX(size.width + 20,80), MAX(size.height + 60,80))]; + + + + [_progressContainer setCenterByView:_progressContainer.superview]; + + + [_progressIndicator setCenteredXByView:_progressIndicator.superview]; + + + + + [_textField setCenteredXByView:_textField.superview]; + [_textField setFrameOrigin:NSMakePoint(NSMinX(_textField.frame), NSMinY(_progressContainer.frame) + 10)]; + + + [_progressIndicator setFrameOrigin:NSMakePoint(NSMinX(_progressIndicator.frame), NSMaxY(_textField.frame) + 10)]; + + [_successImageView setFrameOrigin:NSMakePoint(NSMinX(_successImageView.frame), NSMaxY(_textField.frame) + 5)]; + + } else { + [_progressContainer setFrameSize:NSMakeSize(80, 80)]; + [_progressIndicator setCenterByView:_progressIndicator.superview]; + } + +} + -(void)successAction { [_progressIndicator setHidden:YES]; diff --git a/TelegramTest/TMRowItem.h b/TelegramTest/TMRowItem.h index 7832e2c4..c33afa9e 100644 --- a/TelegramTest/TMRowItem.h +++ b/TelegramTest/TMRowItem.h @@ -7,6 +7,9 @@ // #import + +@class TMTableView; + @protocol TMRowItemDelegate - (void) redrawRow; @@ -24,9 +27,12 @@ @interface TMRowItem : NSObject -@property (nonatomic, weak) id table; +@property (nonatomic, weak) TMTableView *table; -(id)initWithObject:(id)object; - (void) redrawRow; - (NSUInteger)hash; + +@property (nonatomic,assign,getter=isEditable) BOOL editable; + @end diff --git a/TelegramTest/TMRowView.m b/TelegramTest/TMRowView.m index 48663a11..10e44ec8 100644 --- a/TelegramTest/TMRowView.m +++ b/TelegramTest/TMRowView.m @@ -60,6 +60,7 @@ - (void)setHover:(BOOL)hover redraw:(BOOL)redraw { } } + - (void) setItem:(id)item selected:(BOOL)isSelected { self.rowItem = item; diff --git a/TelegramTest/TMSearchTextField.h b/TelegramTest/TMSearchTextField.h index dc6b001c..8c7d2f0f 100644 --- a/TelegramTest/TMSearchTextField.h +++ b/TelegramTest/TMSearchTextField.h @@ -15,6 +15,7 @@ - (void) searchFieldFocus; - (void) searchFieldBlur; - (void) searchFieldDidEnter; +- (void) searchFieldDidResign; @required - (void) searchFieldTextChange:(NSString*)searchString; @@ -31,6 +32,8 @@ - (bool)endEditing; +-(BOOL)isFirstResponder; + -(void)setSelectedRange:(NSRange)range; @end diff --git a/TelegramTest/TMSearchTextField.m b/TelegramTest/TMSearchTextField.m index a6e9a1c1..38ebbc8b 100644 --- a/TelegramTest/TMSearchTextField.m +++ b/TelegramTest/TMSearchTextField.m @@ -45,7 +45,12 @@ - (void)initialize { } -(BOOL)resignFirstResponder { - return [super resignFirstResponder]; + + BOOL res = [super resignFirstResponder]; + + [self.searchDelegate searchFieldDidResign]; + + return res; } - (BOOL)becomeFirstResponder { @@ -165,18 +170,16 @@ - (id) initWithFrame:(NSRect)frameRect { self.textField = [[_TMSearchTextField alloc] initWithFrame:NSZeroRect]; [self.textField setDelegate:self]; [self.textField setSearchDelegate:self]; - NSAttributedString *placeholderAttributed = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"Search", nil) attributes:@{NSForegroundColorAttributeName: NSColorFromRGB(0xaeaeae), NSFontAttributeName: [NSFont fontWithName:@"Helvetica-Light" size:12]}]; + NSAttributedString *placeholderAttributed = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"Search", nil) attributes:@{NSForegroundColorAttributeName: NSColorFromRGB(0xaeaeae), NSFontAttributeName: TGSystemLightFont(12)}]; [[self.textField cell] setPlaceholderAttributedString:placeholderAttributed]; - - [self.textField setBackgroundColor:[NSColor clearColor]]; - [self.textField setFont:[NSFont fontWithName:@"Helvetica-Light" size:12]]; + [self.textField setFont:TGSystemLightFont(12)]; [self.textField setStringValue:NSLocalizedString(@"Search", nil)]; [self.textField sizeToFit]; [self.textField setStringValue:@""]; - [self.textField setFrame:NSMakeRect(textFieldXOffset, roundf((self.bounds.size.height - self.textField.bounds.size.height) / 2) - 3, self.containerView.frame.size.width - 30 - textFieldXOffset, self.textField.bounds.size.height)]; + [self.textField setFrame:NSMakeRect(textFieldXOffset, roundf((self.frame.size.height - self.textField.frame.size.height) / 2) - 1, self.containerView.frame.size.width - 30 - textFieldXOffset, self.textField.bounds.size.height)]; [self.textField setBordered:NO]; @@ -205,9 +208,6 @@ - (id) initWithFrame:(NSRect)frameRect { [self.cancelButton setTarget:self selector:@selector(cancelButtonClick)]; [self addSubview:self.cancelButton]; [self.containerView setWantsLayer:YES]; - - - [self.textField becomeFirstResponder]; } return self; @@ -233,10 +233,17 @@ - (bool)endEditing; success = [[NSApp mainWindow] makeFirstResponder:nil]; + [self centerPosition:YES]; return success; } +-(BOOL)isFirstResponder { + id responder = [self.window firstResponder]; + + return [responder isKindOfClass:[NSTextView class]] && [[responder superview] superview] == self.textField; +} + -(void)setSelectedRange:(NSRange)range { [self.textField setSelectionRange:range]; } @@ -246,7 +253,10 @@ - (void)setFrameSize:(NSSize)newSize { [super setFrameSize:newSize]; - [self.textField setFrameOrigin:NSMakePoint(30, NSMinY(self.textField.frame))]; + + [self.textField setFrame:NSMakeRect(textFieldXOffset, roundf((self.frame.size.height - self.textField.frame.size.height) / 2) - 2, self.containerView.frame.size.width - 30 - textFieldXOffset, self.textField.bounds.size.height)]; + + // [self.textField setFrameOrigin:NSMakePoint(30, NSMinY(self.textField.frame))]; [self.textField setFrameSize:NSMakeSize(self.containerView.frame.size.width - 30 - NSMinX(self.textField.frame), NSHeight(self.textField.frame))]; @@ -374,6 +384,8 @@ - (void) cancelButtonClick { if(![self isTextFieldInFocus:self.textField]) { [self centerPosition:YES]; } + + [self endEditing]; } - (BOOL)isTextFieldInFocus:(NSTextField *)textField { @@ -408,12 +420,26 @@ - (void) searchFieldBlur { // if(self.) // [self centerPosition:YES]; // [self setNeedsDisplay:YES]; + + [self.cancelButton setHidden:self.textField.stringValue.length == 0]; + if([self.delegate respondsToSelector:@selector(searchFieldBlur)]) + [self.delegate searchFieldBlur]; } - (void) searchFieldFocus { self.isActive = YES; [self leftPosition:YES]; // [self setNeedsDisplay:YES]; + [self.cancelButton setHidden:NO]; + + if([self.delegate respondsToSelector:@selector(searchFieldFocus)]) + [self.delegate searchFieldFocus]; +} + +- (void) searchFieldDidResign { + [self.cancelButton setHidden:self.textField.stringValue.length == 0]; + if([self.delegate respondsToSelector:@selector(searchFieldFocus)]) + [self.delegate searchFieldFocus]; } - (void) mouseEntered:(NSEvent *)theEvent { diff --git a/TelegramTest/TMSharedMediaButton.h b/TelegramTest/TMSharedMediaButton.h index 4302e184..64c0eaad 100644 --- a/TelegramTest/TMSharedMediaButton.h +++ b/TelegramTest/TMSharedMediaButton.h @@ -8,8 +8,14 @@ #import "UserInfoShortButtonView.h" +typedef enum { + TMSharedMediaPhotoVideoType, + TMSharedMediaDocumentsType, + TMSharedMediaSharedLinksType +} TMSharedMediaType; + @interface TMSharedMediaButton : UserInfoShortButtonView @property (nonatomic,strong) TL_conversation *conversation; -@property (nonatomic,assign) BOOL isFiles; +@property (nonatomic,assign) TMSharedMediaType type; @end diff --git a/TelegramTest/TMSharedMediaButton.m b/TelegramTest/TMSharedMediaButton.m index c569a5ee..7eb1e89f 100644 --- a/TelegramTest/TMSharedMediaButton.m +++ b/TelegramTest/TMSharedMediaButton.m @@ -34,7 +34,9 @@ +(void)initialize { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ cache = [[NSMutableDictionary alloc] init]; - cache[@"files"] = [[NSMutableDictionary alloc] init]; + cache[@"key-0"] = [[NSMutableDictionary alloc] init]; + cache[@"key-1"] = [[NSMutableDictionary alloc] init]; + cache[@"key-2"] = [[NSMutableDictionary alloc] init]; cache[@"photo-video"] = [[NSMutableDictionary alloc] init]; [Notification addObserver: [TMSharedMediaButton reserved] selector:@selector(didReceivedMedia:) name:MEDIA_RECEIVE]; [Notification addObserver: [TMSharedMediaButton reserved] selector:@selector(didDeletedMessages:) name:MESSAGE_DELETE_EVENT]; @@ -60,24 +62,7 @@ -(id)initWithFrame:(NSRect)frame withName:(NSString *)name andBlock:(dispatch_bl } -(void)didDeletedMessages:(NSNotification *)notification { - -// NSArray *ids = notification.userInfo[KEY_MESSAGE_ID_LIST]; -// -// [ids enumerateObjectsUsingBlock:^(NSNumber *msg_id, NSUInteger idx, BOOL *stop) { -// -// TL_localMessage *msg = [[MessagesManager sharedManager] find:[msg_id intValue]]; -// -// if([msg.media isKindOfClass:[TL_messageMediaPhoto class]] && !self.isFiles) { -// -// NSNumber *count = cache[[self primaryKey]][@(msg.peer_id)]; -// -// if(count != nil) { -// cache[[self primaryKey]][@(msg.peer_id)] = @([count intValue] - 1); -// } -// } -// -// }]; -// + } @@ -99,7 +84,7 @@ +(TMSharedMediaButton *)reserved { - (void)didReceivedMedia:(NSNotification *)notify { PreviewObject *preview = notify.userInfo[KEY_PREVIEW_OBJECT]; - if(cache[[self primaryKey]][@(preview.peerId)] != nil && [[(TL_localMessage *)preview.media media] isKindOfClass:[TL_messageMediaPhoto class]] && !self.isFiles) { + if(cache[[self primaryKey]][@(preview.peerId)] != nil && [[(TL_localMessage *)preview.media media] isKindOfClass:[TL_messageMediaPhoto class]] && self.type == TMSharedMediaPhotoVideoType) { int count = [cache[[self primaryKey]][@(preview.peerId)] intValue]; count++; cache[[self primaryKey]][@(preview.peerId)] = @(count); @@ -143,7 +128,7 @@ -(void)loadCount:(TLInputPeer *)input peer_id:(int)peer_id { //self.count = [[Storage manager] countOfMedia:peer_id]; - [RPCRequest sendRequest:[TLAPI_messages_search createWithPeer:input q:@"" filter:self.isFiles ? [TL_inputMessagesFilterDocument create] : [TL_inputMessagesFilterPhotoVideo create] min_date:0 max_date:0 offset:0 max_id:0 limit:10000] successHandler:^(RPCRequest *request, TL_messages_messages *response) { + [RPCRequest sendRequest:[TLAPI_messages_search createWithFlags:0 peer:input q:@"" filter:self.type == TMSharedMediaDocumentsType ? [TL_inputMessagesFilterDocument create] : self.type == TMSharedMediaPhotoVideoType ? [TL_inputMessagesFilterPhotoVideo create] : [TL_inputMessagesFilterUrl create] min_date:0 max_date:0 offset:0 max_id:0 limit:10000] successHandler:^(RPCRequest *request, TL_messages_messages *response) { [self setLocked:NO]; @@ -162,7 +147,7 @@ -(void)setCount:(int)count { } -(NSString *)primaryKey { - return self.isFiles ? @"files" : @"photo-video"; + return [NSString stringWithFormat:@"key-%d",self.type]; } -(void)rebuild { @@ -175,7 +160,7 @@ -(void)rebuild { [string appendString:str withColor:NSColorFromRGB(0xa1a1a1)]; - [string setFont:[NSFont fontWithName:@"HelveticaNeue-Light" size:15] forRange:string.range]; + [string setFont:TGSystemLightFont(15) forRange:string.range]; [self.field setAttributedStringValue:string]; diff --git a/TelegramTest/TMStatusTextField.h b/TelegramTest/TMStatusTextField.h index f1ef1cae..6148af60 100644 --- a/TelegramTest/TMStatusTextField.h +++ b/TelegramTest/TMStatusTextField.h @@ -30,5 +30,6 @@ @property (nonatomic,assign) BOOL lock; -(void)update; - +-(void)updateWithConversation:(TL_conversation *)conversation; +-(void)clear; @end diff --git a/TelegramTest/TMStatusTextField.m b/TelegramTest/TMStatusTextField.m index a9954e8c..a8beb57e 100644 --- a/TelegramTest/TMStatusTextField.m +++ b/TelegramTest/TMStatusTextField.m @@ -169,7 +169,7 @@ - (void)setChat:(TLChat *)chat { if(chat == nil || self.lock) return; - if(self.chat.type == TLChatTypeNormal && !self.chat.left) { + if((self.chat.type == TLChatTypeNormal && !self.chat.left) || self.chat.isChannel) { self.attributedStringValue = [chat performSelector:self.selector withObject:nil]; } else { self.attributedStringValue = [[NSAttributedString alloc] init]; @@ -190,6 +190,37 @@ - (void)setAttributedStringValue:(NSMutableAttributedString *)obj { } } + +-(void)updateWithConversation:(TL_conversation *)conversation { + + switch (conversation.type) { + + case DialogTypeBroadcast: + [self setBroadcast:conversation.broadcast]; + break; + case DialogTypeChat: case DialogTypeChannel: + [self setChat:conversation.chat]; + break; + case DialogTypeSecretChat: + [self setUser:conversation.encryptedChat.peerUser]; + break; + case DialogTypeUser: + [self setUser:conversation.user]; + default: + break; + + } + +} + +-(void)clear { + self.chat = nil; + self.user = nil; + self->_broadcast = nil; + + self.attributedStringValue = nil; +} + @end @@ -253,4 +284,6 @@ - (void)removeTextField:(TMStatusTextField *)statusTextField { [self.list removeObject:value]; } + + @end diff --git a/TelegramTest/TMTabViewController.m b/TelegramTest/TMTabViewController.m index c65dbfc8..74e02beb 100644 --- a/TelegramTest/TMTabViewController.m +++ b/TelegramTest/TMTabViewController.m @@ -145,7 +145,7 @@ -(void)redraw { TMTextField *field = [TMTextField defaultTextField]; - [field setFont:[NSFont fontWithName:@"HelveticaNeue" size:12]]; + [field setFont:TGSystemFont(12)]; [field setTextColor:obj.textColor]; [field setAlignment:NSCenterTextAlignment]; [field setStringValue:obj.title]; diff --git a/TelegramTest/TMTableView.h b/TelegramTest/TMTableView.h index 51f07582..d0f6287b 100644 --- a/TelegramTest/TMTableView.h +++ b/TelegramTest/TMTableView.h @@ -11,6 +11,9 @@ #import "TMRowView.h" #import "TMScrollView.h" + +@class TMViewController; + @protocol TMTableViewDelegate - (CGFloat)rowHeight:(NSUInteger)row item:(TMRowItem *) item; @@ -29,10 +32,12 @@ @property (nonatomic, strong, readonly) TMScrollView *scrollView; @property (nonatomic, strong, readonly) NSTableColumn *tableColumn; @property (nonatomic) BOOL multipleSelection; -@property (nonatomic, strong) id tm_delegate; +@property (nonatomic, weak) id tm_delegate; @property (nonatomic) BOOL hoverCells; @property (nonatomic) NSTableViewAnimationOptions defaultAnimation; +@property (nonatomic,weak) TMViewController *viewController; + + (TMTableView *)current; + (void)setCurrent:(TMTableView *)table; @@ -85,4 +90,6 @@ - (BOOL) setSelectedObject:(NSObject *)item ; +-(BOOL)rowIsVisible:(NSUInteger)index; + @end diff --git a/TelegramTest/TMTableView.mm b/TelegramTest/TMTableView.mm index 6c384c0d..312298a8 100644 --- a/TelegramTest/TMTableView.mm +++ b/TelegramTest/TMTableView.mm @@ -50,7 +50,7 @@ - (id)init { } - (id)initWithCoder:(NSCoder *)aDecoder { - self = [super init]; + self = [super initWithCoder:aDecoder]; if(self) { [self initialize]; } @@ -83,6 +83,8 @@ - (void)initialize { self.scrollView.documentView = self; + + self.scrollView.hasVerticalScroller = YES; @@ -120,6 +122,16 @@ - (void)initialize { self.lastOverRow = -1; [self updateTrackingAreas]; + + + + id document = self.scrollView.documentView; + BTRClipView *clipView = [[BTRClipView alloc] initWithFrame:self.scrollView.contentView.bounds]; + [clipView setWantsLayer:YES]; + [clipView setDrawsBackground:YES]; + [self.scrollView setContentView:clipView]; + self.scrollView.documentView = document; + } - (void)setHoverCells:(BOOL)hoverCells { @@ -595,4 +607,10 @@ -(void)mouseDragged:(NSEvent *)theEvent [self.scrollView mouseDragged:theEvent]; } +-(BOOL)rowIsVisible:(NSUInteger)index { + NSRange range = [self rowsInRect:[self visibleRect]]; + + return range.location <= index && range.location + range.length >= index; +} + @end diff --git a/TelegramTest/TMTaskRequest.h b/TelegramTest/TMTaskRequest.h index 161354d1..e11a0977 100644 --- a/TelegramTest/TMTaskRequest.h +++ b/TelegramTest/TMTaskRequest.h @@ -10,6 +10,9 @@ #import "ITaskRequest.h" @interface TMTaskRequest : NSObject + +ASQueue *taskQueue(); + +(void)addTask:(id)task; +(void)removeTask:(id)task; diff --git a/TelegramTest/TMTaskRequest.m b/TelegramTest/TMTaskRequest.m index d46323d4..5ad5ed8f 100644 --- a/TelegramTest/TMTaskRequest.m +++ b/TelegramTest/TMTaskRequest.m @@ -10,12 +10,25 @@ @interface TMTaskRequest () @property (nonatomic,strong) NSMutableArray *tasks; + @end @implementation TMTaskRequest +static ASQueue *queue; + +ASQueue *taskQueue() { + + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + queue = [[ASQueue alloc] initWithName:"taskQueue"]; + }); + + return queue; +} + -(void)addTask:(id)task { if(task && [_tasks indexOfObject:task] == NSNotFound) { [task setDelegate:self]; @@ -31,13 +44,13 @@ -(void)removeTask:(id)task { -(void)didCompleteTaskRequest:(id)task { - [ASQueue dispatchOnStageQueue:^{ + [taskQueue() dispatchOnQueue:^{ [self removeTask:task]; }]; } -(void)didStartTaskRequest:(id)task { - [ASQueue dispatchOnStageQueue:^{ + [taskQueue() dispatchOnQueue:^{ [[Storage manager] insertTask:task]; }]; } @@ -48,21 +61,25 @@ -(void)didCancelledTask:(id)task { +(void)addTask:(id)task { - [ASQueue dispatchOnStageQueue:^{ + [taskQueue() dispatchOnQueue:^{ [[TMTaskRequest instance] addTask:task]; }]; } +(void)executeAll { - [[Storage manager] selectTasks:^(NSArray *tasks) { - [tasks enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - [TMTaskRequest addTask:obj]; + + [taskQueue() dispatchOnQueue:^{ + [[Storage manager] selectTasks:^(NSArray *tasks) { + [tasks enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + [TMTaskRequest addTask:obj]; + }]; }]; }]; + } +(void)removeTask:(id)task { - [ASQueue dispatchOnStageQueue:^{ + [taskQueue() dispatchOnQueue:^{ [[TMTaskRequest instance] removeTask:task]; }]; } diff --git a/TelegramTest/TMTextButton.m b/TelegramTest/TMTextButton.m index 6aa224a0..96df57d7 100644 --- a/TelegramTest/TMTextButton.m +++ b/TelegramTest/TMTextButton.m @@ -60,7 +60,7 @@ - (void)initialize { + (instancetype)standartUserProfileButtonWithTitle:(NSString *)title { TMTextButton *button = [[TMTextButton alloc] init]; [button setStringValue:title]; - [button setFont:[NSFont fontWithName:@"HelveticaNeue-Light" size:14]]; + [button setFont:TGSystemLightFont(14)]; [button setTextColor:BLUE_UI_COLOR]; [button setWantsLayer:YES]; [button sizeToFit]; @@ -70,7 +70,7 @@ + (instancetype)standartUserProfileButtonWithTitle:(NSString *)title { + (instancetype)standartUserProfileNavigationButtonWithTitle:(NSString *)title { TMTextButton *button = [[TMTextButton alloc] init]; [button setStringValue:title]; - [button setFont:[NSFont fontWithName:@"HelveticaNeue" size:14]]; + [button setFont:TGSystemFont(14)]; [button setTextColor:BLUE_UI_COLOR]; [button setWantsLayer:YES]; [button sizeToFit]; @@ -81,7 +81,7 @@ + (instancetype)standartUserProfileNavigationButtonWithTitle:(NSString *)title { + (instancetype)standartMessageNavigationButtonWithTitle:(NSString *)title { TMTextButton *button = [[TMTextButton alloc] init]; [button setStringValue:title]; - [button setFont:[NSFont fontWithName:@"HelveticaNeue" size:14]]; + [button setFont:TGSystemFont(14)]; [button setTextColor:BLUE_UI_COLOR]; [button setWantsLayer:YES]; [button sizeToFit]; @@ -94,7 +94,7 @@ + (instancetype)standartMessageNavigationButtonWithTitle:(NSString *)title { + (instancetype)standartButtonWithTitle:(NSString *)title standartImage:(NSImage *)standartImage disabledImage:(NSImage *)disabledImage { TMTextButton *button = [[TMTextButton alloc] init]; [button setStringValue:title]; - [button setFont:[NSFont fontWithName:@"HelveticaNeue" size:14]]; + [button setFont:TGSystemFont(14)]; [button setTextColor:BLUE_UI_COLOR]; [button setWantsLayer:YES]; [button sizeToFit]; diff --git a/TelegramTest/TMTextField.h b/TelegramTest/TMTextField.h index c39ada46..577ea996 100644 --- a/TelegramTest/TMTextField.h +++ b/TelegramTest/TMTextField.h @@ -18,6 +18,9 @@ -(void)textFieldDidChange:(id)field; +@optional +-(void)textFieldDidBecomeFirstResponder:(id)field; + @end diff --git a/TelegramTest/TMTextField.m b/TelegramTest/TMTextField.m index 4f4e566d..5d4485a8 100644 --- a/TelegramTest/TMTextField.m +++ b/TelegramTest/TMTextField.m @@ -74,7 +74,7 @@ + (id)loginPlaceholderTextField { [textField setTextColor:NSColorFromRGB(0xaeaeae)]; [textField setWantsLayer:YES]; [textField setEditable:NO]; - [textField setFont:[NSFont fontWithName:@"HelveticaNeue" size:13]]; + [textField setFont:TGSystemFont(13)]; [textField setBordered:NO]; return textField; @@ -141,9 +141,16 @@ - (BOOL)becomeFirstResponder { self.placeholderView.placeholderPoint = self.placeholderPoint; [self.placeholderView setHidden:!self.placeholder || self.stringValue.length != 0]; + + if([self.fieldDelegate respondsToSelector:@selector(textFieldDidBecomeFirstResponder:)]) { + [self.fieldDelegate textFieldDidBecomeFirstResponder:self]; + } + return result; } + + - (void)setStringValue:(NSString *)aString { [super setStringValue:aString ? aString : @""]; diff --git a/TelegramTest/TMTokenCell.m b/TelegramTest/TMTokenCell.m index fffbe7cc..e3d1d240 100644 --- a/TelegramTest/TMTokenCell.m +++ b/TelegramTest/TMTokenCell.m @@ -24,7 +24,7 @@ @implementation TMTokenCell - (id)initTextCell:(NSString *)aString { self = [super initTextCell:aString]; - self.font = [NSFont fontWithName:@"HelveticaNeue-Light" size:12]; + self.font = TGSystemLightFont(12); return self; } diff --git a/TelegramTest/TMTokenField.m b/TelegramTest/TMTokenField.m index 51e3e65a..2918e413 100644 --- a/TelegramTest/TMTokenField.m +++ b/TelegramTest/TMTokenField.m @@ -97,7 +97,7 @@ - (void)_add:(TokenItem*)token { - (void)textDidChange:(NSNotification *)notification { // NSMutableAttributedString *attributesString = [[NSMutableAttributedString alloc] initWithAttributedString:self.attributedString]; - [[self textStorage] addAttribute:NSFontAttributeName value:[NSFont fontWithName:@"HelveticaNeue-Light" size:13] range:NSMakeRange(0, self.attributedString.length)]; + [[self textStorage] addAttribute:NSFontAttributeName value:TGSystemLightFont(13) range:NSMakeRange(0, self.attributedString.length)]; NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init]; [style setLineSpacing:4]; diff --git a/TelegramTest/TMTypingObject.h b/TelegramTest/TMTypingObject.h index df50f10e..8c8fa84c 100644 --- a/TelegramTest/TMTypingObject.h +++ b/TelegramTest/TMTypingObject.h @@ -15,8 +15,8 @@ @interface TGActionTyping : NSObject @property (nonatomic,strong,readonly) TLSendMessageAction *action; @property (nonatomic,assign,readonly) NSUInteger time; -@property (nonatomic,assign,readonly) NSUInteger user_id; --(id)initWithAction:(TLSendMessageAction *)action time:(int)time user_id:(NSUInteger)user_id; +@property (nonatomic,strong,readonly) TLUser *user; +-(id)initWithAction:(TLSendMessageAction *)action time:(int)time user:(TLUser *)user; @end @@ -26,7 +26,7 @@ - (id) initWithDialog:(TL_conversation *)dialog; - (NSArray *) writeArray; -- (void) addMember:(NSUInteger)uid withAction:(TLSendMessageAction *)action; +- (void) addMember:(TLUser *)user withAction:(TLSendMessageAction *)action; - (void) removeMember:(NSUInteger)uid; - (NSArray *)currentActions; @end diff --git a/TelegramTest/TMTypingObject.m b/TelegramTest/TMTypingObject.m index 2bdaecd0..802d80ef 100644 --- a/TelegramTest/TMTypingObject.m +++ b/TelegramTest/TMTypingObject.m @@ -48,11 +48,11 @@ -(NSComparisonResult)compare:(TLSendMessageAction *)anotherObject { @implementation TGActionTyping --(id)initWithAction:(TLSendMessageAction *)action time:(int)time user_id:(NSUInteger)user_id { +-(id)initWithAction:(TLSendMessageAction *)action time:(int)time user:(TLUser *)user { if(self = [super init]) { _action = action; _time = time; - _user_id = user_id; + _user = user; } return self; @@ -86,16 +86,16 @@ - (id) initWithDialog:(TL_conversation *)dialog { return self; } -- (void) addMember:(NSUInteger)uid withAction:(TLSendMessageAction *)action { +- (void) addMember:(TLUser *)user withAction:(TLSendMessageAction *)action { - TGActionTyping *taction = [[TGActionTyping alloc] initWithAction:action time:[[NSDate date] timeIntervalSince1970] + 5 user_id:uid]; + TGActionTyping *taction = [[TGActionTyping alloc] initWithAction:action time:[[NSDate date] timeIntervalSince1970] + 5 user:user]; - NSMutableDictionary *actions = [self.actions objectForKey:@(uid)]; + NSMutableDictionary *actions = [self.actions objectForKey:@(user.n_id)]; if(!actions) { actions = [[NSMutableDictionary alloc] init]; - [self.actions setObject:actions forKey:@(uid)]; + [self.actions setObject:actions forKey:@(user.n_id)]; } if(![action isKindOfClass:[TL_sendMessageCancelAction class]]) { diff --git a/TelegramTest/TMView.h b/TelegramTest/TMView.h index 5518e8bf..9fac04ea 100644 --- a/TelegramTest/TMView.h +++ b/TelegramTest/TMView.h @@ -32,6 +32,9 @@ typedef NSUInteger TMViewBorder; @property (nonatomic,assign) BOOL movableWindow; +@property (nonatomic,assign) BOOL dragInSuperView; + + - (void)sizeToFit; -(void)removeAllSubviews; diff --git a/TelegramTest/TMView.m b/TelegramTest/TMView.m index 04478f3f..1d841a3a 100644 --- a/TelegramTest/TMView.m +++ b/TelegramTest/TMView.m @@ -11,6 +11,9 @@ @interface TMView () @property (nonatomic,assign) NSPoint movableStartLocation; +@property (nonatomic,assign) NSPoint startPoint; +@property (nonatomic,assign) BOOL isDragged; + @end @implementation TMView @@ -77,12 +80,6 @@ -(void)setFrameSize:(NSSize)newSize { } --(void)mouseUp:(NSEvent *)theEvent { - // if(theEvent.clickCount == 2) - // return; - - [super mouseUp:theEvent]; -} - (void) drawRect:(NSRect)dirtyRect { [super drawRect:dirtyRect]; @@ -146,30 +143,76 @@ - (void)sizeToFit { } --(void)mouseDown:(NSEvent*)theEvent { - +-(void)mouseDown:(NSEvent *)theEvent { if(_movableWindow) _movableStartLocation = [theEvent locationInWindow]; + if(_dragInSuperView) { + _startPoint = [self convertPoint:[theEvent locationInWindow] fromView:nil]; + _isDragged = YES; + } else { + [super mouseDown:theEvent]; + } + + + +} + +-(void)mouseUp:(NSEvent*)theEvent { + if(self.callback) self.callback(); else { // if(theEvent.clickCount == 2) // return; - [super mouseDown:theEvent]; + [super mouseUp:theEvent]; } } +-(void)setDragInSuperView:(BOOL)dragInSuperView { + _dragInSuperView = dragInSuperView; + + if(_dragInSuperView) { + _startPoint = [self.superview convertPoint:[[self window] mouseLocationOutsideOfEventStream] fromView:nil]; + } else + _startPoint = NSMakePoint(0, 0); +} + +- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent { + return YES; +} + - (void)mouseDragged:(NSEvent *)theEvent { - [super mouseDragged:theEvent]; - if(!_movableWindow) + + if(_dragInSuperView) { + + { + + NSPoint newDragLocation = [[self superview] convertPoint:[theEvent locationInWindow] fromView:nil]; + NSPoint thisOrigin = [self frame].origin; + thisOrigin.x += (-self.startPoint.x + newDragLocation.x); + thisOrigin.y += (-self.startPoint.y + newDragLocation.y); + [self setFrameOrigin:thisOrigin]; + self.startPoint = newDragLocation; + + [super mouseDragged:theEvent]; + + } + return; + } + + if(!_movableWindow) { + [super mouseDragged:theEvent]; + return; + } + NSRect screenVisibleFrame = [[NSScreen mainScreen] visibleFrame]; NSRect windowFrame = [self.window frame]; diff --git a/TelegramTest/TMViewController.h b/TelegramTest/TMViewController.h index bc328e9b..439309a8 100644 --- a/TelegramTest/TMViewController.h +++ b/TelegramTest/TMViewController.h @@ -10,7 +10,7 @@ #import "TMView.h" #import "TMTextField.h" - +@class MessagesViewController; @class TGAttachObject; @class TMPopover; @class TMNavigationController; @@ -34,16 +34,19 @@ + - (void)setLeftNavigationBarView:(TMView *)leftNavigationBarView animated:(BOOL)animation; - (void)setRightNavigationBarView:(TMView *)rightNavigationBarView animated:(BOOL)animation; - (void)rightButtonAction; - ++(void)showModalProgressWithDescription:(NSString *)description; +(void)showModalProgress; +(void)hideModalProgress; +-(void)showModalProgressWithWindow:(NSWindow *)window; + -(void)showModalProgress; -(void)hideModalProgress; @@ -83,6 +86,7 @@ -(void)_didStackRemoved; -(BOOL)becomeFirstResponder; +-(BOOL)resignFirstResponder; - (void)loadViewIfNeeded; - (void)loadView; - (void)viewWillAppear:(BOOL)animated; @@ -96,5 +100,7 @@ -(void)setCenterBarViewText:(NSString *)text; -(void)setCenterBarViewTextAttributed:(NSAttributedString *)text; +-(MessagesViewController *)messagesViewController; + @end diff --git a/TelegramTest/TMViewController.m b/TelegramTest/TMViewController.m index 19402240..df27f000 100644 --- a/TelegramTest/TMViewController.m +++ b/TelegramTest/TMViewController.m @@ -14,6 +14,7 @@ #import "TGPasslock.h" #import "TGModalSetCaptionView.h" #import "TGModalView.h" +#import "TGHeadChatPanel.h" @interface TMViewController () @property (nonatomic,strong) TMProgressModalView *progressView; @property (nonatomic,strong) TMBackButton *backButton; @@ -30,6 +31,14 @@ - (id)initWithFrame:(NSRect)frame { return self; } +-(instancetype)init { + if(self = [super init]) { + self.frameInit = NSZeroRect; + } + + return self; +} + - (void) setHidden:(BOOL)isHidden { [self.view setHidden:isHidden]; } @@ -97,7 +106,7 @@ -(void)setCenterBarViewText:(NSString *)text { _centerTextField = [TMTextField defaultTextField]; [_centerTextField setAlignment:NSCenterTextAlignment]; [_centerTextField setAutoresizingMask:NSViewMinXMargin | NSViewMaxXMargin]; - [_centerTextField setFont:[NSFont fontWithName:@"HelveticaNeue" size:15]]; + [_centerTextField setFont:TGSystemFont(15)]; [_centerTextField setTextColor:NSColorFromRGB(0x222222)]; [[_centerTextField cell] setTruncatesLastVisibleLine:YES]; [[_centerTextField cell] setLineBreakMode:NSLineBreakByTruncatingTail]; @@ -138,13 +147,18 @@ -(void)setCenterBarViewTextAttributed:(NSAttributedString *)text { - (void)viewWillAppear:(BOOL)animated { - self.leftNavigationBarView = [self standartLeftBarView]; + [self becomeFirstResponder]; + self.leftNavigationBarView = [self standartLeftBarView]; - if([Telegram isSingleLayout] && [Telegram rightViewController].currentEmptyController == [Telegram rightViewController].navigationViewController.currentController && ![[Telegram rightViewController] isModalViewActive]) + if(self.navigationViewController == [Telegram rightViewController].navigationViewController) { - self.leftNavigationBarView = nil; + if([Telegram isSingleLayout] && [Telegram rightViewController].currentEmptyController == [Telegram rightViewController].navigationViewController.currentController && ![[Telegram rightViewController] isModalViewActive]) + { + self.leftNavigationBarView = nil; + } } + } @@ -185,13 +199,13 @@ - (IBAction)backOrClose:(NSMenuItem *)sender { +(void)showModalProgress { if(!progressView) { - progressView = [[TMProgressModalView alloc] initWithFrame:[[[Telegram delegate] window].contentView bounds]]; + progressView = [[TMProgressModalView alloc] initWithFrame:[appWindow().contentView bounds]]; progressView.layer.opacity = 0; - [progressView setCenterByView:[[Telegram delegate] window].contentView]; + [progressView setCenterByView:appWindow().contentView]; - [[[Telegram delegate] window].contentView addSubview:progressView]; + [appWindow().contentView addSubview:progressView]; } @@ -204,6 +218,12 @@ +(void)showModalProgress { } ++(void)showModalProgressWithDescription:(NSString *)description { + [self showModalProgress]; + + [progressView setDescription:description]; +} + +(void)hideModalProgress { // progressView.layer.opacity = 0.8; @@ -349,7 +369,23 @@ +(void)hideModalProgressWithSuccess { } -(void)showModalProgress { - [TMViewController showModalProgress]; + if(!progressView) { + progressView = [[TMProgressModalView alloc] initWithFrame:[self.view.window.contentView bounds]]; + + progressView.layer.opacity = 0; + + [progressView setCenterByView:self.view.window.contentView]; + + [self.view.window.contentView addSubview:progressView]; + } + + + + [(TelegramWindow *)self.view.window setAcceptEvents:NO]; + + POPBasicAnimation *anim = [TMViewController popAnimationForProgress:progressView.layer.opacity to:0.8]; + + [progressView.layer pop_addAnimation:anim forKey:@"fade"]; } -(void)hideModalProgress { [TMViewController hideModalProgress]; @@ -357,7 +393,7 @@ -(void)hideModalProgress { +(void)showPasslock:(passlockCallback)callback animated:(BOOL)animated { - + [TGHeadChatPanel lockAllControllers]; assert([NSThread isMainThread]); if(passlockView.window) @@ -424,7 +460,7 @@ +(void)becomePasslock { +(void)hidePasslock { - + [TGHeadChatPanel unlockAllControllers]; assert([NSThread isMainThread]); @@ -441,6 +477,8 @@ +(void)hidePasslock { [passlockView.layer pop_addAnimation:anim forKey:@"fade"]; [TGPasslock setVisibility:NO]; + + [[Telegram rightViewController].navigationViewController.currentController viewWillAppear:NO]; } -(void)showPasslock:(passlockCallback)callback { @@ -457,11 +495,17 @@ -(void)_didStackRemoved { } -(BOOL)becomeFirstResponder { + return [TGPasslock isVisibility] ? [passlockView becomeFirstResponder] : [self.view becomeFirstResponder]; } +-(BOOL)resignFirstResponder { + return [self.view resignFirstResponder]; +} + - (void)loadView { - self.view = [[TMView alloc] initWithFrame: self.frameInit]; + if(!_view) + self.view = [[TMView alloc] initWithFrame: self.frameInit]; } @@ -475,6 +519,8 @@ - (TMView *)view { return _view; } - +-(MessagesViewController *)messagesViewController { + return self.navigationViewController.messagesViewController; +} @end diff --git a/TelegramTest/Telegram.h b/TelegramTest/Telegram.h index e061b409..54e69d89 100644 --- a/TelegramTest/Telegram.h +++ b/TelegramTest/Telegram.h @@ -51,6 +51,9 @@ void setMaxBroadcastUsers(int max_broadcast_users); int maxBroadcastUsers(); int maxChatUsers(); +void setMegagroupSizeMax(int b); +int megagroupSizeMax(); + @property (nonatomic) BOOL isWindowActive; @property (nonatomic, assign) BOOL isOnline; @@ -58,9 +61,6 @@ int maxChatUsers(); - (void)setAccountOffline:(BOOL)force; -- (void)showMessagesFromDialog:(TLDialog *)dialog sender:(id)sender; -- (void)showUserInfoWithUserId:(int)userID conversation:(TL_conversation *)conversaion sender:(id)sender; -- (void)showMessagesWidthUser:(TLUser *)user sender:(id)sender; - (void)showNotSelectedDialog; @@ -74,6 +74,8 @@ int maxChatUsers(); +(void)sendLogs; ++(id)findObjectWithName:(NSString *)name; + +(void)saveHashTags:(NSString *)message peer_id:(int)peer_id; diff --git a/TelegramTest/Telegram.m b/TelegramTest/Telegram.m index 4c7053c7..7bfe9acf 100644 --- a/TelegramTest/Telegram.m +++ b/TelegramTest/Telegram.m @@ -34,7 +34,7 @@ + (Telegram *)sharedInstance { } +(TL_conversation *)conversation { - return [Telegram rightViewController].messagesViewController.conversation; + return [Telegram delegate].mainWindow.navigationController.messagesViewController.conversation; } + (AppDelegate *)delegate { @@ -108,14 +108,17 @@ - (void)protocolUpdated:(NSNotification *)notify { [self.accountStatusTimer start]; } -static int max_chat_users = 200; +static int max_chat_users = 199; static int max_broadcast_users = 100; +static int megagroup_size_max = 1000; void setMaxChatUsers(int c) { max_chat_users = c; } int maxChatUsers() { + + return max_chat_users; } @@ -127,12 +130,21 @@ int maxBroadcastUsers() { return max_broadcast_users; } + +void setMegagroupSizeMax(int b) { + megagroup_size_max = b; +} + +int megagroupSizeMax() { + return megagroup_size_max; +} + - (BOOL)canBeOnline { return ([[NSApplication sharedApplication] isActive] && SystemIdleTime() < 30 ); } - (void)setAccountOffline:(BOOL)force { - if([SettingsArchiver checkMaskedSetting:OnlineForever]) + if([SettingsArchiver checkMaskedSetting:OnlineForever] || ![Storage isInitialized]) return; if(force) { @@ -166,7 +178,7 @@ - (void)setIsOnline:(BOOL)isOnline { - (void)setAccountOnline { - if(![self canBeOnline]) { + if(![self canBeOnline] || ![Storage isInitialized]) { [self setAccountOffline:YES]; return; } @@ -174,7 +186,7 @@ - (void)setAccountOnline { [self.accountOfflineStatusTimer invalidate]; self.accountOfflineStatusTimer = nil; - if([[UsersManager currentUser] isOnline]) + if([[UsersManager currentUser] isOnline] ) return; @@ -202,7 +214,7 @@ -(void)notificationDialogUpdate:(NSNotification *)notify { } - (void)showMessagesFromDialog:(TL_conversation *)d sender:(id)sender { - [[Telegram rightViewController] showByDialog:d sender:(id)sender]; + [appWindow().navigationController showMessagesViewController:d]; } - (void)showMessagesWidthUser:(TLUser *)user sender:(id)sender { @@ -217,11 +229,6 @@ - (void)showMessagesWidthUser:(TLUser *)user sender:(id)sender { [self showMessagesFromDialog:dn sender:sender]; } -- (void)showUserInfoWithUserId:(int)userID conversation:(TL_conversation *)conversation sender:(id)sender { - TLUser *user = [[UsersManager sharedManager] find:userID]; - - [self showUserInfoWithUser:user conversation:conversation sender:sender]; -} - (void)showNotSelectedDialog { @@ -229,13 +236,6 @@ - (void)showNotSelectedDialog { } -- (void)showUserInfoWithUser:(TLUser *)user conversation:(TL_conversation *)conversation sender:(id)sender { - if(user == nil) - return ELog(@"User nil"); - - [[Telegram rightViewController] showUserInfoPage:user conversation:conversation]; - [[[Telegram mainViewController].view window] makeFirstResponder:nil]; -} - (void)onAuthSuccess { [[MTNetwork instance] successAuthForDatacenter:[[MTNetwork instance] currentDatacenter]]; @@ -249,7 +249,7 @@ - (void)onLogoutSuccess { BOOL isTestServer() { BOOL result = [[NSProcessInfo processInfo].environment[@"test_server"] boolValue]; - return result; + return result || [[NSUserDefaults standardUserDefaults] boolForKey:@"test-backend"]; } NSString * appName() { @@ -350,12 +350,12 @@ +(void)sendLogs { dispatch_block_t performBlock = ^ { - [[Telegram rightViewController] showByDialog:user.dialog sender:self]; + [appWindow().navigationController showMessagesViewController:user.dialog]; NSArray *files = TGGetLogFilePaths(); [files enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - [[Telegram rightViewController].messagesViewController sendDocument:obj forConversation:user.dialog]; + [appWindow().navigationController.messagesViewController sendDocument:obj forConversation:user.dialog]; }]; }; @@ -385,6 +385,17 @@ +(void)sendLogs { } } ++(id)findObjectWithName:(NSString *)name { + + id obj = [UsersManager findUserByName:name]; + + if(!obj) + obj = [ChatsManager findChatByName:name]; + + return obj; + +} + +(void)initializeDatabase { [self.leftViewController.conversationsViewController initialize]; } diff --git a/TelegramTest/TelegramFirstController.h b/TelegramTest/TelegramFirstController.h index a07cc3b6..0218d6d2 100644 --- a/TelegramTest/TelegramFirstController.h +++ b/TelegramTest/TelegramFirstController.h @@ -10,8 +10,8 @@ @interface TelegramFirstController : NSObject -@property (nonatomic, strong) TMViewController *viewController; -@property (nonatomic, strong) TMViewController *oldViewController; +@property (nonatomic, weak) TMViewController *viewController; +@property (nonatomic, weak) TMViewController *oldViewController; - (IBAction)backOrClose:(NSMenuItem *)sender; diff --git a/TelegramTest/TelegramFirstController.m b/TelegramTest/TelegramFirstController.m index 65bd50e9..136ae12d 100644 --- a/TelegramTest/TelegramFirstController.m +++ b/TelegramTest/TelegramFirstController.m @@ -40,16 +40,10 @@ -(void)awakeFromNib { [main.submenu removeItem:[main.submenu itemWithTag:1000]]; - - main = [menu itemAtIndex:1]; - [main.submenu removeItemAtIndex:1]; #endif - - - } - (void)controller:(TMViewController *)controller performSelector:(SEL)aSelector withObject:(id)anArgument { @@ -78,8 +72,9 @@ - (IBAction)logout:(NSMenuItem *)sender { - (IBAction)openSettings:(id)sender { - [[Telegram rightViewController] showGeneralSettings]; + [[Telegram leftViewController] showTabControllerAtIndex:2]; + } - (IBAction)clearChatHistory:(NSMenuItem *)sender { @@ -100,7 +95,7 @@ - (IBAction)askQuestion:(id)sender { [dialog save]; } - [[Telegram rightViewController] showByDialog:dialog sender:self]; + [appWindow().navigationController showMessagesViewController:dialog]; }; @@ -132,8 +127,13 @@ - (IBAction)settings:(id)sender { [[Telegram leftViewController] showUserSettings]; } - (IBAction)showMedia:(id)sender { - [[Telegram rightViewController] showCollectionPage:[Telegram rightViewController].messagesViewController.conversation]; - // [[TGPhotoViewer viewer] show:nil conversation:[Telegram rightViewController].messagesViewController.conversation]; + + TMCollectionPageController *collectionViewController = [[TMCollectionPageController alloc] initWithFrame:NSZeroRect]; + + [collectionViewController setConversation:[Telegram conversation]]; + + [appWindow().navigationController pushViewController:collectionViewController animated:YES]; + } - (BOOL)validateMenuItem:(NSMenuItem *)menuItem { diff --git a/TelegramTest/TelegramWindow.h b/TelegramTest/TelegramWindow.h index 7418f60c..51bd9150 100644 --- a/TelegramTest/TelegramWindow.h +++ b/TelegramTest/TelegramWindow.h @@ -8,8 +8,12 @@ #import #import "TGWindowArchiver.h" +#import "TMNavigationController.h" @interface TelegramWindow : NSWindow @property (nonatomic, strong) TMViewController *rootViewController; + +@property (nonatomic,strong) TMNavigationController *navigationController; + @property (nonatomic,strong) TGWindowArchiver *autoSaver; - (void)realClose; - (void)initialize; diff --git a/TelegramTest/TelegramWindow.m b/TelegramTest/TelegramWindow.m index b44adff1..ca0e81a6 100644 --- a/TelegramTest/TelegramWindow.m +++ b/TelegramTest/TelegramWindow.m @@ -159,7 +159,13 @@ - (void)setRootViewController:(TMViewController *)rootViewController { } - (void)close { - [[NSApplication sharedApplication] hide:nil]; + if(self.class != NSClassFromString(@"TGHeadChatPanel")) { + [(NSApplication *)[NSApplication sharedApplication] hide:nil]; + } else { + [super close]; + } + + } - (void)dealloc { diff --git a/TelegramTest/Telegraph-Info.plist b/TelegramTest/Telegraph-Info.plist index 9cb9a29f..59edca62 100644 --- a/TelegramTest/Telegraph-Info.plist +++ b/TelegramTest/Telegraph-Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable ${EXECUTABLE_NAME} CFBundleIdentifier - ru.keepcoder.Telegram + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName @@ -15,7 +15,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.71 + 1.98 CFBundleSignature ???? CFBundleURLTypes @@ -31,11 +31,16 @@ CFBundleVersion - 23808 + 33575 LSApplicationCategoryType public.app-category.social-networking LSMinimumSystemVersion ${MACOSX_DEPLOYMENT_TARGET} + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + NSHumanReadableCopyright Copyright © 2015 TELEGRAM MESSENGER LLP. All rights reserved. NSMainNibFile diff --git a/TelegramTest/Telegraph-Prefix.pch b/TelegramTest/Telegraph-Prefix.pch index 82ee84fc..acf198d3 100644 --- a/TelegramTest/Telegraph-Prefix.pch +++ b/TelegramTest/Telegraph-Prefix.pch @@ -17,7 +17,8 @@ #import #import "ImageUtils.h" #import "POP.h" - +#import "ASQueue.h" +#import "TGDispatcher.h" #import "SelectTextManager.h" #import "CMath.h" #import "SharedManager.h" @@ -25,11 +26,13 @@ #import "TL_destructMessage.h" #import "TL_outDocument.h" #import "TL_localMessageService.h" + #import "TL_secretServiceMessage.h" #import "TL_messageActionSetMessageTTL.h" #import "TL_peerSecret.h" #import "TL_peerBroadcast.h" #import "TL_localMessage.h" +#import "TL_localEmptyMessage.h" #import "TL_broadcast.h" #import "TL_messageActionEncryptedChat.h" #import "TL_messageActionBotDescription.h" @@ -37,6 +40,7 @@ #import "TLClassStore.h" #import "UsersManager.h" #import "DialogsManager.h" +#import "ChannelsManager.h" #import "MessagesManager.h" #import "BlockedUsersManager.h" #import "BroadcastManager.h" @@ -70,7 +74,7 @@ #ifdef TGDEBUG -#define ACCEPT_FEATURE ([@[@"vihor",@"Marvin",@"Ricdallaglio",@"Victor",@"Jdkdkdkdmdmdmx",@"dmitry",@"peter",@"Zlomch",@"MarcoK",@"VitocoEP",@"zinoviev",@"ecstasy",@"Gerardo",@"kondratyevdev",@"Markus"] indexOfObject:[UsersManager currentUser].username] != NSNotFound) +#define ACCEPT_FEATURE ([@[@"vihor",@"Marvin",@"Ricdallaglio",@"Victor",@"Jdkdkdkdmdmdmx",@"dmitry",@"peter",@"Zlomch",@"MarcoK",@"VitocoEP",@"zinoviev",@"ecstasy",@"Gerardo",@"kondratyevdev",@"Markus",@"Telegrafm",@"doublespb"] indexOfObject:[UsersManager currentUser].username] != NSNotFound) #else #define ACCEPT_FEATURE YES #endif diff --git a/TelegramTest/TimeObserver.m b/TelegramTest/TimeObserver.m index 3ab41c05..d0374095 100644 --- a/TelegramTest/TimeObserver.m +++ b/TelegramTest/TimeObserver.m @@ -51,7 +51,7 @@ void test_log(NSString *log,NSString *group,dispatch_queue_t dispatch_queue) { __unused const char *queueName = (dispatch_queue_get_label(dispatch_queue)); - MTLog(@"group[%@], %@",group,log); + NSLog(@"group[%@], %@",group,log); #endif } diff --git a/TelegramTest/UploadOperation.m b/TelegramTest/UploadOperation.m index 085599f0..d439e20f 100644 --- a/TelegramTest/UploadOperation.m +++ b/TelegramTest/UploadOperation.m @@ -12,8 +12,11 @@ #import "QueueManager.h" #import "NSMutableData+Extension.h" #import "TGTimer.h" -#import "Crypto.h" +#import +#import +#import #define CONCURENT 3 +#define MD5(data, len, md) CC_MD5(data, len, md) @interface UploadOperation () { int fingerprint; @@ -165,9 +168,26 @@ - (void)encryptedready:(UploadType)type key:(NSData *)key iv:(NSData *)iv { self.aes_key = key; self.aes_iv = [iv mutableCopy]; - NSData *digest = [Crypto md5:[self.aes_key dataWithData:self.aes_iv]]; - NSData *fingerdata = [Crypto xorAB:[digest subdataWithRange:NSMakeRange(0, 4)] b:[digest subdataWithRange:NSMakeRange(4, 4)]]; + NSData *k = [self.aes_key dataWithData:self.aes_iv]; + + unsigned char d[MD5_DIGEST_LENGTH]; + + MD5([k bytes], (int)[k length], d); + + NSData *digest = [NSData dataWithBytes:&d length:MD5_DIGEST_LENGTH]; + + + + NSMutableData *fingerdata = [[digest subdataWithRange:NSMakeRange(0, 4)] mutableCopy]; + + NSData *b = [digest subdataWithRange:NSMakeRange(4, 4)]; + + for (int i = 0; i < (int)fingerdata.length && i < (int)b.length; i++) + { + ((uint8_t *)fingerdata.mutableBytes)[i] ^= ((uint8_t *)b.bytes)[i]; + } + [fingerdata getBytes:&self->fingerprint]; self.isEncrypted = YES; @@ -314,8 +334,14 @@ - (void)startUploadPart:(int)partNumber { data = [self readDataFromPosition:i * self.part_size length:readFromBufferSize]; data = [[data mutableCopy] addPadding:16]; - data = [Crypto aesEncryptModify:data key:self.aes_key iv:self.aes_iv encrypt:YES]; - [self.encryptedParts setObject:data forKey:@(i)]; + + NSMutableData *copy = [data mutableCopy]; + + + MTAesEncryptInplaceAndModifyIv(copy, self.aes_key, self.aes_iv); + [self.encryptedParts setObject:copy forKey:@(i)]; + + data = copy; } self.maxEncryptedPart = partNumber; diff --git a/TelegramTest/UserCardViewController.m b/TelegramTest/UserCardViewController.m index 6d5e5a65..cc9d05e5 100644 --- a/TelegramTest/UserCardViewController.m +++ b/TelegramTest/UserCardViewController.m @@ -60,7 +60,7 @@ -(void)loadView { self.inputField = [[TMBlueInputTextField alloc] initWithFrame:NSMakeRect(18, 80, self.importView.frame.size.width-40, 35)]; - self.inputField.font = self.inputField.placeholderFont = [NSFont fontWithName:@"HelveticaNeue" size:13]; + self.inputField.font = self.inputField.placeholderFont = TGSystemFont(13); self.inputField.placeholderTitle = NSLocalizedString(@"UserCard.exportPlaceholder", nil); self.inputField.placeholderTextColor = NSColorFromRGB(0xc8c8c8); [self.inputField setPlaceholderAligment:NSCenterTextAlignment]; @@ -85,7 +85,7 @@ -(void)loadView { [self.button setAutoresizingMask:NSViewMinXMargin]; [self.button setTarget:self selector:@selector(actionExportCard)]; [self.button setText:NSLocalizedString(@"UserCard.Export", nil)]; - [self.button setTextFont:[NSFont fontWithName:@"HelveticaNeue" size:12]]; + [self.button setTextFont:TGSystemFont(12)]; [self.button setBackgroundColor:NSColorFromRGB(0xfdfdfd)]; @@ -102,7 +102,7 @@ -(void)loadView { self.textField = [TMTextField defaultTextField]; - [self.textField setFont:[NSFont fontWithName:@"HelveticaNeue" size:13]]; + [self.textField setFont:TGSystemFont(13)]; // [self.textField setSelectable:YES]; diff --git a/TelegramTest/UserInfoContainerView.m b/TelegramTest/UserInfoContainerView.m index 2da8d5bd..0410fca2 100644 --- a/TelegramTest/UserInfoContainerView.m +++ b/TelegramTest/UserInfoContainerView.m @@ -26,6 +26,7 @@ #import "TMMenuPopover.h" #import "FullUsersManager.h" #import "ComposeActionAddUserToGroupBehavior.h" +#import "TGShareContactModalView.h" @interface UserInfoContainerView() @property (nonatomic, strong) TMAvatarImageView *avatarImageView; @property (nonatomic, strong) NSTextView *nameTextView; @@ -39,6 +40,7 @@ @interface UserInfoContainerView() @property (nonatomic, strong) TMSharedMediaButton *filesMediaButton; @property (nonatomic, strong) TMSharedMediaButton *sharedMediaButton; +@property (nonatomic, strong) TMSharedMediaButton *sharedLinksButton; @property (nonatomic, strong) UserInfoShortButtonView *startSecretChatButton; @property (nonatomic, strong) UserInfoShortButtonView *setProfilePhotoButton; @property (nonatomic, strong) UserInfoShortButtonView *importContacts; @@ -109,7 +111,7 @@ - (id)initWithFrame:(NSRect)frame { __block UserInfoContainerView *weakSelf = self; self.sendMessageButton = [UserInfoShortButtonView buttonWithText:NSLocalizedString(@"Profile.SendMessage", nil) tapBlock:^{ - [[Telegram sharedInstance] showMessagesWidthUser:weakSelf.user sender:weakSelf]; + [appWindow().navigationController showMessagesViewController:weakSelf.user.dialog]; }]; [self.sendMessageButton setFrameSize:NSMakeSize(offsetRight, 42)]; [self addSubview:self.sendMessageButton]; @@ -120,7 +122,7 @@ - (id)initWithFrame:(NSRect)frame { if(weakSelf.user.isBot) { - [TMViewController showModalProgress]; + [self.controller showModalProgress]; NSPasteboard* cb = [NSPasteboard generalPasteboard]; @@ -129,12 +131,20 @@ - (id)initWithFrame:(NSRect)frame { dispatch_after_seconds(0.2, ^{ - [TMViewController hideModalProgressWithSuccess]; + [self.controller hideModalProgressWithSuccess]; }); } else { - [[Telegram rightViewController] showShareContactModalView:weakSelf.user]; + + TGShareContactModalView *shareContactModalView = [[TGShareContactModalView alloc] initWithFrame:NSMakeRect(0, 0, NSWidth(weakSelf.window.frame), NSHeight(weakSelf.window.frame))]; + + [shareContactModalView setMessagesViewController:weakSelf.controller.navigationViewController.messagesViewController]; + [shareContactModalView setUser:weakSelf.user]; + + [shareContactModalView show:weakSelf.window animated:YES]; + + // [[Telegram rightViewController] showShareContactModalView:weakSelf.user]; } }]; @@ -147,10 +157,10 @@ - (id)initWithFrame:(NSRect)frame { BlockedHandler handlerBlock = ^(BOOL result) { self.blockContact.locked = NO; - if(!self.user.isBlocked) + if(!self.user.isBlocked && self.user.isBot) { - [[Telegram rightViewController] navigationGoBack]; - [[Telegram rightViewController].messagesViewController sendMessage:@"/start" forConversation:[Telegram conversation]]; + [self.controller.navigationViewController goBackWithAnimation:YES]; + [self.controller.navigationViewController.messagesViewController sendMessage:@"/start" forConversation:self.controller.conversation]; } }; @@ -166,36 +176,71 @@ - (id)initWithFrame:(NSRect)frame { self.addToGroupButton =[UserInfoShortButtonView buttonWithText:NSLocalizedString(@"Profile.AddToGroup", nil) tapBlock:^{ - [[Telegram rightViewController] showComposeAddUserToGroup:[[ComposeAction alloc] initWithBehaviorClass:[ComposeActionAddUserToGroupBehavior class] filter:nil object:self.user]]; + ComposeChooseGroupViewController *viewController = [[ComposeChooseGroupViewController alloc] initWithFrame:self.controller.view.bounds]; + + [viewController setAction:[[ComposeAction alloc] initWithBehaviorClass:[ComposeActionAddUserToGroupBehavior class] filter:nil object:self.user]]; + + [self.controller.navigationViewController pushViewController:viewController animated:YES]; }]; self.helpBotButton = [UserInfoShortButtonView buttonWithText:NSLocalizedString(@"Bot.Help", nil) tapBlock:^{ - [[Telegram rightViewController] showByDialog:self.user.dialog sender:self]; + [self.controller.navigationViewController goBackWithAnimation:YES]; - [[Telegram rightViewController].messagesViewController sendMessage:@"/help" forConversation:self.user.dialog]; + [self.controller.navigationViewController.messagesViewController sendMessage:@"/help" forConversation:self.user.dialog]; }]; self.sharedMediaButton = [TMSharedMediaButton buttonWithText:NSLocalizedString(@"Profile.SharedMedia", nil) tapBlock:^{ - [[Telegram rightViewController] showCollectionPage:weakSelf.controller.conversation]; - [[Telegram rightViewController].collectionViewController showAllMedia]; + TMCollectionPageController *viewController = [[TMCollectionPageController alloc] initWithFrame:self.controller.view.bounds]; + [viewController loadViewIfNeeded]; + + [viewController setConversation:self.controller.conversation]; + + [self.controller.navigationViewController pushViewController:viewController animated:YES]; + + + [viewController showAllMedia]; }]; self.filesMediaButton = [TMSharedMediaButton buttonWithText:NSLocalizedString(@"Profile.SharedMediaFiles", nil) tapBlock:^{ - [[Telegram rightViewController] showCollectionPage:weakSelf.controller.conversation]; - [[Telegram rightViewController].collectionViewController showFiles]; + TMCollectionPageController *viewController = [[TMCollectionPageController alloc] initWithFrame:self.controller.view.bounds]; + + [viewController loadViewIfNeeded]; + + [viewController setConversation:self.controller.conversation]; + + [self.controller.navigationViewController pushViewController:viewController animated:YES]; + + [viewController showFiles]; + }]; + + + self.sharedLinksButton = [TMSharedMediaButton buttonWithText:NSLocalizedString(@"Conversation.Filter.SharedLinks", nil) tapBlock:^{ + + TMCollectionPageController *viewController = [[TMCollectionPageController alloc] initWithFrame:self.controller.view.bounds]; + + [viewController loadViewIfNeeded]; + + [viewController setConversation:self.controller.conversation]; + + [self.controller.navigationViewController pushViewController:viewController animated:YES]; + + [viewController showSharedLinks]; }]; - self.filesMediaButton.isFiles = YES; + + self.sharedMediaButton.type = TMSharedMediaPhotoVideoType; + self.filesMediaButton.type = TMSharedMediaDocumentsType; + self.sharedLinksButton.type = TMSharedMediaSharedLinksType; // self.importContacts = [UserInfoShortButtonView buttonWithText:NSLocalizedString(@"Account.ImportContacts", nil) tapBlock:^{ // // [[NewContactsManager sharedManager] syncContacts:^{ @@ -224,6 +269,9 @@ - (id)initWithFrame:(NSRect)frame { [self.sharedMediaButton setFrameSize:NSMakeSize(offsetRight, 42)]; [self addSubview:self.sharedMediaButton]; + [self.sharedLinksButton setFrameSize:NSMakeSize(offsetRight, 42)]; + [self addSubview:self.sharedLinksButton]; + [self.filesMediaButton setFrameSize:NSMakeSize(offsetRight, 42)]; [self addSubview:self.filesMediaButton]; @@ -251,14 +299,18 @@ - (id)initWithFrame:(NSRect)frame { self.deleteSecretChatButton = [UserInfoShortButtonView buttonWithText:NSLocalizedString(@"Conversation.DeleteSecretChat", nil) tapBlock:^{ [weakSelf.deleteSecretChatButton setLocked:YES]; - [[Telegram rightViewController].messagesViewController deleteDialog:[Telegram rightViewController].messagesViewController.conversation callback:^{ + [[Telegram rightViewController].messagesViewController deleteDialog:self.controller.conversation callback:^{ [weakSelf.deleteSecretChatButton setLocked:NO]; }]; }]; self.encryptedKeyButton = [UserInfoShortButtonView buttonWithText:NSLocalizedString(@"Profile.ShowEncryptedKey",nil) tapBlock:^{ - [[Telegram rightViewController] showEncryptedKeyWindow:weakSelf.controller.conversation.encryptedChat]; - // [EncryptedKeyWindow showForChat:weakSelf.controller.conversation.encryptedChat]; + + EncryptedKeyViewController *viewController = [[EncryptedKeyViewController alloc] initWithFrame:self.controller.view.bounds]; + + [viewController showForChat:weakSelf.controller.conversation.encryptedChat]; + + [self.controller.navigationViewController pushViewController:viewController animated:YES]; }]; @@ -387,7 +439,7 @@ - (id)initWithFrame:(NSRect)frame { [Notification addObserver:self selector:@selector(userNameChangedNotification:) name:USER_UPDATE_NAME]; - self.filesMediaButton.textButton.textColor = self.notificationView.textButton.textColor = self.sharedMediaButton.textButton.textColor = self.setTTLButton.textButton.textColor = self.encryptedKeyButton.textButton.textColor = DARK_BLACK; + self.sharedLinksButton.textButton.textColor = self.filesMediaButton.textButton.textColor = self.notificationView.textButton.textColor = self.sharedMediaButton.textButton.textColor = self.setTTLButton.textButton.textColor = self.encryptedKeyButton.textButton.textColor = DARK_BLACK; [Notification addObserver:self selector:@selector(didChangedBlockedUsers:) name:USER_BLOCK]; @@ -397,6 +449,8 @@ - (id)initWithFrame:(NSRect)frame { return self; } + + -(void)didChangedBlockedUsers:(NSNotification *)notification { TL_contactBlocked *user = [notification.userInfo objectForKey:KEY_USER]; @@ -434,7 +488,7 @@ -(void)buildTTLTitle { [string appendString:str withColor:NSColorFromRGB(0xa1a1a1)]; - [string setFont:[NSFont fontWithName:@"HelveticaNeue-Light" size:15] forRange:NSMakeRange(0, string.length)]; + [string setFont:TGSystemLightFont(15) forRange:NSMakeRange(0, string.length)]; [string appendAttributedString:[NSAttributedString attributedStringWithAttachment:attach]]; [self.ttlTitle setAttributedStringValue:string]; @@ -460,7 +514,7 @@ -(void)buildNotificationsTitle { [string appendString:str withColor:NSColorFromRGB(0xa1a1a1)]; - [string setFont:[NSFont fontWithName:@"HelveticaNeue-Light" size:15] forRange:NSMakeRange(0, string.length)]; + [string setFont:TGSystemLightFont(15) forRange:NSMakeRange(0, string.length)]; [string appendAttributedString:[NSAttributedString attributedStringWithAttachment:attach]]; [self.muteUntilTitle setAttributedStringValue:string]; @@ -586,9 +640,21 @@ - (void)buildPage { [self.filesMediaButton setHidden:NO]; + + [self.sharedLinksButton setHidden:self.controller.isSecretProfile]; + + if(!self.controller.isSecretProfile) { + offset-=NSHeight(self.sharedLinksButton.frame); + + [self.sharedLinksButton setFrameOrigin:NSMakePoint(100, offset)]; + + [self.sharedLinksButton setHidden:NO]; + } + } else { [self.sharedMediaButton setHidden:YES]; [self.filesMediaButton setHidden:YES]; + [self.sharedLinksButton setHidden:YES]; } @@ -661,7 +727,7 @@ - (void)setState:(UserInfoViewControllerType)state animation:(BOOL)animation { } -#define DEFAULT_FONT [NSFont fontWithName:@"HelveticaNeue" size:13] +#define DEFAULT_FONT TGSystemFont(13) #define DEFAULT_COLOR NSColorFromRGB(0xa1a1a1) - (void)setUser:(TLUser *)user { @@ -673,6 +739,8 @@ - (void)setUser:(TLUser *)user { [self.filesMediaButton setConversation:self.controller.conversation]; + [self.sharedLinksButton setConversation:self.controller.conversation]; + [self.helpBotButton setHidden:YES]; NSSize size; @@ -680,7 +748,7 @@ - (void)setUser:(TLUser *)user { NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; [paragraphStyle setLineBreakMode: NSLineBreakByTruncatingTail]; - NSAttributedString *userNameAttributedString = [[NSAttributedString alloc] initWithString:user.fullName ? user.fullName : NSLocalizedString(@"User.Deleted", nil) attributes:@{NSForegroundColorAttributeName: NSColorFromRGB(0x333333), NSFontAttributeName: [NSFont fontWithName:@"HelveticaNeue" size:18], NSParagraphStyleAttributeName: paragraphStyle}]; + NSAttributedString *userNameAttributedString = [[NSAttributedString alloc] initWithString:user.fullName ? user.fullName : NSLocalizedString(@"User.Deleted", nil) attributes:@{NSForegroundColorAttributeName: NSColorFromRGB(0x333333), NSFontAttributeName: TGSystemFont(18), NSParagraphStyleAttributeName: paragraphStyle}]; size = [userNameAttributedString sizeForWidth:FLT_MAX height:FLT_MAX]; [[self.nameTextView textStorage] setAttributedString:userNameAttributedString]; diff --git a/TelegramTest/UserInfoShortButtonView.m b/TelegramTest/UserInfoShortButtonView.m index 117b3ab3..9de06f86 100644 --- a/TelegramTest/UserInfoShortButtonView.m +++ b/TelegramTest/UserInfoShortButtonView.m @@ -32,7 +32,7 @@ - (id)initWithFrame:(NSRect)frame withName:(NSString *)name andBlock:(dispatch_b self.textButton = [TMTextButton standartUserProfileButtonWithTitle:name]; self.tapBlock = block; [self.textButton sizeToFit]; - [self.textButton setFrameOrigin:NSMakePoint(0, 12)]; // 10 + [self.textButton setFrameOrigin:NSMakePoint(0, 7)]; // 10 [[self.textButton cell] setLineBreakMode:NSLineBreakByTruncatingTail]; [[self.textButton cell] setTruncatesLastVisibleLine:YES]; [self setAutoresizingMask:NSViewWidthSizable]; diff --git a/TelegramTest/UserInfoShortTextEditView.m b/TelegramTest/UserInfoShortTextEditView.m index e1f55120..2f8d4842 100644 --- a/TelegramTest/UserInfoShortTextEditView.m +++ b/TelegramTest/UserInfoShortTextEditView.m @@ -22,7 +22,7 @@ - (id)initWithFrame:(NSRect)frame { // [[self.textView cell] setTruncatesLastVisibleLine:NO]; // [[self.textView cell] setLineBreakMode:NSLineBreakByTruncatingTail]; - [self.textView setFont:[NSFont fontWithName:@"HelveticaNeue" size:15]]; + [self.textView setFont:TGSystemFont(15)]; // [self.textView setVerticallyResizable:NO]; [self setAutoresizingMask:NSViewWidthSizable]; [self addSubview:self.textView]; diff --git a/TelegramTest/UserInfoViewController.h b/TelegramTest/UserInfoViewController.h index f914c834..3f071342 100644 --- a/TelegramTest/UserInfoViewController.h +++ b/TelegramTest/UserInfoViewController.h @@ -7,7 +7,7 @@ // #import "TMViewController.h" -#import "ChatAvatarImageView.h" +#import "TMAvatarImageView.h" typedef enum { UserInfoViewControllerNormal, UserInfoViewControllerEdit, @@ -18,7 +18,11 @@ typedef enum { @property (nonatomic,assign, readonly) BOOL isSecretProfile; @property (nonatomic, strong, readonly) TLUser *user; @property (nonatomic, strong, readonly) TL_conversation *conversation; -@property (nonatomic,strong, readonly) ChatAvatarImageView *avatarImageView; +@property (nonatomic,strong, readonly) TMAvatarImageView *avatarImageView; + +@property (nonatomic,weak) MessagesViewController *messagesViewController; + + -(void)setUser:(TLUser *)user conversation:(TL_conversation *)conversation; - (void)successDeleteContact; diff --git a/TelegramTest/UserInfoViewController.m b/TelegramTest/UserInfoViewController.m index 56fdba22..20be2c35 100644 --- a/TelegramTest/UserInfoViewController.m +++ b/TelegramTest/UserInfoViewController.m @@ -61,7 +61,9 @@ - (id)initWithFrame:(NSRect)frame -(void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - [Notification addObserver:self selector:@selector(userNameChangedNotification:) name:USER_UPDATE_NAME]; + [Notification addObserver:self selector:@selector(userNameChangedNotification:) name:USER_UPDATE_NAME]; + + } -(void)viewWillDisappear:(BOOL)animated { @@ -82,7 +84,7 @@ -(void)loadView { [flippedClipView setAutoresizesSubviews:YES]; [flippedClipView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; - self.containerView = [[TMView alloc] initWithFrame:NSMakeRect(0, 0, self.view.bounds.size.width, 700)]; + self.containerView = [[TMView alloc] initWithFrame:NSMakeRect(0, 0, self.view.bounds.size.width, 800)]; [self.containerView setAutoresizingMask:NSViewWidthSizable]; self.normalContainer = [[UserInfoContainerView alloc] initWithFrame:self.containerView.bounds]; @@ -102,7 +104,7 @@ -(void)loadView { [self setCenterBarViewText:NSLocalizedString(@"Profile.Info", nil)]; - _avatarImageView = [ChatAvatarImageView standartUserInfoAvatar]; + _avatarImageView = [TMAvatarImageView standartUserInfoAvatar]; [_avatarImageView setFrameSize:NSMakeSize(70, 70)]; [_avatarImageView setFrameOrigin:NSMakePoint(100, self.containerView.bounds.size.height - self.avatarImageView.bounds.size.height - 36)]; @@ -120,8 +122,6 @@ -(void)loadView { } }]; - [_avatarImageView setSourceType:ChatAvatarSourceUser]; - self.scrollView = [[BTRScrollView alloc] initWithFrame:self.view.bounds]; [self.scrollView setAutoresizesSubviews:YES]; @@ -382,6 +382,8 @@ -(void)setUser:(TLUser *)user conversation:(TL_conversation *)conversation { [self.editContainer setUser:user]; [self.avatarImageView setUser:user]; [self setRightNavigationBarView:[self generateRightHeaderButtons]]; + + } @end diff --git a/TelegramTest/UserNameViewController.h b/TelegramTest/UserNameViewController.h index 10b69bec..18d88243 100644 --- a/TelegramTest/UserNameViewController.h +++ b/TelegramTest/UserNameViewController.h @@ -10,4 +10,8 @@ @interface UserNameViewController : TMViewController +@property (nonatomic,strong) TL_channel *channel; + +@property (nonatomic,strong) dispatch_block_t completionHandler; + @end diff --git a/TelegramTest/UserNameViewController.m b/TelegramTest/UserNameViewController.m index d9442b5d..aeb37ce1 100644 --- a/TelegramTest/UserNameViewController.m +++ b/TelegramTest/UserNameViewController.m @@ -84,7 +84,7 @@ -(id)initWithFrame:(NSRect)frameRect { [str appendString:NSLocalizedString(@"UserName.placeHolder", nil) withColor:DARK_GRAY]; [str setAlignment:NSLeftTextAlignment range:str.range]; - [str setFont:[NSFont fontWithName:@"HelveticaNeue" size:15] forRange:str.range]; + [str setFont:TGSystemFont(15) forRange:str.range]; [[self.textView textView].cell setPlaceholderAttributedString:str]; [[self.textView textView] setPlaceholderPoint:NSMakePoint(0, 0)]; @@ -99,12 +99,12 @@ -(id)initWithFrame:(NSRect)frameRect { [self.textView.textView setFrameOrigin:NSMakePoint(0, NSMinY(self.textView.textView.frame))]; - self.descriptionView = [[NSTextView alloc] initWithFrame:NSMakeRect(96, 122, NSWidth(self.frame) - 200, 100)]; + self.descriptionView = [[NSTextView alloc] initWithFrame:NSMakeRect(96, 122, NSWidth(self.frame) - 200, 150)]; [self.descriptionView setString:NSLocalizedString(@"UserName.description", nil)]; - [self.descriptionView setFont:[NSFont fontWithName:@"HelveticaNeue" size:12]]; - + [self.descriptionView setFont:TGSystemFont(12)]; + [self.descriptionView setTextColor:GRAY_TEXT_COLOR]; [self.descriptionView sizeToFit]; [self.descriptionView setSelectable:NO]; @@ -121,7 +121,7 @@ -(id)initWithFrame:(NSRect)frameRect { - (void)performEnter { - if(self.isRemoteChecked && ![[UsersManager currentUser].username isEqualToString:self.checkedUserName]) { + if(self.isRemoteChecked && ![[self defaultUsername] isEqualToString:self.checkedUserName]) { [self.textView.textView resignFirstResponder]; self.controller.doneButton.tapBlock(); } @@ -129,7 +129,7 @@ - (void)performEnter { -(void)updateSaveButton { - if([[UsersManager currentUser].username isEqualToString:self.textView.textView.stringValue]) { + if([[self defaultUsername] isEqualToString:self.textView.textView.stringValue]) { [self.controller.doneButton setDisable:YES]; return; @@ -173,10 +173,23 @@ -(BOOL)isNumberValid { return r.location == 0; } +-(NSString *)defaultUsername { + return self.controller.channel ? self.controller.channel.username : [UsersManager currentUser].username; +} + +-(id)checkUsernameRequest:(NSString *)userNameToCheck { + id request = [TLAPI_account_checkUsername createWithUsername:userNameToCheck]; + + if(self.controller.channel) { + request = [TLAPI_channels_checkUsername createWithChannel:[self.controller.channel inputPeer] username:userNameToCheck]; + } + + return request; +} -(void)updateChecker { - if([self.textView.textView.stringValue isEqualToString:[UsersManager currentUser].username]) { + if([self.textView.textView.stringValue isEqualToString:[self defaultUsername]]) { [self.progressView setHidden:YES]; [self.progressView stopAnimation:self]; [self.successView setHidden:NO]; @@ -188,7 +201,7 @@ -(void)updateChecker { if(!self.timer) { self.isSuccessChecked = NO; - self.isRemoteChecked = [self.textView.textView.stringValue isEqualToString:[UsersManager currentUser].username]; + self.isRemoteChecked = [self.textView.textView.stringValue isEqualToString:[self defaultUsername]]; [self updateSaveButton]; self.timer = [[TGTimer alloc] initWithTimeout:0.2 repeat:NO completion:^{ @@ -204,7 +217,9 @@ -(void)updateChecker { NSString *userNameToCheck = self.textView.textView.stringValue; - self.request = [RPCRequest sendRequest:[TLAPI_account_checkUsername createWithUsername:userNameToCheck] successHandler:^(RPCRequest *request, id response) { + + + self.request = [RPCRequest sendRequest:[self checkUsernameRequest:userNameToCheck] successHandler:^(RPCRequest *request, id response) { self.isSuccessChecked = [response isKindOfClass:[TL_boolTrue class]]; self.isRemoteChecked = YES; @@ -298,16 +313,36 @@ -(void)loadView { [strongSelf showModalProgress]; - [[UsersManager sharedManager] updateUserName:((UserNameViewContainer *)strongSelf.view).checkedUserName completeHandler:^(TLUser *user) { - - [strongSelf hideModalProgress]; - - - [((UserNameViewContainer *)strongSelf.view) controlTextDidChange:nil]; - } errorHandler:^(NSString *error) { - alert(error, error); - [strongSelf hideModalProgress]; - }]; + + if(self.channel != nil) { + [[ChatsManager sharedManager] updateChannelUserName:((UserNameViewContainer *)strongSelf.view).checkedUserName channel:strongSelf.channel completeHandler:^(TL_channel *channel) { + [strongSelf hideModalProgress]; + + + [((UserNameViewContainer *)strongSelf.view) controlTextDidChange:nil]; + + if(strongSelf.completionHandler != nil) { + strongSelf.completionHandler(); + } + + } errorHandler:^(NSString *error) { + alert(error, error); + [strongSelf hideModalProgress]; + }]; + } else { + [[UsersManager sharedManager] updateUserName:((UserNameViewContainer *)strongSelf.view).checkedUserName completeHandler:^(TLUser *user) { + + [strongSelf hideModalProgress]; + + + [((UserNameViewContainer *)strongSelf.view) controlTextDidChange:nil]; + } errorHandler:^(NSString *error) { + alert(error, error); + [strongSelf hideModalProgress]; + }]; + + } + }]; [self.doneButton setDisableColor:GRAY_TEXT_COLOR]; @@ -332,7 +367,7 @@ -(void)loadView { -(void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - [((UserNameViewContainer *)self.view).textView.textView setStringValue:[UsersManager currentUser].username]; + [((UserNameViewContainer *)self.view).textView.textView setStringValue:[(UserNameViewContainer *)self.view defaultUsername]]; [((UserNameViewContainer *)self.view) controlTextDidChange:nil]; } diff --git a/TelegramTest/UsersManager.m b/TelegramTest/UsersManager.m index bd716c87..ed381fa2 100644 --- a/TelegramTest/UsersManager.m +++ b/TelegramTest/UsersManager.m @@ -187,10 +187,17 @@ - (void)add:(NSArray *)all withCustomKey:(NSString *)key update:(BOOL)isNeedUpda newUser.first_name = NSLocalizedString(@"User.Deleted", nil); } + + + BOOL needUpdateUserInDB = NO; if(currentUser) { BOOL isNeedRebuildNames = NO; BOOL isNeedChangeTypeNotify = NO; + + currentUser.flags = newUser.flags; + + if(newUser.type != currentUser.type) { [currentUser setType:newUser.type]; @@ -240,6 +247,7 @@ - (void)add:(NSArray *)all withCustomKey:(NSString *)key update:(BOOL)isNeedUpda } else { + if(newUser.type == TLUserTypeEmpty) { newUser.first_name = @"Deleted"; newUser.last_name = @""; @@ -290,12 +298,24 @@ - (BOOL)setUserStatus:(TLUserStatus *)status forUser:(TLUser *)currentUser { BOOL result = currentUser.status.expires != status.expires && currentUser.status.was_online != status.was_online && currentUser.status.class != status.class; + BOOL saveOnlyTime = currentUser.status.class == status.class || (([currentUser.status isKindOfClass:[TL_userStatusOnline class]] || [currentUser.status isKindOfClass:[TL_userStatusOffline class]]) && ([status isKindOfClass:[TL_userStatusOnline class]] || [status isKindOfClass:[TL_userStatusOffline class]])); + currentUser.status = status; currentUser.lastSeenUpdate = [[MTNetwork instance] getTime]; currentUser.status.was_online = status.was_online; currentUser.status.expires = status.expires; - [Notification perform:USER_STATUS data:@{KEY_USER_ID: @(currentUser.n_id)}]; + if(result) + [Notification perform:USER_STATUS data:@{KEY_USER_ID: @(currentUser.n_id)}]; + + + if(result) { + if(saveOnlyTime) { + [[Storage manager] updateUsersStatus:@[currentUser]]; + } else { + [[Storage manager] insertUser:currentUser completeHandler:nil]; + } + } return result; } @@ -305,9 +325,6 @@ - (void)setUserStatus:(TLUserStatus *)status forUid:(int)uid { TLUser *currentUser = [keys objectForKey:@(uid)]; if(currentUser) { BOOL result = [self setUserStatus:status forUser:currentUser]; - if(result) { - [[Storage manager] insertUser:currentUser completeHandler:nil]; - } } }]; } @@ -347,26 +364,29 @@ -(void)updateUserName:(NSString *)userName completeHandler:(void (^)(TLUser *))c [RPCRequest sendRequest:[TLAPI_account_updateUsername createWithUsername:userName] successHandler:^(RPCRequest *request, TLUser *response) { - [self.queue dispatchOnQueue:^{ - if(response.type == TLUserTypeSelf) { - [self add:@[response]]; - } - - [[Storage manager] insertUser:self.userSelf completeHandler:nil]; - - [[ASQueue mainQueue] dispatchOnQueue:^{ - completeHandler(self.userSelf); - }]; - - [Notification perform:USER_UPDATE_NAME data:@{KEY_USER:self.userSelf}]; + if(response.type == TLUserTypeSelf) { + [self add:@[response]]; + } + + [self.userSelf rebuildNames]; + + [[Storage manager] insertUser:self.userSelf completeHandler:nil]; + + [[ASQueue mainQueue] dispatchOnQueue:^{ + completeHandler(self.userSelf); }]; - + [Notification perform:USER_UPDATE_NAME data:@{KEY_USER:self.userSelf}]; + } errorHandler:^(RPCRequest *request, RpcError *error) { - if(errorHandler) - errorHandler(NSLocalizedString(@"Profile.CantUpdate", nil)); - } timeout:10]; + + [ASQueue dispatchOnMainQueue:^{ + if(errorHandler) + errorHandler(NSLocalizedString(@"Profile.CantUpdate", nil)); + }]; + + } timeout:10 queue:self.queue.nativeQueue]; } diff --git a/TelegramTest/VideoHistoryFilter.h b/TelegramTest/VideoHistoryFilter.h index f004c494..ba2bb99a 100644 --- a/TelegramTest/VideoHistoryFilter.h +++ b/TelegramTest/VideoHistoryFilter.h @@ -7,7 +7,7 @@ // #import "HistoryFilter.h" - -@interface VideoHistoryFilter : HistoryFilter +#import "CommonMediaHistoryFilter.h" +@interface VideoHistoryFilter : CommonMediaHistoryFilter @end diff --git a/TelegramTest/VideoHistoryFilter.m b/TelegramTest/VideoHistoryFilter.m index 3eb04446..cf76894b 100644 --- a/TelegramTest/VideoHistoryFilter.m +++ b/TelegramTest/VideoHistoryFilter.m @@ -10,17 +10,6 @@ #import "ChatHistoryController.h" @implementation VideoHistoryFilter -static NSMutableDictionary * messageItems; -static NSMutableDictionary * messageKeys; - --(id)initWithController:(ChatHistoryController *)controller { - if(self = [super initWithController:controller]) { - - } - - return self; -} - -(int)type { return HistoryFilterVideo; @@ -30,87 +19,8 @@ +(int)type { return HistoryFilterVideo; } -- (NSMutableDictionary *)messageKeys:(int)peer_id { - return [[self class] messageKeys:peer_id]; -} - -- (NSMutableArray *)messageItems:(int)peer_id { - return [[self class] messageItems:peer_id]; -} - -+ (NSMutableDictionary *)messageKeys:(int)peer_id { - - __block NSMutableDictionary *keys; - [ASQueue dispatchOnStageQueue:^{ - - keys = messageKeys[@(peer_id)]; - - if(!keys) - { - keys = [[NSMutableDictionary alloc] init]; - messageKeys[@(peer_id)] = keys; - } - - } synchronous:YES]; - - return keys; -} - -+ (NSMutableArray *)messageItems:(int)peer_id { - __block NSMutableArray *items; - - [ASQueue dispatchOnStageQueue:^{ - - items = messageItems[@(peer_id)]; - - if(!items) - { - items = [[NSMutableArray alloc] init]; - messageItems[@(peer_id)] = items; - } - - } synchronous:YES]; - - - - return items; -} - - -+(void)drop { - [ASQueue dispatchOnStageQueue:^{ - [messageKeys removeAllObjects]; - [messageItems removeAllObjects]; - }]; -} - - -+(void)initialize { - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - messageItems = [[NSMutableDictionary alloc] init]; - messageKeys = [[NSMutableDictionary alloc] init]; - - }); -} - --(void)remoteRequest:(BOOL)next peer_id:(int)peer_id callback:(void (^)(id response))callback { - - self.request = [RPCRequest sendRequest:[TLAPI_messages_search createWithPeer:[self.controller.conversation inputPeer] q:@"" filter:[TL_inputMessagesFilterVideo create] min_date:0 max_date:0 offset:0 max_id:self.controller.max_id limit:(int)self.controller.selectLimit] successHandler:^(RPCRequest *request, id response) { - - - if(callback && self != nil) { - callback(response); - } - - } errorHandler:^(RPCRequest *request, RpcError *error) { - - if(callback) { - callback(nil); - } - - } timeout:10 queue:[ASQueue globalQueue].nativeQueue]; - +-(TLMessagesFilter *)messagesFilter { + return [TL_inputMessagesFilterVideo create]; } -(NSString *)description { diff --git a/TelegramTest/VideoSenderItem.m b/TelegramTest/VideoSenderItem.m index 388ad635..c1dcae0e 100644 --- a/TelegramTest/VideoSenderItem.m +++ b/TelegramTest/VideoSenderItem.m @@ -24,7 +24,7 @@ -(void)setState:(MessageState)state { } --(id)initWithPath:(NSString *)path_for_file forConversation:(TL_conversation *)conversation { +-(id)initWithPath:(NSString *)path_for_file forConversation:(TL_conversation *)conversation additionFlags:(int)additionFlags { if(self = [super init]) { self.path_for_file = path_for_file; self.conversation = conversation; @@ -53,13 +53,15 @@ -(id)initWithPath:(NSString *)path_for_file forConversation:(TL_conversation *)c } - TL_messageMediaVideo *video = [TL_messageMediaVideo createWithVideo:[TL_video createWithN_id:0 access_hash:0 user_id:[UsersManager currentUserId] date:(int)[[MTNetwork instance] getTime] duration:duration size:0 thumb:cachedSize dc_id:0 w:size.width h:size.height] caption:@""]; + TL_messageMediaVideo *video = [TL_messageMediaVideo createWithVideo:[TL_video createWithN_id:0 access_hash:0 date:(int)[[MTNetwork instance] getTime] duration:duration mime_type:mimetypefromExtension([path_for_file pathExtension]) size:0 thumb:cachedSize dc_id:0 w:size.width h:size.height] caption:@""]; [[ImageCache sharedManager] setImage:thumbImage forLocation:[cachedSize location]]; self.message = [MessageSender createOutMessage:@"" media:video conversation:conversation]; - + if(additionFlags & (1 << 4)) + self.message.from_id = 0; + } @@ -98,7 +100,7 @@ -(void)performRequest { if(strongSelf.conversation.type == DialogTypeBroadcast) { request = [TLAPI_messages_sendBroadcast createWithContacts:[strongSelf.conversation.broadcast inputContacts] random_id:[strongSelf.conversation.broadcast generateRandomIds] message:@"" media:media]; } else { - request = [TLAPI_messages_sendMedia createWithFlags:strongSelf.message.reply_to_msg_id != 0 ? 1 : 0 peer:strongSelf.conversation.inputPeer reply_to_msg_id:strongSelf.message.reply_to_msg_id media:media random_id:strongSelf.message.randomId reply_markup:[TL_replyKeyboardMarkup createWithFlags:0 rows:[@[]mutableCopy]]]; + request = [TLAPI_messages_sendMedia createWithFlags:[self senderFlags] peer:strongSelf.conversation.inputPeer reply_to_msg_id:strongSelf.message.reply_to_msg_id media:media random_id:strongSelf.message.randomId reply_markup:[TL_replyKeyboardMarkup createWithFlags:0 rows:[@[]mutableCopy]]]; } @@ -107,6 +109,7 @@ -(void)performRequest { [SharedManager proccessGlobalResponse:response]; + [strongSelf updateMessageId:response]; if(response.updates.count < 2) { @@ -169,7 +172,7 @@ -(void)performRequest { UploadOperation *thumbUpload = [[UploadOperation alloc] init]; [thumbUpload setUploadComplete:^(UploadOperation *thumb, TL_inputFile *inputThumbFile) { - media = [TL_inputMediaUploadedThumbVideo createWithFile:input thumb:inputThumbFile duration:duration w:size.width h:size.height caption:@""]; + media = [TL_inputMediaUploadedThumbVideo createWithFile:input thumb:inputThumbFile duration:duration w:size.width h:size.height mime_type:mimetypefromExtension(@"mp4") caption:@""]; block(); }]; @@ -177,7 +180,7 @@ -(void)performRequest { [thumbUpload setFileData:thumbData]; [thumbUpload ready:UploadImageType]; } else { - media = [TL_inputMediaUploadedVideo createWithFile:input duration:duration w:size.width h:size.height caption:self.message.media.caption]; + media = [TL_inputMediaUploadedVideo createWithFile:input duration:duration w:size.width h:size.height mime_type:mimetypefromExtension(@"mp4") caption:self.message.media.caption]; block(); } } diff --git a/TelegramTest/WeakReference.h b/TelegramTest/WeakReference.h new file mode 100644 index 00000000..d01d43c8 --- /dev/null +++ b/TelegramTest/WeakReference.h @@ -0,0 +1,22 @@ +// +// WeakReference.h +// Telegram +// +// Created by keepcoder on 15.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import + +@interface WeakReference : NSObject { + __weak id nonretainedObjectValue; + __unsafe_unretained id originalObjectValue; +} + ++ (WeakReference *) weakReferenceWithObject:(id) object; + +- (id) nonretainedObjectValue; +- (void *) originalObjectValue; + + +@end diff --git a/TelegramTest/WeakReference.m b/TelegramTest/WeakReference.m new file mode 100644 index 00000000..eb470b9f --- /dev/null +++ b/TelegramTest/WeakReference.m @@ -0,0 +1,34 @@ +// +// WeakReference.m +// Telegram +// +// Created by keepcoder on 15.09.15. +// Copyright (c) 2015 keepcoder. All rights reserved. +// + +#import "WeakReference.h" + +@implementation WeakReference + + +- (id) initWithObject:(id) object { + if (self = [super init]) { + nonretainedObjectValue = originalObjectValue = object; + } + return self; +} + ++ (WeakReference *) weakReferenceWithObject:(id) object { + return [[self alloc] initWithObject:object]; +} + +- (id) nonretainedObjectValue { return nonretainedObjectValue; } +- (void *) originalObjectValue { return (__bridge void *) originalObjectValue; } + +// To work appropriately with NSSet +- (BOOL) isEqual:(WeakReference *) object { + if (![object isKindOfClass:[WeakReference class]]) return NO; + return object.originalObjectValue == self.originalObjectValue; +} + +@end diff --git a/TelegramTest/YoutubeServiceDescription.m b/TelegramTest/YoutubeServiceDescription.m index ec7cd846..ede40d99 100644 --- a/TelegramTest/YoutubeServiceDescription.m +++ b/TelegramTest/YoutubeServiceDescription.m @@ -29,7 +29,7 @@ -(id)initWithSocialURL:(NSString *)url item:(MessageTableItem *)tableItem { NSMutableAttributedString *serviceName = [[NSMutableAttributedString alloc] init]; [serviceName appendString:url withColor:[NSColor whiteColor]]; - [serviceName setFont:[NSFont fontWithName:@"HelveticaNeue" size:12] forRange:serviceName.range]; + [serviceName setFont:TGSystemFont(12) forRange:serviceName.range]; _serviceName = serviceName; _serviceNameSize = [serviceName size]; _serviceNameSize.width = ceil(_serviceNameSize.width + 14); @@ -101,7 +101,7 @@ -(void)setTitle:(NSString *)title { [t appendString:title.length > 25 ? [[title substringToIndex:25] stringByAppendingString:@"..."] : title withColor:[NSColor whiteColor]]; - [t setFont:[NSFont fontWithName:@"HelveticaNeue" size:13] forRange:t.range]; + [t setFont:TGSystemFont(13) forRange:t.range]; _title = t; _titleSize = [t size]; diff --git a/TelegramTest/de.lproj/Localizable.strings b/TelegramTest/de.lproj/Localizable.strings index b66bdb75..ef30ac9f 100644 Binary files a/TelegramTest/de.lproj/Localizable.strings and b/TelegramTest/de.lproj/Localizable.strings differ diff --git a/TelegramTest/en.lproj/Localizable.strings b/TelegramTest/en.lproj/Localizable.strings index f1c65056..80c7ab2a 100644 Binary files a/TelegramTest/en.lproj/Localizable.strings and b/TelegramTest/en.lproj/Localizable.strings differ diff --git a/TelegramTest/es.lproj/Localizable.strings b/TelegramTest/es.lproj/Localizable.strings index ce87c452..922f40ac 100644 Binary files a/TelegramTest/es.lproj/Localizable.strings and b/TelegramTest/es.lproj/Localizable.strings differ diff --git a/TelegramTest/it.lproj/Localizable.strings b/TelegramTest/it.lproj/Localizable.strings index b7d46d7c..16c1aa65 100644 Binary files a/TelegramTest/it.lproj/Localizable.strings and b/TelegramTest/it.lproj/Localizable.strings differ diff --git a/TelegramTest/mime-types.txt b/TelegramTest/mime-types.txt index e194a07e..bdbee1d8 100644 --- a/TelegramTest/mime-types.txt +++ b/TelegramTest/mime-types.txt @@ -192,4 +192,7 @@ xpm:image/x-xpixmap xwd:image/x-xwindowdump z:application/x-compress xml:text/xml -webp:image/webp \ No newline at end of file +webp:image/webp +zip:application/zip +7z:application/zip +dmg:application/zip \ No newline at end of file diff --git a/TelegramTest/nl.lproj/Localizable.strings b/TelegramTest/nl.lproj/Localizable.strings index 6cc75f75..e6737d5c 100644 Binary files a/TelegramTest/nl.lproj/Localizable.strings and b/TelegramTest/nl.lproj/Localizable.strings differ diff --git a/TelegramTest/ru.lproj/Localizable.strings b/TelegramTest/ru.lproj/Localizable.strings deleted file mode 100644 index f1c65056..00000000 Binary files a/TelegramTest/ru.lproj/Localizable.strings and /dev/null differ diff --git a/TelegramTest/ru.lproj/NewMainMenu.strings b/TelegramTest/ru.lproj/NewMainMenu.strings deleted file mode 100644 index 32319f3a..00000000 --- a/TelegramTest/ru.lproj/NewMainMenu.strings +++ /dev/null @@ -1,222 +0,0 @@ - -/* Class = "NSMenuItem"; title = "Bring All to Front"; ObjectID = "5"; */ -"5.title" = "Bring All to Front"; - -/* Class = "NSMenuItem"; title = "Window"; ObjectID = "19"; */ -"19.title" = "Window"; - -/* Class = "NSMenuItem"; title = "Minimize"; ObjectID = "23"; */ -"23.title" = "Minimize"; - -/* Class = "NSMenu"; title = "Window"; ObjectID = "24"; */ -"24.title" = "Window"; - -/* Class = "NSMenu"; title = "AMainMenu"; ObjectID = "29"; */ -"29.title" = "AMainMenu"; - -/* Class = "NSMenuItem"; title = "Telegram"; ObjectID = "56"; */ -"56.title" = "Telegram"; - -/* Class = "NSMenu"; title = "Telegram"; ObjectID = "57"; */ -"57.title" = "Telegram"; - -/* Class = "NSMenuItem"; title = "About"; ObjectID = "129"; */ -"129.title" = "About"; - -/* Class = "NSMenu"; title = "Services"; ObjectID = "130"; */ -"130.title" = "Services"; - -/* Class = "NSMenuItem"; title = "Services"; ObjectID = "131"; */ -"131.title" = "Services"; - -/* Class = "NSMenuItem"; title = "Hide"; ObjectID = "134"; */ -"134.title" = "Hide"; - -/* Class = "NSMenuItem"; title = "Quit Telegram"; ObjectID = "136"; */ -"136.title" = "Quit Telegram"; - -/* Class = "NSMenuItem"; title = "Hide Others"; ObjectID = "145"; */ -"145.title" = "Hide Others"; - -/* Class = "NSMenuItem"; title = "Show All"; ObjectID = "150"; */ -"150.title" = "Show All"; - -/* Class = "NSMenuItem"; title = "Zoom"; ObjectID = "239"; */ -"239.title" = "Zoom"; - -/* Class = "NSMenuItem"; title = "Help"; ObjectID = "490"; */ -"490.title" = "Help"; - -/* Class = "NSMenu"; title = "Spelling"; ObjectID = "18Z-H9-nxX"; */ -"18Z-H9-nxX.title" = "Spelling"; - -/* Class = "NSMenuItem"; title = "Jump to Selection"; ObjectID = "1HI-F0-rTH"; */ -"1HI-F0-rTH.title" = "Jump to Selection"; - -/* Class = "NSMenuItem"; title = "Copy"; ObjectID = "1nJ-Zo-Xvq"; */ -"1nJ-Zo-Xvq.title" = "Copy"; - -/* Class = "NSMenu"; title = "Edit"; ObjectID = "2f6-tO-6dI"; */ -"2f6-tO-6dI.title" = "Edit"; - -/* Class = "NSMenuItem"; title = "Check Spelling While Typing"; ObjectID = "4SB-c1-mUF"; */ -"4SB-c1-mUF.title" = "Check Spelling While Typing"; - -/* Class = "NSMenuItem"; title = "Find and Replace…"; ObjectID = "67V-JU-Mcy"; */ -"67V-JU-Mcy.title" = "Find and Replace…"; - -/* Class = "NSMenuItem"; title = "Stop Speaking"; ObjectID = "8aU-pO-WGh"; */ -"8aU-pO-WGh.title" = "Stop Speaking"; - -/* Class = "NSMenuItem"; title = "File"; ObjectID = "9aa-b0-kdd"; */ -"9aa-b0-kdd.title" = "File"; - -/* Class = "NSMenuItem"; title = "Use Selection for Find"; ObjectID = "BEU-LD-Vwg"; */ -"BEU-LD-Vwg.title" = "Use Selection for Find"; - -/* Class = "NSMenuItem"; title = "Find…"; ObjectID = "C3w-Yr-qpO"; */ -"C3w-Yr-qpO.title" = "Find…"; - -/* Class = "NSMenuItem"; title = "Check Document Now"; ObjectID = "CKW-Pr-X2u"; */ -"CKW-Pr-X2u.title" = "Check Document Now"; - -/* Class = "NSMenuItem"; title = "Show Substitutions"; ObjectID = "Ec1-22-uo0"; */ -"Ec1-22-uo0.title" = "Show Substitutions"; - -/* Class = "NSMenuItem"; title = "Log Out"; ObjectID = "FJL-I9-FV9"; */ -"FJL-I9-FV9.title" = "Log Out"; - -/* Class = "NSMenuItem"; title = "Show Spelling and Grammar"; ObjectID = "GLK-eC-cnx"; */ -"GLK-eC-cnx.title" = "Show Spelling and Grammar"; - -/* Class = "NSMenuItem"; title = "Smart Dashes"; ObjectID = "GYa-tw-Vyc"; */ -"GYa-tw-Vyc.title" = "Smart Dashes"; - -/* Class = "NSMenuItem"; title = "Redo"; ObjectID = "GxW-gd-Q0I"; */ -"GxW-gd-Q0I.title" = "Redo"; - -/* Class = "NSMenuItem"; title = "Save"; ObjectID = "H6s-Mh-WPc"; */ -"H6s-Mh-WPc.title" = "Save"; - -/* Class = "NSMenuItem"; title = "Correct Spelling Automatically"; ObjectID = "JAf-uH-TN3"; */ -"JAf-uH-TN3.title" = "Correct Spelling Automatically"; - -/* Class = "NSMenu"; title = "Substitutions"; ObjectID = "KQO-sI-qMs"; */ -"KQO-sI-qMs.title" = "Substitutions"; - -/* Class = "NSMenuItem"; title = "test."; ObjectID = "KdJ-69-lPo"; */ -"KdJ-69-lPo.title" = "test."; - -/* Class = "NSMenuItem"; title = "Leave from Chat..."; ObjectID = "Mor-AG-ZB5"; */ -"Mor-AG-ZB5.title" = "Leave from Chat..."; - -/* Class = "NSMenuItem"; title = "Paste"; ObjectID = "N1s-6j-TDD"; */ -"N1s-6j-TDD.title" = "Paste"; - -/* Class = "NSMenuItem"; title = "Ask a Question..."; ObjectID = "PlM-u7-PLz"; */ -"PlM-u7-PLz.title" = "Ask a Question..."; - -/* Class = "NSMenuItem"; title = "Start Speaking"; ObjectID = "SSO-TM-nH6"; */ -"SSO-TM-nH6.title" = "Start Speaking"; - -/* Class = "NSMenuItem"; title = "Smart Quotes"; ObjectID = "STA-1x-4Zq"; */ -"STA-1x-4Zq.title" = "Smart Quotes"; - -/* Class = "NSMenuItem"; title = "Data Detectors"; ObjectID = "Sfl-ar-tGl"; */ -"Sfl-ar-tGl.title" = "Data Detectors"; - -/* Class = "NSMenuItem"; title = "Smart Copy/Paste"; ObjectID = "SmM-CB-5od"; */ -"SmM-CB-5od.title" = "Smart Copy/Paste"; - -/* Class = "NSMenu"; title = "Speech"; ObjectID = "T99-9E-T9Y"; */ -"T99-9E-T9Y.title" = "Speech"; - -/* Class = "NSMenuItem"; title = "New Secret Chat..."; ObjectID = "Ue4-BM-2XG"; */ -"Ue4-BM-2XG.title" = "New Secret Chat..."; - -/* Class = "NSMenu"; title = "Find"; ObjectID = "Uhq-UI-QHq"; */ -"Uhq-UI-QHq.title" = "Find"; - -/* Class = "NSMenuItem"; title = "Text Replacement"; ObjectID = "VKp-bH-5hq"; */ -"VKp-bH-5hq.title" = "Text Replacement"; - -/* Class = "NSMenuItem"; title = "Check for Updates..."; ObjectID = "VxH-Ao-S0R"; */ -"VxH-Ao-S0R.title" = "Check for Updates..."; - -/* Class = "NSMenuItem"; title = "Test record"; ObjectID = "XTd-ad-fYp"; */ -"XTd-ad-fYp.title" = "Test record"; - -/* Class = "NSMenuItem"; title = "Delete"; ObjectID = "ZNq-Nx-7c1"; */ -"ZNq-Nx-7c1.title" = "Delete"; - -/* Class = "NSMenuItem"; title = "Make Upper Case"; ObjectID = "aNV-M8-iia"; */ -"aNV-M8-iia.title" = "Make Upper Case"; - -/* Class = "NSMenuItem"; title = "New Group..."; ObjectID = "c7l-Fw-M57"; */ -"c7l-Fw-M57.title" = "New Group..."; - -/* Class = "NSMenuItem"; title = "Edit"; ObjectID = "cEF-g4-S1O"; */ -"cEF-g4-S1O.title" = "Edit"; - -/* Class = "NSMenuItem"; title = "New Message..."; ObjectID = "dvN-Fk-jc2"; */ -"dvN-Fk-jc2.title" = "New Message..."; - -/* Class = "NSMenu"; title = "Transformations"; ObjectID = "eVA-1e-Bx5"; */ -"eVA-1e-Bx5.title" = "Transformations"; - -/* Class = "NSMenuItem"; title = "Check Grammar With Spelling"; ObjectID = "fkH-sn-VYb"; */ -"fkH-sn-VYb.title" = "Check Grammar With Spelling"; - -/* Class = "NSMenuItem"; title = "Find Next"; ObjectID = "iB5-ll-s6Z"; */ -"iB5-ll-s6Z.title" = "Find Next"; - -/* Class = "NSMenuItem"; title = "Speech"; ObjectID = "iDh-HZ-j9V"; */ -"iDh-HZ-j9V.title" = "Speech"; - -/* Class = "NSMenuItem"; title = "Preferences..."; ObjectID = "iOx-Ud-JtE"; */ -"iOx-Ud-JtE.title" = "Preferences..."; - -/* Class = "NSMenuItem"; title = "Capitalize"; ObjectID = "ibD-KD-IAp"; */ -"ibD-KD-IAp.title" = "Capitalize"; - -/* Class = "NSMenuItem"; title = "Undo"; ObjectID = "kg3-05-Cu0"; */ -"kg3-05-Cu0.title" = "Undo"; - -/* Class = "NSMenuItem"; title = "Find Previous"; ObjectID = "lBV-JG-h7X"; */ -"lBV-JG-h7X.title" = "Find Previous"; - -/* Class = "NSMenuItem"; title = "Show Media"; ObjectID = "lWR-cc-Xrk"; */ -"lWR-cc-Xrk.title" = "Show Media"; - -/* Class = "NSMenuItem"; title = "Transformations"; ObjectID = "n1X-kq-7w8"; */ -"n1X-kq-7w8.title" = "Transformations"; - -/* Class = "NSMenuItem"; title = "Cut"; ObjectID = "nUA-QH-jiO"; */ -"nUA-QH-jiO.title" = "Cut"; - -/* Class = "NSMenuItem"; title = "Select All"; ObjectID = "pLu-rH-vDh"; */ -"pLu-rH-vDh.title" = "Select All"; - -/* Class = "NSMenuItem"; title = "Substitutions"; ObjectID = "pqU-2l-cjd"; */ -"pqU-2l-cjd.title" = "Substitutions"; - -/* Class = "NSMenuItem"; title = "Spelling and Grammar"; ObjectID = "uPB-6m-K3K"; */ -"uPB-6m-K3K.title" = "Spelling and Grammar"; - -/* Class = "NSMenuItem"; title = "Close"; ObjectID = "ukn-6g-5Mk"; */ -"ukn-6g-5Mk.title" = "Close"; - -/* Class = "NSMenuItem"; title = "Find"; ObjectID = "v4S-vz-rPP"; */ -"v4S-vz-rPP.title" = "Find"; - -/* Class = "NSMenuItem"; title = "Make Lower Case"; ObjectID = "v9f-x3-pvd"; */ -"v9f-x3-pvd.title" = "Make Lower Case"; - -/* Class = "NSMenuItem"; title = "Paste and Match Style"; ObjectID = "x0e-VT-veY"; */ -"x0e-VT-veY.title" = "Paste and Match Style"; - -/* Class = "NSMenuItem"; title = "Smart Links"; ObjectID = "zUP-Zk-PcO"; */ -"zUP-Zk-PcO.title" = "Smart Links"; - -/* Class = "NSMenu"; title = "File"; ObjectID = "zZt-zA-b9J"; */ -"zZt-zA-b9J.title" = "File"; diff --git a/TelegramTest/ru.lproj/NewMainMenu.xib b/TelegramTest/ru.lproj/NewMainMenu.xib deleted file mode 100644 index 186a2be0..00000000 --- a/TelegramTest/ru.lproj/NewMainMenu.xib +++ /dev/null @@ -1,320 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/TelegramTest/ru.lproj/localizations.strings b/TelegramTest/ru.lproj/localizations.strings deleted file mode 100644 index f6f69eb2..00000000 --- a/TelegramTest/ru.lproj/localizations.strings +++ /dev/null @@ -1,137 +0,0 @@ -/* - localization.strings - TelegramTest - - Created by keepcoder on 03.11.13. - Copyright (c) 2013 keepcoder. All rights reserved. -*/ -"APP_NAME" = "Messenger for Telegram"; - -"#TEXT_CHOOSE_CONVERSATION" = "Choose conversation \n to start messaging"; - -"#ACTION_ADD_MEMBERS" = "Add members"; -"#ACTION_PARTICIPANTS" = "Participants"; - -"#ACTION_DELETE_AND_EXIT" = "Delete and exit"; -"#ACTION_START_SECRET_CHAT" = "Start secret chat"; -"#ACTION_DELETE_CONVERSATION" = "Delete conversation"; -"#ACTION_ADD_TO_CONTACTS" = "Add to contacts"; - -"#ACTION_REMOVE_FROM_CONTACTS" = "Remove from contacts"; -"#ACTION_WRITE_A_MESSAGE" = "Write a message"; - -"Settings" = "Settings"; -"Mute" = "Mute"; -"Unmute" = "Unmute"; -"Actions" = "Actions"; -"Search" = "Search"; -"Send" = "Send"; -"Photo" = "Photo"; -"Video" = "Video"; -"Document" = "Document"; -"Contact" = "Contact"; -"Location" = "Location"; -"members" = "members"; -"Connecting" = "Connecting..."; -"online" = "online"; -"offline" = "offline"; -"Geo" = "Geo"; -"Audio" = "Audio"; -"Unsupported" = "Unsupported"; -"Open" = "Open"; -"Download" = "Download"; -"Save" = "Save"; -"changed group name" = "changed group name"; -"removed group photo" = "removed group photo"; -"changed group photo" = "changed group photo"; -"invited" = "invited"; -"created chat" = "created chat"; -"kicked" = "kicked"; -"left the group"; -"Empty" = "Empty"; -"Write a message..." = "Write a message..."; -"changed group name to" = "changed group name to"; -"removed group photo" = "removed group photo"; -"invited" = "invited"; -"created chat" = "created chat"; -"kicked" = "kicked"; -"left the group" = "left the group"; -"created secret chat" = "created secret chat"; -"is typing" = "is typing"; -"are typing" = "are typing"; - -//date -"Time.last_seen" = "last seen"; -"Time.today" = "today"; -"Time.yesterday" = "yesterday"; -"Time.tomorrow" = "tomorrow"; -"Time.at" = "at"; -"Time.JustNow" = "just now"; -"Time.Ago" = " ago"; -"Time.FromNow" = "from now"; -"Time.FromNowPrefix" = " "; -"Time.LessThan" = "less than "; -"Time.About" = ""; -"Time.Over" = "over "; -"Time.Almost" = ""; -"Time.Seconds" = "seconds"; -"Time.Minute" = "minute"; -"Time.MinuteCard" = "minutes"; -"Time.Minutes" = "minutes"; -"Time.MinutesA" = "minutes"; -"Time.Hour" = "hour"; -"Time.HourCard" = "hours"; -"Time.Hours" = "hours"; -"Time.HoursA" = "hours"; -"Time.Day" = "day"; -"Time.DayCard" = "days"; -"Time.Days" = "days"; -"Time.DaysA" = "days"; -"Time.Month" = "month"; -"Time.MonthCard" = "months"; -"Time.Months" = "months"; -"Time.MonthsA" = "months"; -"Time.Year" = "year"; -"Time.YearCard" = "years"; -"Time.YearAbout" = "years"; -"Time.Years" = "years"; -"Time.YearsA" = "years"; -"Time.YearsAbout" = "years"; -"Month.GenJanuary" = "January"; -"Month.GenFebruary" = "February"; -"Month.GenMarch" = "March"; -"Month.GenApril" = "April"; -"Month.GenMay" = "May"; -"Month.GenJune" = "June"; -"Month.GenJuly" = "July"; -"Month.GenAugust" = "August"; -"Month.GenSeptember" = "September"; -"Month.GenOctober" = "October"; -"Month.GenNovember" = "November"; -"Month.GenDecember" = "December"; -"Month.ShortJanuary" = "Jan"; -"Month.ShortFebruary" = "Feb"; -"Month.ShortMarch" = "Mar"; -"Month.ShortApril" = "Apr"; -"Month.ShortMay" = "May"; -"Month.ShortJune" = "Jun"; -"Month.ShortJuly" = "Jul"; -"Month.ShortAugust" = "Aug"; -"Month.ShortSeptember" = "Sep"; -"Month.ShortOctober" = "Oct"; -"Month.ShortNovember" = "Nov"; -"Month.ShortDecember" = "Dec"; -"Weekday.ShortMonday" = "Mon"; -"Weekday.ShortTuesday" = "Tue"; -"Weekday.ShortWednesday" = "Wed"; -"Weekday.ShortThursday" = "Thu"; -"Weekday.ShortFriday" = "Fri"; -"Weekday.ShortSaturday" = "Sat"; -"Weekday.ShortSunday" = "Sun"; -"Weekday.Monday" = "Monday"; -"Weekday.Tuesday" = "Tuesday"; -"Weekday.Wednesday" = "Wednesday"; -"Weekday.Thursday" = "Thursday"; -"Weekday.Friday" = "Friday"; -"Weekday.Saturday" = "Saturday"; -"Weekday.Sunday" = "Sunday"; diff --git a/YapDatabase/Internal/NSDictionary+YapDatabase.m b/YapDatabase/Internal/NSDictionary+YapDatabase.m index 98033f5b..f4f2f7eb 100755 --- a/YapDatabase/Internal/NSDictionary+YapDatabase.m +++ b/YapDatabase/Internal/NSDictionary+YapDatabase.m @@ -3,6 +3,7 @@ @implementation NSDictionary (YapDatabase) + /** * Originally I named this method simply 'containsKey:'. * But then immediately got a stack overflow when using the category.