diff --git a/TelegramCore.xcodeproj/project.pbxproj b/TelegramCore.xcodeproj/project.pbxproj index ca0e75383e..63080d5951 100644 --- a/TelegramCore.xcodeproj/project.pbxproj +++ b/TelegramCore.xcodeproj/project.pbxproj @@ -1970,6 +1970,125 @@ /* End PBXTargetDependency section */ /* Begin XCBuildConfiguration section */ + C22069BE1E8EB4A200E82730 /* AppStore */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = D03B0E591D63215200955575 /* TelegramCore.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MACOSX_DEPLOYMENT_TARGET = 10.10; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + USER_HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/third-party/FFmpeg-iOS/include"; + VALIDATE_PRODUCT = YES; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = AppStore; + }; + C22069BF1E8EB4A200E82730 /* AppStore */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = D03B0E591D63215200955575 /* TelegramCore.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + APPLICATION_EXTENSION_API_ONLY = YES; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_IDENTITY = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; + COPY_PHASE_STRIP = YES; + DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = X834Q8SBVP; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + INFOPLIST_FILE = TelegramCore/Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/third-party/FFmpeg-iOS/lib", + "$(PROJECT_DIR)/third-party/libwebp/lib", + ); + OTHER_LDFLAGS = "-Wl,-dead_strip"; + PRODUCT_BUNDLE_IDENTIFIER = org.telegram.TelegramCore; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_REFLECTION_METADATA_LEVEL = none; + SWIFT_VERSION = 3.0; + USER_HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/third-party/FFmpeg-iOS/include"; + }; + name = AppStore; + }; + C22069C01E8EB4A200E82730 /* AppStore */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = D03B0E591D63215200955575 /* TelegramCore.xcconfig */; + buildSettings = { + INFOPLIST_FILE = TelegramCoreTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = org.telegram.Telegram.TelegramCoreTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = AppStore; + }; + C22069C11E8EB4A200E82730 /* AppStore */ = { + isa = XCBuildConfiguration; + buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_SUSPICIOUS_MOVES = YES; + CODE_SIGN_IDENTITY = "-"; + COMBINE_HIDPI_IMAGES = YES; + DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = ""; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_VERSION = A; + INFOPLIST_FILE = TelegramCoreMac/Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.11; + PRODUCT_BUNDLE_IDENTIFIER = org.telegram.Telegram.TelegramCoreMac; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 3.0; + }; + name = AppStore; + }; D06706551D51162400DED3E3 /* Hockeyapp */ = { isa = XCBuildConfiguration; baseConfigurationReference = D03B0E591D63215200955575 /* TelegramCore.xcconfig */; @@ -2343,6 +2462,7 @@ buildConfigurations = ( D09D8C131D4FAB1D0081DBEC /* Debug */, D09D8C141D4FAB1D0081DBEC /* Release */, + C22069BE1E8EB4A200E82730 /* AppStore */, D06706551D51162400DED3E3 /* Hockeyapp */, ); defaultConfigurationIsVisible = 0; @@ -2353,6 +2473,7 @@ buildConfigurations = ( D09D8C161D4FAB1D0081DBEC /* Debug */, D09D8C171D4FAB1D0081DBEC /* Release */, + C22069BF1E8EB4A200E82730 /* AppStore */, D06706561D51162400DED3E3 /* Hockeyapp */, ); defaultConfigurationIsVisible = 0; @@ -2363,6 +2484,7 @@ buildConfigurations = ( D09D8C191D4FAB1D0081DBEC /* Debug */, D09D8C1A1D4FAB1D0081DBEC /* Release */, + C22069C01E8EB4A200E82730 /* AppStore */, D06706571D51162400DED3E3 /* Hockeyapp */, ); defaultConfigurationIsVisible = 0; @@ -2373,6 +2495,7 @@ buildConfigurations = ( D0B4186D1D7E03D5004562A4 /* Debug */, D0B4186E1D7E03D5004562A4 /* Release */, + C22069C11E8EB4A200E82730 /* AppStore */, D0B4186F1D7E03D5004562A4 /* Hockeyapp */, ); defaultConfigurationIsVisible = 0; diff --git a/TelegramCore/Account.swift b/TelegramCore/Account.swift index 3e9b7c13eb..27b24d4823 100644 --- a/TelegramCore/Account.swift +++ b/TelegramCore/Account.swift @@ -226,7 +226,7 @@ func accountNetworkUsageInfoPath(basePath: String) -> String { return basePath + "/network-usage" } -private func accountRecordIdPathName(_ id: AccountRecordId) -> String { +public func accountRecordIdPathName(_ id: AccountRecordId) -> String { return "account-\(UInt64(bitPattern: id.int64))" } diff --git a/TelegramCore/AccountState.swift b/TelegramCore/AccountState.swift index 09c5b2aace..047742e12d 100644 --- a/TelegramCore/AccountState.swift +++ b/TelegramCore/AccountState.swift @@ -99,7 +99,7 @@ public enum UnauthorizedAccountStateContents: Coding, Equatable { case empty case phoneEntry(countryCode: Int32, number: String) case confirmationCodeEntry(number: String, type: SentAuthorizationCodeType, hash: String, timeout: Int32?, nextType: AuthorizationCodeNextType?) - case passwordEntry(hint: String) + case passwordEntry(hint: String, number:String?, code:String?) case signUp(number: String, codeHash: String, code: String, firstName: String, lastName: String) public init(decoder: Decoder) { @@ -115,7 +115,7 @@ public enum UnauthorizedAccountStateContents: Coding, Equatable { } self = .confirmationCodeEntry(number: decoder.decodeStringForKey("num"), type: decoder.decodeObjectForKey("t", decoder: { SentAuthorizationCodeType(decoder: $0) }) as! SentAuthorizationCodeType, hash: decoder.decodeStringForKey("h"), timeout: decoder.decodeInt32ForKey("tm"), nextType: nextType) case UnauthorizedAccountStateContentsValue.passwordEntry.rawValue: - self = .passwordEntry(hint: decoder.decodeStringForKey("h")) + self = .passwordEntry(hint: decoder.decodeStringForKey("h"), number: decoder.decodeStringForKey("n"), code: decoder.decodeStringForKey("c")) case UnauthorizedAccountStateContentsValue.signUp.rawValue: self = .signUp(number: decoder.decodeStringForKey("n"), codeHash: decoder.decodeStringForKey("h"), code: decoder.decodeStringForKey("c"), firstName: decoder.decodeStringForKey("f"), lastName: decoder.decodeStringForKey("l")) default: @@ -147,9 +147,19 @@ public enum UnauthorizedAccountStateContents: Coding, Equatable { } else { encoder.encodeNil(forKey: "nt") } - case let .passwordEntry(hint): + case let .passwordEntry(hint, number, code): encoder.encodeInt32(UnauthorizedAccountStateContentsValue.passwordEntry.rawValue, forKey: "v") encoder.encodeString(hint, forKey: "h") + if let number = number { + encoder.encodeString(number, forKey: "n") + } else { + encoder.encodeNil(forKey: "n") + } + if let code = code { + encoder.encodeString(code, forKey: "c") + } else { + encoder.encodeNil(forKey: "c") + } case let .signUp(number, codeHash, code, firstName, lastName): encoder.encodeInt32(UnauthorizedAccountStateContentsValue.signUp.rawValue, forKey: "v") encoder.encodeString(number, forKey: "n") @@ -195,9 +205,9 @@ public enum UnauthorizedAccountStateContents: Coding, Equatable { } else { return false } - case let .passwordEntry(hint): - if case .passwordEntry(hint) = rhs { - return true + case let .passwordEntry(lhsHint, lhsNumber, lhsCode): + if case let .passwordEntry(rhsHint, rhsNumber, rhsCode) = rhs { + return lhsHint == rhsHint && lhsNumber == rhsNumber && lhsCode == rhsCode } else { return false } diff --git a/TelegramCore/AddressNames.swift b/TelegramCore/AddressNames.swift index 050fd9a09c..9ceb6f9f73 100644 --- a/TelegramCore/AddressNames.swift +++ b/TelegramCore/AddressNames.swift @@ -28,7 +28,7 @@ public enum AddressNameDomain { case peer(PeerId) } -public func checkAddressNameFormat(_ value: String) -> AddressNameFormatError? { +public func checkAddressNameFormat(_ value: String, canEmpty: Bool = false) -> AddressNameFormatError? { var index = 0 let length = value.characters.count for char in value.characters { @@ -48,10 +48,9 @@ public func checkAddressNameFormat(_ value: String) -> AddressNameFormatError? { index += 1 } - if length < 5 { + if length < 5 && (!canEmpty || length != 0) { return .tooShort } - return nil } diff --git a/TelegramCore/Authorization.swift b/TelegramCore/Authorization.swift index aec5efe0f7..f9bd453371 100644 --- a/TelegramCore/Authorization.swift +++ b/TelegramCore/Authorization.swift @@ -168,7 +168,7 @@ public func authorizeWithCode(account: UnauthorizedAccount, code: String) -> Sig case .SignUp: modifier.setState(UnauthorizedAccountState(masterDatacenterId: account.masterDatacenterId, contents: .signUp(number: number, codeHash: hash, code: code, firstName: "", lastName: ""))) case let .Password(hint): - modifier.setState(UnauthorizedAccountState(masterDatacenterId: account.masterDatacenterId, contents: .passwordEntry(hint: hint))) + modifier.setState(UnauthorizedAccountState(masterDatacenterId: account.masterDatacenterId, contents: .passwordEntry(hint: hint, number: number, code: code))) case let .Authorization(authorization): switch authorization { case let .authorization(_, _, user): diff --git a/TelegramCore/MultipartUpload.swift b/TelegramCore/MultipartUpload.swift index de53ea8ded..35cfdc1546 100644 --- a/TelegramCore/MultipartUpload.swift +++ b/TelegramCore/MultipartUpload.swift @@ -348,7 +348,7 @@ func multipartUpload(network: Network, postbox: Postbox, source: MultipartUpload case let .resource(resource): dataSignal = postbox.mediaBox.resourceData(resource, option: .incremental(waitUntilFetchStatus: true)) |> map { MultipartUploadData.resourceData($0) } headerSize = resource.headerSize - fetchedResource = postbox.mediaBox.fetchedResource(resource) + fetchedResource = postbox.mediaBox.fetchedResource(resource) |> map {_ in} case let .data(data): dataSignal = .single(.data(data)) headerSize = 0 diff --git a/TelegramCore/RequestEditMessage.swift b/TelegramCore/RequestEditMessage.swift index c96e9866a8..9397909b1a 100644 --- a/TelegramCore/RequestEditMessage.swift +++ b/TelegramCore/RequestEditMessage.swift @@ -9,7 +9,7 @@ import Foundation import MtProtoKitDynamic #endif -public func requestEditMessage(account: Account, messageId: MessageId, text: String, entities:TextEntitiesMessageAttribute? = nil) -> Signal { +public func requestEditMessage(account: Account, messageId: MessageId, text: String, entities:TextEntitiesMessageAttribute? = nil, disableUrlPreview: Bool = false) -> Signal { return account.postbox.modify { modifier -> (Peer?, SimpleDictionary) in var peers:SimpleDictionary = SimpleDictionary() @@ -35,7 +35,9 @@ public func requestEditMessage(account: Account, messageId: MessageId, text: Str flags |= Int32(1 << 3) } - + if disableUrlPreview { + flags |= Int32(1 << 1) + } return account.network.request(Api.functions.messages.editMessage(flags: flags, peer: inputPeer, id: messageId.id, message: text, replyMarkup: nil, entities: apiEntities)) |> map { result -> Api.Updates? in