From a96ae05dd687b7c0ebfd72105c76b26ba2ec4099 Mon Sep 17 00:00:00 2001 From: Benoit Martins Date: Tue, 9 Jul 2024 16:51:35 +0200 Subject: [PATCH] Fix conference pause and resuming --- .../TelecomManager/ProviderDelegate.swift | 9 +- Linphone/TelecomManager/TelecomManager.swift | 13 ++- .../Fragments/ParticipantsListFragment.swift | 2 +- .../UI/Main/History/Model/HistoryModel.swift | 83 ++++++++++++++----- 4 files changed, 75 insertions(+), 32 deletions(-) diff --git a/Linphone/TelecomManager/ProviderDelegate.swift b/Linphone/TelecomManager/ProviderDelegate.swift index 8eb6a3617..779839a8e 100644 --- a/Linphone/TelecomManager/ProviderDelegate.swift +++ b/Linphone/TelecomManager/ProviderDelegate.swift @@ -287,12 +287,9 @@ extension ProviderDelegate: CXProviderDelegate { // attempt to resume another one. action.fulfill() } else { - if call?.conference != nil && core.callsNb > 1 { - /* - try TelecomManager.shared.lc?.enterConference() - action.fulfill() - NotificationCenter.default.post(name: Notification.Name("LinphoneCallUpdate"), object: self) - */ + if call != nil && call?.conference != nil && core.callsNb > 1 { + _ = call!.conference!.enter() + TelecomManager.shared.actionToFulFill = action } else { try call!.resume() // We'll notify callkit that the action is fulfilled when receiving the 200Ok, which is the point diff --git a/Linphone/TelecomManager/TelecomManager.swift b/Linphone/TelecomManager/TelecomManager.swift index 3f7b3f85c..2606b2267 100644 --- a/Linphone/TelecomManager/TelecomManager.swift +++ b/Linphone/TelecomManager/TelecomManager.swift @@ -456,14 +456,19 @@ class TelecomManager: ObservableObject { } } } else { - DispatchQueue.main.async { - self.remoteConfVideo = false - if call.currentParams != nil { - let remoteConfVideoTmp = call.currentParams!.videoEnabled && call.currentParams!.videoDirection == .SendRecv || call.currentParams!.videoDirection == .RecvOnly + if call.currentParams != nil { + let remoteConfVideoTmp = call.currentParams!.videoEnabled && call.currentParams!.videoDirection == .SendRecv || call.currentParams!.videoDirection == .RecvOnly + + DispatchQueue.main.async { + self.remoteConfVideo = false DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { self.remoteConfVideo = remoteConfVideoTmp } } + } else { + DispatchQueue.main.async { + self.remoteConfVideo = false + } } } diff --git a/Linphone/UI/Call/Fragments/ParticipantsListFragment.swift b/Linphone/UI/Call/Fragments/ParticipantsListFragment.swift index 41c77a110..e80c723e6 100644 --- a/Linphone/UI/Call/Fragments/ParticipantsListFragment.swift +++ b/Linphone/UI/Call/Fragments/ParticipantsListFragment.swift @@ -81,7 +81,7 @@ struct ParticipantsListFragment: View { HStack { Spacer() - if callViewModel.myParticipantModel!.isAdmin { + if callViewModel.myParticipantModel != nil && callViewModel.myParticipantModel!.isAdmin { NavigationLink(destination: { AddParticipantsFragment(addParticipantsViewModel: addParticipantsViewModel, confirmAddParticipantsFunc: callViewModel.addParticipants) .onAppear { diff --git a/Linphone/UI/Main/History/Model/HistoryModel.swift b/Linphone/UI/Main/History/Model/HistoryModel.swift index cc356f2f3..4a996b190 100644 --- a/Linphone/UI/Main/History/Model/HistoryModel.swift +++ b/Linphone/UI/Main/History/Model/HistoryModel.swift @@ -26,9 +26,9 @@ class HistoryModel: ObservableObject { static let TAG = "[History Model]" - let callLog: CallLog + var callLog: CallLog - let id: String + var id: String @Published var subject: String @Published var isConf: Bool @Published var addressLinphone: Address @@ -38,35 +38,76 @@ class HistoryModel: ObservableObject { @Published var status: Call.Status @Published var startDate: time_t @Published var duration: Int - @Published var addressFriend: Friend? = nil - @Published var avatarModel: ContactAvatarModel? = nil + @Published var addressFriend: Friend? + @Published var avatarModel: ContactAvatarModel? init(callLog: CallLog) { self.callLog = callLog - self.id = callLog.callId ?? "" - self.subject = callLog.conferenceInfo != nil && callLog.conferenceInfo!.subject != nil ? callLog.conferenceInfo!.subject! : "" - self.isConf = callLog.conferenceInfo != nil + self.id = "" + self.subject = "" + self.isConf = false - let addressLinphoneTmp = callLog.dir == .Outgoing && callLog.toAddress != nil ? callLog.toAddress! : callLog.fromAddress! - self.addressLinphone = addressLinphoneTmp - //let addressLinphone = callLog.dir == .Outgoing && callLog.toAddress != nil ? callLog.toAddress! : callLog.fromAddress! - self.address = addressLinphoneTmp.asStringUriOnly() + self.addressLinphone = callLog.dir == .Outgoing && callLog.toAddress != nil ? callLog.toAddress! : callLog.fromAddress! + self.address = "" - let addressNameTmp = callLog.conferenceInfo != nil && callLog.conferenceInfo!.subject != nil - ? callLog.conferenceInfo!.subject! - : (addressLinphoneTmp.username != nil ? addressLinphoneTmp.username ?? "" : addressLinphoneTmp.displayName ?? "") + self.addressName = "" - self.addressName = addressNameTmp + self.isOutgoing = false - self.isOutgoing = callLog.dir == .Outgoing + self.status = .Success - self.status = callLog.status + self.startDate = 0 - self.startDate = callLog.startDate + self.duration = 0 - self.duration = callLog.duration - - refreshAvatarModel() + self.initValue(callLog: callLog) + } + + func initValue(callLog: CallLog) { + coreContext.doOnCoreQueue { _ in + let callLogTmp = callLog + let idTmp = callLog.callId ?? "" + let subjectTmp = callLog.conferenceInfo != nil && callLog.conferenceInfo!.subject != nil ? callLog.conferenceInfo!.subject! : "" + let isConfTmp = callLog.conferenceInfo != nil + + let addressLinphoneTmp = callLog.dir == .Outgoing && callLog.toAddress != nil ? callLog.toAddress! : callLog.fromAddress! + + let addressNameTmp = callLog.conferenceInfo != nil && callLog.conferenceInfo!.subject != nil + ? callLog.conferenceInfo!.subject! + : (addressLinphoneTmp.username != nil ? addressLinphoneTmp.username ?? "" : addressLinphoneTmp.displayName ?? "") + + let addressTmp = addressLinphoneTmp.asStringUriOnly() + + let isOutgoingTmp = callLog.dir == .Outgoing + + let statusTmp = callLog.status + + let startDateTmp = callLog.startDate + + let durationTmp = callLog.duration + + DispatchQueue.main.async { + self.callLog = callLogTmp + self.id = idTmp + self.subject = subjectTmp + self.isConf = isConfTmp + + self.addressLinphone = addressLinphoneTmp + self.address = addressTmp + + self.addressName = addressNameTmp + + self.isOutgoing = isOutgoingTmp + + self.status = statusTmp + + self.startDate = startDateTmp + + self.duration = durationTmp + } + + self.refreshAvatarModel() + } } func refreshAvatarModel() {