Don't link unused code

This commit is contained in:
Ali 2020-02-01 23:34:19 +04:00
parent 615e2c7e1a
commit 7e4a7df596
23 changed files with 111 additions and 23 deletions

4
BUCK
View File

@ -48,8 +48,8 @@ resource_dependencies = [
"//submodules/LegacyComponents:LegacyComponentsResources", "//submodules/LegacyComponents:LegacyComponentsResources",
"//submodules/TelegramUI:TelegramUIAssets", "//submodules/TelegramUI:TelegramUIAssets",
"//submodules/TelegramUI:TelegramUIResources", "//submodules/TelegramUI:TelegramUIResources",
"//submodules/WalletUI:WalletUIAssets", #"//submodules/WalletUI:WalletUIAssets",
"//submodules/WalletUI:WalletUIResources", #"//submodules/WalletUI:WalletUIResources",
"//submodules/PasswordSetupUI:PasswordSetupUIResources", "//submodules/PasswordSetupUI:PasswordSetupUIResources",
"//submodules/PasswordSetupUI:PasswordSetupUIAssets", "//submodules/PasswordSetupUI:PasswordSetupUIAssets",
"//submodules/OverlayStatusController:OverlayStatusControllerResources", "//submodules/OverlayStatusController:OverlayStatusControllerResources",

View File

@ -16,7 +16,7 @@ static_library(
"//submodules/Postbox:Postbox#shared", "//submodules/Postbox:Postbox#shared",
"//submodules/TelegramCore:TelegramCore#shared", "//submodules/TelegramCore:TelegramCore#shared",
"//submodules/SyncCore:SyncCore#shared", "//submodules/SyncCore:SyncCore#shared",
"//submodules/WalletCore:WalletCore", #"//submodules/WalletCore:WalletCore",
], ],
frameworks = [ frameworks = [
"$SDKROOT/System/Library/Frameworks/Foundation.framework", "$SDKROOT/System/Library/Frameworks/Foundation.framework",

View File

@ -8,7 +8,10 @@ import SwiftSignalKit
import Display import Display
import DeviceLocationManager import DeviceLocationManager
import TemporaryCachedPeerDataManager import TemporaryCachedPeerDataManager
#if ENABLE_WALLET
import WalletCore import WalletCore
#endif
public final class TelegramApplicationOpenUrlCompletion { public final class TelegramApplicationOpenUrlCompletion {
public let completion: (Bool) -> Void public let completion: (Bool) -> Void
@ -175,7 +178,9 @@ public enum ResolvedUrl {
case share(url: String?, text: String?, to: String?) case share(url: String?, text: String?, to: String?)
case wallpaper(WallpaperUrlParameter) case wallpaper(WallpaperUrlParameter)
case theme(String) case theme(String)
#if ENABLE_WALLET
case wallet(address: String, amount: Int64?, comment: String?) case wallet(address: String, amount: Int64?, comment: String?)
#endif
case settings(ResolvedUrlSettingsSection) case settings(ResolvedUrlSettingsSection)
} }
@ -378,10 +383,12 @@ public final class ContactSelectionControllerParams {
} }
} }
#if ENABLE_WALLET
public enum OpenWalletContext { public enum OpenWalletContext {
case generic case generic
case send(address: String, amount: Int64?, comment: String?) case send(address: String, amount: Int64?, comment: String?)
} }
#endif
public let defaultContactLabel: String = "_$!<Mobile>!$_" public let defaultContactLabel: String = "_$!<Mobile>!$_"
@ -464,7 +471,9 @@ public protocol SharedAccountContext: class {
func openAddContact(context: AccountContext, firstName: String, lastName: String, phoneNumber: String, label: String, present: @escaping (ViewController, Any?) -> Void, pushController: @escaping (ViewController) -> Void, completed: @escaping () -> Void) func openAddContact(context: AccountContext, firstName: String, lastName: String, phoneNumber: String, label: String, present: @escaping (ViewController, Any?) -> Void, pushController: @escaping (ViewController) -> Void, completed: @escaping () -> Void)
func openAddPersonContact(context: AccountContext, peerId: PeerId, pushController: @escaping (ViewController) -> Void, present: @escaping (ViewController, Any?) -> Void) func openAddPersonContact(context: AccountContext, peerId: PeerId, pushController: @escaping (ViewController) -> Void, present: @escaping (ViewController, Any?) -> Void)
func presentContactsWarningSuppression(context: AccountContext, present: (ViewController, Any?) -> Void) func presentContactsWarningSuppression(context: AccountContext, present: (ViewController, Any?) -> Void)
#if ENABLE_WALLET
func openWallet(context: AccountContext, walletContext: OpenWalletContext, present: @escaping (ViewController) -> Void) func openWallet(context: AccountContext, walletContext: OpenWalletContext, present: @escaping (ViewController) -> Void)
#endif
func openImagePicker(context: AccountContext, completion: @escaping (UIImage) -> Void, present: @escaping (ViewController) -> Void) func openImagePicker(context: AccountContext, completion: @escaping (UIImage) -> Void, present: @escaping (ViewController) -> Void)
func makeRecentSessionsController(context: AccountContext, activeSessionsContext: ActiveSessionsContext) -> ViewController & RecentSessionsController func makeRecentSessionsController(context: AccountContext, activeSessionsContext: ActiveSessionsContext) -> ViewController & RecentSessionsController
@ -477,6 +486,7 @@ public protocol SharedAccountContext: class {
func beginNewAuth(testingEnvironment: Bool) func beginNewAuth(testingEnvironment: Bool)
} }
#if ENABLE_WALLET
private final class TonInstanceData { private final class TonInstanceData {
var config: String? var config: String?
var blockchainName: String? var blockchainName: String?
@ -541,10 +551,15 @@ public final class TonContext {
} }
} }
#endif
public protocol AccountContext: class { public protocol AccountContext: class {
var sharedContext: SharedAccountContext { get } var sharedContext: SharedAccountContext { get }
var account: Account { get } var account: Account { get }
#if ENABLE_WALLET
var tonContext: StoredTonContext? { get } var tonContext: StoredTonContext? { get }
#endif
var liveLocationManager: LiveLocationManager? { get } var liveLocationManager: LiveLocationManager? { get }
var fetchManager: FetchManager { get } var fetchManager: FetchManager { get }
@ -552,8 +567,11 @@ public protocol AccountContext: class {
var peerChannelMemberCategoriesContextsManager: PeerChannelMemberCategoriesContextsManager { get } var peerChannelMemberCategoriesContextsManager: PeerChannelMemberCategoriesContextsManager { get }
var wallpaperUploadManager: WallpaperUploadManager? { get } var wallpaperUploadManager: WallpaperUploadManager? { get }
var watchManager: WatchManager? { get } var watchManager: WatchManager? { get }
#if ENABLE_WALLET
var hasWallets: Signal<Bool, NoError> { get } var hasWallets: Signal<Bool, NoError> { get }
var hasWalletAccess: Signal<Bool, NoError> { get } var hasWalletAccess: Signal<Bool, NoError> { get }
#endif
var currentLimitsConfiguration: Atomic<LimitsConfiguration> { get } var currentLimitsConfiguration: Atomic<LimitsConfiguration> { get }
var currentContentSettings: Atomic<ContentSettings> { get } var currentContentSettings: Atomic<ContentSettings> { get }

View File

@ -99,7 +99,7 @@ private final class ContextControllerContentSourceImpl: ContextControllerContent
} }
} }
public class ChatListControllerImpl: TelegramBaseController, ChatListController, UIViewControllerPreviewingDelegate, TabBarContainedController { public class ChatListControllerImpl: TelegramBaseController, ChatListController, UIViewControllerPreviewingDelegate/*, TabBarContainedController*/ {
private var validLayout: ContainerViewLayout? private var validLayout: ContainerViewLayout?
public let context: AccountContext public let context: AccountContext
@ -1808,7 +1808,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController,
} }
} }
public func presentTabBarPreviewingController(sourceNodes: [ASDisplayNode]) { /*public func presentTabBarPreviewingController(sourceNodes: [ASDisplayNode]) {
if self.isNodeLoaded { if self.isNodeLoaded {
let _ = (self.context.account.postbox.transaction { transaction -> [ChatListFilterPreset] in let _ = (self.context.account.postbox.transaction { transaction -> [ChatListFilterPreset] in
let settings = transaction.getPreferencesEntry(key: ApplicationSpecificPreferencesKeys.chatListFilterSettings) as? ChatListFilterSettings ?? ChatListFilterSettings.default let settings = transaction.getPreferencesEntry(key: ApplicationSpecificPreferencesKeys.chatListFilterSettings) as? ChatListFilterSettings ?? ChatListFilterSettings.default
@ -1852,5 +1852,5 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController,
public func updateTabBarPreviewingControllerPresentation(_ update: TabBarContainedControllerPresentationUpdate) { public func updateTabBarPreviewingControllerPresentation(_ update: TabBarContainedControllerPresentationUpdate) {
} }*/
} }

