forked from mirrors/linphone-iphone
Switch app Core to SharedCore, which will be required to have a working AppExtension
This commit is contained in:
parent
ea1420356d
commit
c0a16e62be
3 changed files with 21 additions and 24 deletions
|
|
@ -70,38 +70,35 @@ final class CoreContext: ObservableObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
func initialiseCore() throws {
|
func initialiseCore() throws {
|
||||||
|
|
||||||
#if USE_CRASHLYTICS
|
#if USE_CRASHLYTICS
|
||||||
FirebaseApp.configure()
|
FirebaseApp.configure()
|
||||||
#endif
|
#endif
|
||||||
coreQueue.async {
|
coreQueue.async {
|
||||||
|
|
||||||
LoggingService.Instance.logLevel = LogLevel.Debug
|
LoggingService.Instance.logLevel = LogLevel.Debug
|
||||||
let configDir = Factory.Instance.getConfigDir(context: nil)
|
Factory.Instance.logCollectionPath = Factory.Instance.getConfigDir(context: nil)
|
||||||
|
|
||||||
Factory.Instance.logCollectionPath = configDir
|
|
||||||
Factory.Instance.enableLogCollection(state: LogCollectionState.Enabled)
|
Factory.Instance.enableLogCollection(state: LogCollectionState.Enabled)
|
||||||
|
|
||||||
Log.info("Initialising core")
|
Log.info("Checking if linphonerc file exists already. If not, creating one as a copy of linphonerc-default")
|
||||||
let url = NSURL(fileURLWithPath: configDir)
|
if let rcDir = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: Config.appGroupName)?
|
||||||
if let pathComponent = url.appendingPathComponent("linphonerc") {
|
.appendingPathComponent("Library/Preferences/linphone") {
|
||||||
let filePath = pathComponent.path
|
let rcFileUrl = rcDir.appendingPathComponent("linphonerc")
|
||||||
let fileManager = FileManager.default
|
if !FileManager.default.fileExists(atPath: rcFileUrl.path) {
|
||||||
if !fileManager.fileExists(atPath: filePath) {
|
do {
|
||||||
let path = Bundle.main.path(forResource: "linphonerc-default", ofType: nil)
|
try FileManager.default.createDirectory(at: rcDir, withIntermediateDirectories: true)
|
||||||
if path != nil {
|
if let pathToDefaultConfig = Bundle.main.path(forResource: "linphonerc-default", ofType: nil) {
|
||||||
try? FileManager.default.copyItem(at: NSURL(fileURLWithPath: path!) as URL, to: pathComponent)
|
try FileManager.default.copyItem(at: URL(fileURLWithPath: pathToDefaultConfig), to: rcFileUrl)
|
||||||
|
Log.info("Successfully copied linphonerc-default configuration")
|
||||||
|
}
|
||||||
|
} catch let error {
|
||||||
|
Log.error("Failed to copy default linphonerc file: \(error.localizedDescription)")
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Log.info("Found existing linphonerc file, skip copying of linphonerc-default configuration")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let config = try? Factory.Instance.createConfigWithFactory(
|
Log.info("Initialising core")
|
||||||
path: "\(configDir)/linphonerc",
|
self.mCore = try? Factory.Instance.createSharedCoreWithConfig(config: Config.get(), systemContext: nil, appGroupId: Config.appGroupName, mainCore: true)
|
||||||
factoryPath: Bundle.main.path(forResource: "linphonerc-factory", ofType: nil)
|
|
||||||
)
|
|
||||||
if config != nil {
|
|
||||||
self.mCore = try? Factory.Instance.createCoreWithConfig(config: config!, systemContext: nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
linphone_core_set_push_registry_dispatch_queue(self.mCore.getCobject, Unmanaged.passUnretained(coreQueue).toOpaque())
|
linphone_core_set_push_registry_dispatch_queue(self.mCore.getCobject, Unmanaged.passUnretained(coreQueue).toOpaque())
|
||||||
self.mCore.autoIterateEnabled = false
|
self.mCore.autoIterateEnabled = false
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@
|
||||||
<string>group.belledonne-communications.linphone</string>
|
<string>group.belledonne-communications.linphone</string>
|
||||||
<string>group.org.linphone.phone.linphoneExtension</string>
|
<string>group.org.linphone.phone.linphoneExtension</string>
|
||||||
<string>group.org.linphone.phone.msgNotification</string>
|
<string>group.org.linphone.phone.msgNotification</string>
|
||||||
<string>group.org.linphone.phone.logs</string>
|
|
||||||
</array>
|
</array>
|
||||||
<key>com.apple.security.files.user-selected.read-only</key>
|
<key>com.apple.security.files.user-selected.read-only</key>
|
||||||
<true/>
|
<true/>
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,8 @@ extension Config {
|
||||||
|
|
||||||
public static func get() -> Config {
|
public static func get() -> Config {
|
||||||
if _instance == nil {
|
if _instance == nil {
|
||||||
let factoryPath = FileUtil.bundleFilePath(Core.runsInsideExtension() ? "linphonerc-factory-appex" : "linphonerc-factory-app")!
|
let factoryPath = FileUtil.bundleFilePath("linphonerc-factory")!
|
||||||
|
let configDir = Factory.Instance.getConfigDir(context: nil)
|
||||||
_instance = Config.newForSharedCore(appGroupId: Config.appGroupName, configFilename: "linphonerc", factoryConfigFilename: factoryPath)!
|
_instance = Config.newForSharedCore(appGroupId: Config.appGroupName, configFilename: "linphonerc", factoryConfigFilename: factoryPath)!
|
||||||
}
|
}
|
||||||
return _instance!
|
return _instance!
|
||||||
|
|
@ -46,7 +47,7 @@ extension Config {
|
||||||
return hasEntry(section: section, key: key) == 1 ? getString(section: section, key: key, defaultString: "") : nil
|
return hasEntry(section: section, key: key) == 1 ? getString(section: section, key: key, defaultString: "") : nil
|
||||||
}
|
}
|
||||||
|
|
||||||
static let appGroupName = "group.org.linphone.phone.logs"
|
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
|
// 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 teamID = Config.get().getString(section: "app", key: "team_id", defaultString: "")
|
||||||
static let earlymediaContentExtCatIdentifier = Config.get().getString(section: "app", key: "extension_category", defaultString: "")
|
static let earlymediaContentExtCatIdentifier = Config.get().getString(section: "app", key: "extension_category", defaultString: "")
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue