Commit 2be13f34 authored by Christophe Deschamps's avatar Christophe Deschamps
Browse files

SDK Update to 4.5 + push account creation


Former-commit-id: dd34cd13f94ff4eb107404047cc0e2dd77537242
parent 6151faa9
......@@ -8,19 +8,19 @@
<entry name="quality_reporting_enabled" overwrite="true">1</entry>
<entry name="quality_reporting_interval" overwrite="true">180</entry>
<entry name="reg_expires" overwrite="true">31536000</entry>
<entry name="reg_identity" overwrite="true">sip:?@linphone.org</entry>
<entry name="reg_proxy" overwrite="true">&lt;sip:sip.linphone.org;transport=tls&gt;</entry>
<entry name="reg_route" overwrite="true">&lt;sip:sip.linphone.org;transport=tls&gt;</entry>
<entry name="reg_identity" overwrite="true">sip:?@lindoor.org</entry>
<entry name="reg_proxy" overwrite="true">&lt;sip:sip.lindoor.org;transport=tls&gt;</entry>
<entry name="reg_route" overwrite="true">&lt;sip:sip.lindoor.org;transport=tls&gt;</entry>
<entry name="reg_sendregister" overwrite="true">1</entry>
<entry name="nat_policy_ref" overwrite="true">nat_policy_default_values</entry>
<entry name="realm" overwrite="true">sip.linphone.org</entry>
<entry name="realm" overwrite="true">sip.lindoor.org</entry>
</section>
<section name="nat_policy_default_values">
<entry name="stun_server" overwrite="true">stun.linphone.org</entry>
<entry name="protocols" overwrite="true">stun,ice</entry>
</section>
<section name="assistant">
<entry name="domain" overwrite="true">sip.linphone.org</entry>
<entry name="domain" overwrite="true">sip.lindoor.org</entry>
<entry name="algorithm" overwrite="true">SHA-256</entry>
<entry name="password_max_length" overwrite="true">-1</entry>
<entry name="password_min_length" overwrite="true">1</entry>
......
......@@ -32,10 +32,10 @@ enabled=1
[assistant]
xmlrpc_url=https://subscribe.linphone.org:444/wizard.php
xmlrpc_url=https://subscribe.lindoor.org:444/wizard.php
; MD5 / SHA-256
password_algo=SHA-256
domain=sip.linphone.org
domain=sip.lindoor.org
freesip_url=https://www.linphone.org/freesip/home
## End of factory rc
package org.lindoor.customisation
import org.lindoor.customisation.Customisation.actionTypesConfig
import org.lindoor.linphonecore.extensions.getString
import org.lindoor.ui.widgets.SpinnerItem
import java.util.*
......@@ -12,7 +13,7 @@ object ActionTypes {
config.sectionsNamesList.forEach {
spinnerItems.add(
SpinnerItem(
config.getString(it, "textkey", "missing"),
config.getString(it, "textkey", nonNullDefault = "missing"),
config.getString(it, "icon", null),
it
)
......@@ -23,13 +24,13 @@ object ActionTypes {
fun typeNameForActionType(typeKey: String): String {
return actionTypesConfig.let { config ->
Texts.get(config.getString(typeKey, "textkey", null))
Texts.get(config.getString(typeKey, "textkey", nonNullDefault = typeKey))
}
}
fun iconNameForActionType(typeKey: String): String {
return actionTypesConfig.let { config ->
config.getString(typeKey, "icon", null)
config.getString(typeKey, "icon", nonNullDefault = typeKey )
}
}
......
......@@ -3,6 +3,8 @@ package org.lindoor.customisation
import org.lindoor.customisation.Customisation.actionsMethodTypesConfig
import org.lindoor.ui.widgets.SpinnerItem
import java.util.*
import org.lindoor.linphonecore.extensions.getString
object ActionsMethodTypes {
var spinnerItems: ArrayList<SpinnerItem> = ArrayList()
......@@ -11,7 +13,7 @@ object ActionsMethodTypes {
actionsMethodTypesConfig.let { config ->
config.sectionsNamesList.forEach {
spinnerItems.add(
SpinnerItem(config.getString(it, "textkey", "missing"), null, it)
SpinnerItem(config.getString(it, "textkey", nonNullDefault = "missing"), null, it)
)
}
}
......
......@@ -3,6 +3,8 @@ package org.lindoor.customisation
import org.lindoor.customisation.Customisation.deviceTypesConfig
import org.lindoor.ui.widgets.SpinnerItem
import java.util.*
import org.lindoor.linphonecore.extensions.getString
object DeviceTypes {
var deviceTypes: ArrayList<SpinnerItem> = ArrayList()
......@@ -15,7 +17,7 @@ object DeviceTypes {
defaultType = it
deviceTypes.add(
SpinnerItem(
config.getString(it, "textkey", "missing"),
config.getString(it, "textkey", nonNullDefault = "missing"),
config.getString(it, "icon", null),
it
)
......@@ -32,7 +34,9 @@ object DeviceTypes {
fun typeNameForDeviceType(typeKey: String): String? {
return deviceTypesConfig.let { config ->
Texts.get(config.getString(typeKey, "textkey", deviceTypes.get(0).backingKey))
config.getString(typeKey, "textkey", deviceTypes.get(0).backingKey)?.let {
Texts.get(it)
}
}
}
......
......@@ -2,19 +2,15 @@ package org.lindoor.entities
import android.text.TextUtils
import androidx.lifecycle.MutableLiveData
import org.lindoor.LindoorApplication
import org.lindoor.LindoorApplication.Companion.coreContext
import org.lindoor.LindoorApplication.Companion.corePreferences
import org.lindoor.utils.extensions.xDigitsUUID
import org.linphone.core.AccountCreator
import org.linphone.core.AccountCreatorListenerStub
import org.linphone.core.ProxyConfig
import java.util.*
import org.lindoor.utils.cdlog
import org.linphone.core.*
object Account {
private const val PUSH_GW_ID_KEY = "lindoor_pushgateway"
private const val PUSH_GW_USER_PREFIX = "lindoor_generated"
private const val PUSH_GW_DISPLAY_NAME = "Lindoor"
fun configured(): Boolean {
return coreContext.core.proxyConfigList.isNotEmpty()
......@@ -28,12 +24,8 @@ object Account {
return null
}
fun lindoorAccountCreate(accountCreator: AccountCreator) {
accountCreator.createProxyConfig().idkey = PUSH_GW_ID_KEY
}
fun lindoorAccountLogin(accountCreator: AccountCreator) {
accountCreator.createProxyConfig().idkey = PUSH_GW_ID_KEY
fun lindoorAccountCreateProxyConfig(accountCreator: AccountCreator) {
accountCreator.createProxyConfig()
}
fun sipAccountLogin(
......@@ -44,7 +36,9 @@ object Account {
) {
val proxyConfig: ProxyConfig? = accountCreator.createProxyConfig()
proxyConfig?.expires = expiration.toInt()
proxyConfig?.serverAddr = if (!TextUtils.isEmpty(proxy)) proxy else accountCreator.domain
if (!TextUtils.isEmpty(proxy)) {
proxyConfig?.serverAddr = proxy
}
if (pushGateway() != null)
linkProxiesWithPushGateway(pushReady)
else
......@@ -57,39 +51,46 @@ object Account {
fun createPushGateway(pushReady: MutableLiveData<Boolean>) {
coreContext.core.loadConfigFromXml(corePreferences.lindoorAccountDefaultValuesPath)
val accountCreator =
coreContext.core.createAccountCreator(corePreferences.xmlRpcServerUrl)
accountCreator.language = Locale.getDefault().language
val user: String = PUSH_GW_USER_PREFIX + xDigitsUUID()
val pass = UUID.randomUUID().toString()
accountCreator.domain = corePreferences.loginDomain
accountCreator.username = user
accountCreator.password = pass
accountCreator.email = "$user@${accountCreator.domain}"
accountCreator.displayName = PUSH_GW_DISPLAY_NAME
accountCreator.addListener(object : AccountCreatorListenerStub() {
override fun onCreateAccount(
creator: AccountCreator?,
status: AccountCreator.Status?,
resp: String?
) {
if (status == AccountCreator.Status.AccountCreated) // TODO Adjust when server setup
creator?.also {
val pushGw = it.createProxyConfig()
pushGw.idkey = PUSH_GW_ID_KEY
pushGw.enableRegister(true)
pushGw.enablePublish(false)
pushGw.expires = 31536000
pushGw.serverAddr = "sips:${it.domain}:5061;transport=tls"
pushGw.route = pushGw.serverAddr
pushGw.isPushNotificationAllowed = true
linkProxiesWithPushGateway(pushReady)
val xmlRpcSession = corePreferences.xmlRpcServerUrl?.let {
LindoorApplication.coreContext.core.createXmlRpcSession(
it
)
}
val xmlRpcRequest =
xmlRpcSession?.createRequest(XmlRpcArgType.StringStruct, "create_push_account")
xmlRpcRequest?.addStringArg(coreContext.core.userAgent)
xmlRpcRequest?.setListener { request ->
val status = request.status
val responseValues = request.listResponse
cdlog("Status : ${request.status} listResponse size : ${request.listResponse.size} ")
if (request.status == XmlRpcStatus.Ok) {
val pushGw = coreContext.core.createProxyConfig()
pushGw.idkey = PUSH_GW_ID_KEY
pushGw.enableRegister(true)
pushGw.enablePublish(false)
pushGw.expires = 31536000
pushGw.serverAddr = "sips:${responseValues.get(1)};transport=tls"
pushGw.setRoutes(arrayOf(pushGw.serverAddr))
pushGw.isPushNotificationAllowed = true
coreContext.core.createAddress("sip:${responseValues.get(0)}@${responseValues.get(1)}")?.let {
pushGw.setIdentityAddress(it)
}
}
})
if ( accountCreator.createAccount()!= AccountCreator.Status.RequestOk)
pushReady.value = false
val authInfo = Factory.instance().createAuthInfo(responseValues.get(0),responseValues.get(0),null,responseValues.get(2),responseValues.get(1),responseValues.get(1))
coreContext.core.addAuthInfo(authInfo)
coreContext.core.addProxyConfig(pushGw)
linkProxiesWithPushGateway(pushReady)
} else {
pushReady.value = false
}
}
if (xmlRpcRequest != null) {
xmlRpcSession?.sendRequest(xmlRpcRequest)
}
}
fun linkProxiesWithPushGateway(pushReady: MutableLiveData<Boolean>) {
......
......@@ -54,15 +54,19 @@ data class Device(
}
fun call() {
val params: CallParams = LindoorApplication.coreContext.core.createCallParams(null)
val params: CallParams? = LindoorApplication.coreContext.core.createCallParams(null)
type?.also {
params.enableVideo(DeviceTypes.supportsVideo(it))
params.enableAudio(DeviceTypes.supportsAudio(it))
params?.enableVideo(DeviceTypes.supportsVideo(it))
params?.enableAudio(DeviceTypes.supportsAudio(it))
}
val historyEvent = HistoryEvent()
params.recordFile = historyEvent.mediaFileName
params?.recordFile = historyEvent.mediaFileName
LindoorApplication.coreContext.core.createAddress(address)?.let {
val call = LindoorApplication.coreContext.core.inviteAddressWithParams(it, params)
val call = params?.let { parameters ->
LindoorApplication.coreContext.core.inviteAddressWithParams(it,
parameters
)
}
if (call != null)
call.callLog.userData =
historyEvent // Retrieved in CallViewModel and bound with call ID when available
......
......@@ -28,6 +28,7 @@ import java.io.File
import java.io.FileOutputStream
import java.math.BigInteger
import java.security.MessageDigest
import org.lindoor.linphonecore.extensions.getString
class CorePreferences constructor(private val context: Context) {
private var _config: Config? = null
......@@ -73,7 +74,7 @@ class CorePreferences constructor(private val context: Context) {
/* Video */
var deviceName: String
get() = config.getString("app", "device_name", Compatibility.getDeviceName(context))
get() = config.getString("app", "device_name", nonNullDefault = Compatibility.getDeviceName(context))
set(value) = config.setString("app", "device_name", value)
......
......@@ -8,20 +8,20 @@ import org.linphone.core.MediaDirection
fun Call.extendedAcceptEarlyMedia() {
if (state == Call.State.IncomingReceived) {
val earlyMediaCallParams: CallParams = coreContext.core.createCallParams(this)
earlyMediaCallParams.videoDirection = MediaDirection.RecvOnly
earlyMediaCallParams.audioDirection = MediaDirection.Inactive
earlyMediaCallParams.recordFile = callLog.historyEvent().mediaFileName
val earlyMediaCallParams: CallParams? = coreContext.core.createCallParams(this)
earlyMediaCallParams?.videoDirection = MediaDirection.RecvOnly
earlyMediaCallParams?.audioDirection = MediaDirection.Inactive
earlyMediaCallParams?.recordFile = callLog.historyEvent().mediaFileName
acceptEarlyMediaWithParams(earlyMediaCallParams)
startRecording()
}
}
fun Call.extendedAccept() {
val inCallParams: CallParams = coreContext.core.createCallParams(this)
inCallParams.videoDirection = MediaDirection.RecvOnly
inCallParams.audioDirection = MediaDirection.SendRecv
inCallParams.recordFile = callLog.historyEvent().mediaFileName
val inCallParams: CallParams? = coreContext.core.createCallParams(this)
inCallParams?.videoDirection = MediaDirection.RecvOnly
inCallParams?.audioDirection = MediaDirection.SendRecv
inCallParams?.recordFile = callLog.historyEvent().mediaFileName
acceptWithParams(inCallParams)
startRecording()
}
......
package org.lindoor.linphonecore.extensions
import org.linphone.core.Config
fun Config.getString(section:String, key:String, nonNullDefault:String): String {
return getString(section, key, nonNullDefault)?:nonNullDefault
}
......@@ -39,7 +39,7 @@ class NotificationBroadcastReceiver : BroadcastReceiver() {
coreContext.notificationsManager.getSipUriForCallNotificationId(notificationId)
val core: Core = coreContext.core
val call = core.findCallFromUri(remoteAddress)
val call = remoteAddress?.let { core.findCallFromUri(it) }
if (call == null) {
Log.e("[Notification Broadcast Receiver] Couldn't find call from remote address $remoteAddress")
return
......
......@@ -425,7 +425,7 @@ class NotificationsManager(private val context: Context) {
} else {
val name = DeviceStore.findDeviceByAddress(call.remoteAddress)?.name
?: call.remoteAddress.username
body = Texts.get("notif_missed_call", name)
body = Texts.get("notif_missed_call", name?:"device")
Log.i("[Notifications Manager] Creating missed call notification")
}
......
......@@ -7,6 +7,7 @@ import org.lindoor.store.StorageManager.devicesXml
import org.linphone.core.Address
import org.linphone.core.Config
import org.linphone.core.Factory
import org.lindoor.linphonecore.extensions.getString
object DeviceStore {
......@@ -36,8 +37,8 @@ object DeviceStore {
Device(
it,
devicesConfig.getString(it, "type", null),
devicesConfig.getString(it, "name", "missing"),
devicesConfig.getString(it, "address", "missing"),
devicesConfig.getString(it, "name", nonNullDefault = "missing"),
devicesConfig.getString(it, "address", nonNullDefault = "missing"),
devicesConfig.getString(it, "actions_method_type", null),
actions
)
......
......@@ -4,6 +4,8 @@ import org.lindoor.entities.HistoryEvent
import org.lindoor.store.StorageManager.historyEventsXml
import org.linphone.core.Config
import org.linphone.core.Factory
import org.lindoor.linphonecore.extensions.getString
object HistoryEventStore {
......@@ -23,12 +25,12 @@ object HistoryEventStore {
val result = HashMap<String, HistoryEvent>()
historyEventsConfig.sectionsNamesList.forEach {
result.put(
historyEventsConfig.getString(it, "call_id", null), HistoryEvent(
historyEventsConfig.getString(it, "call_id", null)!!, HistoryEvent(
it,
historyEventsConfig.getString(it, "call_id", null),
historyEventsConfig.getBool(it, "viewed_by_user", false),
historyEventsConfig.getString(it, "media_file_name", null),
historyEventsConfig.getString(it, "media_thumbnail_file_name", null),
historyEventsConfig.getString(it, "media_file_name", null)!!,
historyEventsConfig.getString(it, "media_thumbnail_file_name", null)!!,
historyEventsConfig.getBool(it, "has_video", false)
)
)
......
......@@ -37,7 +37,7 @@ class AccountViewModel : ViewModel() {
init {
LindoorApplication.coreContext.core.proxyConfigList.forEach {
cdlog("${it.identityAddress.asString()} ${it.idkey}")
cdlog("${it.identityAddress?.asString()} ${it.idkey}")
}
LindoorApplication.coreContext.core.addListener(coreListener)
}
......@@ -54,7 +54,7 @@ class AccountViewModel : ViewModel() {
fun getDescription(key:String, proxyConfig: ProxyConfig?): String? {
return account?.state?.toHumanReadable()?.let {
return proxyConfig?.state?.toHumanReadable()?.let {
proxyConfig?.identityAddress?.asStringUriOnly()?.let { it1 ->
Texts.get(key, it1,
it
......
......@@ -30,7 +30,7 @@ class CreateLindoorAccountViewModel :
) {
if (status == AccountCreator.Status.AccountCreated)
creator?.also {
Account.lindoorAccountCreate(creator)
Account.lindoorAccountCreateProxyConfig(creator)
}
creationResult.postValue(status)
}
......
......@@ -42,16 +42,18 @@ class LoginLindoorAccountFragment : CreatorAssistantFragment() {
if (model.fieldsValid()) {
hideKeyboard()
showProgress()
val xmlRpcSession = LindoorApplication.coreContext.core.createXmlRpcSession(
corePreferences.xmlRpcServerUrl
)
val xmlRpcSession = corePreferences.xmlRpcServerUrl?.let { it1 ->
LindoorApplication.coreContext.core.createXmlRpcSession(
it1
)
}
val xmlRpcRequest =
xmlRpcSession.createRequest(XmlRpcArgType.String, "check_authentication")
xmlRpcRequest.setListener { request ->
xmlRpcSession?.createRequest(XmlRpcArgType.String, "check_authentication")
xmlRpcRequest?.setListener { request ->
hideProgress()
if (request != null) {
if (request.stringResponse == "OK") {
Account.lindoorAccountLogin(model.accountCreator)
Account.lindoorAccountCreateProxyConfig(model.accountCreator)
mainactivity.navController.popBackStack(R.id.navigation_devices, false)
DialogUtil.info("lindoor_account_loggedin")
} else {
......@@ -59,15 +61,17 @@ class LoginLindoorAccountFragment : CreatorAssistantFragment() {
}
}
}
xmlRpcRequest.addStringArg(model.username.first.value)
xmlRpcRequest.addStringArg(
xmlRpcRequest?.addStringArg(model.username.first.value!!)
xmlRpcRequest?.addStringArg(
corePreferences.encryptedPass(
model.username.first.value!!,
model.pass1.first.value!!
)
)
xmlRpcRequest.addStringArg(corePreferences.loginDomain)
xmlRpcSession.sendRequest(xmlRpcRequest)
corePreferences.loginDomain?.let { it1 -> xmlRpcRequest?.addStringArg(it1) }
if (xmlRpcRequest != null) {
xmlRpcSession?.sendRequest(xmlRpcRequest)
}
}
}
......
......@@ -158,18 +158,18 @@ class CallViewModel(val call: Call) : ViewModel() {
when (d.actionsMethodType) {
"method_dtmf_sip_info" -> {
coreContext.core.useInfoForDtmf = true
call.sendDtmfs(action.code)
action.code?.let { call.sendDtmfs(it) }
}
"method_dtmf_rfc_4733" -> {
coreContext.core.useRfc2833ForDtmf = true
call.sendDtmfs(action.code)
action.code?.let { call.sendDtmfs(it) }
}
"method_sip_message" -> {
val message = coreContext.core.createInfoMessage()
val content = coreContext.core.createContent()
content.type = "text/plain"
action.code?.length?.let { content.setBuffer(action.code.toByteArray(), it) }
message.content = content
message.setContent(content)
call.sendInfoMessage(message)
}
}
......
......@@ -13,6 +13,7 @@ import org.lindoor.LindoorApplication
import org.lindoor.R
import org.lindoor.databinding.ActivityPlayerBinding
import org.lindoor.linphonecore.extensions.historyEvent
import org.linphone.core.AudioDevice
class PlayerActivity : GenericActivity(allowsLandscapeOnSmartPhones = true) {
......@@ -34,11 +35,23 @@ class PlayerActivity : GenericActivity(allowsLandscapeOnSmartPhones = true) {
DataBindingUtil.setContentView(this, R.layout.activity_player) as ActivityPlayerBinding
binding.lifecycleOwner = this
intent.getStringExtra("callId")?.also { callId ->
LindoorApplication.Companion.coreContext.core.findCallLogFromCallId(callId)
LindoorApplication.coreContext.core.findCallLogFromCallId(callId)
?.historyEvent()?.also { event ->
LindoorApplication.Companion.coreContext.core.createLocalPlayer(
null,
null,
var speakerCard: String? = null
var earpieceCard: String? = null
for (device in LindoorApplication.coreContext.core.audioDevices) {
if (device.hasCapability(AudioDevice.Capabilities.CapabilityPlay)) {
if (device.type == AudioDevice.Type.Speaker) {
speakerCard = device.id
} else if (device.type == AudioDevice.Type.Earpiece) {
earpieceCard = device.id
}
}
}
LindoorApplication.coreContext.core.createLocalPlayer(
speakerCard ?: earpieceCard,
"MSAndroidTextureDisplay",
if (event.hasVideo) binding.root.video.surfaceTexture else null
)?.also { player ->
playerViewModel =
......
......@@ -22,7 +22,7 @@ class PlayerViewModelFactory(private val callId: String, private val player: Pla
class PlayerViewModel(val callId: String, val player: Player) : ViewModel() {
val historyEvent =
LindoorApplication.coreContext.core.findCallLogFromCallId(callId).historyEvent()
LindoorApplication.coreContext.core.findCallLogFromCallId(callId)?.historyEvent()
val playing = MutableLiveData(false)
val position: MutableLiveData<Int> = MutableLiveData(0)
val reset = MutableLiveData(false)
......
buildscript {
ext.kotlin_version = '1.3.72'
ext.linphone_sdk_version = '4.4.0-alpha+'
ext.linphone_sdk_version = '4.5.0-alpha.47+db7ac3c'
repositories {
google()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment