diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9c3655b428..df98411938 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,28 +8,26 @@ variables: internal: tags: - - ios + - ios_internal stage: build only: - master except: - tags script: - - sh ~/ios-prepare-build.sh $CI_PROJECT_DIR/.. - - fastlane internalhockeyapp + - sh buildbox/build-telegram.sh hockeyapp environment: name: internal beta_testflight: tags: - - ios + - ios_beta stage: build only: - beta except: - tags script: - - sh ~/ios-prepare-build.sh $CI_PROJECT_DIR/.. - - fastlane testflight_llc + - sh buildbox/build-telegram.sh appstore environment: name: testflight_llc diff --git a/NotificationContent/Info.plist b/NotificationContent/Info.plist index fe3d0478fb..80cbbcd91c 100644 --- a/NotificationContent/Info.plist +++ b/NotificationContent/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType XPC! CFBundleShortVersionString - 5.5 + 5.5.1 CFBundleVersion ${BUILD_NUMBER} NSExtension diff --git a/NotificationContent/NotificationViewController.swift b/NotificationContent/NotificationViewController.swift index 346460738c..d53b74a556 100644 --- a/NotificationContent/NotificationViewController.swift +++ b/NotificationContent/NotificationViewController.swift @@ -117,7 +117,7 @@ class NotificationViewController: UIViewController, UNNotificationContentExtensi let appVersion = (Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String) ?? "unknown" - sharedAccountContext = SharedAccountContext(mainWindow: nil, basePath: rootPath, accountManager: accountManager, applicationBindings: applicationBindings, initialPresentationDataAndSettings: initialPresentationDataAndSettings!, networkArguments: NetworkInitializationArguments(apiId: apiId, languagesCategory: languagesCategory, appVersion: appVersion, voipMaxLayer: 0, appData: BuildConfig.shared().bundleData), rootPath: rootPath, legacyBasePath: nil, legacyCache: nil, apsNotificationToken: .never(), voipNotificationToken: .never(), setNotificationCall: { _ in }, navigateToChat: { _, _, _ in }) + sharedAccountContext = SharedAccountContext(mainWindow: nil, basePath: rootPath, encryptionKey: BuildConfig.encryptionKey(rootPath), accountManager: accountManager, applicationBindings: applicationBindings, initialPresentationDataAndSettings: initialPresentationDataAndSettings!, networkArguments: NetworkInitializationArguments(apiId: apiId, languagesCategory: languagesCategory, appVersion: appVersion, voipMaxLayer: 0, appData: BuildConfig.shared().bundleData), rootPath: rootPath, legacyBasePath: nil, legacyCache: nil, apsNotificationToken: .never(), voipNotificationToken: .never(), setNotificationCall: { _ in }, navigateToChat: { _, _, _ in }) } } diff --git a/NotificationService/Info.plist b/NotificationService/Info.plist index 5ff53bd917..18eceb0557 100644 --- a/NotificationService/Info.plist +++ b/NotificationService/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType XPC! CFBundleShortVersionString - 5.5 + 5.5.1 CFBundleVersion ${BUILD_NUMBER} NSExtension diff --git a/Share/Info.plist b/Share/Info.plist index c5a9adb70a..2b77913fa3 100644 --- a/Share/Info.plist +++ b/Share/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType XPC! CFBundleShortVersionString - 5.5 + 5.5.1 CFBundleVersion ${BUILD_NUMBER} NSExtension diff --git a/Share/ShareRootController.swift b/Share/ShareRootController.swift index eb5e5fbcb5..4a2918b73f 100644 --- a/Share/ShareRootController.swift +++ b/Share/ShareRootController.swift @@ -160,7 +160,7 @@ class ShareRootController: UIViewController { }) semaphore.wait() - let sharedContext = SharedAccountContext(mainWindow: nil, basePath: rootPath, accountManager: accountManager, applicationBindings: applicationBindings, initialPresentationDataAndSettings: initialPresentationDataAndSettings!, networkArguments: NetworkInitializationArguments(apiId: apiId, languagesCategory: languagesCategory, appVersion: appVersion, voipMaxLayer: 0, appData: BuildConfig.shared().bundleData), rootPath: rootPath, legacyBasePath: nil, legacyCache: nil, apsNotificationToken: .never(), voipNotificationToken: .never(), setNotificationCall: { _ in }, navigateToChat: { _, _, _ in }) + let sharedContext = SharedAccountContext(mainWindow: nil, basePath: rootPath, encryptionKey: BuildConfig.encryptionKey(rootPath), accountManager: accountManager, applicationBindings: applicationBindings, initialPresentationDataAndSettings: initialPresentationDataAndSettings!, networkArguments: NetworkInitializationArguments(apiId: apiId, languagesCategory: languagesCategory, appVersion: appVersion, voipMaxLayer: 0, appData: BuildConfig.shared().bundleData), rootPath: rootPath, legacyBasePath: nil, legacyCache: nil, apsNotificationToken: .never(), voipNotificationToken: .never(), setNotificationCall: { _ in }, navigateToChat: { _, _, _ in }) sharedExtensionContext = SharedExtensionContext(sharedContext: sharedContext) globalSharedExtensionContext = sharedExtensionContext } diff --git a/SiriIntents/Info.plist b/SiriIntents/Info.plist index 330c3508d8..9890849e7e 100644 --- a/SiriIntents/Info.plist +++ b/SiriIntents/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType XPC! CFBundleShortVersionString - 5.5 + 5.5.1 CFBundleVersion ${BUILD_NUMBER} NSExtension diff --git a/SiriIntents/IntentHandler.swift b/SiriIntents/IntentHandler.swift index 5710b215ae..c7bf7f8b17 100644 --- a/SiriIntents/IntentHandler.swift +++ b/SiriIntents/IntentHandler.swift @@ -84,7 +84,7 @@ class IntentHandler: INExtension, INSendMessageIntentHandling, INSearchForMessag initializeAccountManagement() let accountManager = AccountManager(basePath: rootPath + "/accounts-metadata") - account = currentAccount(allocateIfNotExists: false, networkArguments: NetworkInitializationArguments(apiId: apiId, languagesCategory: languagesCategory, appVersion: appVersion, voipMaxLayer: 0, appData: BuildConfig.shared().bundleData), supplementary: true, manager: accountManager, rootPath: rootPath, auxiliaryMethods: accountAuxiliaryMethods) + account = currentAccount(allocateIfNotExists: false, networkArguments: NetworkInitializationArguments(apiId: apiId, languagesCategory: languagesCategory, appVersion: appVersion, voipMaxLayer: 0, appData: BuildConfig.shared().bundleData), supplementary: true, manager: accountManager, rootPath: rootPath, auxiliaryMethods: accountAuxiliaryMethods, encryptionKey: BuildConfig.encryptionKey(rootPath)) |> mapToSignal { account -> Signal in if let account = account { switch account { diff --git a/Telegram-iOS/AppDelegate.swift b/Telegram-iOS/AppDelegate.swift index 125df21817..34321da6ed 100644 --- a/Telegram-iOS/AppDelegate.swift +++ b/Telegram-iOS/AppDelegate.swift @@ -120,7 +120,7 @@ private enum QueuedWakeup: Int32 { case backgroundLocation } -private final class SharedApplicationContext { +final class SharedApplicationContext { let sharedContext: SharedAccountContext let notificationManager: SharedNotificationManager let wakeupManager: SharedWakeupManager @@ -372,6 +372,8 @@ private final class SharedApplicationContext { let rootPath = rootPathForBasePath(appGroupUrl.path) performAppGroupUpgrades(appGroupPath: appGroupUrl.path, rootPath: rootPath) + let encryptionKey = BuildConfig.encryptionKey(rootPath) + TempBox.initializeShared(basePath: rootPath, processType: "app", launchSpecificId: arc4random64()) let logsPath = rootPath + "/logs" @@ -571,131 +573,154 @@ private final class SharedApplicationContext { self.window?.rootViewController?.dismiss(animated: true, completion: nil) }) - // Move back to signal - let accountManager = AccountManager(basePath: rootPath + "/accounts-metadata") - let upgradeSemaphore = DispatchSemaphore(value: 0) - let _ = upgradedAccounts(accountManager: accountManager, rootPath: rootPath).start(completed: { - upgradeSemaphore.signal() - }) - upgradeSemaphore.wait() - - var initialPresentationDataAndSettings: InitialPresentationDataAndSettings? - let semaphore = DispatchSemaphore(value: 0) - let _ = currentPresentationDataAndSettings(accountManager: accountManager).start(next: { value in - initialPresentationDataAndSettings = value - semaphore.signal() - }) - semaphore.wait() - - let legacyBasePath = appGroupUrl.path - let legacyCache = LegacyCache(path: legacyBasePath + "/Caches") - - var setPresentationCall: ((PresentationCall?) -> Void)? - let sharedContext = SharedAccountContext(mainWindow: self.mainWindow, basePath: rootPath, accountManager: accountManager, applicationBindings: applicationBindings, initialPresentationDataAndSettings: initialPresentationDataAndSettings!, networkArguments: networkArguments, rootPath: rootPath, legacyBasePath: legacyBasePath, legacyCache: legacyCache, apsNotificationToken: self.notificationTokenPromise.get() |> map(Optional.init), voipNotificationToken: self.voipTokenPromise.get() |> map(Optional.init), setNotificationCall: { call in - setPresentationCall?(call) - }, navigateToChat: { accountId, peerId, messageId in - self.openChatWhenReady(accountId: accountId, peerId: peerId, messageId: messageId) - }) - - let rawAccounts = sharedContext.activeAccounts - |> map { _, accounts, _ -> [Account] in - return accounts.map({ $0.1 }) + let accountManagerSignal = Signal { subscriber in + let accountManager = AccountManager(basePath: rootPath + "/accounts-metadata") + return upgradedAccounts(accountManager: accountManager, rootPath: rootPath, encryptionKey: encryptionKey).start(completed: { + subscriber.putNext(accountManager) + subscriber.putCompletion() + }) + return EmptyDisposable } - let _ = (sharedAccountInfos(accountManager: sharedContext.accountManager, accounts: rawAccounts) - |> deliverOn(Queue())).start(next: { infos in - storeAccountsData(rootPath: rootPath, accounts: infos) - }) - sharedContext.presentGlobalController = { [weak self] c, a in - guard let strongSelf = self else { - return - } - strongSelf.mainWindow.present(c, on: .root) - } - sharedContext.presentCrossfadeController = { [weak self] in - guard let strongSelf = self else { - return - } - var exists = false - strongSelf.mainWindow.forEachViewController { controller in - if controller is ThemeSettingsCrossfadeController { - exists = true - } - return true + let sharedContextSignal = accountManagerSignal + |> deliverOnMainQueue + |> mapToSignal { accountManager -> Signal<(SharedApplicationContext, LoggingSettings), NoError> in + var initialPresentationDataAndSettings: InitialPresentationDataAndSettings? + let semaphore = DispatchSemaphore(value: 0) + let _ = currentPresentationDataAndSettings(accountManager: accountManager).start(next: { value in + initialPresentationDataAndSettings = value + semaphore.signal() + }) + semaphore.wait() + + if let initialPresentationDataAndSettings = initialPresentationDataAndSettings { + self.window?.backgroundColor = initialPresentationDataAndSettings.presentationData.theme.chatList.backgroundColor } - if !exists { - strongSelf.mainWindow.present(ThemeSettingsCrossfadeController(), on: .root) - } - } - - let notificationManager = SharedNotificationManager(episodeId: self.episodeId, application: application, clearNotificationsManager: clearNotificationsManager, inForeground: applicationBindings.applicationInForeground, accounts: sharedContext.activeAccounts |> map { primary, accounts, _ in accounts.map({ ($0.1, $0.1.id == primary?.id) }) }, pollLiveLocationOnce: { accountId in - let _ = (self.context.get() - |> filter { - return $0 != nil - } - |> take(1) - |> deliverOnMainQueue).start(next: { context in - if let context = context, context.context.account.id == accountId { - context.context.liveLocationManager?.pollOnce() + let legacyBasePath = appGroupUrl.path + let legacyCache = LegacyCache(path: legacyBasePath + "/Caches") + + var setPresentationCall: ((PresentationCall?) -> Void)? + let sharedContext = SharedAccountContext(mainWindow: self.mainWindow, basePath: rootPath, encryptionKey: encryptionKey, accountManager: accountManager, applicationBindings: applicationBindings, initialPresentationDataAndSettings: initialPresentationDataAndSettings!, networkArguments: networkArguments, rootPath: rootPath, legacyBasePath: legacyBasePath, legacyCache: legacyCache, apsNotificationToken: self.notificationTokenPromise.get() |> map(Optional.init), voipNotificationToken: self.voipTokenPromise.get() |> map(Optional.init), setNotificationCall: { call in + setPresentationCall?(call) + }, navigateToChat: { accountId, peerId, messageId in + self.openChatWhenReady(accountId: accountId, peerId: peerId, messageId: messageId) + }, displayUpgradeProgress: { progress in + if let progress = progress { + if self.dataImportSplash == nil { + self.dataImportSplash = LegacyDataImportSplash(theme: initialPresentationDataAndSettings?.presentationData.theme, strings: initialPresentationDataAndSettings?.presentationData.strings) + self.mainWindow.coveringView = self.dataImportSplash + } + self.dataImportSplash?.progress = (.generic, progress) + } else if let dataImportSplash = self.dataImportSplash { + self.dataImportSplash = nil + if self.mainWindow.coveringView === dataImportSplash { + self.mainWindow.coveringView = nil + } } }) - }) - setPresentationCall = { call in - notificationManager.setNotificationCall(call, strings: sharedContext.currentPresentationData.with({ $0 }).strings) - } - let liveLocationPolling = self.context.get() - |> mapToSignal { context -> Signal in - if let context = context, let liveLocationManager = context.context.liveLocationManager { - let accountId = context.context.account.id - return liveLocationManager.isPolling - |> distinctUntilChanged - |> map { value -> AccountRecordId? in - if value { - return accountId - } else { - return nil - } + + let rawAccounts = sharedContext.activeAccounts + |> map { _, accounts, _ -> [Account] in + return accounts.map({ $0.1 }) + } + let _ = (sharedAccountInfos(accountManager: sharedContext.accountManager, accounts: rawAccounts) + |> deliverOn(Queue())).start(next: { infos in + storeAccountsData(rootPath: rootPath, accounts: infos) + }) + + sharedContext.presentGlobalController = { [weak self] c, a in + guard let strongSelf = self else { + return } - } else { - return .single(nil) + strongSelf.mainWindow.present(c, on: .root) + } + sharedContext.presentCrossfadeController = { [weak self] in + guard let strongSelf = self else { + return + } + var exists = false + strongSelf.mainWindow.forEachViewController { controller in + if controller is ThemeSettingsCrossfadeController { + exists = true + } + return true + } + + if !exists { + strongSelf.mainWindow.present(ThemeSettingsCrossfadeController(), on: .root) + } + } + + let notificationManager = SharedNotificationManager(episodeId: self.episodeId, application: application, clearNotificationsManager: clearNotificationsManager, inForeground: applicationBindings.applicationInForeground, accounts: sharedContext.activeAccounts |> map { primary, accounts, _ in accounts.map({ ($0.1, $0.1.id == primary?.id) }) }, pollLiveLocationOnce: { accountId in + let _ = (self.context.get() + |> filter { + return $0 != nil + } + |> take(1) + |> deliverOnMainQueue).start(next: { context in + if let context = context, context.context.account.id == accountId { + context.context.liveLocationManager?.pollOnce() + } + }) + }) + setPresentationCall = { call in + notificationManager.setNotificationCall(call, strings: sharedContext.currentPresentationData.with({ $0 }).strings) + } + let liveLocationPolling = self.context.get() + |> mapToSignal { context -> Signal in + if let context = context, let liveLocationManager = context.context.liveLocationManager { + let accountId = context.context.account.id + return liveLocationManager.isPolling + |> distinctUntilChanged + |> map { value -> AccountRecordId? in + if value { + return accountId + } else { + return nil + } + } + } else { + return .single(nil) + } + } + let watchTasks = self.context.get() + |> mapToSignal { context -> Signal in + if let context = context, let watchManager = context.context.watchManager { + let accountId = context.context.account.id + let runningTasks: Signal = .single(nil) + |> then(watchManager.runningTasks) + return runningTasks + |> distinctUntilChanged + |> map { value -> AccountRecordId? in + if let value = value, value.running { + return accountId + } else { + return nil + } + } + |> distinctUntilChanged + } else { + return .single(nil) + } + } + let wakeupManager = SharedWakeupManager(beginBackgroundTask: { name, expiration in application.beginBackgroundTask(withName: name, expirationHandler: expiration) }, endBackgroundTask: { id in application.endBackgroundTask(id) }, backgroundTimeRemaining: { application.backgroundTimeRemaining }, activeAccounts: sharedContext.activeAccounts |> map { ($0.0, $0.1.map { ($0.0, $0.1) }) }, liveLocationPolling: liveLocationPolling, watchTasks: watchTasks, inForeground: applicationBindings.applicationInForeground, hasActiveAudioSession: self.hasActiveAudioSession.get(), notificationManager: notificationManager, mediaManager: sharedContext.mediaManager, callManager: sharedContext.callManager, accountUserInterfaceInUse: { id in + return sharedContext.accountUserInterfaceInUse(id) + }) + let sharedApplicationContext = SharedApplicationContext(sharedContext: sharedContext, notificationManager: notificationManager, wakeupManager: wakeupManager) + sharedApplicationContext.sharedContext.mediaManager.overlayMediaManager.attachOverlayMediaController(sharedApplicationContext.overlayMediaController) + + return accountManager.transaction { transaction -> (SharedApplicationContext, LoggingSettings) in + return (sharedApplicationContext, transaction.getSharedData(SharedDataKeys.loggingSettings) as? LoggingSettings ?? LoggingSettings.defaultSettings) } } - let watchTasks = self.context.get() - |> mapToSignal { context -> Signal in - if let context = context, let watchManager = context.context.watchManager { - let accountId = context.context.account.id - let runningTasks: Signal = .single(nil) - |> then(watchManager.runningTasks) - return runningTasks - |> distinctUntilChanged - |> map { value -> AccountRecordId? in - if let value = value, value.running { - return accountId - } else { - return nil - } - } - |> distinctUntilChanged - } else { - return .single(nil) - } - } - let wakeupManager = SharedWakeupManager(beginBackgroundTask: { name, expiration in application.beginBackgroundTask(withName: name, expirationHandler: expiration) }, endBackgroundTask: { id in application.endBackgroundTask(id) }, backgroundTimeRemaining: { application.backgroundTimeRemaining }, activeAccounts: sharedContext.activeAccounts |> map { ($0.0, $0.1.map { ($0.0, $0.1) }) }, liveLocationPolling: liveLocationPolling, watchTasks: watchTasks, inForeground: applicationBindings.applicationInForeground, hasActiveAudioSession: hasActiveAudioSession.get(), notificationManager: notificationManager, mediaManager: sharedContext.mediaManager, callManager: sharedContext.callManager, accountUserInterfaceInUse: { id in - return sharedContext.accountUserInterfaceInUse(id) - }) - let sharedApplicationContext = SharedApplicationContext(sharedContext: sharedContext, notificationManager: notificationManager, wakeupManager: wakeupManager) - sharedApplicationContext.sharedContext.mediaManager.overlayMediaManager.attachOverlayMediaController(sharedApplicationContext.overlayMediaController) - self.sharedContextPromise.set( - accountManager.transaction { transaction -> (SharedApplicationContext, LoggingSettings) in - return (sharedApplicationContext, transaction.getSharedData(SharedDataKeys.loggingSettings) as? LoggingSettings ?? LoggingSettings.defaultSettings) - } + self.sharedContextPromise.set(sharedContextSignal |> mapToSignal { sharedApplicationContext, loggingSettings -> Signal in Logger.shared.logToFile = loggingSettings.logToFile Logger.shared.logToConsole = loggingSettings.logToConsole Logger.shared.redactSensitiveData = loggingSettings.redactSensitiveData - return importedLegacyAccount(basePath: appGroupUrl.path, accountManager: sharedApplicationContext.sharedContext.accountManager, present: { controller in + return importedLegacyAccount(basePath: appGroupUrl.path, accountManager: sharedApplicationContext.sharedContext.accountManager, encryptionKey: encryptionKey, present: { controller in self.window?.rootViewController?.present(controller, animated: true, completion: nil) }) |> `catch` { _ -> Signal in @@ -720,7 +745,7 @@ private final class SharedApplicationContext { case let .progress(type, value): Queue.mainQueue().async { if self.dataImportSplash == nil { - self.dataImportSplash = LegacyDataImportSplash() + self.dataImportSplash = LegacyDataImportSplash(theme: nil, strings: nil) self.dataImportSplash?.serviceAction = { self.debugPressed() } @@ -793,7 +818,7 @@ private final class SharedApplicationContext { |> map { accountAndSettings -> AuthorizedApplicationContext? in return accountAndSettings.flatMap { account, limitsConfiguration, callListSettings in let context = AccountContext(sharedContext: sharedApplicationContext.sharedContext, account: account, limitsConfiguration: limitsConfiguration) - return AuthorizedApplicationContext(mainWindow: self.mainWindow, watchManagerArguments: watchManagerArgumentsPromise.get(), context: context, accountManager: sharedApplicationContext.sharedContext.accountManager, showCallsTab: callListSettings.showTab, reinitializedNotificationSettings: { + return AuthorizedApplicationContext(sharedApplicationContext: sharedApplicationContext, mainWindow: self.mainWindow, watchManagerArguments: watchManagerArgumentsPromise.get(), context: context, accountManager: sharedApplicationContext.sharedContext.accountManager, showCallsTab: callListSettings.showTab, reinitializedNotificationSettings: { let _ = (self.context.get() |> take(1) |> deliverOnMainQueue).start(next: { context in @@ -932,7 +957,7 @@ private final class SharedApplicationContext { } return true }) - self.mainWindow.topLevelOverlayControllers = [sharedApplicationContext.overlayMediaController, context.notificationController] + self.mainWindow.topLevelOverlayControllers = [context.sharedApplicationContext.overlayMediaController, context.notificationController] var authorizeNotifications = true if #available(iOS 10.0, *) { authorizeNotifications = false @@ -979,7 +1004,10 @@ private final class SharedApplicationContext { })) self.watchCommunicationManagerPromise.set(watchCommunicationManager(context: self.context, allowBackgroundTimeExtension: { timeout in - wakeupManager.allowBackgroundTimeExtension(timeout: timeout) + let _ = (self.sharedContextPromise.get() + |> take(1)).start(next: { sharedContext in + sharedContext.wakeupManager.allowBackgroundTimeExtension(timeout: timeout) + }) })) let _ = self.watchCommunicationManagerPromise.get().start(next: { manager in if let manager = manager { @@ -1059,8 +1087,10 @@ private final class SharedApplicationContext { } })) } - let presentationData = sharedContext.currentPresentationData.with { $0 } - strongSelf.mainWindow.present(standardTextAlertController(theme: AlertControllerTheme(presentationTheme: presentationData.theme), title: alert.title, text: alert.message ?? "", actions: actions), on: .root) + if let sharedContext = strongSelf.contextValue?.context.sharedContext { + let presentationData = sharedContext.currentPresentationData.with { $0 } + strongSelf.mainWindow.present(standardTextAlertController(theme: AlertControllerTheme(presentationTheme: presentationData.theme), title: alert.title, text: alert.message ?? "", actions: actions), on: .root) + } } }) diff --git a/Telegram-iOS/ApplicationContext.swift b/Telegram-iOS/ApplicationContext.swift index 16f24bdfb4..38904b5c90 100644 --- a/Telegram-iOS/ApplicationContext.swift +++ b/Telegram-iOS/ApplicationContext.swift @@ -46,6 +46,7 @@ private struct PasscodeState: Equatable { } final class AuthorizedApplicationContext { + let sharedApplicationContext: SharedApplicationContext let mainWindow: Window1 let lockedCoveringView: LockedWindowCoveringView @@ -99,7 +100,9 @@ final class AuthorizedApplicationContext { private var showCallsTabDisposable: Disposable? private var enablePostboxTransactionsDiposable: Disposable? - init(mainWindow: Window1, watchManagerArguments: Signal, context: AccountContext, accountManager: AccountManager, showCallsTab: Bool, reinitializedNotificationSettings: @escaping () -> Void) { + init(sharedApplicationContext: SharedApplicationContext, mainWindow: Window1, watchManagerArguments: Signal, context: AccountContext, accountManager: AccountManager, showCallsTab: Bool, reinitializedNotificationSettings: @escaping () -> Void) { + self.sharedApplicationContext = sharedApplicationContext + setupLegacyComponents(context: context) let presentationData = context.sharedContext.currentPresentationData.with { $0 } @@ -121,6 +124,9 @@ final class AuthorizedApplicationContext { if KeyShortcutsController.isAvailable { let keyShortcutsController = KeyShortcutsController { [weak self] f in if let strongSelf = self { + if strongSelf.isLocked { + return + } if let tabController = strongSelf.rootController.rootTabController { let controller = tabController.controllers[tabController.selectedIndex] if !f(controller) { @@ -695,10 +701,20 @@ final class AuthorizedApplicationContext { self.displayAlertsDisposable = (context.account.stateManager.displayAlerts |> deliverOnMainQueue).start(next: { [weak self] alerts in - if let strongSelf = self{ - for text in alerts { + if let strongSelf = self { + for (text, isDropAuth) in alerts { let presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 } - let controller = textAlertController(context: strongSelf.context, title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]) + let actions: [TextAlertAction] + if isDropAuth { + actions = [TextAlertAction(type: .genericAction, title: presentationData.strings.Common_Cancel, action: {}), TextAlertAction(type: .genericAction, title: presentationData.strings.LogoutOptions_LogOut, action: { + if let strongSelf = self { + let _ = logoutFromAccount(id: strongSelf.context.account.id, accountManager: strongSelf.context.sharedContext.accountManager).start() + } + })] + } else { + actions = [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})] + } + let controller = textAlertController(context: strongSelf.context, title: nil, text: text, actions: actions) (strongSelf.rootController.viewControllers.last as? ViewController)?.present(controller, in: .window(.root)) } } diff --git a/Telegram-iOS/BuildConfig.h b/Telegram-iOS/BuildConfig.h index 09863f7b4d..f0e898e28a 100644 --- a/Telegram-iOS/BuildConfig.h +++ b/Telegram-iOS/BuildConfig.h @@ -13,4 +13,6 @@ @property (nonatomic, readonly) int64_t appStoreId; @property (nonatomic, strong, readonly) NSString * _Nonnull appSpecificUrlScheme; ++ (NSData * _Nonnull)encryptionKey:(NSString * _Nonnull)rootPath; + @end diff --git a/Telegram-iOS/BuildConfig.m b/Telegram-iOS/BuildConfig.m index dee236810a..08b5d8102a 100644 --- a/Telegram-iOS/BuildConfig.m +++ b/Telegram-iOS/BuildConfig.m @@ -382,4 +382,17 @@ static MTPKCS * _Nullable checkSignature(const char *filename) { return @(APP_SPECIFIC_URL_SCHEME); } ++ (NSData * _Nonnull)encryptionKey:(NSString * _Nonnull)rootPath { + NSString *filePath = [rootPath stringByAppendingPathComponent:@".tempkey"]; + NSData *data = [NSData dataWithContentsOfFile:filePath]; + if (data != nil) { + return data; + } + NSMutableData *randomData = [[NSMutableData alloc] initWithLength:32]; + int result = SecRandomCopyBytes(kSecRandomDefault, randomData.length, [randomData mutableBytes]); + assert(result == 0); + [randomData writeToFile:filePath atomically:false]; + return randomData; +} + @end diff --git a/Telegram-iOS/Info.plist b/Telegram-iOS/Info.plist index 64bcb6a6e0..4d9d9b0fb5 100644 --- a/Telegram-iOS/Info.plist +++ b/Telegram-iOS/Info.plist @@ -19,7 +19,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 5.5 + 5.5.1 CFBundleSignature ???? CFBundleURLTypes diff --git a/Telegram-iOS/LegacyDataImport.swift b/Telegram-iOS/LegacyDataImport.swift index 62c8f60c90..8086706845 100644 --- a/Telegram-iOS/LegacyDataImport.swift +++ b/Telegram-iOS/LegacyDataImport.swift @@ -106,7 +106,7 @@ enum ImportedLegacyAccountEvent { case result(AccountRecordId?) } -func importedLegacyAccount(basePath: String, accountManager: AccountManager, present: @escaping (UIViewController) -> Void) -> Signal { +func importedLegacyAccount(basePath: String, accountManager: AccountManager, encryptionKey: Data, present: @escaping (UIViewController) -> Void) -> Signal { let queue = Queue() return deferred { () -> Signal in let documentsPath = basePath + "/Documents" @@ -218,7 +218,7 @@ func importedLegacyAccount(basePath: String, accountManager: AccountManager, pre } } - return temporaryAccount(manager: accountManager, rootPath: rootPathForBasePath(basePath)) + return temporaryAccount(manager: accountManager, rootPath: rootPathForBasePath(basePath), encryptionKey: encryptionKey) |> introduceError(AccountImportError.self) |> mapToSignal { account -> Signal in let actions = importedAccountData(basePath: basePath, documentsPath: documentsPath, accountManager: accountManager, account: account, database: database) diff --git a/Telegram-iOS/LegacyDataImportSplash.swift b/Telegram-iOS/LegacyDataImportSplash.swift index 0cf3713817..4db218b648 100644 --- a/Telegram-iOS/LegacyDataImportSplash.swift +++ b/Telegram-iOS/LegacyDataImportSplash.swift @@ -4,22 +4,25 @@ import AsyncDisplayKit import TelegramUI final class LegacyDataImportSplash: WindowCoveringView { + private let theme: PresentationTheme? + private let strings: PresentationStrings? + var progress: (AccountImportProgressType, Float) = (.generic, 0.0) { didSet { if self.progress.0 != oldValue.0 { if let size = self.validSize { switch self.progress.0 { case .generic: - self.textNode.attributedText = NSAttributedString(string: "Optimizing", font: Font.regular(17.0), textColor: .black) + self.textNode.attributedText = NSAttributedString(string: self.strings?.DataUpgrade_Running ?? "Optimizing...", font: Font.regular(17.0), textColor: self.theme?.list.itemPrimaryTextColor ?? .black) case .media: - self.textNode.attributedText = NSAttributedString(string: "Optimizing cache", font: Font.regular(17.0), textColor: .black) + self.textNode.attributedText = NSAttributedString(string: "Optimizing cache", font: Font.regular(17.0), textColor: self.theme?.list.itemPrimaryTextColor ?? .black) case .messages: - self.textNode.attributedText = NSAttributedString(string: "Optimizing database", font: Font.regular(17.0), textColor: .black) + self.textNode.attributedText = NSAttributedString(string: "Optimizing database", font: Font.regular(17.0), textColor: self.theme?.list.itemPrimaryTextColor ?? .black) } self.updateLayout(size) } } - self.progressNode.transitionToState(.progress(color: UIColor(rgb: 0x007ee5), lineWidth: 2.0, value: CGFloat(max(0.025, self.progress.1)), cancelEnabled: false), animated: false, completion: {}) + self.progressNode.transitionToState(.progress(color: self.theme?.list.itemAccentColor ?? UIColor(rgb: 0x007ee5), lineWidth: 2.0, value: CGFloat(max(0.025, self.progress.1)), cancelEnabled: false), animated: false, completion: {}) } } @@ -30,12 +33,17 @@ final class LegacyDataImportSplash: WindowCoveringView { private var validSize: CGSize? - override init(frame: CGRect) { - self.progressNode = RadialStatusNode(backgroundNodeColor: UIColor.white) - self.textNode = ImmediateTextNode() - self.textNode.attributedText = NSAttributedString(string: "Optimizing", font: Font.regular(17.0), textColor: .black) + init(theme: PresentationTheme?, strings: PresentationStrings?) { + self.theme = theme + self.strings = strings - super.init(frame: frame) + self.progressNode = RadialStatusNode(backgroundNodeColor: theme?.list.plainBackgroundColor ?? .white) + self.textNode = ImmediateTextNode() + self.textNode.attributedText = NSAttributedString(string: self.strings?.DataUpgrade_Running ?? "Optimizing...", font: Font.regular(17.0), textColor: self.theme?.list.itemPrimaryTextColor ?? .black) + + super.init(frame: CGRect()) + + self.backgroundColor = self.theme?.list.plainBackgroundColor ?? .white self.addSubnode(self.progressNode) self.progressNode.isUserInteractionEnabled = false diff --git a/Telegram-iOS/SharedNotificationManager.swift b/Telegram-iOS/SharedNotificationManager.swift index b855d7d78e..b18cd81d58 100644 --- a/Telegram-iOS/SharedNotificationManager.swift +++ b/Telegram-iOS/SharedNotificationManager.swift @@ -198,6 +198,7 @@ final class SharedNotificationManager { let aps = payload["aps"] as? [AnyHashable: Any] var readMessageId: MessageId? + var removedMessageId: MessageId? var isCall = false var isAnnouncement = false var isLocationPolling = false diff --git a/Telegram-iOS/en.lproj/Localizable.strings b/Telegram-iOS/en.lproj/Localizable.strings index 34f68766fb..9157db2e40 100644 --- a/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram-iOS/en.lproj/Localizable.strings @@ -3926,8 +3926,9 @@ Unused sets are archived when you add more."; "ChatList.DeleteSavedMessagesConfirmation" = "Are you sure you want to delete\nSaved Messages?"; "Undo.Undo" = "Undo"; -"Undo.MessagesDeleted" = "Messages deleted"; "Undo.ChatDeleted" = "Chat deleted"; +"Undo.ChatCleared" = "Chat cleared"; +"Undo.ChatClearedForBothSides" = "Chat cleared for both sides"; "Undo.SecretChatDeleted" = "Secret Chat deleted"; "Undo.LeftChannel" = "Left channel"; "Undo.LeftGroup" = "Left group"; @@ -4195,3 +4196,12 @@ Unused sets are archived when you add more."; "ChatList.DeleteForEveryone" = "Delete for me and %@"; "ChatList.ClearChatConfirmation" = "Are you sure you want to delete all\nmessages in the chat with %@?"; + +"Settings.CheckPhoneNumberTitle" = "Is %@ still your number?"; +"Settings.CheckPhoneNumberText" = "Keep your number up to date to ensure you can always log in to Telegram. [Learn more]()"; +"Settings.KeepPhoneNumber" = "Keep %@"; +"Settings.ChangePhoneNumber" = "Change Number"; + +"Undo.ChatDeletedForBothSides" = "Chat deleted for both sides"; + +"DataUpgrade.Running" = "Optimizing..."; diff --git a/Watch/App/Info.plist b/Watch/App/Info.plist index f6b63768b0..b40b6bd78f 100644 --- a/Watch/App/Info.plist +++ b/Watch/App/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 5.5 + 5.5.1 CFBundleVersion ${BUILD_NUMBER} UISupportedInterfaceOrientations diff --git a/Watch/Extension/Info.plist b/Watch/Extension/Info.plist index cff3e8511b..251de38f75 100644 --- a/Watch/Extension/Info.plist +++ b/Watch/Extension/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType XPC! CFBundleShortVersionString - 5.5 + 5.5.1 CFBundleVersion ${BUILD_NUMBER} NSExtension diff --git a/Widget/Info.plist b/Widget/Info.plist index 2eff403b88..e2c70d7d60 100644 --- a/Widget/Info.plist +++ b/Widget/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType XPC! CFBundleShortVersionString - 5.5 + 5.5.1 CFBundleVersion ${BUILD_NUMBER} NSExtension diff --git a/Widget/TodayViewController.swift b/Widget/TodayViewController.swift index f6c7770a6b..c701a44b70 100644 --- a/Widget/TodayViewController.swift +++ b/Widget/TodayViewController.swift @@ -78,7 +78,7 @@ class TodayViewController: UIViewController, NCWidgetProviding { let appVersion = (Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String) ?? "unknown" initializeAccountManagement() let accountManager = AccountManager(basePath: rootPath + "/accounts-metadata") - account = currentAccount(allocateIfNotExists: false, networkArguments: NetworkInitializationArguments(apiId: apiId, languagesCategory: languagesCategory, appVersion: appVersion, voipMaxLayer: 0, appData: BuildConfig.shared().bundleData), supplementary: true, manager: accountManager, rootPath: rootPath, auxiliaryMethods: auxiliaryMethods) + account = currentAccount(allocateIfNotExists: false, networkArguments: NetworkInitializationArguments(apiId: apiId, languagesCategory: languagesCategory, appVersion: appVersion, voipMaxLayer: 0, appData: BuildConfig.shared().bundleData), supplementary: true, manager: accountManager, rootPath: rootPath, auxiliaryMethods: auxiliaryMethods, encryptionKey: BuildConfig.encryptionKey(rootPath)) |> mapToSignal { account -> Signal in if let account = account { switch account { diff --git a/buildbox/.gitignore b/buildbox/.gitignore new file mode 100644 index 0000000000..9387f5c0d1 --- /dev/null +++ b/buildbox/.gitignore @@ -0,0 +1,2 @@ +transient-data + diff --git a/buildbox/build-telegram.sh b/buildbox/build-telegram.sh new file mode 100644 index 0000000000..f704e244f0 --- /dev/null +++ b/buildbox/build-telegram.sh @@ -0,0 +1,91 @@ +#!/bin/sh + +set -e + +BUILD_TELEGRAM_VERSION="1" + +if [ `which cleanup-telegram-build-vms.sh` ]; then + cleanup-telegram-build-vms.sh +fi + +BUILDBOX_DIR="buildbox" + +mkdir -p "$BUILDBOX_DIR/transient-data" + +BUILD_CONFIGURATION="$1" + +if [ "$BUILD_CONFIGURATION" == "hockeyapp" ]; then + CODESIGNING_SUBPATH="transient-data/codesigning" +elif [ "$BUILD_CONFIGURATION" == "appstore" ]; then + CODESIGNING_SUBPATH="transient-data/codesigning" +elif [ "$BUILD_CONFIGURATION" == "verify" ]; then + CODESIGNING_SUBPATH="fake-codesigning" +else + echo "Unknown configuration $1" + exit 1 +fi + +BASE_DIR=$(pwd) + +if [ "$BUILD_CONFIGURATION" == "hockeyapp" ] || [ "$BUILD_CONFIGURATION" == "appstore" ]; then + if [ ! `which setup-telegram-build.sh` ]; then + echo "setup-telegram-build.sh not found in PATH $PATH" + exit 1 + fi + source `which setup-telegram-build.sh` + setup_telegram_build "$BUILD_CONFIGURATION" "$BASE_DIR/$BUILDBOX_DIR/transient-data" + if [ "$SETUP_TELEGRAM_BUILD_VERSION" != "$BUILD_TELEGRAM_VERSION" ]; then + echo "setup-telegram-build.sh script version doesn't match" + exit 1 + fi + if [ "$BUILD_CONFIGURATION" == "appstore" ]; then + if [ -z "$TELEGRAM_BUILD_APPSTORE_PASSWORD" ]; then + echo "TELEGRAM_BUILD_APPSTORE_PASSWORD is not set" + exit 1 + fi + fi +fi + +if [ ! -d "$BUILDBOX_DIR/$CODESIGNING_SUBPATH" ]; then + echo "$BUILDBOX_DIR/$CODESIGNING_SUBPATH does not exist" + exit 1 +fi + +SOURCE_DIR=$(basename "$BASE_DIR") +cd .. +rm -f "$SOURCE_DIR/$BUILDBOX_DIR/transient-data/source.tar" +tar cf "$SOURCE_DIR/$BUILDBOX_DIR/transient-data/source.tar" --exclude "$SOURCE_DIR/$BUILDBOX_DIR" "$SOURCE_DIR" +cd "$BASE_DIR" + +VM_BASE_NAME="macos10_14_3_Xcode10_1" + +SNAPSHOT_ID=$(prlctl snapshot-list "$VM_BASE_NAME" | grep -Eo '\{(\d|[a-f]|-)*\}' | tr '\n' '\0') + +if [ -z "$SNAPSHOT_ID" ]; then + echo "$VM_BASE_NAME is required to have one snapshot" + exit 1 +fi + +PROCESS_ID="$$" +VM_NAME="$VM_BASE_NAME-$(openssl rand -hex 10)-build-telegram-$PROCESS_ID" + +prlctl clone "$VM_BASE_NAME" --name "$VM_NAME" +prlctl snapshot-switch "$VM_NAME" -i "$SNAPSHOT_ID" + +VM_IP=$(prlctl exec "$VM_NAME" "ifconfig | grep inet | grep broadcast | grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}' | head -1 | tr '\n' '\0'") + +scp -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -pr "$BUILDBOX_DIR/$CODESIGNING_SUBPATH" telegram@"$VM_IP":codesigning_data + +if [ "$BUILD_CONFIGURATION" == "verify" ]; then + scp -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -pr "$BUILDBOX_DIR/fake-shared" telegram@"$VM_IP":telegram-ios-shared +else + scp -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -pr "$BUILDBOX_DIR/transient-data/telegram-ios-shared" telegram@"$VM_IP":telegram-ios-shared +fi +scp -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -pr "$BUILDBOX_DIR/guest-build-telegram.sh" "$BUILDBOX_DIR/transient-data/source.tar" telegram@"$VM_IP": + +ssh -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null telegram@"$VM_IP" -o ServerAliveInterval=60 -t "export TELEGRAM_BUILD_APPSTORE_PASSWORD=$TELEGRAM_BUILD_APPSTORE_PASSWORD; bash -l guest-build-telegram.sh $BUILD_CONFIGURATION" + +scp -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -pr telegram@"$VM_IP":telegram-ios/Telegram-iOS-AppStoreLLC.ipa ./ + +prlctl stop "$VM_NAME" --kill +prlctl delete "$VM_NAME" diff --git a/buildbox/fake-codesigning/certs/SelfSigned.p12 b/buildbox/fake-codesigning/certs/SelfSigned.p12 new file mode 100644 index 0000000000..aa2097875b Binary files /dev/null and b/buildbox/fake-codesigning/certs/SelfSigned.p12 differ diff --git a/buildbox/fake-codesigning/profiles/self_17a6dde8-0db2-42b4-9215-d8544da24da1.mobileprovision b/buildbox/fake-codesigning/profiles/self_17a6dde8-0db2-42b4-9215-d8544da24da1.mobileprovision new file mode 100644 index 0000000000..1aa18b4714 Binary files /dev/null and b/buildbox/fake-codesigning/profiles/self_17a6dde8-0db2-42b4-9215-d8544da24da1.mobileprovision differ diff --git a/buildbox/fake-codesigning/profiles/self_38e2d395-3b03-4327-b13e-5a81d77a417f.mobileprovision b/buildbox/fake-codesigning/profiles/self_38e2d395-3b03-4327-b13e-5a81d77a417f.mobileprovision new file mode 100644 index 0000000000..fd919b2eaf Binary files /dev/null and b/buildbox/fake-codesigning/profiles/self_38e2d395-3b03-4327-b13e-5a81d77a417f.mobileprovision differ diff --git a/buildbox/fake-codesigning/profiles/self_66d9e1ed-89b0-43a9-81dc-c5db42768deb.mobileprovision b/buildbox/fake-codesigning/profiles/self_66d9e1ed-89b0-43a9-81dc-c5db42768deb.mobileprovision new file mode 100644 index 0000000000..9c07924826 Binary files /dev/null and b/buildbox/fake-codesigning/profiles/self_66d9e1ed-89b0-43a9-81dc-c5db42768deb.mobileprovision differ diff --git a/buildbox/fake-codesigning/profiles/self_a064880e-5214-4456-96f3-3beab43c8a49.mobileprovision b/buildbox/fake-codesigning/profiles/self_a064880e-5214-4456-96f3-3beab43c8a49.mobileprovision new file mode 100644 index 0000000000..e51dbf5f7a Binary files /dev/null and b/buildbox/fake-codesigning/profiles/self_a064880e-5214-4456-96f3-3beab43c8a49.mobileprovision differ diff --git a/buildbox/fake-codesigning/profiles/self_c7ce0e4f-4a34-4f37-9bdf-d93d7e67f935.mobileprovision b/buildbox/fake-codesigning/profiles/self_c7ce0e4f-4a34-4f37-9bdf-d93d7e67f935.mobileprovision new file mode 100644 index 0000000000..6fbbd2bde9 Binary files /dev/null and b/buildbox/fake-codesigning/profiles/self_c7ce0e4f-4a34-4f37-9bdf-d93d7e67f935.mobileprovision differ diff --git a/buildbox/fake-codesigning/profiles/self_d5420e53-0e9a-4745-ab22-1dc7f0f8f0e6.mobileprovision b/buildbox/fake-codesigning/profiles/self_d5420e53-0e9a-4745-ab22-1dc7f0f8f0e6.mobileprovision new file mode 100644 index 0000000000..86b7d0a3f8 Binary files /dev/null and b/buildbox/fake-codesigning/profiles/self_d5420e53-0e9a-4745-ab22-1dc7f0f8f0e6.mobileprovision differ diff --git a/buildbox/fake-codesigning/profiles/self_f5d6daf2-b88a-4de9-846a-bc207ea9b8dd.mobileprovision b/buildbox/fake-codesigning/profiles/self_f5d6daf2-b88a-4de9-846a-bc207ea9b8dd.mobileprovision new file mode 100644 index 0000000000..ffa8bb22b6 Binary files /dev/null and b/buildbox/fake-codesigning/profiles/self_f5d6daf2-b88a-4de9-846a-bc207ea9b8dd.mobileprovision differ diff --git a/buildbox/fake-codesigning/profiles/self_fd2bced7-6353-4f44-8022-979f48e73c04.mobileprovision b/buildbox/fake-codesigning/profiles/self_fd2bced7-6353-4f44-8022-979f48e73c04.mobileprovision new file mode 100644 index 0000000000..e2e7954016 Binary files /dev/null and b/buildbox/fake-codesigning/profiles/self_fd2bced7-6353-4f44-8022-979f48e73c04.mobileprovision differ diff --git a/buildbox/fake-shared/Config/AppStoreLLC/Config.xcconfig b/buildbox/fake-shared/Config/AppStoreLLC/Config.xcconfig new file mode 100644 index 0000000000..d381ccc3d0 --- /dev/null +++ b/buildbox/fake-shared/Config/AppStoreLLC/Config.xcconfig @@ -0,0 +1,8 @@ +APP_NAME=Telegram +APP_BUNDLE_ID=ph.telegra.Telegraph +APP_SPECIFIC_URL_SCHEME=tgapp + +GLOBAL_CONSTANTS = APP_CONFIG_IS_INTERNAL_BUILD=false APP_CONFIG_IS_APPSTORE_BUILD=true APP_CONFIG_APPSTORE_ID=686449807 APP_SPECIFIC_URL_SCHEME="\"$(APP_SPECIFIC_URL_SCHEME)\"" +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) $(GLOBAL_CONSTANTS) + +#include "Data.xcconfig" diff --git a/buildbox/fake-shared/Config/AppStoreLLC/Data.xcconfig b/buildbox/fake-shared/Config/AppStoreLLC/Data.xcconfig new file mode 100644 index 0000000000..935e871569 --- /dev/null +++ b/buildbox/fake-shared/Config/AppStoreLLC/Data.xcconfig @@ -0,0 +1 @@ +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) APP_CONFIG_DATA="\"\"" \ No newline at end of file diff --git a/buildbox/fake-shared/fastlane/Fastfile b/buildbox/fake-shared/fastlane/Fastfile new file mode 100644 index 0000000000..e69de29bb2 diff --git a/buildbox/guest-build-telegram.sh b/buildbox/guest-build-telegram.sh new file mode 100644 index 0000000000..fc4f1c31fc --- /dev/null +++ b/buildbox/guest-build-telegram.sh @@ -0,0 +1,52 @@ +#!/bin/sh + +if [ "$1" == "hockeyapp" ]; then + FASTLANE_BUILD_CONFIGURATION="internalhockeyapp" +elif [ "$1" == "appstore" ]; then + FASTLANE_BUILD_CONFIGURATION="testflight_llc" + if [ -z "$TELEGRAM_BUILD_APPSTORE_PASSWORD" ]; then + echo "TELEGRAM_BUILD_APPSTORE_PASSWORD is not set" + exit 1 + fi + FASTLANE_PASSWORD="$TELEGRAM_BUILD_APPSTORE_PASSWORD" +elif [ "$1" == "verify" ]; then + FASTLANE_BUILD_CONFIGURATION="build_for_appstore" +else + echo "Unknown configuration $1" + exit 1 +fi + +MY_KEYCHAIN="temp.keychain" +MY_KEYCHAIN_PASSWORD="secret" + +security create-keychain -p "$MY_KEYCHAIN_PASSWORD" "$MY_KEYCHAIN" +security list-keychains -d user -s "$MY_KEYCHAIN" $(security list-keychains -d user | sed s/\"//g) +security set-keychain-settings "$MY_KEYCHAIN" +security unlock-keychain -p "$MY_KEYCHAIN_PASSWORD" "$MY_KEYCHAIN" + +CERTS_PATH="codesigning_data/certs" +for f in $(ls "$CERTS_PATH"); do + fastlane run import_certificate "certificate_path:$CERTS_PATH/$f" keychain_name:"$MY_KEYCHAIN" keychain_password:"$MY_KEYCHAIN_PASSWORD" log_output:true +done + +mkdir -p "$HOME/Library/MobileDevice/Provisioning Profiles" + +PROFILES_PATH="codesigning_data/profiles" +for f in $(ls "$PROFILES_PATH"); do + PROFILE_PATH="$PROFILES_PATH/$f" + uuid=`grep UUID -A1 -a "$PROFILE_PATH" | grep -io "[-A-F0-9]\{36\}"` + cp "$PROFILE_PATH" "$HOME/Library/MobileDevice/Provisioning Profiles/$uuid.mobileprovision" +done + +SOURCE_PATH="telegram-ios" + +if [ -d "$SOURCE_PATH" ]; then + echo "$SOURCE_PATH must not exist" + exit 1 +fi + +echo "Unpacking files..." +tar -xf "source.tar" + +cd "$SOURCE_PATH" +FASTLANE_PASSWORD="$FASTLANE_PASSWORD" fastlane "$FASTLANE_BUILD_CONFIGURATION" diff --git a/fastlane/Fastfile b/fastlane/Fastfile index f75068ddbd..f8d9f1f6fa 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -13,6 +13,7 @@ app_identifier_llc = [ base_app_identifier_llc + ".watchkitapp.watchkitextension", base_app_identifier_llc + ".NotificationService" ] +signing_identity_llc = "iPhone Distribution: Digital Fortress LLC (C67CF9S4VU)" lane :do_build_app do |options| gym( @@ -31,7 +32,8 @@ lane :do_build_app do |options| iCloudContainerEnvironment: "Production", provisioningProfiles: options[:provisioningProfiles], stripSwiftSymbols: true, - uploadBitcode: false + uploadBitcode: false, + signingCertificate: options[:signingCertificate] } ) end @@ -47,6 +49,7 @@ lane :build_for_appstore do |options| export_method: "app-store", build_number: commit_count_string, commit_id: commit[:commit_hash], + signingCertificate: signing_identity_llc, provisioningProfiles: { base_app_identifier_llc => "match AppStore " + base_app_identifier_llc, base_app_identifier_llc + ".Share" => "match AppStore " + base_app_identifier_llc + ".Share", diff --git a/submodules/Display b/submodules/Display index 61d43c3c4b..7d0164259f 160000 --- a/submodules/Display +++ b/submodules/Display @@ -1 +1 @@ -Subproject commit 61d43c3c4b5286f1bc26cfe0202979925d969e06 +Subproject commit 7d0164259f2aa48516393a43822b5b8ab701d843 diff --git a/submodules/LegacyComponents b/submodules/LegacyComponents index 0d44c9e101..443e039839 160000 --- a/submodules/LegacyComponents +++ b/submodules/LegacyComponents @@ -1 +1 @@ -Subproject commit 0d44c9e1016591c4cfdf1886e743b46acc3646fe +Subproject commit 443e039839ba5bf4a54ca56e9ebb70b2224a9662 diff --git a/submodules/Postbox b/submodules/Postbox index 3d0b885f6a..434eeb4df2 160000 --- a/submodules/Postbox +++ b/submodules/Postbox @@ -1 +1 @@ -Subproject commit 3d0b885f6a272c6d931b7d289b7cf427880a2753 +Subproject commit 434eeb4df24371ec094070a6453b31bf58d8e35c diff --git a/submodules/TelegramCore b/submodules/TelegramCore index b3b73b2fde..414fc5cd9f 160000 --- a/submodules/TelegramCore +++ b/submodules/TelegramCore @@ -1 +1 @@ -Subproject commit b3b73b2fdeb5d5d1f1d93223603d9dd0b2b66882 +Subproject commit 414fc5cd9f8ae41a95af4dc72f205052313e76fd diff --git a/submodules/TelegramUI b/submodules/TelegramUI index 53b3408cb7..89715366c8 160000 --- a/submodules/TelegramUI +++ b/submodules/TelegramUI @@ -1 +1 @@ -Subproject commit 53b3408cb72bae7a2dabc026792daae873bdff68 +Subproject commit 89715366c8346d28c97d0b109bd7d00c63436fde diff --git a/submodules/ffmpeg b/submodules/ffmpeg index 4ea8057cf2..0495e4606b 160000 --- a/submodules/ffmpeg +++ b/submodules/ffmpeg @@ -1 +1 @@ -Subproject commit 4ea8057cf28b1872bdcf5539481195c75af8e1ed +Subproject commit 0495e4606b6a109f951f963c95b3d57ed5e031ff