View File

@ -78,7 +78,7 @@ static_library(
"//submodules/InstantPageCache:InstantPageCache", "//submodules/InstantPageCache:InstantPageCache",
"//submodules/AppBundle:AppBundle", "//submodules/AppBundle:AppBundle",
"//submodules/ContextUI:ContextUI", "//submodules/ContextUI:ContextUI",
"//submodules/WalletUI:WalletUI", #"//submodules/WalletUI:WalletUI",
"//submodules/Markdown:Markdown", "//submodules/Markdown:Markdown",
"//submodules/UndoUI:UndoUI", "//submodules/UndoUI:UndoUI",
"//submodules/DeleteChatPeerActionSheetItem:DeleteChatPeerActionSheetItem", "//submodules/DeleteChatPeerActionSheetItem:DeleteChatPeerActionSheetItem",

View File

@ -17,7 +17,6 @@ import ItemListUI
import PresentationDataUtils import PresentationDataUtils
import OverlayStatusController import OverlayStatusController
import AccountContext import AccountContext
import WalletUI
@objc private final class DebugControllerMailComposeDelegate: NSObject, MFMailComposeViewControllerDelegate { @objc private final class DebugControllerMailComposeDelegate: NSObject, MFMailComposeViewControllerDelegate {
public func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) { public func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {

View File

@ -219,7 +219,11 @@ func logoutOptionsController(context: AccountContext, navigationController: Navi
presentControllerImpl?(alertController, nil) presentControllerImpl?(alertController, nil)
}) })
#if ENABLE_WALLET
let hasWallets = context.hasWallets let hasWallets = context.hasWallets
#else
let hasWallets: Signal<Bool, NoError> = .single(false)
#endif
let signal = combineLatest(queue: .mainQueue(), let signal = combineLatest(queue: .mainQueue(),
context.sharedContext.presentationData, context.sharedContext.presentationData,

View File

@ -882,6 +882,7 @@ func settingsSearchableItems(context: AccountContext, notificationExceptionsList
}) })
allItems.append(passport) allItems.append(passport)
#if ENABLE_WALLET
if hasWallet { if hasWallet {
let wallet = SettingsSearchableItem(id: .wallet(0), title: strings.Settings_Wallet, alternate: synonyms(strings.SettingsSearch_Synonyms_Wallet), icon: .wallet, breadcrumbs: [], present: { context, _, present in let wallet = SettingsSearchableItem(id: .wallet(0), title: strings.Settings_Wallet, alternate: synonyms(strings.SettingsSearch_Synonyms_Wallet), icon: .wallet, breadcrumbs: [], present: { context, _, present in
context.sharedContext.openWallet(context: context, walletContext: .generic, present: { c in context.sharedContext.openWallet(context: context, walletContext: .generic, present: { c in
@ -890,6 +891,7 @@ func settingsSearchableItems(context: AccountContext, notificationExceptionsList
}) })
allItems.append(wallet) allItems.append(wallet)
} }
#endif
let support = SettingsSearchableItem(id: .support(0), title: strings.Settings_Support, alternate: synonyms(strings.SettingsSearch_Synonyms_Support), icon: .support, breadcrumbs: [], present: { context, _, present in let support = SettingsSearchableItem(id: .support(0), title: strings.Settings_Support, alternate: synonyms(strings.SettingsSearch_Synonyms_Support), icon: .support, breadcrumbs: [], present: { context, _, present in
let _ = (supportPeerId(account: context.account) let _ = (supportPeerId(account: context.account)

View File

@ -33,7 +33,9 @@ import PeerAvatarGalleryUI
import MapResourceToAvatarSizes import MapResourceToAvatarSizes
import AppBundle import AppBundle
import ContextUI import ContextUI
#if ENABLE_WALLET
import WalletUI import WalletUI
#endif
import PhoneNumberFormat import PhoneNumberFormat
import AccountUtils import AccountUtils
import AuthTransferUI import AuthTransferUI
@ -221,7 +223,9 @@ private indirect enum SettingsEntry: ItemListNodeEntry {
case themes(PresentationTheme, UIImage?, String) case themes(PresentationTheme, UIImage?, String)
case language(PresentationTheme, UIImage?, String, String) case language(PresentationTheme, UIImage?, String, String)
case passport(PresentationTheme, UIImage?, String, String) case passport(PresentationTheme, UIImage?, String, String)
#if ENABLE_WALLET
case wallet(PresentationTheme, UIImage?, String, String) case wallet(PresentationTheme, UIImage?, String, String)
#endif
case watch(PresentationTheme, UIImage?, String, String) case watch(PresentationTheme, UIImage?, String, String)
case askAQuestion(PresentationTheme, UIImage?, String) case askAQuestion(PresentationTheme, UIImage?, String)
@ -243,8 +247,12 @@ private indirect enum SettingsEntry: ItemListNodeEntry {
return SettingsSection.media.rawValue return SettingsSection.media.rawValue
case .notificationsAndSounds, .privacyAndSecurity, .dataAndStorage, .themes, .language, .contentStickers: case .notificationsAndSounds, .privacyAndSecurity, .dataAndStorage, .themes, .language, .contentStickers:
return SettingsSection.generalSettings.rawValue return SettingsSection.generalSettings.rawValue
case .passport, .wallet, .watch : case .passport, .watch:
return SettingsSection.advanced.rawValue return SettingsSection.advanced.rawValue
#if ENABLE_WALLET
case .wallet:
return SettingsSection.advanced.rawValue
#endif
case .askAQuestion, .faq: case .askAQuestion, .faq:
return SettingsSection.help.rawValue return SettingsSection.help.rawValue
} }
@ -290,8 +298,10 @@ private indirect enum SettingsEntry: ItemListNodeEntry {
return 1012 return 1012
case .contentStickers: case .contentStickers:
return 1013 return 1013
#if ENABLE_WALLET
case .wallet: case .wallet:
return 1014 return 1014
#endif
case .passport: case .passport:
return 1015 return 1015
case .watch: case .watch:
@ -457,12 +467,14 @@ private indirect enum SettingsEntry: ItemListNodeEntry {
} else { } else {
return false return false
} }
#if ENABLE_WALLET
case let .wallet(lhsTheme, lhsImage, lhsText, lhsValue): case let .wallet(lhsTheme, lhsImage, lhsText, lhsValue):
if case let .wallet(rhsTheme, rhsImage, rhsText, rhsValue) = rhs, lhsTheme === rhsTheme, lhsImage === rhsImage, lhsText == rhsText, lhsValue == rhsValue { if case let .wallet(rhsTheme, rhsImage, rhsText, rhsValue) = rhs, lhsTheme === rhsTheme, lhsImage === rhsImage, lhsText == rhsText, lhsValue == rhsValue {
return true return true
} else { } else {
return false return false
} }
#endif
case let .watch(lhsTheme, lhsImage, lhsText, lhsValue): case let .watch(lhsTheme, lhsImage, lhsText, lhsValue):
if case let .watch(rhsTheme, rhsImage, rhsText, rhsValue) = rhs, lhsTheme === rhsTheme, lhsImage === rhsImage, lhsText == rhsText, lhsValue == rhsValue { if case let .watch(rhsTheme, rhsImage, rhsText, rhsValue) = rhs, lhsTheme === rhsTheme, lhsImage === rhsImage, lhsText == rhsText, lhsValue == rhsValue {
return true return true
@ -596,10 +608,12 @@ private indirect enum SettingsEntry: ItemListNodeEntry {
return ItemListDisclosureItem(presentationData: presentationData, icon: image, title: text, label: value, sectionId: ItemListSectionId(self.section), style: .blocks, action: { return ItemListDisclosureItem(presentationData: presentationData, icon: image, title: text, label: value, sectionId: ItemListSectionId(self.section), style: .blocks, action: {
arguments.openPassport() arguments.openPassport()
}) })
#if ENABLE_WALLET
case let .wallet(theme, image, text, value): case let .wallet(theme, image, text, value):
return ItemListDisclosureItem(presentationData: presentationData, icon: image, title: text, label: value, sectionId: ItemListSectionId(self.section), style: .blocks, action: { return ItemListDisclosureItem(presentationData: presentationData, icon: image, title: text, label: value, sectionId: ItemListSectionId(self.section), style: .blocks, action: {
arguments.openWallet() arguments.openWallet()
}) })
#endif
case let .watch(theme, image, text, value): case let .watch(theme, image, text, value):
return ItemListDisclosureItem(presentationData: presentationData, icon: image, title: text, label: value, sectionId: ItemListSectionId(self.section), style: .blocks, action: { return ItemListDisclosureItem(presentationData: presentationData, icon: image, title: text, label: value, sectionId: ItemListSectionId(self.section), style: .blocks, action: {
arguments.openWatch() arguments.openWatch()
@ -685,9 +699,11 @@ private func settingsEntries(account: Account, presentationData: PresentationDat
entries.append(.language(presentationData.theme, PresentationResourcesSettings.language, presentationData.strings.Settings_AppLanguage, languageName.isEmpty ? presentationData.strings.Localization_LanguageName : languageName)) entries.append(.language(presentationData.theme, PresentationResourcesSettings.language, presentationData.strings.Settings_AppLanguage, languageName.isEmpty ? presentationData.strings.Localization_LanguageName : languageName))
entries.append(.contentStickers(presentationData.theme, PresentationResourcesSettings.stickers, presentationData.strings.ChatSettings_Stickers, unreadTrendingStickerPacks == 0 ? "" : "\(unreadTrendingStickerPacks)", archivedPacks)) entries.append(.contentStickers(presentationData.theme, PresentationResourcesSettings.stickers, presentationData.strings.ChatSettings_Stickers, unreadTrendingStickerPacks == 0 ? "" : "\(unreadTrendingStickerPacks)", archivedPacks))
#if ENABLE_WALLET
if hasWallet { if hasWallet {
entries.append(.wallet(presentationData.theme, PresentationResourcesSettings.wallet, "Gram Wallet", "")) entries.append(.wallet(presentationData.theme, PresentationResourcesSettings.wallet, "Gram Wallet", ""))
} }
#endif
if hasPassport { if hasPassport {
entries.append(.passport(presentationData.theme, PresentationResourcesSettings.passport, presentationData.strings.Settings_Passport, "")) entries.append(.passport(presentationData.theme, PresentationResourcesSettings.passport, presentationData.strings.Settings_Passport, ""))
} }
@ -989,6 +1005,7 @@ public func settingsController(context: AccountContext, accountManager: AccountM
pushControllerImpl?(SecureIdAuthController(context: context, mode: .list)) pushControllerImpl?(SecureIdAuthController(context: context, mode: .list))
}) })
}, openWallet: { }, openWallet: {
#if ENABLE_WALLET
let _ = (contextValue.get() let _ = (contextValue.get()
|> deliverOnMainQueue |> deliverOnMainQueue
|> take(1)).start(next: { context in |> take(1)).start(next: { context in
@ -996,6 +1013,7 @@ public func settingsController(context: AccountContext, accountManager: AccountM
pushControllerImpl?(c) pushControllerImpl?(c)
}) })
}) })
#endif
}, openWatch: { }, openWatch: {
let _ = (contextValue.get() let _ = (contextValue.get()
|> deliverOnMainQueue |> deliverOnMainQueue
@ -1252,11 +1270,14 @@ public func settingsController(context: AccountContext, accountManager: AccountM
} }
) )
) )
#if ENABLE_WALLET
let hasWallet = contextValue.get() let hasWallet = contextValue.get()
|> mapToSignal { context in |> mapToSignal { context in
return context.hasWalletAccess return context.hasWalletAccess
} }
#else
let hasWallet: Signal<Bool, NoError> = .single(false)
#endif
let hasPassport = ValuePromise<Bool>(false) let hasPassport = ValuePromise<Bool>(false)
let updatePassport: () -> Void = { let updatePassport: () -> Void = {

View File

@ -186,8 +186,8 @@ framework(
"//submodules/MessageReactionListUI:MessageReactionListUI", "//submodules/MessageReactionListUI:MessageReactionListUI",
"//submodules/SegmentedControlNode:SegmentedControlNode", "//submodules/SegmentedControlNode:SegmentedControlNode",
"//submodules/AppBundle:AppBundle", "//submodules/AppBundle:AppBundle",
"//submodules/WalletUI:WalletUI", #"//submodules/WalletUI:WalletUI",
"//submodules/WalletCore:WalletCore", #"//submodules/WalletCore:WalletCore",
"//submodules/Markdown:Markdown", "//submodules/Markdown:Markdown",
"//submodules/SearchPeerMembers:SearchPeerMembers", "//submodules/SearchPeerMembers:SearchPeerMembers",
"//submodules/WidgetItems:WidgetItems", "//submodules/WidgetItems:WidgetItems",

View File

@ -10,8 +10,10 @@ import TelegramPresentationData
import AccountContext import AccountContext
import LiveLocationManager import LiveLocationManager
import TemporaryCachedPeerDataManager import TemporaryCachedPeerDataManager
#if ENABLE_WALLET
import WalletCore import WalletCore
import WalletUI import WalletUI
#endif
import PhoneNumberFormat import PhoneNumberFormat
private final class DeviceSpecificContactImportContext { private final class DeviceSpecificContactImportContext {
@ -106,7 +108,9 @@ public final class AccountContextImpl: AccountContext {
} }
public let account: Account public let account: Account
#if ENABLE_WALLET
public let tonContext: StoredTonContext? public let tonContext: StoredTonContext?
#endif
public let fetchManager: FetchManager public let fetchManager: FetchManager
private let prefetchManager: PrefetchManager? private let prefetchManager: PrefetchManager?
@ -142,6 +146,7 @@ public final class AccountContextImpl: AccountContext {
private let deviceSpecificContactImportContexts: QueueLocalObject<DeviceSpecificContactImportContexts> private let deviceSpecificContactImportContexts: QueueLocalObject<DeviceSpecificContactImportContexts>
private var managedAppSpecificContactsDisposable: Disposable? private var managedAppSpecificContactsDisposable: Disposable?
#if ENABLE_WALLET
public var hasWallets: Signal<Bool, NoError> { public var hasWallets: Signal<Bool, NoError> {
return WalletStorageInterfaceImpl(postbox: self.account.postbox).getWalletRecords() return WalletStorageInterfaceImpl(postbox: self.account.postbox).getWalletRecords()
|> map { records in |> map { records in
@ -164,11 +169,15 @@ public final class AccountContextImpl: AccountContext {
} }
|> distinctUntilChanged |> distinctUntilChanged
} }
#endif
public init(sharedContext: SharedAccountContextImpl, account: Account, tonContext: StoredTonContext?, limitsConfiguration: LimitsConfiguration, contentSettings: ContentSettings, temp: Bool = false) { public init(sharedContext: SharedAccountContextImpl, account: Account, /*tonContext: StoredTonContext?, */limitsConfiguration: LimitsConfiguration, contentSettings: ContentSettings, temp: Bool = false)
{
self.sharedContextImpl = sharedContext self.sharedContextImpl = sharedContext
self.account = account self.account = account
#if ENABLE_WALLET
self.tonContext = tonContext self.tonContext = tonContext
#endif
self.downloadedMediaStoreManager = DownloadedMediaStoreManagerImpl(postbox: account.postbox, accountManager: sharedContext.accountManager) self.downloadedMediaStoreManager = DownloadedMediaStoreManagerImpl(postbox: account.postbox, accountManager: sharedContext.accountManager)

View File

@ -26,10 +26,14 @@ import WatchBridge
import LegacyDataImport import LegacyDataImport
import SettingsUI import SettingsUI
import AppBundle import AppBundle
#if ENABLE_WALLET
import WalletUI import WalletUI
#endif
import UrlHandling import UrlHandling
#if ENABLE_WALLET
import WalletUrl import WalletUrl
import WalletCore import WalletCore
#endif
import OpenSSLEncryptionProvider import OpenSSLEncryptionProvider
import AppLock import AppLock
import PresentationDataUtils import PresentationDataUtils
@ -680,6 +684,7 @@ final class SharedApplicationContext {
}) })
} }
#if ENABLE_WALLET
let tonKeychain: TonKeychain let tonKeychain: TonKeychain
#if targetEnvironment(simulator) #if targetEnvironment(simulator)
@ -741,6 +746,7 @@ final class SharedApplicationContext {
} }
}) })
#endif #endif
#endif
let sharedContextSignal = accountManagerSignal let sharedContextSignal = accountManagerSignal
|> deliverOnMainQueue |> deliverOnMainQueue
@ -1003,8 +1009,10 @@ final class SharedApplicationContext {
|> deliverOnMainQueue |> deliverOnMainQueue
|> map { accountAndSettings -> AuthorizedApplicationContext? in |> map { accountAndSettings -> AuthorizedApplicationContext? in
return accountAndSettings.flatMap { account, limitsConfiguration, callListSettings, contentSettings in return accountAndSettings.flatMap { account, limitsConfiguration, callListSettings, contentSettings in
#if ENABLE_WALLET
let tonContext = StoredTonContext(basePath: account.basePath, postbox: account.postbox, network: account.network, keychain: tonKeychain) let tonContext = StoredTonContext(basePath: account.basePath, postbox: account.postbox, network: account.network, keychain: tonKeychain)
let context = AccountContextImpl(sharedContext: sharedApplicationContext.sharedContext, account: account, tonContext: tonContext, limitsConfiguration: limitsConfiguration, contentSettings: contentSettings) #endif
let context = AccountContextImpl(sharedContext: sharedApplicationContext.sharedContext, account: account/*, tonContext: tonContext*/, limitsConfiguration: limitsConfiguration, contentSettings: contentSettings)
return AuthorizedApplicationContext(sharedApplicationContext: sharedApplicationContext, 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() let _ = (self.context.get()
|> take(1) |> take(1)
@ -1741,10 +1749,13 @@ final class SharedApplicationContext {
}), TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), on: .root, blockInteraction: false, completion: {}) }), TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), on: .root, blockInteraction: false, completion: {})
} else if let confirmationCode = parseConfirmationCodeUrl(url) { } else if let confirmationCode = parseConfirmationCodeUrl(url) {
authContext.rootController.applyConfirmationCode(confirmationCode) authContext.rootController.applyConfirmationCode(confirmationCode)
} else if let _ = parseWalletUrl(url) { }
#if ENABLE_WALLET
if let _ = parseWalletUrl(url) {
let presentationData = authContext.sharedContext.currentPresentationData.with { $0 } let presentationData = authContext.sharedContext.currentPresentationData.with { $0 }
authContext.rootController.currentWindow?.present(standardTextAlertController(theme: AlertControllerTheme(presentationData: presentationData), title: nil, text: "Please log in to your account to use Gram Wallet.", actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), on: .root, blockInteraction: false, completion: {}) authContext.rootController.currentWindow?.present(standardTextAlertController(theme: AlertControllerTheme(presentationData: presentationData), title: nil, text: "Please log in to your account to use Gram Wallet.", actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), on: .root, blockInteraction: false, completion: {})
} }
#endif
} }
}) })
} }

