From 4c45a9bb1ea4cb1c451f6277f28c9d3b64dcbcfe Mon Sep 17 00:00:00 2001 From: Benoit Martins Date: Thu, 18 Dec 2025 10:42:28 +0100 Subject: [PATCH] Disable video calls when core.videoEnabled is false --- Linphone/GeneratedGit.swift | 2 +- Linphone/UI/Call/CallView.swift | 52 ++++++------- .../UI/Call/MeetingWaitingRoomFragment.swift | 32 ++++---- .../Fragments/ContactInnerFragment.swift | 74 ++++++++++--------- .../Fragments/HistoryContactFragment.swift | 44 +++++------ .../Main/Viewmodel/SharedMainViewModel.swift | 15 +++- .../xcshareddata/swiftpm/Package.resolved | 2 +- 7 files changed, 121 insertions(+), 100 deletions(-) diff --git a/Linphone/GeneratedGit.swift b/Linphone/GeneratedGit.swift index d83a76821..5cc2080c9 100644 --- a/Linphone/GeneratedGit.swift +++ b/Linphone/GeneratedGit.swift @@ -2,6 +2,6 @@ import Foundation public enum AppGitInfo { public static let branch = "master" - public static let commit = "1501dae01" + public static let commit = "4feae7fcc" public static let tag = "6.1.0-alpha" } diff --git a/Linphone/UI/Call/CallView.swift b/Linphone/UI/Call/CallView.swift index 1381a3c65..fbe85853c 100644 --- a/Linphone/UI/Call/CallView.swift +++ b/Linphone/UI/Call/CallView.swift @@ -1956,36 +1956,38 @@ struct CallView: View { Spacer() - ZStack { - Button { - if optionsChangeLayout == 3 { - optionsChangeLayout = 2 - callViewModel.toggleVideoMode(isAudioOnlyMode: false) - } else { - callViewModel.displayMyVideo() + if !SharedMainViewModel.shared.disableVideoCall { + ZStack { + Button { + if optionsChangeLayout == 3 { + optionsChangeLayout = 2 + callViewModel.toggleVideoMode(isAudioOnlyMode: false) + } else { + callViewModel.displayMyVideo() + } + } label: { + HStack { + Image(callViewModel.videoDisplayed ? "video-camera" : "video-camera-slash") + .renderingMode(.template) + .resizable() + .foregroundStyle(.white) + .frame(width: 32, height: 32) + } } - } label: { - HStack { - Image(callViewModel.videoDisplayed ? "video-camera" : "video-camera-slash") - .renderingMode(.template) - .resizable() - .foregroundStyle(.white) - .frame(width: 32, height: 32) + .buttonStyle(PressedButtonStyle(buttonSize: buttonSize)) + .frame(width: buttonSize, height: buttonSize) + .background(Color.gray500) + .cornerRadius(40) + .disabled(callViewModel.isPaused || telecomManager.isPausedByRemote || telecomManager.outgoingCallStarted || optionsChangeLayout == 3) + + if callViewModel.isPaused || telecomManager.isPausedByRemote || telecomManager.outgoingCallStarted || optionsChangeLayout == 3 { + Color.gray600.opacity(0.8) + .cornerRadius(40) + .allowsHitTesting(false) } } - .buttonStyle(PressedButtonStyle(buttonSize: buttonSize)) .frame(width: buttonSize, height: buttonSize) - .background(Color.gray500) - .cornerRadius(40) - .disabled(callViewModel.isPaused || telecomManager.isPausedByRemote || telecomManager.outgoingCallStarted || optionsChangeLayout == 3) - - if callViewModel.isPaused || telecomManager.isPausedByRemote || telecomManager.outgoingCallStarted || optionsChangeLayout == 3 { - Color.gray600.opacity(0.8) - .cornerRadius(40) - .allowsHitTesting(false) - } } - .frame(width: buttonSize, height: buttonSize) Button { callViewModel.toggleMuteMicrophone() diff --git a/Linphone/UI/Call/MeetingWaitingRoomFragment.swift b/Linphone/UI/Call/MeetingWaitingRoomFragment.swift index 485f956f6..af9160fc2 100644 --- a/Linphone/UI/Call/MeetingWaitingRoomFragment.swift +++ b/Linphone/UI/Call/MeetingWaitingRoomFragment.swift @@ -266,23 +266,25 @@ struct MeetingWaitingRoomFragment: View { HStack { Spacer() - Button { - !meetingWaitingRoomViewModel.videoDisplayed - ? meetingWaitingRoomViewModel.enableVideoPreview() : meetingWaitingRoomViewModel.disableVideoPreview() - } label: { - HStack { - Image(meetingWaitingRoomViewModel.videoDisplayed ? "video-camera" : "video-camera-slash") - .renderingMode(.template) - .resizable() - .foregroundStyle(.white) - .frame(width: 32, height: 32) + if !SharedMainViewModel.shared.disableVideoCall { + Button { + !meetingWaitingRoomViewModel.videoDisplayed + ? meetingWaitingRoomViewModel.enableVideoPreview() : meetingWaitingRoomViewModel.disableVideoPreview() + } label: { + HStack { + Image(meetingWaitingRoomViewModel.videoDisplayed ? "video-camera" : "video-camera-slash") + .renderingMode(.template) + .resizable() + .foregroundStyle(.white) + .frame(width: 32, height: 32) + } } + .buttonStyle(PressedButtonStyle(buttonSize: 60)) + .frame(width: 60, height: 60) + .background(Color.gray500) + .cornerRadius(40) + .padding(.horizontal, 5) } - .buttonStyle(PressedButtonStyle(buttonSize: 60)) - .frame(width: 60, height: 60) - .background(Color.gray500) - .cornerRadius(40) - .padding(.horizontal, 5) Button { meetingWaitingRoomViewModel.toggleMuteMicrophone() diff --git a/Linphone/UI/Main/Contacts/Fragments/ContactInnerFragment.swift b/Linphone/UI/Main/Contacts/Fragments/ContactInnerFragment.swift index bece283f3..0b89f735a 100644 --- a/Linphone/UI/Main/Contacts/Fragments/ContactInnerFragment.swift +++ b/Linphone/UI/Main/Contacts/Fragments/ContactInnerFragment.swift @@ -225,45 +225,47 @@ struct ContactInnerFragment: View { Spacer() - Button(action: { - CoreContext.shared.doOnCoreQueue { core in - if contactAvatarModel.addresses.count == 1 { - do { - let address = try Factory.Instance.createAddress(addr: contactAvatarModel.address) - telecomManager.doCallOrJoinConf(address: address, isVideo: true) - } catch { - Log.error("[ContactInnerFragment] unable to create address for a new outgoing call : \(contactAvatarModel.address) \(error) ") - } - } else if contactAvatarModel.addresses.count < 1 && contactAvatarModel.phoneNumbersWithLabel.count == 1 { - if let firstPhoneNumbersWithLabel = contactAvatarModel.phoneNumbersWithLabel.first, let address = core.interpretUrl(url: firstPhoneNumbersWithLabel.phoneNumber, applyInternationalPrefix: LinphoneUtils.applyInternationalPrefix(core: core)) { - telecomManager.doCallOrJoinConf(address: address, isVideo: true) - } - } else { - DispatchQueue.main.async { - isShowSipAddressesPopupType = 2 - isShowSipAddressesPopup = true + if !SharedMainViewModel.shared.disableVideoCall { + Button(action: { + CoreContext.shared.doOnCoreQueue { core in + if contactAvatarModel.addresses.count == 1 { + do { + let address = try Factory.Instance.createAddress(addr: contactAvatarModel.address) + telecomManager.doCallOrJoinConf(address: address, isVideo: true) + } catch { + Log.error("[ContactInnerFragment] unable to create address for a new outgoing call : \(contactAvatarModel.address) \(error) ") + } + } else if contactAvatarModel.addresses.count < 1 && contactAvatarModel.phoneNumbersWithLabel.count == 1 { + if let firstPhoneNumbersWithLabel = contactAvatarModel.phoneNumbersWithLabel.first, let address = core.interpretUrl(url: firstPhoneNumbersWithLabel.phoneNumber, applyInternationalPrefix: LinphoneUtils.applyInternationalPrefix(core: core)) { + telecomManager.doCallOrJoinConf(address: address, isVideo: true) + } + } else { + DispatchQueue.main.async { + isShowSipAddressesPopupType = 2 + isShowSipAddressesPopup = true + } } } - } - }, label: { - VStack { - HStack(alignment: .center) { - Image("video-camera") - .renderingMode(.template) - .resizable() - .foregroundStyle(Color.grayMain2c600) - .frame(width: 25, height: 25) + }, label: { + VStack { + HStack(alignment: .center) { + Image("video-camera") + .renderingMode(.template) + .resizable() + .foregroundStyle(Color.grayMain2c600) + .frame(width: 25, height: 25) + } + .padding(16) + .background(Color.grayMain2c200) + .cornerRadius(40) + + Text("contact_video_call_action") + .default_text_style(styleSize: 14) } - .padding(16) - .background(Color.grayMain2c200) - .cornerRadius(40) - - Text("contact_video_call_action") - .default_text_style(styleSize: 14) - } - }) - - Spacer() + }) + + Spacer() + } } .padding(.top, 20) .frame(maxWidth: .infinity) diff --git a/Linphone/UI/Main/History/Fragments/HistoryContactFragment.swift b/Linphone/UI/Main/History/Fragments/HistoryContactFragment.swift index 3361d0d23..055c72e34 100644 --- a/Linphone/UI/Main/History/Fragments/HistoryContactFragment.swift +++ b/Linphone/UI/Main/History/Fragments/HistoryContactFragment.swift @@ -283,29 +283,31 @@ struct HistoryContactFragment: View { } }) } - - Spacer() - Button(action: { - telecomManager.doCallOrJoinConf(address: historyModel.addressLinphone, isVideo: true) - }, label: { - VStack { - HStack(alignment: .center) { - Image("video-camera") - .renderingMode(.template) - .resizable() - .foregroundStyle(Color.grayMain2c600) - .frame(width: 25, height: 25) + if !SharedMainViewModel.shared.disableVideoCall { + Spacer() + + Button(action: { + telecomManager.doCallOrJoinConf(address: historyModel.addressLinphone, isVideo: true) + }, label: { + VStack { + HStack(alignment: .center) { + Image("video-camera") + .renderingMode(.template) + .resizable() + .foregroundStyle(Color.grayMain2c600) + .frame(width: 25, height: 25) + } + .padding(16) + .background(Color.grayMain2c200) + .cornerRadius(40) + + Text("contact_video_call_action") + .default_text_style(styleSize: 14) + .frame(minWidth: 80) } - .padding(16) - .background(Color.grayMain2c200) - .cornerRadius(40) - - Text("contact_video_call_action") - .default_text_style(styleSize: 14) - .frame(minWidth: 80) - } - }) + }) + } } else { Button(action: { withAnimation { diff --git a/Linphone/UI/Main/Viewmodel/SharedMainViewModel.swift b/Linphone/UI/Main/Viewmodel/SharedMainViewModel.swift index 700508eab..39fa3e889 100644 --- a/Linphone/UI/Main/Viewmodel/SharedMainViewModel.swift +++ b/Linphone/UI/Main/Viewmodel/SharedMainViewModel.swift @@ -48,6 +48,7 @@ class SharedMainViewModel: ObservableObject { @Published var missedCallsCount: Int = 0 @Published var cardDavFriendsListsCount: Int = 0 + @Published var disableVideoCall: Bool = false @Published var disableChatFeature: Bool = false @Published var disableMeetingFeature: Bool = false @@ -95,8 +96,9 @@ class SharedMainViewModel: ObservableObject { } updateMissedCallsCount() - updateUnreadMessagesCount() + updateDisableVideoCall() updateDisableChatFeature() + updateUnreadMessagesCount() updateDisableMeetingFeature() getCardDavFriendsListsCount() @@ -225,6 +227,16 @@ class SharedMainViewModel: ObservableObject { } } + func updateDisableVideoCall() { + CoreContext.shared.doOnCoreQueue { core in + let disableVideoCallFeatureTmp = !core.videoEnabled + + DispatchQueue.main.async { + self.disableVideoCall = disableVideoCallFeatureTmp + } + } + } + func updateDisableChatFeature() { CoreContext.shared.doOnCoreQueue { core in let disableChatFeatureTmp = CorePreferences.disableChatFeature @@ -246,6 +258,7 @@ class SharedMainViewModel: ObservableObject { } func updateConfigChanges() { + updateDisableVideoCall() updateDisableChatFeature() updateDisableMeetingFeature() } diff --git a/LinphoneApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/LinphoneApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 36efcf90a..49a76e624 100644 --- a/LinphoneApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/LinphoneApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -123,7 +123,7 @@ "location" : "https://gitlab.linphone.org/BC/public/linphone-sdk-swift-ios.git", "state" : { "branch" : "alpha", - "revision" : "1e266452f9e464d8d6ea8359722d9038c5f46b9d" + "revision" : "e82eb03f276a3c6f4b9b4d87ca7faff5f5d42b8a" } }, {