diff --git a/ElementX/Sources/Application/AppSettings.swift b/ElementX/Sources/Application/AppSettings.swift index 8fc3a7c5d..53842c889 100644 --- a/ElementX/Sources/Application/AppSettings.swift +++ b/ElementX/Sources/Application/AppSettings.swift @@ -231,9 +231,6 @@ final class AppSettings { @UserPreference(key: UserDefaultsKeys.elementCallBaseURL, defaultValue: "https://call.element.io", storageType: .userDefaults(store)) var elementCallBaseURL: URL - @UserPreference(key: UserDefaultsKeys.elementCallEncryptionEnabled, defaultValue: true, storageType: .userDefaults(store)) - var elementCallUseEncryption - // MARK: - Notifications @UserPreference(key: UserDefaultsKeys.enableNotifications, defaultValue: true, storageType: .userDefaults(store)) diff --git a/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift index 11e7a16a5..8f07ad2c6 100644 --- a/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift +++ b/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift @@ -495,8 +495,7 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol { private func presentCallScreen(roomProxy: RoomProxyProtocol) { let callScreenCoordinator = CallScreenCoordinator(parameters: .init(roomProxy: roomProxy, callBaseURL: appSettings.elementCallBaseURL, - clientID: InfoPlistReader.main.bundleIdentifier, - useEncryption: appSettings.elementCallUseEncryption)) + clientID: InfoPlistReader.main.bundleIdentifier)) callScreenCoordinator.actions .sink { [weak self] action in diff --git a/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift b/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift index 8a593edb4..81ef995ed 100644 --- a/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift +++ b/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift @@ -754,23 +754,23 @@ class ElementCallWidgetDriverMock: ElementCallWidgetDriverProtocol { //MARK: - start - var startBaseURLClientIDUseEncryptionCallsCount = 0 - var startBaseURLClientIDUseEncryptionCalled: Bool { - return startBaseURLClientIDUseEncryptionCallsCount > 0 + var startBaseURLClientIDCallsCount = 0 + var startBaseURLClientIDCalled: Bool { + return startBaseURLClientIDCallsCount > 0 } - var startBaseURLClientIDUseEncryptionReceivedArguments: (baseURL: URL, clientID: String, useEncryption: Bool)? - var startBaseURLClientIDUseEncryptionReceivedInvocations: [(baseURL: URL, clientID: String, useEncryption: Bool)] = [] - var startBaseURLClientIDUseEncryptionReturnValue: Result! - var startBaseURLClientIDUseEncryptionClosure: ((URL, String, Bool) async -> Result)? + var startBaseURLClientIDReceivedArguments: (baseURL: URL, clientID: String)? + var startBaseURLClientIDReceivedInvocations: [(baseURL: URL, clientID: String)] = [] + var startBaseURLClientIDReturnValue: Result! + var startBaseURLClientIDClosure: ((URL, String) async -> Result)? - func start(baseURL: URL, clientID: String, useEncryption: Bool) async -> Result { - startBaseURLClientIDUseEncryptionCallsCount += 1 - startBaseURLClientIDUseEncryptionReceivedArguments = (baseURL: baseURL, clientID: clientID, useEncryption: useEncryption) - startBaseURLClientIDUseEncryptionReceivedInvocations.append((baseURL: baseURL, clientID: clientID, useEncryption: useEncryption)) - if let startBaseURLClientIDUseEncryptionClosure = startBaseURLClientIDUseEncryptionClosure { - return await startBaseURLClientIDUseEncryptionClosure(baseURL, clientID, useEncryption) + func start(baseURL: URL, clientID: String) async -> Result { + startBaseURLClientIDCallsCount += 1 + startBaseURLClientIDReceivedArguments = (baseURL: baseURL, clientID: clientID) + startBaseURLClientIDReceivedInvocations.append((baseURL: baseURL, clientID: clientID)) + if let startBaseURLClientIDClosure = startBaseURLClientIDClosure { + return await startBaseURLClientIDClosure(baseURL, clientID) } else { - return startBaseURLClientIDUseEncryptionReturnValue + return startBaseURLClientIDReturnValue } } //MARK: - sendMessage diff --git a/ElementX/Sources/Mocks/RoomProxyMock.swift b/ElementX/Sources/Mocks/RoomProxyMock.swift index b931b49b3..b5ca2d3c7 100644 --- a/ElementX/Sources/Mocks/RoomProxyMock.swift +++ b/ElementX/Sources/Mocks/RoomProxyMock.swift @@ -96,7 +96,7 @@ extension RoomProxyMock { fatalError() } - widgetDriver.startBaseURLClientIDUseEncryptionReturnValue = .success(url) + widgetDriver.startBaseURLClientIDReturnValue = .success(url) elementCallWidgetDriverReturnValue = widgetDriver } diff --git a/ElementX/Sources/Screens/CallScreen/CallScreenCoordinator.swift b/ElementX/Sources/Screens/CallScreen/CallScreenCoordinator.swift index 4ec0f19ec..58954e9f7 100644 --- a/ElementX/Sources/Screens/CallScreen/CallScreenCoordinator.swift +++ b/ElementX/Sources/Screens/CallScreen/CallScreenCoordinator.swift @@ -23,8 +23,6 @@ struct CallScreenCoordinatorParameters { let callBaseURL: URL /// A way to identify the current client against Element Call let clientID: String - /// Whether encryption should be used within the call - let useEncryption: Bool } enum CallScreenCoordinatorAction { @@ -43,8 +41,7 @@ final class CallScreenCoordinator: CoordinatorProtocol { init(parameters: CallScreenCoordinatorParameters) { viewModel = CallScreenViewModel(roomProxy: parameters.roomProxy, callBaseURL: parameters.callBaseURL, - clientID: parameters.clientID, - useEncryption: parameters.useEncryption) + clientID: parameters.clientID) } func start() { diff --git a/ElementX/Sources/Screens/CallScreen/CallScreenViewModel.swift b/ElementX/Sources/Screens/CallScreen/CallScreenViewModel.swift index 15dc4ce3f..ec13a0542 100644 --- a/ElementX/Sources/Screens/CallScreen/CallScreenViewModel.swift +++ b/ElementX/Sources/Screens/CallScreen/CallScreenViewModel.swift @@ -48,8 +48,7 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol /// - clientID: Something to identify the current client on the Element Call side init(roomProxy: RoomProxyProtocol, callBaseURL: URL, - clientID: String, - useEncryption: Bool) { + clientID: String) { self.roomProxy = roomProxy widgetDriver = roomProxy.elementCallWidgetDriver() @@ -98,7 +97,7 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol .store(in: &cancellables) Task { - switch await widgetDriver.start(baseURL: callBaseURL, clientID: clientID, useEncryption: useEncryption) { + switch await widgetDriver.start(baseURL: callBaseURL, clientID: clientID) { case .success(let url): state.url = url case .failure(let error): diff --git a/ElementX/Sources/Screens/CallScreen/View/CallScreen.swift b/ElementX/Sources/Screens/CallScreen/View/CallScreen.swift index fb07696c1..0fc219b32 100644 --- a/ElementX/Sources/Screens/CallScreen/View/CallScreen.swift +++ b/ElementX/Sources/Screens/CallScreen/View/CallScreen.swift @@ -163,14 +163,13 @@ struct CallScreen_Previews: PreviewProvider { let widgetDriver = ElementCallWidgetDriverMock() widgetDriver.underlyingMessagePublisher = .init() widgetDriver.underlyingActions = PassthroughSubject().eraseToAnyPublisher() - widgetDriver.startBaseURLClientIDUseEncryptionReturnValue = .success(URL.userDirectory) + widgetDriver.startBaseURLClientIDReturnValue = .success(URL.userDirectory) roomProxy.elementCallWidgetDriverReturnValue = widgetDriver return CallScreenViewModel(roomProxy: roomProxy, callBaseURL: "https://call.element.io", - clientID: "io.element.elementx", - useEncryption: false) + clientID: "io.element.elementx") }() static var previews: some View { diff --git a/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/DeveloperOptionsScreenModels.swift b/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/DeveloperOptionsScreenModels.swift index 4f7c83d63..a8b7e99b3 100644 --- a/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/DeveloperOptionsScreenModels.swift +++ b/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/DeveloperOptionsScreenModels.swift @@ -53,7 +53,6 @@ protocol DeveloperOptionsProtocol: AnyObject { var roomListFiltersEnabled: Bool { get set } var elementCallBaseURL: URL { get set } - var elementCallUseEncryption: Bool { get set } } extension AppSettings: DeveloperOptionsProtocol { } diff --git a/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/View/DeveloperOptionsScreen.swift b/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/View/DeveloperOptionsScreen.swift index 4e16634a1..05d086425 100644 --- a/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/View/DeveloperOptionsScreen.swift +++ b/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/View/DeveloperOptionsScreen.swift @@ -75,10 +75,6 @@ struct DeveloperOptionsScreen: View { .autocorrectionDisabled(true) .autocapitalization(.none) .foregroundColor(URL(string: elementCallBaseURLString) == nil ? .red : .primary) - - Toggle(isOn: $context.elementCallUseEncryption) { - Text("Use encryption") - } } Section { diff --git a/ElementX/Sources/Services/ElementCall/ElementCallWidgetDriver.swift b/ElementX/Sources/Services/ElementCall/ElementCallWidgetDriver.swift index 34f709ffc..1f263eaec 100644 --- a/ElementX/Sources/Services/ElementCall/ElementCallWidgetDriver.swift +++ b/ElementX/Sources/Services/ElementCall/ElementCallWidgetDriver.swift @@ -52,11 +52,13 @@ class ElementCallWidgetDriver: WidgetCapabilitiesProvider, ElementCallWidgetDriv self.room = room } - func start(baseURL: URL, clientID: String, useEncryption: Bool) async -> Result { + func start(baseURL: URL, clientID: String) async -> Result { guard let room = room as? Room else { return .failure(.roomInvalid) } + let useEncryption = (try? room.isEncrypted()) ?? false + guard let widgetSettings = try? newVirtualElementCallWidget(props: .init(elementCallUrl: baseURL.absoluteString, widgetId: UUID().uuidString, parentUrl: nil, diff --git a/ElementX/Sources/Services/ElementCall/ElementCallWidgetDriverProtocol.swift b/ElementX/Sources/Services/ElementCall/ElementCallWidgetDriverProtocol.swift index 11a4f137b..74332ce52 100644 --- a/ElementX/Sources/Services/ElementCall/ElementCallWidgetDriverProtocol.swift +++ b/ElementX/Sources/Services/ElementCall/ElementCallWidgetDriverProtocol.swift @@ -35,7 +35,7 @@ protocol ElementCallWidgetDriverProtocol { var messagePublisher: PassthroughSubject { get } var actions: AnyPublisher { get } - func start(baseURL: URL, clientID: String, useEncryption: Bool) async -> Result + func start(baseURL: URL, clientID: String) async -> Result func sendMessage(_ message: String) async -> Result }