Newer
Older
QuentinArguillere
committed
// Created by QuentinArguillere on 17/08/2020.
// Copyright © 2020 BelledonneCommunications. All rights reserved.
//
import Foundation
import linphonesw
QuentinArguillere
committed
func createAndInitializeAccount(core: Core, identity: String, password: String, withVoipPush: Bool = false, withRemotePush: Bool = false) throws -> Account {
let accountParams = try core.createAccountParams()
let address = try factory.createAddress(addr: identity)
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=tcp")
QuentinArguillere
committed
// 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"
QuentinArguillere
committed
accountParams.pushNotificationAllowed = withVoipPush
accountParams.remotePushNotificationAllowed = withRemotePush
core.addAuthInfo(info: info)
return try core.createAccount(params: accountParams)
QuentinArguillere
committed
}
class LoggingUnit
{
var logsEnabled : Bool = true {
didSet {
LoggingService.Instance.logLevel = logsEnabled ? LogLevel.Debug: LogLevel.Fatal
}
}
class LinphoneLoggingServiceImpl: LoggingServiceDelegate {
func onLogMessageWritten(logService: LoggingService, domain: String, level: LogLevel, message: String) {
init() {
//FIXME commentaires
LoggingService.Instance.addDelegate(delegate: LinphoneLoggingServiceImpl())
LoggingService.Instance.logLevel = LogLevel.Debug