mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
2.1 KiB
Swift
63 lines
2.1 KiB
Swift
// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
|
|
|
|
import Foundation
|
|
import SessionUtilitiesKit
|
|
|
|
public class SessionEnvironment {
|
|
public static var shared: SessionEnvironment?
|
|
|
|
public let reachabilityManager: SSKReachabilityManager
|
|
|
|
public let audioSession: OWSAudioSession
|
|
public let proximityMonitoringManager: OWSProximityMonitoringManager
|
|
public let windowManager: OWSWindowManager
|
|
public var isRequestingPermission: Bool
|
|
|
|
// Note: This property is configured after Environment is created.
|
|
public let callManager: Atomic<CallManagerProtocol?> = Atomic(nil)
|
|
|
|
// Note: This property is configured after Environment is created.
|
|
public let notificationsManager: Atomic<NotificationsProtocol?> = Atomic(nil)
|
|
|
|
public var isComplete: Bool {
|
|
(notificationsManager.wrappedValue != nil)
|
|
}
|
|
|
|
// MARK: - Initialization
|
|
|
|
public init(
|
|
reachabilityManager: SSKReachabilityManager,
|
|
audioSession: OWSAudioSession,
|
|
proximityMonitoringManager: OWSProximityMonitoringManager,
|
|
windowManager: OWSWindowManager
|
|
) {
|
|
self.reachabilityManager = reachabilityManager
|
|
self.audioSession = audioSession
|
|
self.proximityMonitoringManager = proximityMonitoringManager
|
|
self.windowManager = windowManager
|
|
self.isRequestingPermission = false
|
|
|
|
if SessionEnvironment.shared == nil {
|
|
SessionEnvironment.shared = self
|
|
}
|
|
}
|
|
|
|
// MARK: - Functions
|
|
|
|
public static func clearSharedForTests() {
|
|
shared = nil
|
|
}
|
|
}
|
|
|
|
// MARK: - Objective C Support
|
|
|
|
@objc(SMKEnvironment)
|
|
public class SMKEnvironment: NSObject {
|
|
@objc public static let shared: SMKEnvironment = SMKEnvironment()
|
|
|
|
@objc public var audioSession: OWSAudioSession? { SessionEnvironment.shared?.audioSession }
|
|
@objc public var windowManager: OWSWindowManager? { SessionEnvironment.shared?.windowManager }
|
|
|
|
@objc public var isRequestingPermission: Bool { (SessionEnvironment.shared?.isRequestingPermission == true) }
|
|
}
|