mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
211 lines
10 KiB
Swift
211 lines
10 KiB
Swift
import Foundation
|
|
import Postbox
|
|
import TelegramCore
|
|
import TelegramPresentationData
|
|
import TelegramUIPreferences
|
|
import SwiftSignalKit
|
|
import Display
|
|
import DeviceLocationManager
|
|
import TemporaryCachedPeerDataManager
|
|
|
|
public final class TelegramApplicationOpenUrlCompletion {
|
|
public let completion: (Bool) -> Void
|
|
|
|
public init(completion: @escaping (Bool) -> Void) {
|
|
self.completion = completion
|
|
}
|
|
}
|
|
|
|
public enum AccessType {
|
|
case notDetermined
|
|
case allowed
|
|
case denied
|
|
case restricted
|
|
case unreachable
|
|
}
|
|
|
|
public final class TelegramApplicationBindings {
|
|
public let isMainApp: Bool
|
|
public let containerPath: String
|
|
public let appSpecificScheme: String
|
|
public let openUrl: (String) -> Void
|
|
public let openUniversalUrl: (String, TelegramApplicationOpenUrlCompletion) -> Void
|
|
public let canOpenUrl: (String) -> Bool
|
|
public let getTopWindow: () -> UIWindow?
|
|
public let displayNotification: (String) -> Void
|
|
public let applicationInForeground: Signal<Bool, NoError>
|
|
public let applicationIsActive: Signal<Bool, NoError>
|
|
public let clearMessageNotifications: ([MessageId]) -> Void
|
|
public let pushIdleTimerExtension: () -> Disposable
|
|
public let openSettings: () -> Void
|
|
public let openAppStorePage: () -> Void
|
|
public let registerForNotifications: (@escaping (Bool) -> Void) -> Void
|
|
public let requestSiriAuthorization: (@escaping (Bool) -> Void) -> Void
|
|
public let siriAuthorization: () -> AccessType
|
|
public let getWindowHost: () -> WindowHost?
|
|
public let presentNativeController: (UIViewController) -> Void
|
|
public let dismissNativeController: () -> Void
|
|
public let getAvailableAlternateIcons: () -> [PresentationAppIcon]
|
|
public let getAlternateIconName: () -> String?
|
|
public let requestSetAlternateIconName: (String?, @escaping (Bool) -> Void) -> Void
|
|
|
|
public init(isMainApp: Bool, containerPath: String, appSpecificScheme: String, openUrl: @escaping (String) -> Void, openUniversalUrl: @escaping (String, TelegramApplicationOpenUrlCompletion) -> Void, canOpenUrl: @escaping (String) -> Bool, getTopWindow: @escaping () -> UIWindow?, displayNotification: @escaping (String) -> Void, applicationInForeground: Signal<Bool, NoError>, applicationIsActive: Signal<Bool, NoError>, clearMessageNotifications: @escaping ([MessageId]) -> Void, pushIdleTimerExtension: @escaping () -> Disposable, openSettings: @escaping () -> Void, openAppStorePage: @escaping () -> Void, registerForNotifications: @escaping (@escaping (Bool) -> Void) -> Void, requestSiriAuthorization: @escaping (@escaping (Bool) -> Void) -> Void, siriAuthorization: @escaping () -> AccessType, getWindowHost: @escaping () -> WindowHost?, presentNativeController: @escaping (UIViewController) -> Void, dismissNativeController: @escaping () -> Void, getAvailableAlternateIcons: @escaping () -> [PresentationAppIcon], getAlternateIconName: @escaping () -> String?, requestSetAlternateIconName: @escaping (String?, @escaping (Bool) -> Void) -> Void) {
|
|
self.isMainApp = isMainApp
|
|
self.containerPath = containerPath
|
|
self.appSpecificScheme = appSpecificScheme
|
|
self.openUrl = openUrl
|
|
self.openUniversalUrl = openUniversalUrl
|
|
self.canOpenUrl = canOpenUrl
|
|
self.getTopWindow = getTopWindow
|
|
self.displayNotification = displayNotification
|
|
self.applicationInForeground = applicationInForeground
|
|
self.applicationIsActive = applicationIsActive
|
|
self.clearMessageNotifications = clearMessageNotifications
|
|
self.pushIdleTimerExtension = pushIdleTimerExtension
|
|
self.openSettings = openSettings
|
|
self.openAppStorePage = openAppStorePage
|
|
self.registerForNotifications = registerForNotifications
|
|
self.requestSiriAuthorization = requestSiriAuthorization
|
|
self.siriAuthorization = siriAuthorization
|
|
self.presentNativeController = presentNativeController
|
|
self.dismissNativeController = dismissNativeController
|
|
self.getWindowHost = getWindowHost
|
|
self.getAvailableAlternateIcons = getAvailableAlternateIcons
|
|
self.getAlternateIconName = getAlternateIconName
|
|
self.requestSetAlternateIconName = requestSetAlternateIconName
|
|
}
|
|
}
|
|
|
|
public enum TextLinkItemActionType {
|
|
case tap
|
|
case longTap
|
|
}
|
|
|
|
public enum TextLinkItem {
|
|
case url(String)
|
|
case mention(String)
|
|
case hashtag(String?, String)
|
|
}
|
|
|
|
public final class AccountWithInfo: Equatable {
|
|
public let account: Account
|
|
public let peer: Peer
|
|
|
|
public init(account: Account, peer: Peer) {
|
|
self.account = account
|
|
self.peer = peer
|
|
}
|
|
|
|
public static func ==(lhs: AccountWithInfo, rhs: AccountWithInfo) -> Bool {
|
|
if lhs.account !== rhs.account {
|
|
return false
|
|
}
|
|
if !arePeersEqual(lhs.peer, rhs.peer) {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
}
|
|
|
|
public enum OpenURLContext {
|
|
case generic
|
|
case chat
|
|
}
|
|
|
|
public struct ChatAvailableMessageActionOptions: OptionSet {
|
|
public var rawValue: Int32
|
|
|
|
public init(rawValue: Int32) {
|
|
self.rawValue = rawValue
|
|
}
|
|
|
|
public init() {
|
|
self.rawValue = 0
|
|
}
|
|
|
|
public static let deleteLocally = ChatAvailableMessageActionOptions(rawValue: 1 << 0)
|
|
public static let deleteGlobally = ChatAvailableMessageActionOptions(rawValue: 1 << 1)
|
|
public static let forward = ChatAvailableMessageActionOptions(rawValue: 1 << 2)
|
|
public static let report = ChatAvailableMessageActionOptions(rawValue: 1 << 3)
|
|
public static let viewStickerPack = ChatAvailableMessageActionOptions(rawValue: 1 << 4)
|
|
public static let rateCall = ChatAvailableMessageActionOptions(rawValue: 1 << 5)
|
|
public static let cancelSending = ChatAvailableMessageActionOptions(rawValue: 1 << 6)
|
|
public static let unsendPersonal = ChatAvailableMessageActionOptions(rawValue: 1 << 7)
|
|
public static let sendScheduledNow = ChatAvailableMessageActionOptions(rawValue: 1 << 8)
|
|
public static let editScheduledTime = ChatAvailableMessageActionOptions(rawValue: 1 << 9)
|
|
}
|
|
|
|
public struct ChatAvailableMessageActions {
|
|
public var options: ChatAvailableMessageActionOptions
|
|
public var banAuthor: Peer?
|
|
|
|
public init(options: ChatAvailableMessageActionOptions, banAuthor: Peer?) {
|
|
self.options = options
|
|
self.banAuthor = banAuthor
|
|
}
|
|
}
|
|
|
|
public protocol SharedAccountContext: class {
|
|
var basePath: String { get }
|
|
var mainWindow: Window1? { get }
|
|
var accountManager: AccountManager { get }
|
|
|
|
var currentPresentationData: Atomic<PresentationData> { get }
|
|
var presentationData: Signal<PresentationData, NoError> { get }
|
|
|
|
var currentAutomaticMediaDownloadSettings: Atomic<MediaAutoDownloadSettings> { get }
|
|
var automaticMediaDownloadSettings: Signal<MediaAutoDownloadSettings, NoError> { get }
|
|
var immediateExperimentalUISettings: ExperimentalUISettings { get }
|
|
var currentInAppNotificationSettings: Atomic<InAppNotificationSettings> { get }
|
|
var currentMediaInputSettings: Atomic<MediaInputSettings> { get }
|
|
|
|
var applicationBindings: TelegramApplicationBindings { get }
|
|
|
|
var mediaManager: MediaManager { get }
|
|
var locationManager: DeviceLocationManager? { get }
|
|
var callManager: PresentationCallManager? { get }
|
|
var contactDataManager: DeviceContactDataManager? { get }
|
|
|
|
var activeAccounts: Signal<(primary: Account?, accounts: [(AccountRecordId, Account, Int32)], currentAuth: UnauthorizedAccount?), NoError> { get }
|
|
var activeAccountsWithInfo: Signal<(primary: AccountRecordId?, accounts: [AccountWithInfo]), NoError> { get }
|
|
|
|
var presentGlobalController: (ViewController, Any?) -> Void { get }
|
|
|
|
func makeTempAccountContext(account: Account) -> AccountContext
|
|
|
|
func updateNotificationTokensRegistration()
|
|
func setAccountUserInterfaceInUse(_ id: AccountRecordId) -> Disposable
|
|
func handleTextLinkAction(context: AccountContext, peerId: PeerId?, navigateDisposable: MetaDisposable, controller: ViewController, action: TextLinkItemActionType, itemLink: TextLinkItem)
|
|
func navigateToChat(accountId: AccountRecordId, peerId: PeerId, messageId: MessageId?)
|
|
func openChatMessage(_ params: OpenChatMessageParams) -> Bool
|
|
func messageFromPreloadedChatHistoryViewForLocation(id: MessageId, location: ChatHistoryLocationInput, account: Account, chatLocation: ChatLocation, tagMask: MessageTags?) -> Signal<(MessageIndex?, Bool), NoError>
|
|
func makeOverlayAudioPlayerController(context: AccountContext, peerId: PeerId, type: MediaManagerPlayerType, initialMessageId: MessageId, initialOrder: MusicPlaybackSettingsOrder, parentNavigationController: NavigationController?) -> ViewController & OverlayAudioPlayerController
|
|
func makePeerInfoController(context: AccountContext, peer: Peer) -> ViewController?
|
|
func openExternalUrl(context: AccountContext, urlContext: OpenURLContext, url: String, forceExternal: Bool, presentationData: PresentationData, navigationController: NavigationController?, dismissInput: @escaping () -> Void)
|
|
func chatAvailableMessageActions(postbox: Postbox, accountPeerId: PeerId, messageIds: Set<MessageId>) -> Signal<ChatAvailableMessageActions, NoError>
|
|
|
|
func navigateToCurrentCall()
|
|
var hasOngoingCall: ValuePromise<Bool> { get }
|
|
var immediateHasOngoingCall: Bool { get }
|
|
|
|
func switchToAccount(id: AccountRecordId, fromSettingsController settingsController: ViewController?, withChatListController chatListController: ViewController?)
|
|
func beginNewAuth(testingEnvironment: Bool)
|
|
}
|
|
|
|
public protocol AccountContext: class {
|
|
var sharedContext: SharedAccountContext { get }
|
|
var account: Account { get }
|
|
|
|
var liveLocationManager: LiveLocationManager? { get }
|
|
var fetchManager: FetchManager { get }
|
|
var downloadedMediaStoreManager: DownloadedMediaStoreManager { get }
|
|
var peerChannelMemberCategoriesContextsManager: PeerChannelMemberCategoriesContextsManager { get }
|
|
var wallpaperUploadManager: WallpaperUploadManager? { get }
|
|
var watchManager: WatchManager? { get }
|
|
|
|
var currentLimitsConfiguration: Atomic<LimitsConfiguration> { get }
|
|
|
|
func storeSecureIdPassword(password: String)
|
|
func getStoredSecureIdPassword() -> String?
|
|
}
|