premier commentaires
This commit is contained in:
parent
3f09bddbf5
commit
2a1b1aaa56
@ -60,7 +60,7 @@ struct ContentView: View {
|
||||
}
|
||||
Group {
|
||||
Spacer()
|
||||
Toggle(isOn: $tutorialContext.loggingUnit.logsEnabled.value) {
|
||||
Toggle(isOn: $tutorialContext.loggingUnit.logsEnabled) {
|
||||
Text("Logs collection")
|
||||
.multilineTextAlignment(.trailing)
|
||||
}
|
||||
|
@ -27,12 +27,15 @@ class LoginTutorialContext : ObservableObject
|
||||
init()
|
||||
{
|
||||
// Initialize Linphone Core
|
||||
try? mCore = Factory.Instance.createCore(configPath: "", factoryConfigPath: "", systemContext: nil)
|
||||
//FIXME ne peut on avoir une fonction de création sans param plutot que des params vide ?
|
||||
try? mCore = Factory.Instance.createCore(configPath: nil, factoryConfigPath: nil, systemContext: nil)
|
||||
|
||||
// main loop for receiving notifications and doing background linphonecore work:
|
||||
mCore.autoIterateEnabled = true
|
||||
//FIXME plus necessaire en 5.0
|
||||
mCore.autoIterateEnabled = true
|
||||
try? mCore.start()
|
||||
// Add callbacks to the Linphone Core
|
||||
//pourquoi un attribue de class ? une variable locale serait sufisante.
|
||||
mRegistrationDelegate = CoreDelegateStub(onAccountRegistrationStateChanged: { (core: Core, account: Account, state: RegistrationState, message: String) in
|
||||
print("New registration state \(state) for user id \( String(describing: account.params?.identityAddress?.asString()))\n")
|
||||
if (state == .Ok) {
|
||||
@ -45,6 +48,8 @@ class LoginTutorialContext : ObservableObject
|
||||
mCore.addDelegate(delegate: mRegistrationDelegate)
|
||||
}
|
||||
|
||||
|
||||
//FIXME expliquer ce que ça fait
|
||||
func registrationExample()
|
||||
{
|
||||
if (!loggedIn) {
|
||||
@ -52,10 +57,8 @@ class LoginTutorialContext : ObservableObject
|
||||
if (account == nil) {
|
||||
account = try createAndInitializeAccount(core : mCore, identity: id, password: passwd)
|
||||
try mCore.addAccount(account: account!)
|
||||
if ( mCore.defaultAccount == nil) {
|
||||
// IMPORTANT : default account setting MUST be done AFTER adding the config to the core !)
|
||||
mCore.defaultAccount = account
|
||||
}
|
||||
// IMPORTANT : default account setting MUST be done AFTER adding the config to the core !)
|
||||
mCore.defaultAccount = account
|
||||
}
|
||||
else {
|
||||
let registeredParams = account?.params?.clone()
|
||||
|
@ -5,7 +5,7 @@ source "https://gitlab.linphone.org/BC/public/podspec.git"
|
||||
|
||||
def basic_pods
|
||||
if ENV['PODFILE_PATH'].nil?
|
||||
pod 'linphone-sdk', '~> 5.0.0-alpha'
|
||||
pod 'linphone-sdk', '~> 5.0.0'
|
||||
else
|
||||
pod 'linphone-sdk', :path => ENV['PODFILE_PATH'] # local sdk
|
||||
end
|
||||
|
@ -1,3 +1,5 @@
|
||||
//FIXME GPL
|
||||
|
||||
// Created by QuentinArguillere on 17/08/2020.
|
||||
// Copyright © 2020 BelledonneCommunications. All rights reserved.
|
||||
//
|
||||
@ -5,20 +7,21 @@
|
||||
import Foundation
|
||||
import linphonesw
|
||||
|
||||
|
||||
//FIXME expliquer
|
||||
func createAndInitializeAccount(core: Core, identity: String, password: String, withVoipPush: Bool = false, withRemotePush: Bool = false) throws -> Account {
|
||||
let factory = Factory.Instance
|
||||
|
||||
let accountParams = try core.createAccountParams()
|
||||
let address = try factory.createAddress(addr: identity)
|
||||
let info = try factory.createAuthInfo(username: address.username, userid: "", passwd: password, ha1: "", realm: "", domain: address.domain)
|
||||
let info = try factory.createAuthInfo(username: address.username, userid: nil, passwd: password, ha1: nil, realm: nil, domain: address.domain)
|
||||
|
||||
try accountParams.setIdentityaddress(newValue: address)
|
||||
try accountParams.setServeraddr(newValue: "sip:" + address.domain + ";transport=tls")
|
||||
try accountParams.setServeraddr(newValue: "sip:" + address.domain + ";transport=tcp")
|
||||
accountParams.registerEnabled = true
|
||||
|
||||
// This is necessary to register to the server and handle push Notifications. Make sure you have a certificate to match your app's bundle ID.
|
||||
accountParams.pushNotificationConfig?.provider = "apns.dev"
|
||||
|
||||
//FIXME + de coomtaires
|
||||
accountParams.pushNotificationAllowed = withVoipPush
|
||||
accountParams.remotePushNotificationAllowed = withRemotePush
|
||||
core.addAuthInfo(info: info)
|
||||
@ -28,35 +31,22 @@ func createAndInitializeAccount(core: Core, identity: String, password: String,
|
||||
|
||||
class LoggingUnit
|
||||
{
|
||||
class BoolHolder : ObservableObject
|
||||
{
|
||||
@Published var value : Bool
|
||||
init(val : Bool) {
|
||||
value = val
|
||||
}
|
||||
}
|
||||
|
||||
var logsEnabled : BoolHolder
|
||||
var logDelegate : LinphoneLoggingServiceImpl
|
||||
var log : LoggingService
|
||||
|
||||
var logsEnabled : Bool = true {
|
||||
didSet {
|
||||
LoggingService.Instance.logLevel = logsEnabled ? LogLevel.Debug: LogLevel.Fatal
|
||||
}
|
||||
}
|
||||
|
||||
class LinphoneLoggingServiceImpl: LoggingServiceDelegate {
|
||||
var logsEnabled : BoolHolder!
|
||||
func onLogMessageWritten(logService: LoggingService, domain: String, level: LogLevel, message: String) {
|
||||
if (logsEnabled.value) {
|
||||
print("Linphone logs: \(message)")
|
||||
}
|
||||
print("Linphone logs: \(message)")
|
||||
}
|
||||
}
|
||||
|
||||
init()
|
||||
{
|
||||
logsEnabled = BoolHolder(val: true)
|
||||
logDelegate = LinphoneLoggingServiceImpl()
|
||||
logDelegate.logsEnabled = logsEnabled;
|
||||
log = LoggingService.Instance
|
||||
log.addDelegate(delegate: logDelegate)
|
||||
log.logLevel = LogLevel.Debug
|
||||
Factory.Instance.enableLogCollection(state: LogCollectionState.Enabled)
|
||||
init() {
|
||||
//FIXME commentaires
|
||||
LoggingService.Instance.addDelegate(delegate: LinphoneLoggingServiceImpl())
|
||||
LoggingService.Instance.logLevel = LogLevel.Debug
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user