From d25c19ff8e4d32c0e168e1473ab30f5b1cf11e08 Mon Sep 17 00:00:00 2001 From: Benoit Martins Date: Tue, 27 Jan 2026 15:55:57 +0100 Subject: [PATCH] Refactor of Config and CorePreferences --- Linphone/Contacts/ContactsManager.swift | 8 +- Linphone/Core/CoreContext.swift | 50 ++++- Linphone/Core/CorePreferences.swift | 195 +++++++++--------- Linphone/GeneratedGit.swift | 2 +- Linphone/UI/Call/CallView.swift | 8 +- .../UI/Call/ViewModel/CallViewModel.swift | 2 +- Linphone/UI/Main/Contacts/ContactsView.swift | 2 +- .../ContactInnerActionsFragment.swift | 4 +- .../Fragments/ContactInnerFragment.swift | 2 +- .../Fragments/EditContactFragment.swift | 2 +- .../ViewModel/ContactsListViewModel.swift | 2 +- .../ConversationForwardMessageFragment.swift | 2 +- .../Fragments/ConversationInfoFragment.swift | 6 +- .../Fragments/StartConversationFragment.swift | 2 +- .../ConversationForwardMessageViewModel.swift | 2 +- .../ViewModel/ConversationViewModel.swift | 2 +- .../StartConversationViewModel.swift | 2 +- .../Main/Fragments/SideMenuAccountRow.swift | 2 +- .../Main/Help/Fragments/DebugFragment.swift | 2 +- .../UI/Main/Help/Fragments/HelpFragment.swift | 2 +- .../Main/Help/ViewModel/HelpViewModel.swift | 2 +- .../Fragments/HistoryContactFragment.swift | 6 +- .../Fragments/HistoryListBottomSheet.swift | 2 +- .../History/Fragments/StartCallFragment.swift | 2 +- .../ViewModel/HistoryListViewModel.swift | 2 +- .../ViewModel/StartCallViewModel.swift | 2 +- .../Fragments/AddParticipantsFragment.swift | 2 +- .../Fragments/ScheduleMeetingFragment.swift | 2 +- .../Meetings/ViewModel/MeetingViewModel.swift | 2 +- .../ViewModel/MeetingsListViewModel.swift | 2 +- .../Fragments/AccountProfileFragment.swift | 2 +- .../Settings/ViewModel/CardDavViewModel.swift | 14 +- .../ViewModel/SettingsViewModel.swift | 30 +-- .../Main/Viewmodel/SharedMainViewModel.swift | 4 +- .../Utils/Extensions/ConfigExtension.swift | 29 --- Linphone/Utils/FileUtils.swift | 4 +- Linphone/Utils/Log.swift | 3 +- Linphone/Utils/MagicSearchSingleton.swift | 10 +- Linphone/Utils/URIHandler.swift | 2 +- LinphoneApp.xcodeproj/project.pbxproj | 4 - .../xcshareddata/swiftpm/Package.resolved | 2 +- .../NotificationService.swift | 14 +- 42 files changed, 231 insertions(+), 210 deletions(-) diff --git a/Linphone/Contacts/ContactsManager.swift b/Linphone/Contacts/ContactsManager.swift index adda9f5ee..73db13146 100644 --- a/Linphone/Contacts/ContactsManager.swift +++ b/Linphone/Contacts/ContactsManager.swift @@ -252,19 +252,19 @@ final class ContactsManager: ObservableObject { return } - let base64Tmp = existingFriend?.friendList?.type == .CardDAV || linphoneAddressBookFriendList != CorePreferences.friendListInWhichStoreNewlyCreatedFriends + let base64Tmp = existingFriend?.friendList?.type == .CardDAV || linphoneAddressBookFriendList != AppServices.corePreferences.friendListInWhichStoreNewlyCreatedFriends awaitDataWrite(data: data, name: name, prefix: prefix, base64: base64Tmp) { result in if existingFriend?.friendList?.type != .CardDAV || (existingFriend?.friendList?.type == .CardDAV && linphoneFriend == self.linphoneAddressBookFriendList) - || (editingFriend && linphoneFriend == CorePreferences.friendListInWhichStoreNewlyCreatedFriends) { + || (editingFriend && linphoneFriend == AppServices.corePreferences.friendListInWhichStoreNewlyCreatedFriends) { self.saveFriend(result: result, contact: contact, existingFriend: existingFriend) { resultFriend in self.coreContext.doOnCoreQueue { core in if let friend = resultFriend { if linphoneFriend != self.nativeAddressBookFriendList && existingFriend == nil { if let linphoneFL = self.linphoneFriendList, linphoneFriend == linphoneFL.displayName { _ = linphoneFL.addFriend(linphoneFriend: friend) - } else if let linphoneFL = core.friendsLists.first(where: { $0.type == .CardDAV && $0.displayName == CorePreferences.friendListInWhichStoreNewlyCreatedFriends }) { + } else if let linphoneFL = core.friendsLists.first(where: { $0.type == .CardDAV && $0.displayName == AppServices.corePreferences.friendListInWhichStoreNewlyCreatedFriends }) { if linphoneFL.type == .CardDAV { _ = linphoneFL.addFriend(linphoneFriend: friend) } @@ -337,7 +337,7 @@ final class ContactsManager: ObservableObject { } // Set photo - friend.photo = (friend.friendList?.type != .CardDAV && self.linphoneAddressBookFriendList == CorePreferences.friendListInWhichStoreNewlyCreatedFriends ? "file:/" : "") + result + friend.photo = (friend.friendList?.type != .CardDAV && self.linphoneAddressBookFriendList == AppServices.corePreferences.friendListInWhichStoreNewlyCreatedFriends ? "file:/" : "") + result // Linphone subscription settings try friend.setSubscribesenabled(newValue: false) diff --git a/Linphone/Core/CoreContext.swift b/Linphone/Core/CoreContext.swift index c7eae4e81..2b8b7cacb 100644 --- a/Linphone/Core/CoreContext.swift +++ b/Linphone/Core/CoreContext.swift @@ -59,6 +59,36 @@ class CoreContext: ObservableObject { var digestAuthInfoPendingPasswordUpdate: AuthInfo? + let appGroupName = "group.org.linphone.phone.msgNotification" + + var teamID: String { + AppServices.config.getString(section: "app", key: "team_id", defaultString: "") + } + + var earlymediaContentExtCatIdentifier: String { + AppServices.config.getString(section: "app", key: "extension_category", defaultString: "") + } + + var serveraddress: String { + AppServices.config.getString(section: "app", key: "server", defaultString: "") + } + + var defaultUsername: String { + AppServices.config.getString(section: "app", key: "user", defaultString: "") + } + + var defaultPass: String { + AppServices.config.getString(section: "app", key: "pass", defaultString: "") + } + + var pushNotificationsInterval: Int { + AppServices.config.getInt(section: "net", key: "pn-call-remote-push-interval", defaultValue: 3) + } + + var voiceRecordingMaxDuration: Int { + AppServices.config.getInt(section: "app", key: "voice_recording_max_duration", defaultValue: 600000) + } + @Published var reloadID = UUID() private init() { @@ -122,11 +152,11 @@ class CoreContext: ObservableObject { coreQueue.async { LoggingService.Instance.logLevel = LogLevel.Debug - Factory.Instance.logCollectionPath = Factory.Instance.getDataDir(context: UnsafeMutablePointer(mutating: (Config.appGroupName as NSString).utf8String)) + Factory.Instance.logCollectionPath = Factory.Instance.getDataDir(context: UnsafeMutablePointer(mutating: (self.appGroupName as NSString).utf8String)) Factory.Instance.enableLogCollection(state: LogCollectionState.Enabled) Log.info("Checking if linphonerc file exists already. If not, creating one as a copy of linphonerc-default") - if let rcDir = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: Config.appGroupName)? + if let rcDir = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: self.appGroupName)? .appendingPathComponent("Library/Preferences/linphone") { let rcFileUrl = rcDir.appendingPathComponent("linphonerc") if !FileManager.default.fileExists(atPath: rcFileUrl.path) { @@ -144,7 +174,7 @@ class CoreContext: ObservableObject { } } - self.mCore = try? Factory.Instance.createSharedCoreWithConfig(config: Config.get(), systemContext: Unmanaged.passUnretained(coreQueue).toOpaque(), appGroupId: Config.appGroupName, mainCore: true) + self.mCore = try? Factory.Instance.createSharedCoreWithConfig(config: AppServices.config, systemContext: Unmanaged.passUnretained(coreQueue).toOpaque(), appGroupId: self.appGroupName, mainCore: true) self.mCore.callkitEnabled = true self.mCore.pushNotificationEnabled = true @@ -325,7 +355,7 @@ class CoreContext: ObservableObject { } }, onConfiguringStatus: { (_: Core, status: ConfiguringState, message: String) in Log.info("New configuration state is \(status) = \(message)\n") - let themeMainColor = CorePreferences.themeMainColor + let themeMainColor = AppServices.corePreferences.themeMainColor SharedMainViewModel.shared.updateConfigChanges() DispatchQueue.main.async { if status == ConfiguringState.Successful { @@ -524,7 +554,7 @@ class CoreContext: ObservableObject { } func copyDatabaseFileToDocumentsDirectory() { - if let rcDir = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: Config.appGroupName)? + if let rcDir = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: self.appGroupName)? .appendingPathComponent("Library/Application Support/linphone") { let rcFileUrl = rcDir.appendingPathComponent("linphone.db") let directory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first @@ -542,6 +572,16 @@ class CoreContext: ObservableObject { } } +enum AppServices { + static let config = Config.newForSharedCore( + appGroupId: "group.org.linphone.phone.msgNotification", + configFilename: "linphonerc", + factoryConfigFilename: FileUtil.bundleFilePath("linphonerc-factory") + )! + + static let corePreferences = CorePreferences(config: config) +} + // swiftlint:enable line_length // swiftlint:enable cyclomatic_complexity // swiftlint:enable identifier_name diff --git a/Linphone/Core/CorePreferences.swift b/Linphone/Core/CorePreferences.swift index a4e04a327..6bca2ebe9 100644 --- a/Linphone/Core/CorePreferences.swift +++ b/Linphone/Core/CorePreferences.swift @@ -21,219 +21,226 @@ import Foundation import linphonesw class CorePreferences { - static var printLogsInLogcat: Bool { + + private let config: Config + + init(config: Config) { + self.config = config + } + + var printLogsInLogcat: Bool { get { - return Config.get().getBool(section: "app", key: "debug", defaultValue: true) + config.getBool(section: "app", key: "debug", defaultValue: true) } set { - Config.get().setBool(section: "app", key: "debug", value: newValue) + config.setBool(section: "app", key: "debug", value: newValue) } } - static var firstLaunch: Bool { + var firstLaunch: Bool { get { - return Config.get().getBool(section: "app", key: "first_6.0_launch", defaultValue: true) + config.getBool(section: "app", key: "first_6.0_launch", defaultValue: true) } set { - Config.get().setBool(section: "app", key: "first_6.0_launch", value: newValue) + config.setBool(section: "app", key: "first_6.0_launch", value: newValue) } } - static var linphoneConfigurationVersion: Int { + var linphoneConfigurationVersion: Int { get { - return Config.get().getInt(section: "app", key: "config_version", defaultValue: 52005) + config.getInt(section: "app", key: "config_version", defaultValue: 52005) } set { - Config.get().setInt(section: "app", key: "config_version", value: newValue) + config.setInt(section: "app", key: "config_version", value: newValue) } } - static var checkForUpdateServerUrl: String { + var checkForUpdateServerUrl: String { get { - let raw = Config.get().getString(section: "misc", key: "version_check_url_root", defaultString: "") + let raw = config.getString(section: "misc", key: "version_check_url_root", defaultString: "") return safeString(raw, defaultValue: "") } set { - Config.get().setString(section: "misc", key: "version_check_url_root", value: newValue) + config.setString(section: "misc", key: "version_check_url_root", value: newValue) } } - static var conditionsAndPrivacyPolicyAccepted: Bool { + var conditionsAndPrivacyPolicyAccepted: Bool { get { - return Config.get().getBool(section: "app", key: "read_and_agree_terms_and_privacy", defaultValue: false) + config.getBool(section: "app", key: "read_and_agree_terms_and_privacy", defaultValue: false) } set { - Config.get().setBool(section: "app", key: "read_and_agree_terms_and_privacy", value: newValue) + config.setBool(section: "app", key: "read_and_agree_terms_and_privacy", value: newValue) } } - static var publishPresence: Bool { + var publishPresence: Bool { get { - return Config.get().getBool(section: "app", key: "publish_presence", defaultValue: true) + config.getBool(section: "app", key: "publish_presence", defaultValue: true) } set { - Config.get().setBool(section: "app", key: "publish_presence", value: newValue) + config.setBool(section: "app", key: "publish_presence", value: newValue) } } - static var keepServiceAlive: Bool { + var keepServiceAlive: Bool { get { - return Config.get().getBool(section: "app", key: "keep_service_alive", defaultValue: false) + config.getBool(section: "app", key: "keep_service_alive", defaultValue: false) } set { - Config.get().setBool(section: "app", key: "keep_service_alive", value: newValue) + config.setBool(section: "app", key: "keep_service_alive", value: newValue) } } - static var deviceName: String { + var deviceName: String { get { - let raw = Config.get().getString(section: "app", key: "device", defaultString: "").trimmingCharacters(in: .whitespaces) + let raw = config.getString(section: "app", key: "device", defaultString: "").trimmingCharacters(in: .whitespaces) return safeString(raw, defaultValue: "") } set { - Config.get().setString(section: "app", key: "device", value: newValue.trimmingCharacters(in: .whitespaces)) + config.setString(section: "app", key: "device", value: newValue.trimmingCharacters(in: .whitespaces)) } } - static var routeAudioToSpeakerWhenVideoIsEnabled: Bool { + var routeAudioToSpeakerWhenVideoIsEnabled: Bool { get { - return Config.get().getBool(section: "app", key: "route_audio_to_speaker_when_video_enabled", defaultValue: true) + config.getBool(section: "app", key: "route_audio_to_speaker_when_video_enabled", defaultValue: true) } set { - Config.get().setBool(section: "app", key: "route_audio_to_speaker_when_video_enabled", value: newValue) + config.setBool(section: "app", key: "route_audio_to_speaker_when_video_enabled", value: newValue) } } - static var automaticallyStartCallRecording: Bool { + var automaticallyStartCallRecording: Bool { get { - return Config.get().getBool(section: "app", key: "auto_start_call_record", defaultValue: false) + return config.getBool(section: "app", key: "auto_start_call_record", defaultValue: false) } set { - Config.get().setBool(section: "app", key: "auto_start_call_record", value: newValue) + config.setBool(section: "app", key: "auto_start_call_record", value: newValue) } } - static var showDialogWhenCallingDeviceUuidDirectly: Bool { + var showDialogWhenCallingDeviceUuidDirectly: Bool { get { - return Config.get().getBool(section: "app", key: "show_confirmation_dialog_zrtp_trust_call", defaultValue: true) + return config.getBool(section: "app", key: "show_confirmation_dialog_zrtp_trust_call", defaultValue: true) } set { - Config.get().setBool(section: "app", key: "show_confirmation_dialog_zrtp_trust_call", value: newValue) + config.setBool(section: "app", key: "show_confirmation_dialog_zrtp_trust_call", value: newValue) } } - static var markConversationAsReadWhenDismissingMessageNotification: Bool { + var markConversationAsReadWhenDismissingMessageNotification: Bool { get { - return Config.get().getBool(section: "app", key: "mark_as_read_notif_dismissal", defaultValue: false) + config.getBool(section: "app", key: "mark_as_read_notif_dismissal", defaultValue: false) } set { - Config.get().setBool(section: "app", key: "mark_as_read_notif_dismissal", value: newValue) + config.setBool(section: "app", key: "mark_as_read_notif_dismissal", value: newValue) } } - static var contactsFilter: String { + var contactsFilter: String { get { - let raw = Config.get().getString(section: "ui", key: "contacts_filter", defaultString: "") + let raw = config.getString(section: "ui", key: "contacts_filter", defaultString: "") return safeString(raw, defaultValue: "") } set { - Config.get().setString(section: "ui", key: "contacts_filter", value: newValue) + config.setString(section: "ui", key: "contacts_filter", value: newValue) } } - static var disableAddContact: Bool { + var disableAddContact: Bool { get { - return Config.get().getBool(section: "ui", key: "disable_add_contact", defaultValue: false) + config.getBool(section: "ui", key: "disable_add_contact", defaultValue: false) } set { - Config.get().setBool(section: "ui", key: "disable_add_contact", value: newValue) + config.setBool(section: "ui", key: "disable_add_contact", value: newValue) } } - static var showFavoriteContacts: Bool { + var showFavoriteContacts: Bool { get { - return Config.get().getBool(section: "ui", key: "show_favorites_contacts", defaultValue: true) + config.getBool(section: "ui", key: "show_favorites_contacts", defaultValue: true) } set { - Config.get().setBool(section: "ui", key: "show_favorites_contacts", value: newValue) + config.setBool(section: "ui", key: "show_favorites_contacts", value: newValue) } } - static var friendListInWhichStoreNewlyCreatedFriends: String { + var friendListInWhichStoreNewlyCreatedFriends: String { get { - return Config.get().getString(section: "app", key: "friend_list_to_store_newly_created_contacts", defaultString: "Linphone address-book") + config.getString(section: "app", key: "friend_list_to_store_newly_created_contacts", defaultString: "Linphone address-book") } set { - Config.get().setString(section: "app", key: "friend_list_to_store_newly_created_contacts", value: newValue) + config.setString(section: "app", key: "friend_list_to_store_newly_created_contacts", value: newValue) } } - static var voiceRecordingMaxDuration: Int { + var voiceRecordingMaxDuration: Int { get { - return Config.get().getInt(section: "app", key: "voice_recording_max_duration", defaultValue: 600000) + config.getInt(section: "app", key: "voice_recording_max_duration", defaultValue: 600000) } set { - Config.get().setInt(section: "app", key: "voice_recording_max_duration", value: newValue) + config.setInt(section: "app", key: "voice_recording_max_duration", value: newValue) } } - static var darkMode: Int { + var darkMode: Int { get { if !darkModeAllowed { return 0 } - return Config.get().getInt(section: "app", key: "dark_mode", defaultValue: -1) + return config.getInt(section: "app", key: "dark_mode", defaultValue: -1) } set { - Config.get().setInt(section: "app", key: "dark_mode", value: newValue) + config.setInt(section: "app", key: "dark_mode", value: newValue) } } - static var enableSecureMode: Bool { + var enableSecureMode: Bool { get { - return Config.get().getBool(section: "ui", key: "enable_secure_mode", defaultValue: true) + config.getBool(section: "ui", key: "enable_secure_mode", defaultValue: true) } set { - Config.get().setBool(section: "ui", key: "enable_secure_mode", value: newValue) + config.setBool(section: "ui", key: "enable_secure_mode", value: newValue) } } - static var themeMainColor: String { + var themeMainColor: String { get { - let raw = Config.get().getString(section: "ui", key: "theme_main_color", defaultString: "orange") + let raw = config.getString(section: "ui", key: "theme_main_color", defaultString: "orange") return safeString(raw, defaultValue: "orange") } set { - Config.get().setString(section: "ui", key: "theme_main_color", value: newValue) + config.setString(section: "ui", key: "theme_main_color", value: newValue) } } - static var themeAboutPictureUrl: String? { + var themeAboutPictureUrl: String? { get { - return Config.get().getString(section: "ui", key: "theme_about_picture_url", defaultString: nil) + return config.getString(section: "ui", key: "theme_about_picture_url", defaultString: nil) } } - static var darkModeAllowed: Bool { - return Config.get().getBool(section: "ui", key: "dark_mode_allowed", defaultValue: true) + var darkModeAllowed: Bool { + config.getBool(section: "ui", key: "dark_mode_allowed", defaultValue: true) } - static var changeMainColorAllowed: Bool { - return Config.get().getBool(section: "ui", key: "change_main_color_allowed", defaultValue: false) + var changeMainColorAllowed: Bool { + config.getBool(section: "ui", key: "change_main_color_allowed", defaultValue: false) } - static var hideSettings: Bool { - return Config.get().getBool(section: "ui", key: "hide_settings", defaultValue: false) + var hideSettings: Bool { + config.getBool(section: "ui", key: "hide_settings", defaultValue: false) } - static var maxAccountsCount: Int { - return Config.get().getInt(section: "ui", key: "max_account", defaultValue: 0) + var maxAccountsCount: Int { + config.getInt(section: "ui", key: "max_account", defaultValue: 0) } /* - static var configPath: String { + var configPath: String { return context.view.window?.rootViewController?.view.frame.origin.x ?? "" + "/.linphonerc" } - static var factoryConfigPath: String { + var factoryConfigPath: String { return context.view.window?.rootViewController?.view.frame.origin.x ?? "" + "/linphonerc" } @@ -243,67 +250,67 @@ class CorePreferences { } */ - static var vfsEnabled: Bool { + var vfsEnabled: Bool { get { - return Config.get().getBool(section: "app", key: "vfs_enabled", defaultValue: false) + config.getBool(section: "app", key: "vfs_enabled", defaultValue: false) } set { - Config.get().setBool(section: "app", key: "vfs_enabled", value: newValue) + config.setBool(section: "app", key: "vfs_enabled", value: newValue) } } - static var acceptEarlyMedia: Bool { + var acceptEarlyMedia: Bool { get { - return Config.get().getBool(section: "sip", key: "incoming_calls_early_media", defaultValue: false) + config.getBool(section: "sip", key: "incoming_calls_early_media", defaultValue: false) } set { - Config.get().setBool(section: "sip", key: "incoming_calls_early_media", value: newValue) + config.setBool(section: "sip", key: "incoming_calls_early_media", value: newValue) } } - static var allowOutgoingEarlyMedia: Bool { + var allowOutgoingEarlyMedia: Bool { get { - return Config.get().getBool(section: "sip", key: "real_early_media", defaultValue: false) + config.getBool(section: "sip", key: "real_early_media", defaultValue: false) } set { - Config.get().setBool(section: "sip", key: "real_early_media", value: newValue) + config.setBool(section: "sip", key: "real_early_media", value: newValue) } } - static var defaultDomain: String { + var defaultDomain: String { get { - let raw = Config.get().getString(section: "app", key: "default_domain", defaultString: "sip.linphone.org") + let raw = config.getString(section: "app", key: "default_domain", defaultString: "sip.linphone.org") return safeString(raw, defaultValue: "sip.linphone.org") } set { - Config.get().setString(section: "app", key: "default_domain", value: newValue) + config.setString(section: "app", key: "default_domain", value: newValue) } } - static var disableChatFeature: Bool { + var disableChatFeature: Bool { get { - return Config.get().getBool(section: "ui", key: "disable_chat_feature", defaultValue: false) + config.getBool(section: "ui", key: "disable_chat_feature", defaultValue: false) } set { - Config.get().setBool(section: "ui", key: "disable_chat_feature", value: newValue) + config.setBool(section: "ui", key: "disable_chat_feature", value: newValue) } } - static var disableMeetings: Bool { + var disableMeetings: Bool { get { - return Config.get().getBool(section: "ui", key: "disable_meetings_feature", defaultValue: false) + config.getBool(section: "ui", key: "disable_meetings_feature", defaultValue: false) } set { - Config.get().setBool(section: "ui", key: "disable_meetings_feature", value: newValue) + config.setBool(section: "ui", key: "disable_meetings_feature", value: newValue) } } - static var hideSipAddresses: Bool { + var hideSipAddresses: Bool { get { - return Config.get().getBool(section: "ui", key: "hide_sip_addresses", defaultValue: false) + config.getBool(section: "ui", key: "hide_sip_addresses", defaultValue: false) } set { - Config.get().setBool(section: "ui", key: "hide_sip_addresses", value: newValue) + config.setBool(section: "ui", key: "hide_sip_addresses", value: newValue) } } @@ -322,7 +329,7 @@ class CorePreferences { } } - private static func safeString(_ raw: String?, defaultValue: String = "") -> String { + private func safeString(_ raw: String?, defaultValue: String = "") -> String { guard let raw = raw else { return defaultValue } if let data = raw.data(using: .utf8) { return String(decoding: data, as: UTF8.self) diff --git a/Linphone/GeneratedGit.swift b/Linphone/GeneratedGit.swift index b5808f0c6..51223d951 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 = "dc5f131ce" + public static let commit = "e64c0611f" public static let tag = "6.1.0-alpha" } diff --git a/Linphone/UI/Call/CallView.swift b/Linphone/UI/Call/CallView.swift index bd16c1b15..9a155956f 100644 --- a/Linphone/UI/Call/CallView.swift +++ b/Linphone/UI/Call/CallView.swift @@ -526,7 +526,7 @@ struct CallView: View { .padding(.top) .default_text_style_white(styleSize: 22) - if !CorePreferences.hideSipAddresses { + if !AppServices.corePreferences.hideSipAddresses { Text(callViewModel.remoteAddressCleanedString) .default_text_style_white_300(styleSize: 16) } @@ -2281,7 +2281,7 @@ struct CallView: View { .frame(height: geo.size.height * 0.15) HStack(spacing: 0) { - if !CorePreferences.disableChatFeature && callViewModel.chatEnabled { + if !AppServices.corePreferences.disableChatFeature && callViewModel.chatEnabled { VStack { Button { callViewModel.createConversation() @@ -2441,7 +2441,7 @@ struct CallView: View { .frame(width: geo.size.width * 0.24, height: geo.size.width * 0.24) .hidden() - if CorePreferences.disableChatFeature || !callViewModel.chatEnabled { + if AppServices.corePreferences.disableChatFeature || !callViewModel.chatEnabled { VStack { Button { } label: { @@ -2707,7 +2707,7 @@ struct CallView: View { .frame(width: geo.size.width * 0.125, height: geo.size.width * 0.125) } - if !CorePreferences.disableChatFeature && callViewModel.chatEnabled { + if !AppServices.corePreferences.disableChatFeature && callViewModel.chatEnabled { VStack { Button { callViewModel.createConversation() diff --git a/Linphone/UI/Call/ViewModel/CallViewModel.swift b/Linphone/UI/Call/ViewModel/CallViewModel.swift index 830684a0a..da4300cd9 100644 --- a/Linphone/UI/Call/ViewModel/CallViewModel.swift +++ b/Linphone/UI/Call/ViewModel/CallViewModel.swift @@ -1299,7 +1299,7 @@ class CallViewModel: ObservableObject { if let chatParams = params.chatParams { chatParams.ephemeralLifetime = 0 // Make sure ephemeral is disabled by default - let sameDomain = remoteAddress?.domain == CorePreferences.defaultDomain && remoteAddress?.domain == account.params?.domain + let sameDomain = remoteAddress?.domain == AppServices.corePreferences.defaultDomain && remoteAddress?.domain == account.params?.domain if account.params != nil && (account.params!.instantMessagingEncryptionMandatory && sameDomain) { Log.info( "\(CallViewModel.TAG) Account is in secure mode & domain matches, requesting E2E encryption" diff --git a/Linphone/UI/Main/Contacts/ContactsView.swift b/Linphone/UI/Main/Contacts/ContactsView.swift index dba35cf4a..374e09afd 100644 --- a/Linphone/UI/Main/Contacts/ContactsView.swift +++ b/Linphone/UI/Main/Contacts/ContactsView.swift @@ -32,7 +32,7 @@ struct ContactsView: View { ZStack(alignment: .bottomTrailing) { ContactsFragment(isShowDeletePopup: $isShowDeletePopup, text: $text) - if !CorePreferences.disableAddContact { + if !AppServices.corePreferences.disableAddContact { Button { withAnimation { contactsListViewModel.selectedEditFriend = nil diff --git a/Linphone/UI/Main/Contacts/Fragments/ContactInnerActionsFragment.swift b/Linphone/UI/Main/Contacts/Fragments/ContactInnerActionsFragment.swift index fe1c0c62d..d411ed26c 100644 --- a/Linphone/UI/Main/Contacts/Fragments/ContactInnerActionsFragment.swift +++ b/Linphone/UI/Main/Contacts/Fragments/ContactInnerActionsFragment.swift @@ -40,7 +40,7 @@ struct ContactInnerActionsFragment: View { var actionEditButton: () -> Void var body: some View { - if !CorePreferences.hideSipAddresses || (CorePreferences.hideSipAddresses && !contactAvatarModel.phoneNumbersWithLabel.isEmpty) { + if !AppServices.corePreferences.hideSipAddresses || (AppServices.corePreferences.hideSipAddresses && !contactAvatarModel.phoneNumbersWithLabel.isEmpty) { HStack(alignment: .center) { Text("contact_details_numbers_and_addresses_title") .default_text_style_800(styleSize: 15) @@ -67,7 +67,7 @@ struct ContactInnerActionsFragment: View { if informationIsOpen { VStack(spacing: 0) { - if !CorePreferences.hideSipAddresses { + if !AppServices.corePreferences.hideSipAddresses { ForEach(0.. 0 && !CorePreferences.disableChatFeature { + if model.notificationsCount > 0 && !AppServices.corePreferences.disableChatFeature { VStack { Text(String(model.notificationsCount)) .foregroundStyle(.white) diff --git a/Linphone/UI/Main/Help/Fragments/DebugFragment.swift b/Linphone/UI/Main/Help/Fragments/DebugFragment.swift index 638f8e5ff..7f887b8f5 100644 --- a/Linphone/UI/Main/Help/Fragments/DebugFragment.swift +++ b/Linphone/UI/Main/Help/Fragments/DebugFragment.swift @@ -245,7 +245,7 @@ struct DebugFragment: View { func showConfigFile() { Log.info("[DebugFragment][showConfigFile] Dumping & displaying Core's config") - if let rcDir = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: Config.appGroupName)? + if let rcDir = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: CoreContext.shared.appGroupName)? .appendingPathComponent("Library/Preferences/linphone") { let rcFileUrl = rcDir.appendingPathComponent("linphonerc") if FileManager.default.fileExists(atPath: rcFileUrl.path) { diff --git a/Linphone/UI/Main/Help/Fragments/HelpFragment.swift b/Linphone/UI/Main/Help/Fragments/HelpFragment.swift index 549e64d49..8a5b6fba9 100644 --- a/Linphone/UI/Main/Help/Fragments/HelpFragment.swift +++ b/Linphone/UI/Main/Help/Fragments/HelpFragment.swift @@ -73,7 +73,7 @@ struct HelpFragment: View { ScrollView { VStack(spacing: 0) { VStack(spacing: 20) { - if let urlString = CorePreferences.themeAboutPictureUrl, + if let urlString = AppServices.corePreferences.themeAboutPictureUrl, let url = URL(string: urlString) { AsyncImage(url: url) { phase in switch phase { diff --git a/Linphone/UI/Main/Help/ViewModel/HelpViewModel.swift b/Linphone/UI/Main/Help/ViewModel/HelpViewModel.swift index 476e80e13..ec987d8db 100644 --- a/Linphone/UI/Main/Help/ViewModel/HelpViewModel.swift +++ b/Linphone/UI/Main/Help/ViewModel/HelpViewModel.swift @@ -118,7 +118,7 @@ class HelpViewModel: ObservableObject { func toggleLogcat() { let newValue = !self.logcat CoreContext.shared.doOnCoreQueue { core in - CorePreferences.printLogsInLogcat = newValue + AppServices.corePreferences.printLogsInLogcat = newValue Factory.Instance.enableLogcatLogs(newValue) self.logcat = newValue } diff --git a/Linphone/UI/Main/History/Fragments/HistoryContactFragment.swift b/Linphone/UI/Main/History/Fragments/HistoryContactFragment.swift index dd85deb3a..e0098abd8 100644 --- a/Linphone/UI/Main/History/Fragments/HistoryContactFragment.swift +++ b/Linphone/UI/Main/History/Fragments/HistoryContactFragment.swift @@ -70,7 +70,7 @@ struct HistoryContactFragment: View { Spacer() Menu { - let disableAddContact = CorePreferences.disableAddContact + let disableAddContact = AppServices.corePreferences.disableAddContact let isFriend = historyModel.isFriend == true if !historyModel.isConf && (!disableAddContact || (disableAddContact && isFriend)) { @@ -189,7 +189,7 @@ struct HistoryContactFragment: View { .frame(maxWidth: .infinity) .padding(.top, 10) - if !CorePreferences.hideSipAddresses { + if !AppServices.corePreferences.hideSipAddresses { Text(historyModel.address) .foregroundStyle(Color.grayMain2c700) .multilineTextAlignment(.center) @@ -258,7 +258,7 @@ struct HistoryContactFragment: View { } }) - if !CorePreferences.disableChatFeature { + if !AppServices.corePreferences.disableChatFeature { Spacer() Button(action: { diff --git a/Linphone/UI/Main/History/Fragments/HistoryListBottomSheet.swift b/Linphone/UI/Main/History/Fragments/HistoryListBottomSheet.swift index cbb88e6c4..72e10523a 100644 --- a/Linphone/UI/Main/History/Fragments/HistoryListBottomSheet.swift +++ b/Linphone/UI/Main/History/Fragments/HistoryListBottomSheet.swift @@ -59,7 +59,7 @@ struct HistoryListBottomSheet: View { Spacer() - let disableAddContact = CorePreferences.disableAddContact + let disableAddContact = AppServices.corePreferences.disableAddContact let isFriend = historyListViewModel.selectedCall?.isFriend == true if !disableAddContact || (disableAddContact && isFriend) { diff --git a/Linphone/UI/Main/History/Fragments/StartCallFragment.swift b/Linphone/UI/Main/History/Fragments/StartCallFragment.swift index 6e526c32c..9190b846f 100644 --- a/Linphone/UI/Main/History/Fragments/StartCallFragment.swift +++ b/Linphone/UI/Main/History/Fragments/StartCallFragment.swift @@ -393,7 +393,7 @@ struct StartCallFragment: View { HStack { if index < contactsManager.lastSearchSuggestions.count && contactsManager.lastSearchSuggestions[index].address != nil { - if contactsManager.lastSearchSuggestions[index].address!.domain != CorePreferences.defaultDomain { + if contactsManager.lastSearchSuggestions[index].address!.domain != AppServices.corePreferences.defaultDomain { Image(uiImage: contactsManager.textToImage( firstName: String(contactsManager.lastSearchSuggestions[index].address!.asStringUriOnly().dropFirst(4)), lastName: "")) diff --git a/Linphone/UI/Main/History/ViewModel/HistoryListViewModel.swift b/Linphone/UI/Main/History/ViewModel/HistoryListViewModel.swift index e515e48a1..3473a3b2e 100644 --- a/Linphone/UI/Main/History/ViewModel/HistoryListViewModel.swift +++ b/Linphone/UI/Main/History/ViewModel/HistoryListViewModel.swift @@ -254,7 +254,7 @@ class HistoryListViewModel: ObservableObject { guard let chatParams = params.chatParams else { return } chatParams.ephemeralLifetime = 0 // Make sure ephemeral is disabled by default - let sameDomain = remote.domain == CorePreferences.defaultDomain && remote.domain == account!.params?.domain + let sameDomain = remote.domain == AppServices.corePreferences.defaultDomain && remote.domain == account!.params?.domain if account!.params != nil && (account!.params!.instantMessagingEncryptionMandatory && sameDomain) { Log.info("\(ConversationForwardMessageViewModel.TAG) Account is in secure mode & domain matches, creating an E2E encrypted conversation") chatParams.backend = ChatRoom.Backend.FlexisipChat diff --git a/Linphone/UI/Main/History/ViewModel/StartCallViewModel.swift b/Linphone/UI/Main/History/ViewModel/StartCallViewModel.swift index 99d9c45dc..0423ea77d 100644 --- a/Linphone/UI/Main/History/ViewModel/StartCallViewModel.swift +++ b/Linphone/UI/Main/History/ViewModel/StartCallViewModel.swift @@ -51,7 +51,7 @@ class StartCallViewModel: ObservableObject { } func updateGroupCallButtonVisibility(core: Core) { - let hideGroupCall = CorePreferences.disableMeetings || + let hideGroupCall = AppServices.corePreferences.disableMeetings || !LinphoneUtils.isRemoteConferencingAvailable(core: core) || core.callsNb > 0 DispatchQueue.main.async { diff --git a/Linphone/UI/Main/Meetings/Fragments/AddParticipantsFragment.swift b/Linphone/UI/Main/Meetings/Fragments/AddParticipantsFragment.swift index 7d2df6c33..e142a3c70 100644 --- a/Linphone/UI/Main/Meetings/Fragments/AddParticipantsFragment.swift +++ b/Linphone/UI/Main/Meetings/Fragments/AddParticipantsFragment.swift @@ -290,7 +290,7 @@ struct AddParticipantsFragment: View { HStack { if index < contactsManager.lastSearchSuggestions.count && contactsManager.lastSearchSuggestions[index].address != nil { - if contactsManager.lastSearchSuggestions[index].address!.domain != CorePreferences.defaultDomain { + if contactsManager.lastSearchSuggestions[index].address!.domain != AppServices.corePreferences.defaultDomain { Image(uiImage: contactsManager.textToImage( firstName: String(contactsManager.lastSearchSuggestions[index].address!.asStringUriOnly().dropFirst(4)), lastName: "")) diff --git a/Linphone/UI/Main/Meetings/Fragments/ScheduleMeetingFragment.swift b/Linphone/UI/Main/Meetings/Fragments/ScheduleMeetingFragment.swift index 41db8fc3e..6e95e035e 100644 --- a/Linphone/UI/Main/Meetings/Fragments/ScheduleMeetingFragment.swift +++ b/Linphone/UI/Main/Meetings/Fragments/ScheduleMeetingFragment.swift @@ -301,7 +301,7 @@ struct ScheduleMeetingFragment: View { } } - if !CorePreferences.disableChatFeature { + if !AppServices.corePreferences.disableChatFeature { Rectangle() .foregroundStyle(.clear) .frame(height: 1) diff --git a/Linphone/UI/Main/Meetings/ViewModel/MeetingViewModel.swift b/Linphone/UI/Main/Meetings/ViewModel/MeetingViewModel.swift index 7dd87d9d8..c1c212a84 100644 --- a/Linphone/UI/Main/Meetings/ViewModel/MeetingViewModel.swift +++ b/Linphone/UI/Main/Meetings/ViewModel/MeetingViewModel.swift @@ -221,7 +221,7 @@ class MeetingViewModel: ObservableObject { } } - if self.sendInvitations && !CorePreferences.disableChatFeature { + if self.sendInvitations && !AppServices.corePreferences.disableChatFeature { Log.info("\(MeetingViewModel.TAG) User asked for invitations to be sent, let's do it") self.sendIcsInvitation(core: core) } else { diff --git a/Linphone/UI/Main/Meetings/ViewModel/MeetingsListViewModel.swift b/Linphone/UI/Main/Meetings/ViewModel/MeetingsListViewModel.swift index 2ae43d0a0..6e8b60f22 100644 --- a/Linphone/UI/Main/Meetings/ViewModel/MeetingsListViewModel.swift +++ b/Linphone/UI/Main/Meetings/ViewModel/MeetingsListViewModel.swift @@ -157,7 +157,7 @@ class MeetingsListViewModel: ObservableObject { let mSchedulerDelegate = ConferenceSchedulerDelegateStub(onStateChanged: { (_: ConferenceScheduler, state: ConferenceScheduler.State) in Log.info("\(MeetingViewModel.TAG) Conference state changed \(state)") if state == ConferenceScheduler.State.Ready { - if !CorePreferences.disableChatFeature { + if !AppServices.corePreferences.disableChatFeature { self.sendIcsInvitation(core: core, conferenceScheduler: conferenceScheduler) } diff --git a/Linphone/UI/Main/Settings/Fragments/AccountProfileFragment.swift b/Linphone/UI/Main/Settings/Fragments/AccountProfileFragment.swift index 21aec010d..c13e66c02 100644 --- a/Linphone/UI/Main/Settings/Fragments/AccountProfileFragment.swift +++ b/Linphone/UI/Main/Settings/Fragments/AccountProfileFragment.swift @@ -270,7 +270,7 @@ struct AccountProfileFragment: View { if accountModel.avatarModel != nil { VStack(spacing: 0) { VStack(spacing: 30) { - if !CorePreferences.hideSipAddresses { + if !AppServices.corePreferences.hideSipAddresses { HStack { Text(String(localized: "sip_address") + ":") .default_text_style_700(styleSize: 15) diff --git a/Linphone/UI/Main/Settings/ViewModel/CardDavViewModel.swift b/Linphone/UI/Main/Settings/ViewModel/CardDavViewModel.swift index e8cffdc39..a55ba6598 100644 --- a/Linphone/UI/Main/Settings/ViewModel/CardDavViewModel.swift +++ b/Linphone/UI/Main/Settings/ViewModel/CardDavViewModel.swift @@ -85,7 +85,7 @@ class CardDavViewModel: ObservableObject { } let isReadOnlyTmp = friendList.isReadOnly - let friendListInWhichStoreNewlyCreatedFriendsTmp = CorePreferences.friendListInWhichStoreNewlyCreatedFriends + let friendListInWhichStoreNewlyCreatedFriendsTmp = AppServices.corePreferences.friendListInWhichStoreNewlyCreatedFriends let uriTmp = friendList.uri ?? "" DispatchQueue.main.async { self.isEdit = true @@ -104,9 +104,9 @@ class CardDavViewModel: ObservableObject { self.coreContext.doOnCoreQueue { core in if self.isEdit, let friendList = self.friendList { let name = friendList.displayName - if name == CorePreferences.friendListInWhichStoreNewlyCreatedFriends { + if name == AppServices.corePreferences.friendListInWhichStoreNewlyCreatedFriends { Log.info("\(CardDavViewModel.TAG) Deleting friend list configured to be used to store newly created friends, updating default friend list back to \(self.linphoneAddressBookFriendList)") - CorePreferences.friendListInWhichStoreNewlyCreatedFriends = self.linphoneAddressBookFriendList + AppServices.corePreferences.friendListInWhichStoreNewlyCreatedFriends = self.linphoneAddressBookFriendList } if let tempRemoteFriendList = core.getFriendListByName(name: self.tempRemoteAddressBookFriendList) { @@ -201,9 +201,9 @@ class CardDavViewModel: ObservableObject { Log.info("\(CardDavViewModel.TAG) CardDAV friend list \(name) created with server URL \(server), synchronizing it") } - if !self.storeNewContactsInIt && CorePreferences.friendListInWhichStoreNewlyCreatedFriends == name { + if !self.storeNewContactsInIt && AppServices.corePreferences.friendListInWhichStoreNewlyCreatedFriends == name { Log.info("\(CardDavViewModel.TAG) No longer using friend list \(name) as default friend list, switching back to \(self.linphoneAddressBookFriendList)") - CorePreferences.friendListInWhichStoreNewlyCreatedFriends = self.linphoneAddressBookFriendList + AppServices.corePreferences.friendListInWhichStoreNewlyCreatedFriends = self.linphoneAddressBookFriendList } if let friendList = self.friendList { @@ -231,13 +231,13 @@ class CardDavViewModel: ObservableObject { let name = self.displayName if self.storeNewContactsInIt { - let previous = CorePreferences.friendListInWhichStoreNewlyCreatedFriends + let previous = AppServices.corePreferences.friendListInWhichStoreNewlyCreatedFriends if friendList.isReadOnly { Log.warn("\(CardDavViewModel.TAG) User asked to add newly created contacts in this friend list but it is read only, keep currently default friend list \(previous)") self.storeNewContactsInIt = false } else { Log.info("\(CardDavViewModel.TAG) Updating default friend list to store newly created contacts from \(previous) to \(name)") - CorePreferences.friendListInWhichStoreNewlyCreatedFriends = name + AppServices.corePreferences.friendListInWhichStoreNewlyCreatedFriends = name } DispatchQueue.main.async { diff --git a/Linphone/UI/Main/Settings/ViewModel/SettingsViewModel.swift b/Linphone/UI/Main/Settings/ViewModel/SettingsViewModel.swift index 59fbd88ed..bb4075e57 100644 --- a/Linphone/UI/Main/Settings/ViewModel/SettingsViewModel.swift +++ b/Linphone/UI/Main/Settings/ViewModel/SettingsViewModel.swift @@ -73,11 +73,11 @@ class SettingsViewModel: ObservableObject { init() { CoreContext.shared.doOnCoreQueue { core in - let enableVfsTmp = CorePreferences.vfsEnabled + let enableVfsTmp = AppServices.corePreferences.vfsEnabled let adaptiveRateControlTmp = core.adaptiveRateControlEnabled let enableVideoTmp = core.videoEnabled - let autoRecordTmp = CorePreferences.automaticallyStartCallRecording + let autoRecordTmp = AppServices.corePreferences.automaticallyStartCallRecording let autoDownloadTmp = core.maxSizeForAutoDownloadIncomingFiles == 0 @@ -100,9 +100,9 @@ class SettingsViewModel: ObservableObject { mediaEncryptionTmp = "DTLS" } let mediaEncryptionMandatoryTmp = core.isMediaEncryptionMandatory - let acceptEarlyMediaTmp = CorePreferences.acceptEarlyMedia - let allowOutgoingEarlyMediaTmp = CorePreferences.allowOutgoingEarlyMedia - let deviceIdTmp = CorePreferences.deviceName + let acceptEarlyMediaTmp = AppServices.corePreferences.acceptEarlyMedia + let allowOutgoingEarlyMediaTmp = AppServices.corePreferences.allowOutgoingEarlyMedia + let deviceIdTmp = AppServices.corePreferences.deviceName let fileSharingServerUrlTmp = core.fileTransferServer let remoteProvisioningUrlTmp = core.provisioningUri @@ -342,8 +342,8 @@ class SettingsViewModel: ObservableObject { func saveChangesWhenLeaving() { CoreContext.shared.doOnCoreQueue { core in - if CorePreferences.vfsEnabled != self.enableVfs { - CorePreferences.vfsEnabled = self.enableVfs + if AppServices.corePreferences.vfsEnabled != self.enableVfs { + AppServices.corePreferences.vfsEnabled = self.enableVfs } if core.adaptiveRateControlEnabled != self.adaptiveRateControl { @@ -355,8 +355,8 @@ class SettingsViewModel: ObservableObject { core.videoDisplayEnabled = self.enableVideo } - if CorePreferences.automaticallyStartCallRecording != self.autoRecord { - CorePreferences.automaticallyStartCallRecording = self.autoRecord + if AppServices.corePreferences.automaticallyStartCallRecording != self.autoRecord { + AppServices.corePreferences.automaticallyStartCallRecording = self.autoRecord } if (core.maxSizeForAutoDownloadIncomingFiles == 0) != self.autoDownload { @@ -402,16 +402,16 @@ class SettingsViewModel: ObservableObject { core.mediaEncryptionMandatory = self.mediaEncryptionMandatory } - if CorePreferences.acceptEarlyMedia != self.acceptEarlyMedia { - CorePreferences.acceptEarlyMedia = self.acceptEarlyMedia + if AppServices.corePreferences.acceptEarlyMedia != self.acceptEarlyMedia { + AppServices.corePreferences.acceptEarlyMedia = self.acceptEarlyMedia } - if CorePreferences.allowOutgoingEarlyMedia != self.allowOutgoingEarlyMedia { - CorePreferences.allowOutgoingEarlyMedia = self.allowOutgoingEarlyMedia + if AppServices.corePreferences.allowOutgoingEarlyMedia != self.allowOutgoingEarlyMedia { + AppServices.corePreferences.allowOutgoingEarlyMedia = self.allowOutgoingEarlyMedia } - if CorePreferences.deviceName != self.deviceId { - CorePreferences.deviceName = self.deviceId + if AppServices.corePreferences.deviceName != self.deviceId { + AppServices.corePreferences.deviceName = self.deviceId } if core.fileTransferServer != self.uploadServerUrl && !(core.fileTransferServer == nil && self.uploadServerUrl.isEmpty) { diff --git a/Linphone/UI/Main/Viewmodel/SharedMainViewModel.swift b/Linphone/UI/Main/Viewmodel/SharedMainViewModel.swift index 39fa3e889..18c625eba 100644 --- a/Linphone/UI/Main/Viewmodel/SharedMainViewModel.swift +++ b/Linphone/UI/Main/Viewmodel/SharedMainViewModel.swift @@ -239,7 +239,7 @@ class SharedMainViewModel: ObservableObject { func updateDisableChatFeature() { CoreContext.shared.doOnCoreQueue { core in - let disableChatFeatureTmp = CorePreferences.disableChatFeature + let disableChatFeatureTmp = AppServices.corePreferences.disableChatFeature DispatchQueue.main.async { self.disableChatFeature = disableChatFeatureTmp @@ -249,7 +249,7 @@ class SharedMainViewModel: ObservableObject { func updateDisableMeetingFeature() { CoreContext.shared.doOnCoreQueue { core in - let disableMeetingFeatureTmp = CorePreferences.disableMeetings || + let disableMeetingFeatureTmp = AppServices.corePreferences.disableMeetings || !LinphoneUtils.isRemoteConferencingAvailable(core: core) DispatchQueue.main.async { self.disableMeetingFeature = disableMeetingFeatureTmp diff --git a/Linphone/Utils/Extensions/ConfigExtension.swift b/Linphone/Utils/Extensions/ConfigExtension.swift index 843bb861b..c1370c631 100644 --- a/Linphone/Utils/Extensions/ConfigExtension.swift +++ b/Linphone/Utils/Extensions/ConfigExtension.swift @@ -23,9 +23,6 @@ import linphonesw // Singleton that manages the Shared Config between app and app extension. extension Config { - - private static var _instance: Config? - public func getDouble(section: String, key: String, defaultValue: Double) -> Double { if self.hasEntry(section: section, key: key) != 1 { return defaultValue @@ -33,35 +30,9 @@ extension Config { let stringValue = self.getString(section: section, key: key, defaultString: "") return Double(stringValue) ?? defaultValue } - - public static func get() -> Config { - if _instance == nil { - let factoryPath = FileUtil.bundleFilePath("linphonerc-factory")! - _instance = Config.newForSharedCore(appGroupId: Config.appGroupName, configFilename: "linphonerc", factoryConfigFilename: factoryPath)! - let themeMainColor = CorePreferences.themeMainColor - DispatchQueue.main.async { - ThemeManager.shared.applyTheme(named: themeMainColor) - } - } - return _instance! - } public func getString(section: String, key: String) -> String? { return hasEntry(section: section, key: key) == 1 ? getString(section: section, key: key, defaultString: "") : nil } - static let appGroupName = "group.org.linphone.phone.msgNotification" - // Needs to be the same name in App Group (capabilities in ALL targets - app & extensions - content + service), can't be stored in the Config itself the Config needs this value to get created - static let teamID = Config.get().getString(section: "app", key: "team_id", defaultString: "") - static let earlymediaContentExtCatIdentifier = Config.get().getString(section: "app", key: "extension_category", defaultString: "") - - // Default values in app - static let serveraddress = Config.get().getString(section: "app", key: "server", defaultString: "") - static let defaultUsername = Config.get().getString(section: "app", key: "user", defaultString: "") - static let defaultPass = Config.get().getString(section: "app", key: "pass", defaultString: "") - - static let pushNotificationsInterval = Config.get().getInt(section: "net", key: "pn-call-remote-push-interval", defaultValue: 3) - - static let voiceRecordingMaxDuration = Config.get().getInt(section: "app", key: "voice_recording_max_duration", defaultValue: 600000) - } diff --git a/Linphone/Utils/FileUtils.swift b/Linphone/Utils/FileUtils.swift index d39a93193..8d2ce82f8 100644 --- a/Linphone/Utils/FileUtils.swift +++ b/Linphone/Utils/FileUtils.swift @@ -23,6 +23,8 @@ import UniformTypeIdentifiers class FileUtil: NSObject { + let appGroupName = "group.org.linphone.phone.msgNotification" + public enum MimeType { case plainText case pdf @@ -77,7 +79,7 @@ class FileUtil: NSObject { } public class func sharedContainerUrl() -> URL { - return FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: Config.appGroupName)! + return FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.org.linphone.phone.msgNotification")! } public class func ensureDirectoryExists(path: String) { diff --git a/Linphone/Utils/Log.swift b/Linphone/Utils/Log.swift index d09da8240..738f51d70 100644 --- a/Linphone/Utils/Log.swift +++ b/Linphone/Utils/Log.swift @@ -34,10 +34,11 @@ class Log: LoggingServiceDelegate { var debugEnabled = true // Todo : bind to app parameters var service = LoggingService.Instance + let appGroupName = "group.org.linphone.phone.msgNotification" private init() { service.domain = Bundle.main.bundleIdentifier! - Core.setLogCollectionPath(path: Factory.Instance.getDataDir(context: UnsafeMutablePointer(mutating: (Config.appGroupName as NSString).utf8String))) + Core.setLogCollectionPath(path: Factory.Instance.getDataDir(context: UnsafeMutablePointer(mutating: (appGroupName as NSString).utf8String))) Core.enableLogCollection(state: LogCollectionState.Enabled) setMask() LoggingService.Instance.addDelegate(delegate: self) diff --git a/Linphone/Utils/MagicSearchSingleton.swift b/Linphone/Utils/MagicSearchSingleton.swift index 5031e65e5..fb639e1eb 100644 --- a/Linphone/Utils/MagicSearchSingleton.swift +++ b/Linphone/Utils/MagicSearchSingleton.swift @@ -56,11 +56,11 @@ final class MagicSearchSingleton: ObservableObject { } private init() { - allContact = CorePreferences.contactsFilter == "" + allContact = AppServices.corePreferences.contactsFilter == "" coreContext.doOnCoreQueue { core in - self.linphoneDomain = CorePreferences.defaultDomain == core.defaultAccount?.params?.domain - self.domainDefaultAccount = CorePreferences.contactsFilter + self.linphoneDomain = AppServices.corePreferences.defaultDomain == core.defaultAccount?.params?.domain + self.domainDefaultAccount = AppServices.corePreferences.contactsFilter self.magicSearch = try? core.createMagicSearch() @@ -158,8 +158,8 @@ final class MagicSearchSingleton: ObservableObject { func changeAllContact(allContactBool: Bool) { allContact = allContactBool - domainDefaultAccount = allContactBool ? "" : (linphoneDomain ? CorePreferences.defaultDomain : "*") - CorePreferences.contactsFilter = domainDefaultAccount + domainDefaultAccount = allContactBool ? "" : (linphoneDomain ? AppServices.corePreferences.defaultDomain : "*") + AppServices.corePreferences.contactsFilter = domainDefaultAccount } func updateContacts( diff --git a/Linphone/Utils/URIHandler.swift b/Linphone/Utils/URIHandler.swift index 09d6af463..5c4b3e7ee 100644 --- a/Linphone/Utils/URIHandler.swift +++ b/Linphone/Utils/URIHandler.swift @@ -165,7 +165,7 @@ class URIHandler { } private static func autoRemoteProvisioningOnConfigUriHandler() -> Bool { - return Config.get().getBool(section: "app", key: "auto_apply_provisioning_config_uri_handler", defaultValue: true) + return AppServices.config.getBool(section: "app", key: "auto_apply_provisioning_config_uri_handler", defaultValue: true) } private static func toast(_ message: String) { diff --git a/LinphoneApp.xcodeproj/project.pbxproj b/LinphoneApp.xcodeproj/project.pbxproj index 150fc733f..dd176fdb1 100644 --- a/LinphoneApp.xcodeproj/project.pbxproj +++ b/LinphoneApp.xcodeproj/project.pbxproj @@ -35,7 +35,6 @@ 66F08C892C2AFEF700D9AE2F /* MeetingsListBottomSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66F08C882C2AFEF700D9AE2F /* MeetingsListBottomSheet.swift */; }; 66F626B22BCEBB86003E2DEC /* AddParticipantsFragment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66F626B12BCEBB86003E2DEC /* AddParticipantsFragment.swift */; }; 66FBFC482B83B8CC00BC6AB1 /* Log.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66C492002B24DB6900CEA16D /* Log.swift */; }; - 66FBFC492B83BD2400BC6AB1 /* ConfigExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66C491F82B24D25A00CEA16D /* ConfigExtension.swift */; }; 66FBFC4A2B83BD3300BC6AB1 /* FileUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66C491FE2B24D4AC00CEA16D /* FileUtils.swift */; }; 66FBFC4B2B83BD7B00BC6AB1 /* CoreExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66C491FA2B24D32600CEA16D /* CoreExtension.swift */; }; 66FDB7812C7C689A00561566 /* EventEditViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66FDB7802C7C689A00561566 /* EventEditViewController.swift */; }; @@ -128,7 +127,6 @@ D74DA0122C047F0700A8561D /* HistoryModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D74DA0112C047F0700A8561D /* HistoryModel.swift */; }; D750D3392AD3E6EE00EC99C5 /* PopupLoadingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D750D3382AD3E6EE00EC99C5 /* PopupLoadingView.swift */; }; D756C8152D34FF9200A58F2F /* SettingsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D756C8142D34FF8900A58F2F /* SettingsViewModel.swift */; }; - D756C8172D352C5F00A58F2F /* CorePreferences.swift in Sources */ = {isa = PBXBuildFile; fileRef = D756C8162D352C5600A58F2F /* CorePreferences.swift */; }; D756C8182D352C5F00A58F2F /* CorePreferences.swift in Sources */ = {isa = PBXBuildFile; fileRef = D756C8162D352C5600A58F2F /* CorePreferences.swift */; }; D75759322B56D40900E7AC10 /* ZRTPPopup.swift in Sources */ = {isa = PBXBuildFile; fileRef = D75759312B56D40900E7AC10 /* ZRTPPopup.swift */; }; D759CB642C3FBD4200AC35E8 /* StartConversationFragment.swift in Sources */ = {isa = PBXBuildFile; fileRef = D759CB632C3FBD4200AC35E8 /* StartConversationFragment.swift */; }; @@ -1420,11 +1418,9 @@ files = ( 66FBFC482B83B8CC00BC6AB1 /* Log.swift in Sources */, 6691CA7E2B839C2D00B2A7B8 /* NotificationService.swift in Sources */, - 66FBFC492B83BD2400BC6AB1 /* ConfigExtension.swift in Sources */, C642277D2E8E4E2B0094FEDC /* ColorExtension.swift in Sources */, 66FBFC4A2B83BD3300BC6AB1 /* FileUtils.swift in Sources */, 66FBFC4B2B83BD7B00BC6AB1 /* CoreExtension.swift in Sources */, - D756C8172D352C5F00A58F2F /* CorePreferences.swift in Sources */, C642277C2E8E4D900094FEDC /* ThemeManager.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/LinphoneApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/LinphoneApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 823cb244f..84ef69fff 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" : "a280d1dc67a2ffd1baceff28186e316b81f187fc" + "revision" : "e2c24740b5f3479ae5d80f0eda11165937c448f8" } }, { diff --git a/msgNotificationService/NotificationService.swift b/msgNotificationService/NotificationService.swift index 806542b62..3951c66be 100644 --- a/msgNotificationService/NotificationService.swift +++ b/msgNotificationService/NotificationService.swift @@ -26,12 +26,13 @@ import Firebase #endif var LINPHONE_DUMMY_SUBJECT = "dummy subject" +let appGroupName = "group.org.linphone.phone.msgNotification" extension String { func getDisplayNameFromSipAddress(lc: Core) -> String? { Log.info("looking for display name for \(self)") - let defaults = UserDefaults.init(suiteName: Config.appGroupName) + let defaults = UserDefaults.init(suiteName: appGroupName) let addressBook = defaults?.dictionary(forKey: "addressBook") if addressBook == nil { @@ -87,12 +88,12 @@ class NotificationService: UNNotificationServiceExtension { bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent) LoggingService.Instance.logLevel = LogLevel.Debug - Factory.Instance.logCollectionPath = Factory.Instance.getDataDir(context: UnsafeMutablePointer(mutating: (Config.appGroupName as NSString).utf8String)) + Factory.Instance.logCollectionPath = Factory.Instance.getDataDir(context: UnsafeMutablePointer(mutating: (appGroupName as NSString).utf8String)) Factory.Instance.enableLogCollection(state: LogCollectionState.Enabled) Log.info("[msgNotificationService] start msgNotificationService extension") /* - if (VFSUtil.vfsEnabled(groupName: Config.appGroupName) && !VFSUtil.activateVFS()) { + if (VFSUtil.vfsEnabled(groupName: AppServices.config.appGroupName) && !VFSUtil.activateVFS()) { VFSUtil.log("[VFS] Error unable to activate.", .error) } */ @@ -117,7 +118,7 @@ class NotificationService: UNNotificationServiceExtension { } /* - let defaults = UserDefaults.init(suiteName: Config.appGroupName) + let defaults = UserDefaults.init(suiteName: AppServices.config.appGroupName) if let chatroomsPushStatus = defaults?.dictionary(forKey: "chatroomsPushStatus") { let aps = bestAttemptContent.userInfo["aps"] as? NSDictionary let alert = aps?["alert"] as? NSDictionary @@ -303,8 +304,11 @@ class NotificationService: UNNotificationServiceExtension { func createCore() { Log.info("[msgNotificationService] create core") + + let factoryPath = FileUtil.bundleFilePath("linphonerc-factory")! + let config = Config.newForSharedCore(appGroupId: appGroupName, configFilename: "linphonerc", factoryConfigFilename: factoryPath)! - lc = try? Factory.Instance.createSharedCoreWithConfig(config: Config.get(), systemContext: nil, appGroupId: Config.appGroupName, mainCore: false) + lc = try? Factory.Instance.createSharedCoreWithConfig(config: config, systemContext: nil, appGroupId: appGroupName, mainCore: false) } func stopCore() {