premier commentaires
This commit is contained in:
parent
3f09bddbf5
commit
2a1b1aaa56
@ -60,7 +60,7 @@ struct ContentView: View {
|
|||||||
}
|
}
|
||||||
Group {
|
Group {
|
||||||
Spacer()
|
Spacer()
|
||||||
Toggle(isOn: $tutorialContext.loggingUnit.logsEnabled.value) {
|
Toggle(isOn: $tutorialContext.loggingUnit.logsEnabled) {
|
||||||
Text("Logs collection")
|
Text("Logs collection")
|
||||||
.multilineTextAlignment(.trailing)
|
.multilineTextAlignment(.trailing)
|
||||||
}
|
}
|
||||||
|
@ -27,12 +27,15 @@ class LoginTutorialContext : ObservableObject
|
|||||||
init()
|
init()
|
||||||
{
|
{
|
||||||
// Initialize Linphone Core
|
// 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:
|
// 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()
|
try? mCore.start()
|
||||||
// Add callbacks to the Linphone Core
|
// 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
|
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")
|
print("New registration state \(state) for user id \( String(describing: account.params?.identityAddress?.asString()))\n")
|
||||||
if (state == .Ok) {
|
if (state == .Ok) {
|
||||||
@ -45,6 +48,8 @@ class LoginTutorialContext : ObservableObject
|
|||||||
mCore.addDelegate(delegate: mRegistrationDelegate)
|
mCore.addDelegate(delegate: mRegistrationDelegate)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//FIXME expliquer ce que ça fait
|
||||||
func registrationExample()
|
func registrationExample()
|
||||||
{
|
{
|
||||||
if (!loggedIn) {
|
if (!loggedIn) {
|
||||||
@ -52,10 +57,8 @@ class LoginTutorialContext : ObservableObject
|
|||||||
if (account == nil) {
|
if (account == nil) {
|
||||||
account = try createAndInitializeAccount(core : mCore, identity: id, password: passwd)
|
account = try createAndInitializeAccount(core : mCore, identity: id, password: passwd)
|
||||||
try mCore.addAccount(account: account!)
|
try mCore.addAccount(account: account!)
|
||||||
if ( mCore.defaultAccount == nil) {
|
// IMPORTANT : default account setting MUST be done AFTER adding the config to the core !)
|
||||||
// IMPORTANT : default account setting MUST be done AFTER adding the config to the core !)
|
mCore.defaultAccount = account
|
||||||
mCore.defaultAccount = account
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let registeredParams = account?.params?.clone()
|
let registeredParams = account?.params?.clone()
|
||||||
|
@ -5,7 +5,7 @@ source "https://gitlab.linphone.org/BC/public/podspec.git"
|
|||||||
|
|
||||||
def basic_pods
|
def basic_pods
|
||||||
if ENV['PODFILE_PATH'].nil?
|
if ENV['PODFILE_PATH'].nil?
|
||||||
pod 'linphone-sdk', '~> 5.0.0-alpha'
|
pod 'linphone-sdk', '~> 5.0.0'
|
||||||
else
|
else
|
||||||
pod 'linphone-sdk', :path => ENV['PODFILE_PATH'] # local sdk
|
pod 'linphone-sdk', :path => ENV['PODFILE_PATH'] # local sdk
|
||||||
end
|
end
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
//FIXME GPL
|
||||||
|
|
||||||
// Created by QuentinArguillere on 17/08/2020.
|
// Created by QuentinArguillere on 17/08/2020.
|
||||||
// Copyright © 2020 BelledonneCommunications. All rights reserved.
|
// Copyright © 2020 BelledonneCommunications. All rights reserved.
|
||||||
//
|
//
|
||||||
@ -5,20 +7,21 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import linphonesw
|
import linphonesw
|
||||||
|
|
||||||
|
//FIXME expliquer
|
||||||
func createAndInitializeAccount(core: Core, identity: String, password: String, withVoipPush: Bool = false, withRemotePush: Bool = false) throws -> Account {
|
func createAndInitializeAccount(core: Core, identity: String, password: String, withVoipPush: Bool = false, withRemotePush: Bool = false) throws -> Account {
|
||||||
let factory = Factory.Instance
|
let factory = Factory.Instance
|
||||||
|
|
||||||
let accountParams = try core.createAccountParams()
|
let accountParams = try core.createAccountParams()
|
||||||
let address = try factory.createAddress(addr: identity)
|
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.setIdentityaddress(newValue: address)
|
||||||
try accountParams.setServeraddr(newValue: "sip:" + address.domain + ";transport=tls")
|
try accountParams.setServeraddr(newValue: "sip:" + address.domain + ";transport=tcp")
|
||||||
accountParams.registerEnabled = true
|
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.
|
// 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"
|
accountParams.pushNotificationConfig?.provider = "apns.dev"
|
||||||
|
//FIXME + de coomtaires
|
||||||
accountParams.pushNotificationAllowed = withVoipPush
|
accountParams.pushNotificationAllowed = withVoipPush
|
||||||
accountParams.remotePushNotificationAllowed = withRemotePush
|
accountParams.remotePushNotificationAllowed = withRemotePush
|
||||||
core.addAuthInfo(info: info)
|
core.addAuthInfo(info: info)
|
||||||
@ -28,35 +31,22 @@ func createAndInitializeAccount(core: Core, identity: String, password: String,
|
|||||||
|
|
||||||
class LoggingUnit
|
class LoggingUnit
|
||||||
{
|
{
|
||||||
class BoolHolder : ObservableObject
|
|
||||||
{
|
|
||||||
@Published var value : Bool
|
|
||||||
init(val : Bool) {
|
|
||||||
value = val
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var logsEnabled : BoolHolder
|
var logsEnabled : Bool = true {
|
||||||
var logDelegate : LinphoneLoggingServiceImpl
|
didSet {
|
||||||
var log : LoggingService
|
LoggingService.Instance.logLevel = logsEnabled ? LogLevel.Debug: LogLevel.Fatal
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class LinphoneLoggingServiceImpl: LoggingServiceDelegate {
|
class LinphoneLoggingServiceImpl: LoggingServiceDelegate {
|
||||||
var logsEnabled : BoolHolder!
|
|
||||||
func onLogMessageWritten(logService: LoggingService, domain: String, level: LogLevel, message: String) {
|
func onLogMessageWritten(logService: LoggingService, domain: String, level: LogLevel, message: String) {
|
||||||
if (logsEnabled.value) {
|
print("Linphone logs: \(message)")
|
||||||
print("Linphone logs: \(message)")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
init()
|
init() {
|
||||||
{
|
//FIXME commentaires
|
||||||
logsEnabled = BoolHolder(val: true)
|
LoggingService.Instance.addDelegate(delegate: LinphoneLoggingServiceImpl())
|
||||||
logDelegate = LinphoneLoggingServiceImpl()
|
LoggingService.Instance.logLevel = LogLevel.Debug
|
||||||
logDelegate.logsEnabled = logsEnabled;
|
|
||||||
log = LoggingService.Instance
|
|
||||||
log.addDelegate(delegate: logDelegate)
|
|
||||||
log.logLevel = LogLevel.Debug
|
|
||||||
Factory.Instance.enableLogCollection(state: LogCollectionState.Enabled)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user