View File

@ -49,8 +49,10 @@ import ReactionSelectionNode
import AvatarNode import AvatarNode
import MessageReactionListUI import MessageReactionListUI
import AppBundle import AppBundle
#if ENABLE_WALLET
import WalletUI import WalletUI
import WalletUrl import WalletUrl
#endif
import LocalizedPeerData import LocalizedPeerData
import PhoneNumberFormat import PhoneNumberFormat
import SettingsUI import SettingsUI
@ -5695,9 +5697,9 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
if let strongSelf = self { if let strongSelf = self {
if let (host, port, username, password, secret) = parseProxyUrl(code) { if let (host, port, username, password, secret) = parseProxyUrl(code) {
strongSelf.openResolved(ResolvedUrl.proxy(host: host, port: port, username: username, password: password, secret: secret)) strongSelf.openResolved(ResolvedUrl.proxy(host: host, port: port, username: username, password: password, secret: secret))
} else if let url = URL(string: code), let parsedWalletUrl = parseWalletUrl(url) { }/* else if let url = URL(string: code), let parsedWalletUrl = parseWalletUrl(url) {
//strongSelf.openResolved(ResolvedUrl.wallet(address: parsedWalletUrl.address, amount: parsedWalletUrl.amount, comment: parsedWalletUrl.comment)) //strongSelf.openResolved(ResolvedUrl.wallet(address: parsedWalletUrl.address, amount: parsedWalletUrl.amount, comment: parsedWalletUrl.comment))
} }*/
} }
}, presentSchedulePicker: { [weak self] done in }, presentSchedulePicker: { [weak self] done in
if let strongSelf = self { if let strongSelf = self {

View File

@ -813,8 +813,10 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode {
break break
case .theme: case .theme:
break break
#if ENABLE_WALLET
case .wallet: case .wallet:
break break
#endif
case .settings: case .settings:
break break
} }

View File

@ -371,11 +371,13 @@ func openResolvedUrlImpl(_ resolvedUrl: ResolvedUrl, context: AccountContext, ur
present(textAlertController(context: context, title: nil, text: errorText, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil) present(textAlertController(context: context, title: nil, text: errorText, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil)
})) }))
dismissInput() dismissInput()
#if ENABLE_WALLET
case let .wallet(address, amount, comment): case let .wallet(address, amount, comment):
dismissInput() dismissInput()
context.sharedContext.openWallet(context: context, walletContext: .send(address: address, amount: amount, comment: comment)) { c in context.sharedContext.openWallet(context: context, walletContext: .send(address: address, amount: amount, comment: comment)) { c in
navigationController?.pushViewController(c) navigationController?.pushViewController(c)
} }
#endif
case let .settings(section): case let .settings(section):
dismissInput() dismissInput()
switch section { switch section {

View File

@ -16,8 +16,10 @@ import AccountContext
import UrlEscaping import UrlEscaping
import PassportUI import PassportUI
import UrlHandling import UrlHandling
#if ENABLE_WALLET
import WalletUI import WalletUI
import WalletUrl import WalletUrl
#endif
import OpenInExternalAppUI import OpenInExternalAppUI
public struct ParsedSecureIdUrl { public struct ParsedSecureIdUrl {
@ -144,6 +146,7 @@ func formattedConfirmationCode(_ code: Int) -> String {
} }
func openExternalUrlImpl(context: AccountContext, urlContext: OpenURLContext, url: String, forceExternal: Bool, presentationData: PresentationData, navigationController: NavigationController?, dismissInput: @escaping () -> Void) { func openExternalUrlImpl(context: AccountContext, urlContext: OpenURLContext, url: String, forceExternal: Bool, presentationData: PresentationData, navigationController: NavigationController?, dismissInput: @escaping () -> Void) {
#if ENABLE_WALLET
if url.hasPrefix("ton://") { if url.hasPrefix("ton://") {
if let url = URL(string: url), let parsedUrl = parseWalletUrl(url) { if let url = URL(string: url), let parsedUrl = parseWalletUrl(url) {
context.sharedContext.openWallet(context: context, walletContext: .send(address: parsedUrl.address, amount: parsedUrl.amount, comment: parsedUrl.comment)) { c in context.sharedContext.openWallet(context: context, walletContext: .send(address: parsedUrl.address, amount: parsedUrl.amount, comment: parsedUrl.comment)) { c in
@ -153,6 +156,7 @@ func openExternalUrlImpl(context: AccountContext, urlContext: OpenURLContext, ur
return return
} }
#endif
if forceExternal || url.lowercased().hasPrefix("tel:") || url.lowercased().hasPrefix("calshow:") { if forceExternal || url.lowercased().hasPrefix("tel:") || url.lowercased().hasPrefix("calshow:") {
context.sharedContext.applicationBindings.openUrl(url) context.sharedContext.applicationBindings.openUrl(url)

View File

@ -271,7 +271,7 @@ public class ShareRootControllerImpl {
|> castError(ShareAuthorizationError.self) |> castError(ShareAuthorizationError.self)
|> map { sharedData, limitsConfigurationAndContentSettings, data -> (AccountContext, PostboxAccessChallengeData, [AccountWithInfo]) in |> map { sharedData, limitsConfigurationAndContentSettings, data -> (AccountContext, PostboxAccessChallengeData, [AccountWithInfo]) in
updateLegacyLocalization(strings: sharedContext.currentPresentationData.with({ $0 }).strings) updateLegacyLocalization(strings: sharedContext.currentPresentationData.with({ $0 }).strings)
let context = AccountContextImpl(sharedContext: sharedContext, account: account, tonContext: nil, limitsConfiguration: limitsConfigurationAndContentSettings.0, contentSettings: limitsConfigurationAndContentSettings.1) let context = AccountContextImpl(sharedContext: sharedContext, account: account/*, tonContext: nil*/, limitsConfiguration: limitsConfigurationAndContentSettings.0, contentSettings: limitsConfigurationAndContentSettings.1)
return (context, data.data, otherAccounts) return (context, data.data, otherAccounts)
} }
} }

View File

@ -15,13 +15,15 @@ import PeersNearbyUI
import PeerInfoUI import PeerInfoUI
import SettingsUI import SettingsUI
import UrlHandling import UrlHandling
#if ENABLE_WALLET
import WalletUI import WalletUI
import WalletCore
#endif
import LegacyMediaPickerUI import LegacyMediaPickerUI
import LocalMediaResources import LocalMediaResources
import OverlayStatusController import OverlayStatusController
import AlertUI import AlertUI
import PresentationDataUtils import PresentationDataUtils
import WalletCore
private enum CallStatusText: Equatable { private enum CallStatusText: Equatable {
case none case none
@ -892,7 +894,7 @@ public final class SharedAccountContextImpl: SharedAccountContext {
} }
public func makeTempAccountContext(account: Account) -> AccountContext { public func makeTempAccountContext(account: Account) -> AccountContext {
return AccountContextImpl(sharedContext: self, account: account, tonContext: nil, limitsConfiguration: .defaultValue, contentSettings: .default, temp: true) return AccountContextImpl(sharedContext: self, account: account/*, tonContext: nil*/, limitsConfiguration: .defaultValue, contentSettings: .default, temp: true)
} }
public func openChatMessage(_ params: OpenChatMessageParams) -> Bool { public func openChatMessage(_ params: OpenChatMessageParams) -> Bool {
@ -1146,6 +1148,7 @@ public final class SharedAccountContextImpl: SharedAccountContext {
return ChatMessageDateHeader(timestamp: timestamp, scheduled: false, presentationData: ChatPresentationData(theme: ChatPresentationThemeData(theme: theme, wallpaper: wallpaper), fontSize: fontSize, strings: strings, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameOrder, disableAnimations: false, largeEmoji: false, chatBubbleCorners: chatBubbleCorners, animatedEmojiScale: 1.0, isPreview: true), context: context) return ChatMessageDateHeader(timestamp: timestamp, scheduled: false, presentationData: ChatPresentationData(theme: ChatPresentationThemeData(theme: theme, wallpaper: wallpaper), fontSize: fontSize, strings: strings, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameOrder, disableAnimations: false, largeEmoji: false, chatBubbleCorners: chatBubbleCorners, animatedEmojiScale: 1.0, isPreview: true), context: context)
} }
#if ENABLE_WALLET
public func openWallet(context: AccountContext, walletContext: OpenWalletContext, present: @escaping (ViewController) -> Void) { public func openWallet(context: AccountContext, walletContext: OpenWalletContext, present: @escaping (ViewController) -> Void) {
guard let storedContext = context.tonContext else { guard let storedContext = context.tonContext else {
return return
@ -1205,6 +1208,7 @@ public final class SharedAccountContextImpl: SharedAccountContext {
} }
}) })
} }
#endif
public func openImagePicker(context: AccountContext, completion: @escaping (UIImage) -> Void, present: @escaping (ViewController) -> Void) { public func openImagePicker(context: AccountContext, completion: @escaping (UIImage) -> Void, present: @escaping (ViewController) -> Void) {
let presentationData = context.sharedContext.currentPresentationData.with { $0 } let presentationData = context.sharedContext.currentPresentationData.with { $0 }

View File

@ -66,10 +66,12 @@ func handleTextLinkActionImpl(context: AccountContext, peerId: PeerId?, navigate
controller.present(JoinLinkPreviewController(context: context, link: link, navigateToPeer: { peerId in controller.present(JoinLinkPreviewController(context: context, link: link, navigateToPeer: { peerId in
openResolvedPeerImpl(peerId, .chat(textInputState: nil, subject: nil)) openResolvedPeerImpl(peerId, .chat(textInputState: nil, subject: nil))
}, parentNavigationController: controller.navigationController as? NavigationController), in: .window(.root)) }, parentNavigationController: controller.navigationController as? NavigationController), in: .window(.root))
#if ENABLE_WALLET
case let .wallet(address, amount, comment): case let .wallet(address, amount, comment):
context.sharedContext.openWallet(context: context, walletContext: .send(address: address, amount: amount, comment: comment)) { c in context.sharedContext.openWallet(context: context, walletContext: .send(address: address, amount: amount, comment: comment)) { c in
(controller.navigationController as? NavigationController)?.pushViewController(c) (controller.navigationController as? NavigationController)?.pushViewController(c)
} }
#endif
default: default:
break break
} }

View File

@ -1,3 +1,5 @@
#if ENABLE_WALLET
import Foundation import Foundation
import UIKit import UIKit
import Display import Display
@ -278,3 +280,5 @@ final class WalletContextImpl: WalletContext {
}) })
} }
} }
#endif

View File

@ -13,7 +13,7 @@ static_library(
"//submodules/MtProtoKit:MtProtoKit#shared", "//submodules/MtProtoKit:MtProtoKit#shared",
"//submodules/AccountContext:AccountContext", "//submodules/AccountContext:AccountContext",
"//submodules/TelegramUIPreferences:TelegramUIPreferences", "//submodules/TelegramUIPreferences:TelegramUIPreferences",
"//submodules/WalletUrl:WalletUrl", #"//submodules/WalletUrl:WalletUrl",
], ],
frameworks = [ frameworks = [
"$SDKROOT/System/Library/Frameworks/Foundation.framework", "$SDKROOT/System/Library/Frameworks/Foundation.framework",

View File

@ -12,7 +12,9 @@ import MtProtoKitDynamic
import TelegramPresentationData import TelegramPresentationData
import TelegramUIPreferences import TelegramUIPreferences
import AccountContext import AccountContext
#if ENABLE_WALLET
import WalletUrl import WalletUrl
#endif
public enum ParsedInternalPeerUrlParameter { public enum ParsedInternalPeerUrlParameter {
case botStart(String) case botStart(String)
@ -425,11 +427,13 @@ public func parseWallpaperUrl(_ url: String) -> WallpaperUrlParameter? {
} }
public func resolveUrlImpl(account: Account, url: String) -> Signal<ResolvedUrl, NoError> { public func resolveUrlImpl(account: Account, url: String) -> Signal<ResolvedUrl, NoError> {
#if ENABLE_WALLET
if url.hasPrefix("ton://") { if url.hasPrefix("ton://") {
if let url = URL(string: url), let parsedUrl = parseWalletUrl(url) { if let url = URL(string: url), let parsedUrl = parseWalletUrl(url) {
return .single(.wallet(address: parsedUrl.address, amount: parsedUrl.amount, comment: parsedUrl.comment)) return .single(.wallet(address: parsedUrl.address, amount: parsedUrl.amount, comment: parsedUrl.comment))
} }
} }
#endif
let schemes = ["http://", "https://", ""] let schemes = ["http://", "https://", ""]
let baseTelegramMePaths = ["telegram.me", "t.me"] let baseTelegramMePaths = ["telegram.me", "t.me"]
for basePath in baseTelegramMePaths { for basePath in baseTelegramMePaths {

View File

@ -37,8 +37,8 @@ static_library(
"//submodules/LocalAuth:LocalAuth", "//submodules/LocalAuth:LocalAuth",
"//submodules/ScreenCaptureDetection:ScreenCaptureDetection", "//submodules/ScreenCaptureDetection:ScreenCaptureDetection",
"//submodules/AnimatedStickerNode:AnimatedStickerNode", "//submodules/AnimatedStickerNode:AnimatedStickerNode",
"//submodules/WalletUrl:WalletUrl", #"//submodules/WalletUrl:WalletUrl",
"//submodules/WalletCore:WalletCore", #"//submodules/WalletCore:WalletCore",
"//submodules/StringPluralization:StringPluralization", "//submodules/StringPluralization:StringPluralization",
"//submodules/ActivityIndicator:ActivityIndicator", "//submodules/ActivityIndicator:ActivityIndicator",
"//submodules/ProgressNavigationButtonNode:ProgressNavigationButtonNode", "//submodules/ProgressNavigationButtonNode:ProgressNavigationButtonNode",