diff --git a/submodules/AsyncDisplayKit/BUILD b/submodules/AsyncDisplayKit/BUILD index 6d054283b8..c7b86e3485 100644 --- a/submodules/AsyncDisplayKit/BUILD +++ b/submodules/AsyncDisplayKit/BUILD @@ -14,6 +14,9 @@ objc_library( "Source/**/*.m", "Source/**/*.mm", ]) + private_headers, + copts = [ + "-Werror", + ], hdrs = public_headers, defines = [ "MINIMAL_ASDK", diff --git a/submodules/AsyncDisplayKit/Source/ASDisplayNode.mm b/submodules/AsyncDisplayKit/Source/ASDisplayNode.mm index f17f390aff..29fe8db76b 100644 --- a/submodules/AsyncDisplayKit/Source/ASDisplayNode.mm +++ b/submodules/AsyncDisplayKit/Source/ASDisplayNode.mm @@ -68,6 +68,9 @@ static ASDisplayNodeNonFatalErrorBlock _nonFatalErrorBlock = nil; @end +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wincomplete-implementation" + @implementation ASDisplayNode @dynamic layoutElementType; @@ -386,9 +389,12 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c) - (instancetype)initWithViewBlock:(ASDisplayNodeViewBlock)viewBlock didLoadBlock:(ASDisplayNodeDidLoadBlock)didLoadBlock { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wobjc-designated-initializers" if (!(self = [self init])) { return nil; } +#pragma clang diagnostic pop [self setViewBlock:viewBlock]; if (didLoadBlock != nil) { @@ -405,9 +411,12 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c) - (instancetype)initWithLayerBlock:(ASDisplayNodeLayerBlock)layerBlock didLoadBlock:(ASDisplayNodeDidLoadBlock)didLoadBlock { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wobjc-designated-initializers" if (!(self = [self init])) { return nil; } +#pragma clang diagnostic pop [self setLayerBlock:layerBlock]; if (didLoadBlock != nil) { @@ -3816,3 +3825,5 @@ static const char *ASDisplayNodeAssociatedNodeKey = "ASAssociatedNode"; } @end + +#pragma clang diagnostic pop diff --git a/submodules/AsyncDisplayKit/Source/ASEditableTextNode.mm b/submodules/AsyncDisplayKit/Source/ASEditableTextNode.mm index fdd08f0929..984e293e31 100644 --- a/submodules/AsyncDisplayKit/Source/ASEditableTextNode.mm +++ b/submodules/AsyncDisplayKit/Source/ASEditableTextNode.mm @@ -687,7 +687,10 @@ } - (bool)isCurrentlyEmoji { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" NSString *value = [[UITextInputMode currentInputMode] primaryLanguage]; +#pragma clang diagnostic pop if ([value isEqualToString:@"emoji"]) { return true; } else { diff --git a/submodules/AsyncDisplayKit/Source/PublicHeaders/AsyncDisplayKit/ASDisplayNode+Subclasses.h b/submodules/AsyncDisplayKit/Source/PublicHeaders/AsyncDisplayKit/ASDisplayNode+Subclasses.h index 5ea0b2e6fe..8165b73087 100644 --- a/submodules/AsyncDisplayKit/Source/PublicHeaders/AsyncDisplayKit/ASDisplayNode+Subclasses.h +++ b/submodules/AsyncDisplayKit/Source/PublicHeaders/AsyncDisplayKit/ASDisplayNode+Subclasses.h @@ -133,7 +133,6 @@ AS_CATEGORY_IMPLEMENTABLE * @note This method should not be called directly outside of ASDisplayNode; use -layoutThatFits: or -calculatedLayout instead. */ - (ASLayout *)calculateLayoutThatFits:(ASSizeRange)constrainedSize; -- (CGSize)calculateSizeThatFits:(CGSize)contrainedSize; /** * ASDisplayNode's implementation of -layoutThatFits:parentSize: calls this method to resolve the node's size diff --git a/submodules/AsyncDisplayKit/Source/_ASAsyncTransaction.mm b/submodules/AsyncDisplayKit/Source/_ASAsyncTransaction.mm index c147f5f263..f8e0d9ca04 100644 --- a/submodules/AsyncDisplayKit/Source/_ASAsyncTransaction.mm +++ b/submodules/AsyncDisplayKit/Source/_ASAsyncTransaction.mm @@ -16,10 +16,6 @@ #import #import -#ifndef __STRICT_ANSI__ - #warning "Texture must be compiled with std=c++11 to prevent layout issues. gnu++ is not supported. This is hopefully temporary." -#endif - AS_EXTERN NSRunLoopMode const UITrackingRunLoopMode; NSInteger const ASDefaultTransactionPriority = 0; diff --git a/submodules/AsyncDisplayKit/Source/_ASDisplayViewAccessiblity.mm b/submodules/AsyncDisplayKit/Source/_ASDisplayViewAccessiblity.mm index b24e8e9f58..6e0b33541b 100644 --- a/submodules/AsyncDisplayKit/Source/_ASDisplayViewAccessiblity.mm +++ b/submodules/AsyncDisplayKit/Source/_ASDisplayViewAccessiblity.mm @@ -294,9 +294,7 @@ static void CollectAccessibilityElementsForView(UIView *view, NSMutableArray *el if (viewNode == nil) { return @[]; } - if (true || _accessibilityElements == nil) { - _accessibilityElements = [viewNode accessibilityElements]; - } + _accessibilityElements = [viewNode accessibilityElements]; return _accessibilityElements; } diff --git a/submodules/AsyncDisplayKit/Source/_ASPendingState.mm b/submodules/AsyncDisplayKit/Source/_ASPendingState.mm index 5bf75e50d1..39426df1d2 100644 --- a/submodules/AsyncDisplayKit/Source/_ASPendingState.mm +++ b/submodules/AsyncDisplayKit/Source/_ASPendingState.mm @@ -588,8 +588,8 @@ static UIColor *defaultTintColor = nil; _flags.setSemanticContentAttribute = YES; } -- (void)setAccessibilityCustomActions:(NSArray *)accessibilityCustomActions { - self->accessibilityCustomActions = accessibilityCustomActions; +- (void)setAccessibilityCustomActions:(NSArray *)accessibilityCustomActions_ { + self->accessibilityCustomActions = accessibilityCustomActions_; _flags.setAccessibilityCustomActions = YES; } diff --git a/submodules/BuildConfig/BUILD b/submodules/BuildConfig/BUILD index d3f9c56360..10c5c92dbb 100644 --- a/submodules/BuildConfig/BUILD +++ b/submodules/BuildConfig/BUILD @@ -17,6 +17,7 @@ objc_library( "Sources/*.m", ]), copts = [ + "-Werror", "-DAPP_CONFIG_API_ID={}".format(telegram_api_id), "-DAPP_CONFIG_API_HASH=\\\"{}\\\"".format(telegram_api_hash), "-DAPP_CONFIG_APP_CENTER_ID=\\\"{}\\\"".format(telegram_app_center_id), diff --git a/submodules/BuildConfig/PublicHeaders/BuildConfig/BuildConfig.h b/submodules/BuildConfig/PublicHeaders/BuildConfig/BuildConfig.h index 562a63ce27..d735dd74bc 100644 --- a/submodules/BuildConfig/PublicHeaders/BuildConfig/BuildConfig.h +++ b/submodules/BuildConfig/PublicHeaders/BuildConfig/BuildConfig.h @@ -22,8 +22,8 @@ + (DeviceSpecificEncryptionParameters * _Nonnull)deviceSpecificEncryptionParameters:(NSString * _Nonnull)rootPath baseAppBundleId:(NSString * _Nonnull)baseAppBundleId; - (NSData * _Nullable)bundleDataWithAppToken:(NSData * _Nullable)appToken signatureDict:(NSDictionary * _Nullable)signatureDict; -+ (void)getHardwareEncryptionAvailableWithBaseAppBundleId:(NSString * _Nonnull)baseAppBundleId completion:(void (^)(NSData * _Nullable))completion; -+ (void)encryptApplicationSecret:(NSData * _Nonnull)secret baseAppBundleId:(NSString * _Nonnull)baseAppBundleId completion:(void (^)(NSData * _Nullable, NSData * _Nullable))completion; -+ (void)decryptApplicationSecret:(NSData * _Nonnull)secret publicKey:(NSData * _Nonnull)publicKey baseAppBundleId:(NSString * _Nonnull)baseAppBundleId completion:(void (^)(NSData * _Nullable, bool))completion; ++ (void)getHardwareEncryptionAvailableWithBaseAppBundleId:(NSString * _Nonnull)baseAppBundleId completion:(void (^ _Nonnull)(NSData * _Nullable))completion; ++ (void)encryptApplicationSecret:(NSData * _Nonnull)secret baseAppBundleId:(NSString * _Nonnull)baseAppBundleId completion:(void (^ _Nonnull)(NSData * _Nullable, NSData * _Nullable))completion; ++ (void)decryptApplicationSecret:(NSData * _Nonnull)secret publicKey:(NSData * _Nonnull)publicKey baseAppBundleId:(NSString * _Nonnull)baseAppBundleId completion:(void (^ _Nonnull)(NSData * _Nullable, bool))completion; @end diff --git a/submodules/BuildConfig/Sources/BuildConfig.m b/submodules/BuildConfig/Sources/BuildConfig.m index a4a4cffa9e..3dde1749ae 100644 --- a/submodules/BuildConfig/Sources/BuildConfig.m +++ b/submodules/BuildConfig/Sources/BuildConfig.m @@ -207,7 +207,7 @@ API_AVAILABLE(ios(10)) return bundleSeedID; } -+ (NSString * _Nonnull)applicationSecretTag:(bool)isCheckKey { ++ (NSData * _Nullable)applicationSecretTag:(bool)isCheckKey { if (isCheckKey) { return [[telegramApplicationSecretKey stringByAppendingString:@"_check"] dataUsingEncoding:NSUTF8StringEncoding]; } else { @@ -349,7 +349,7 @@ API_AVAILABLE(ios(10)) CFAbsoluteTime startTime = CFAbsoluteTimeGetCurrent(); NSString *filePath = [rootPath stringByAppendingPathComponent:@".tempkey"]; - NSString *encryptedPath = [rootPath stringByAppendingPathComponent:@".tempkeyEncrypted"]; + //NSString *encryptedPath = [rootPath stringByAppendingPathComponent:@".tempkeyEncrypted"]; NSData *currentData = [NSData dataWithContentsOfFile:filePath]; NSData *resultData = nil; diff --git a/submodules/BuildConfigExtra/BUILD b/submodules/BuildConfigExtra/BUILD index 7e3972e6a0..fb403a5b73 100644 --- a/submodules/BuildConfigExtra/BUILD +++ b/submodules/BuildConfigExtra/BUILD @@ -7,6 +7,9 @@ objc_library( "Sources/**/*.m", "Sources/**/*.h", ]), + copts = [ + "-Werror", + ], hdrs = glob([ "PublicHeaders/**/*.h", ]), diff --git a/submodules/BuildConfigExtra/PublicHeaders/BuildConfigExtra/BuildConfigExtra.h b/submodules/BuildConfigExtra/PublicHeaders/BuildConfigExtra/BuildConfigExtra.h index bd4c629fa0..576a2e45e6 100644 --- a/submodules/BuildConfigExtra/PublicHeaders/BuildConfigExtra/BuildConfigExtra.h +++ b/submodules/BuildConfigExtra/PublicHeaders/BuildConfigExtra/BuildConfigExtra.h @@ -2,8 +2,6 @@ @interface BuildConfigExtra : NSObject -- (instancetype _Nonnull)initWithBaseAppBundleId:(NSString * _Nonnull)baseAppBundleId; - + (NSDictionary * _Nonnull)signatureDict; @end diff --git a/submodules/CloudData/BUILD b/submodules/CloudData/BUILD index 83da0d43aa..874cb8a64f 100644 --- a/submodules/CloudData/BUILD +++ b/submodules/CloudData/BUILD @@ -11,7 +11,6 @@ swift_library( ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", - "//submodules/Postbox:Postbox", "//submodules/MtProtoKit:MtProtoKit", "//submodules/EncryptionProvider:EncryptionProvider", ], diff --git a/submodules/ComposePollUI/Sources/CreatePollController.swift b/submodules/ComposePollUI/Sources/CreatePollController.swift index 3a8e3eb8a4..cc5c5a3652 100644 --- a/submodules/ComposePollUI/Sources/CreatePollController.swift +++ b/submodules/ComposePollUI/Sources/CreatePollController.swift @@ -2,7 +2,6 @@ import Foundation import UIKit import Display import SwiftSignalKit -import Postbox import TelegramCore import TelegramPresentationData import ItemListUI @@ -11,6 +10,7 @@ import AccountContext import AlertUI import PresentationDataUtils import TextFormat +import Postbox private struct OrderedLinkedListItemOrderingId: RawRepresentable, Hashable { var rawValue: Int @@ -423,7 +423,7 @@ private struct CreatePollControllerState: Equatable { var isEditingSolution: Bool = false } -private func createPollControllerEntries(presentationData: PresentationData, peer: Peer, state: CreatePollControllerState, limitsConfiguration: LimitsConfiguration, defaultIsQuiz: Bool?) -> [CreatePollEntry] { +private func createPollControllerEntries(presentationData: PresentationData, peer: EnginePeer, state: CreatePollControllerState, limitsConfiguration: EngineConfiguration.Limits, defaultIsQuiz: Bool?) -> [CreatePollEntry] { var entries: [CreatePollEntry] = [] var textLimitText = ItemListSectionHeaderAccessoryText(value: "", color: .generic) @@ -453,7 +453,7 @@ private func createPollControllerEntries(presentationData: PresentationData, pee } var canBePublic = true - if let channel = peer as? TelegramChannel, case .broadcast = channel.info { + if case let .channel(channel) = peer, case .broadcast = channel.info { canBePublic = false } @@ -483,7 +483,7 @@ private func createPollControllerEntries(presentationData: PresentationData, pee return entries } -public func createPollController(context: AccountContext, peer: Peer, isQuiz: Bool? = nil, completion: @escaping (EnqueueMessage) -> Void) -> ViewController { +public func createPollController(context: AccountContext, peer: EnginePeer, isQuiz: Bool? = nil, completion: @escaping (EnqueueMessage) -> Void) -> ViewController { var initialState = CreatePollControllerState() if let isQuiz = isQuiz { initialState.isQuiz = isQuiz @@ -742,12 +742,13 @@ public func createPollController(context: AccountContext, peer: Peer, isQuiz: Bo }) let previousOptionIds = Atomic<[Int]?>(value: nil) - - let limitsKey = PostboxViewKey.preferences(keys: Set([PreferencesKeys.limitsConfiguration])) - let signal = combineLatest(context.sharedContext.presentationData, statePromise.get() |> deliverOnMainQueue, context.account.postbox.combinedView(keys: [limitsKey])) - |> map { presentationData, state, combinedView -> (ItemListControllerState, (ItemListNodeState, Any)) in - let limitsConfiguration: LimitsConfiguration = (combinedView.views[limitsKey] as? PreferencesView)?.values[PreferencesKeys.limitsConfiguration] as? LimitsConfiguration ?? LimitsConfiguration.defaultValue - + + let signal = combineLatest(queue: .mainQueue(), + context.sharedContext.presentationData, + statePromise.get(), + context.engine.data.subscribe(TelegramEngine.EngineData.Item.Configuration.Limits()) + ) + |> map { presentationData, state, limitsConfiguration -> (ItemListControllerState, (ItemListNodeState, Any)) in var enabled = true if processPollText(state.text).isEmpty { enabled = false diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Data/Configuration.swift b/submodules/TelegramCore/Sources/TelegramEngine/Data/Configuration.swift new file mode 100644 index 0000000000..48f702ccad --- /dev/null +++ b/submodules/TelegramCore/Sources/TelegramEngine/Data/Configuration.swift @@ -0,0 +1,93 @@ +import SwiftSignalKit +import Postbox + +public enum EngineConfiguration { + public struct Limits: Equatable { + public static let timeIntervalForever: Int32 = 0x7fffffff + + public var maxPinnedChatCount: Int32 + public var maxArchivedPinnedChatCount: Int32 + public var maxGroupMemberCount: Int32 + public var maxSupergroupMemberCount: Int32 + public var maxMessageForwardBatchSize: Int32 + public var maxSavedGifCount: Int32 + public var maxRecentStickerCount: Int32 + public var maxMessageEditingInterval: Int32 + public var maxMediaCaptionLength: Int32 + public var canRemoveIncomingMessagesInPrivateChats: Bool + public var maxMessageRevokeInterval: Int32 + public var maxMessageRevokeIntervalInPrivateChats: Int32 + + public init( + maxPinnedChatCount: Int32, + maxArchivedPinnedChatCount: Int32, + maxGroupMemberCount: Int32, + maxSupergroupMemberCount: Int32, + maxMessageForwardBatchSize: Int32, + maxSavedGifCount: Int32, + maxRecentStickerCount: Int32, + maxMessageEditingInterval: Int32, + maxMediaCaptionLength: Int32, + canRemoveIncomingMessagesInPrivateChats: Bool, + maxMessageRevokeInterval: Int32, + maxMessageRevokeIntervalInPrivateChats: Int32 + ) { + self.maxPinnedChatCount = maxPinnedChatCount + self.maxArchivedPinnedChatCount = maxArchivedPinnedChatCount + self.maxGroupMemberCount = maxGroupMemberCount + self.maxSupergroupMemberCount = maxSupergroupMemberCount + self.maxMessageForwardBatchSize = maxMessageForwardBatchSize + self.maxSavedGifCount = maxSavedGifCount + self.maxRecentStickerCount = maxRecentStickerCount + self.maxMessageEditingInterval = maxMessageEditingInterval + self.maxMediaCaptionLength = maxMediaCaptionLength + self.canRemoveIncomingMessagesInPrivateChats = canRemoveIncomingMessagesInPrivateChats + self.maxMessageRevokeInterval = maxMessageRevokeInterval + self.maxMessageRevokeIntervalInPrivateChats = maxMessageRevokeIntervalInPrivateChats + } + } +} + +extension EngineConfiguration.Limits { + init(_ limitsConfiguration: LimitsConfiguration) { + self.init( + maxPinnedChatCount: limitsConfiguration.maxPinnedChatCount, + maxArchivedPinnedChatCount: limitsConfiguration.maxArchivedPinnedChatCount, + maxGroupMemberCount: limitsConfiguration.maxGroupMemberCount, + maxSupergroupMemberCount: limitsConfiguration.maxSupergroupMemberCount, + maxMessageForwardBatchSize: limitsConfiguration.maxMessageForwardBatchSize, + maxSavedGifCount: limitsConfiguration.maxSavedGifCount, + maxRecentStickerCount: limitsConfiguration.maxRecentStickerCount, + maxMessageEditingInterval: limitsConfiguration.maxMessageEditingInterval, + maxMediaCaptionLength: limitsConfiguration.maxMediaCaptionLength, + canRemoveIncomingMessagesInPrivateChats: limitsConfiguration.canRemoveIncomingMessagesInPrivateChats, + maxMessageRevokeInterval: limitsConfiguration.maxMessageRevokeInterval, + maxMessageRevokeIntervalInPrivateChats: limitsConfiguration.maxMessageRevokeIntervalInPrivateChats + ) + } +} + +public extension TelegramEngine.EngineData.Item { + enum Configuration { + public struct Limits: TelegramEngineDataItem, PostboxViewDataItem { + public typealias Result = EngineConfiguration.Limits + + public init() { + } + + var key: PostboxViewKey { + return .preferences(keys: Set([PreferencesKeys.limitsConfiguration])) + } + + func extract(view: PostboxView) -> Result { + guard let view = view as? PreferencesView else { + preconditionFailure() + } + guard let limitsConfiguration = view.values[PreferencesKeys.limitsConfiguration] as? LimitsConfiguration else { + return EngineConfiguration.Limits(LimitsConfiguration.defaultValue) + } + return EngineConfiguration.Limits(limitsConfiguration) + } + } + } +} diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index 10ac5efc37..b2621488df 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -9689,7 +9689,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G private func presentPollCreation(isQuiz: Bool? = nil) { if let peer = self.presentationInterfaceState.renderedPeer?.peer { - self.effectiveNavigationController?.pushViewController(createPollController(context: self.context, peer: peer, isQuiz: isQuiz, completion: { [weak self] message in + self.effectiveNavigationController?.pushViewController(createPollController(context: self.context, peer: EnginePeer(peer), isQuiz: isQuiz, completion: { [weak self] message in guard let strongSelf = self else { return }