2023-10-17 12:41:56 +03:00
|
|
|
//
|
2024-09-06 16:34:30 +03:00
|
|
|
// Copyright 2023, 2024 New Vector Ltd.
|
2023-10-17 12:41:56 +03:00
|
|
|
//
|
2025-01-06 11:27:37 +01:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|
|
|
// Please see LICENSE files in the repository root for full details.
|
2023-10-17 12:41:56 +03:00
|
|
|
//
|
|
|
|
|
|
|
|
import Combine
|
2024-07-09 12:07:13 +01:00
|
|
|
import SwiftUI
|
2023-10-17 12:41:56 +03:00
|
|
|
|
|
|
|
enum ElementCallWidgetDriverError: Error {
|
|
|
|
case roomInvalid
|
|
|
|
case failedBuildingCallURL
|
|
|
|
case failedBuildingWidgetSettings
|
|
|
|
case failedBuildingWidgetDriver
|
|
|
|
case failedParsingCallURL
|
|
|
|
case driverNotSetup
|
|
|
|
}
|
|
|
|
|
|
|
|
enum ElementCallWidgetDriverAction {
|
|
|
|
case callEnded
|
2024-08-06 13:23:29 +03:00
|
|
|
case mediaStateChanged(audioEnabled: Bool, videoEnabled: Bool)
|
2023-10-17 12:41:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// sourcery: AutoMockable
|
|
|
|
protocol ElementCallWidgetDriverProtocol {
|
2024-05-24 13:09:52 +03:00
|
|
|
var widgetID: String { get }
|
|
|
|
|
2023-10-17 12:41:56 +03:00
|
|
|
var messagePublisher: PassthroughSubject<String, Never> { get }
|
|
|
|
var actions: AnyPublisher<ElementCallWidgetDriverAction, Never> { get }
|
|
|
|
|
2024-07-09 12:07:13 +01:00
|
|
|
func start(baseURL: URL, clientID: String, colorScheme: ColorScheme) async -> Result<URL, ElementCallWidgetDriverError>
|
2023-10-17 12:41:56 +03:00
|
|
|
|
2024-08-19 17:21:25 +01:00
|
|
|
/// Passes a message from the Widget to the SDK to handle, returning a Bool that represents whether or not the widget driver is still running.
|
|
|
|
func handleMessage(_ message: String) async -> Result<Bool, ElementCallWidgetDriverError>
|
2023-10-17 12:41:56 +03:00
|
|
|
}
|