mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-04-30 18:56:23 +00:00
Improved Linphone login adding automatically default domain to username if not entered by user
This commit is contained in:
parent
6ceee7fdb7
commit
9c855ef923
1 changed files with 19 additions and 2 deletions
|
|
@ -132,8 +132,22 @@ open class AccountLoginViewModel @UiThread constructor() : ViewModel() {
|
||||||
coreContext.postOnCoreThread { core ->
|
coreContext.postOnCoreThread { core ->
|
||||||
core.loadConfigFromXml(corePreferences.linphoneDefaultValuesPath)
|
core.loadConfigFromXml(corePreferences.linphoneDefaultValuesPath)
|
||||||
|
|
||||||
val identity = sipIdentity.value.orEmpty().trim()
|
val userInput = sipIdentity.value.orEmpty().trim()
|
||||||
val identityAddress = core.interpretUrl(identity, false)
|
val defaultDomain = corePreferences.defaultDomain
|
||||||
|
val identity = if (userInput.startsWith("sip:")) {
|
||||||
|
if (userInput.contains("@")) {
|
||||||
|
userInput
|
||||||
|
} else {
|
||||||
|
"$userInput@$defaultDomain"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (userInput.contains("@")) {
|
||||||
|
"sip:$userInput"
|
||||||
|
} else {
|
||||||
|
"sip:$userInput@$defaultDomain"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val identityAddress = Factory.instance().createAddress(identity)
|
||||||
if (identityAddress == null) {
|
if (identityAddress == null) {
|
||||||
Log.e("$TAG Can't parse [$identity] as Address!")
|
Log.e("$TAG Can't parse [$identity] as Address!")
|
||||||
// TODO: show error
|
// TODO: show error
|
||||||
|
|
@ -185,6 +199,9 @@ open class AccountLoginViewModel @UiThread constructor() : ViewModel() {
|
||||||
|
|
||||||
registrationInProgress.postValue(true)
|
registrationInProgress.postValue(true)
|
||||||
core.addListener(coreListener)
|
core.addListener(coreListener)
|
||||||
|
Log.i(
|
||||||
|
"$TAG Trying to log in account with SIP identity [${identityAddress.asStringUriOnly()}]"
|
||||||
|
)
|
||||||
core.addAccount(newlyCreatedAccount)
|
core.addAccount(newlyCreatedAccount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue