Prevent LIME X3DH server URL & friends lists RLS URI to be set for non sip.linphone.org accounts
This commit is contained in:
parent
595510028d
commit
e8ad1e039b
13 changed files with 57 additions and 54 deletions
|
@ -24,6 +24,9 @@
|
||||||
<entry name="stun_server" overwrite="true"></entry>
|
<entry name="stun_server" overwrite="true"></entry>
|
||||||
<entry name="protocols" overwrite="true"></entry>
|
<entry name="protocols" overwrite="true"></entry>
|
||||||
</section>
|
</section>
|
||||||
|
<section name="net">
|
||||||
|
<entry name="friendlist_subscription_enabled" overwrite="true">0</entry>
|
||||||
|
</section>
|
||||||
<section name="assistant">
|
<section name="assistant">
|
||||||
<entry name="domain" overwrite="true"></entry>
|
<entry name="domain" overwrite="true"></entry>
|
||||||
<entry name="algorithm" overwrite="true">MD5</entry>
|
<entry name="algorithm" overwrite="true">MD5</entry>
|
||||||
|
|
|
@ -24,11 +24,8 @@
|
||||||
<entry name="stun_server" overwrite="true">stun.linphone.org</entry>
|
<entry name="stun_server" overwrite="true">stun.linphone.org</entry>
|
||||||
<entry name="protocols" overwrite="true">stun,ice</entry>
|
<entry name="protocols" overwrite="true">stun,ice</entry>
|
||||||
</section>
|
</section>
|
||||||
<section name="sip">
|
<section name="net">
|
||||||
<entry name="rls_uri" overwrite="true">sips:rls@sip.linphone.org</entry>
|
<entry name="friendlist_subscription_enabled" overwrite="true">1</entry>
|
||||||
</section>
|
|
||||||
<section name="lime">
|
|
||||||
<entry name="x3dh_server_url" overwrite="true">https://lime.linphone.org/lime-server/lime-server.php</entry>
|
|
||||||
</section>
|
</section>
|
||||||
<section name="assistant">
|
<section name="assistant">
|
||||||
<entry name="domain" overwrite="true">sip.linphone.org</entry>
|
<entry name="domain" overwrite="true">sip.linphone.org</entry>
|
||||||
|
|
|
@ -93,7 +93,7 @@ class AccountLoginFragment : AbstractPhoneFragment<AssistantAccountLoginFragment
|
||||||
viewLifecycleOwner
|
viewLifecycleOwner
|
||||||
) {
|
) {
|
||||||
it.consume {
|
it.consume {
|
||||||
coreContext.contactsManager.updateLocalContacts()
|
coreContext.newAccountConfigured(true)
|
||||||
|
|
||||||
if (coreContext.core.isEchoCancellerCalibrationRequired) {
|
if (coreContext.core.isEchoCancellerCalibrationRequired) {
|
||||||
navigateToEchoCancellerCalibration()
|
navigateToEchoCancellerCalibration()
|
||||||
|
|
|
@ -52,7 +52,7 @@ class EmailAccountValidationFragment : GenericFragment<AssistantEmailAccountVali
|
||||||
viewLifecycleOwner
|
viewLifecycleOwner
|
||||||
) {
|
) {
|
||||||
it.consume {
|
it.consume {
|
||||||
coreContext.contactsManager.updateLocalContacts()
|
coreContext.newAccountConfigured(true)
|
||||||
|
|
||||||
val args = Bundle()
|
val args = Bundle()
|
||||||
args.putBoolean("AllowSkip", true)
|
args.putBoolean("AllowSkip", true)
|
||||||
|
|
|
@ -24,6 +24,7 @@ import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||||
|
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||||
import org.linphone.R
|
import org.linphone.R
|
||||||
import org.linphone.activities.GenericFragment
|
import org.linphone.activities.GenericFragment
|
||||||
import org.linphone.activities.assistant.AssistantActivity
|
import org.linphone.activities.assistant.AssistantActivity
|
||||||
|
@ -57,7 +58,8 @@ class GenericAccountLoginFragment : GenericFragment<AssistantGenericAccountLogin
|
||||||
viewLifecycleOwner
|
viewLifecycleOwner
|
||||||
) {
|
) {
|
||||||
it.consume {
|
it.consume {
|
||||||
coreContext.contactsManager.updateLocalContacts()
|
val isLinphoneAccount = viewModel.domain.value.orEmpty() == corePreferences.defaultDomain
|
||||||
|
coreContext.newAccountConfigured(isLinphoneAccount)
|
||||||
|
|
||||||
if (coreContext.core.isEchoCancellerCalibrationRequired) {
|
if (coreContext.core.isEchoCancellerCalibrationRequired) {
|
||||||
navigateToEchoCancellerCalibration()
|
navigateToEchoCancellerCalibration()
|
||||||
|
|
|
@ -64,7 +64,7 @@ class PhoneAccountValidationFragment : GenericFragment<AssistantPhoneAccountVali
|
||||||
it.consume {
|
it.consume {
|
||||||
when {
|
when {
|
||||||
viewModel.isLogin.value == true || viewModel.isCreation.value == true -> {
|
viewModel.isLogin.value == true || viewModel.isCreation.value == true -> {
|
||||||
coreContext.contactsManager.updateLocalContacts()
|
coreContext.newAccountConfigured(true)
|
||||||
|
|
||||||
if (coreContext.core.isEchoCancellerCalibrationRequired) {
|
if (coreContext.core.isEchoCancellerCalibrationRequired) {
|
||||||
navigateToEchoCancellerCalibration()
|
navigateToEchoCancellerCalibration()
|
||||||
|
|
|
@ -24,7 +24,6 @@ import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||||
import org.linphone.LinphoneApplication.Companion.corePreferences
|
|
||||||
import org.linphone.core.*
|
import org.linphone.core.*
|
||||||
import org.linphone.core.tools.Log
|
import org.linphone.core.tools.Log
|
||||||
import org.linphone.utils.Event
|
import org.linphone.utils.Event
|
||||||
|
@ -141,13 +140,6 @@ class GenericLoginViewModel(private val accountCreator: AccountCreator) : ViewMo
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.i("[Assistant] [Generic Login] Proxy config created")
|
Log.i("[Assistant] [Generic Login] Proxy config created")
|
||||||
// The following is required to keep the app alive
|
|
||||||
// and be able to receive calls while in background
|
|
||||||
if (domain.value.orEmpty() != corePreferences.defaultDomain) {
|
|
||||||
Log.i("[Assistant] [Generic Login] Background mode with foreground service automatically enabled")
|
|
||||||
corePreferences.keepServiceAlive = true
|
|
||||||
coreContext.notificationsManager.startForeground()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isLoginButtonEnabled(): Boolean {
|
private fun isLoginButtonEnabled(): Boolean {
|
||||||
|
|
|
@ -328,17 +328,14 @@ class DialerFragment : SecureFragment<DialerFragmentBinding>() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkForUpdate() {
|
private fun checkForUpdate() {
|
||||||
val url: String? = corePreferences.checkIfUpdateAvailableUrl
|
val lastTimestamp: Int = corePreferences.lastUpdateAvailableCheckTimestamp
|
||||||
if (url != null && url.isNotEmpty()) {
|
val currentTimeStamp = System.currentTimeMillis().toInt()
|
||||||
val lastTimestamp: Int = corePreferences.lastUpdateAvailableCheckTimestamp
|
val interval: Int = corePreferences.checkUpdateAvailableInterval
|
||||||
val currentTimeStamp = System.currentTimeMillis().toInt()
|
if (lastTimestamp == 0 || currentTimeStamp - lastTimestamp >= interval) {
|
||||||
val interval: Int = corePreferences.checkUpdateAvailableInterval
|
val currentVersion = BuildConfig.VERSION_NAME
|
||||||
if (lastTimestamp == 0 || currentTimeStamp - lastTimestamp >= interval) {
|
Log.i("[Dialer] Checking for update using current version [$currentVersion]")
|
||||||
val currentVersion = BuildConfig.VERSION_NAME
|
coreContext.core.checkForUpdate(currentVersion)
|
||||||
Log.i("[Dialer] Checking for update using url [$url] and current version [$currentVersion]")
|
corePreferences.lastUpdateAvailableCheckTimestamp = currentTimeStamp
|
||||||
coreContext.core.checkForUpdate(currentVersion)
|
|
||||||
corePreferences.lastUpdateAvailableCheckTimestamp = currentTimeStamp
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ class ContactsSettingsViewModel : GenericSettingsViewModel() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val friendListSubscribe = MutableLiveData<Boolean>()
|
val friendListSubscribe = MutableLiveData<Boolean>()
|
||||||
|
val rlsAddressAvailable = MutableLiveData<Boolean>()
|
||||||
|
|
||||||
val showNewContactAccountDialogListener = object : SettingListenerStub() {
|
val showNewContactAccountDialogListener = object : SettingListenerStub() {
|
||||||
override fun onBoolValueChanged(newValue: Boolean) {
|
override fun onBoolValueChanged(newValue: Boolean) {
|
||||||
|
@ -95,6 +96,7 @@ class ContactsSettingsViewModel : GenericSettingsViewModel() {
|
||||||
readContactsPermissionGranted.value = PermissionHelper.get().hasReadContactsPermission()
|
readContactsPermissionGranted.value = PermissionHelper.get().hasReadContactsPermission()
|
||||||
|
|
||||||
friendListSubscribe.value = core.isFriendListSubscriptionEnabled
|
friendListSubscribe.value = core.isFriendListSubscriptionEnabled
|
||||||
|
rlsAddressAvailable.value = core.defaultFriendList?.rlsAddress?.asStringUriOnly().orEmpty().isNotEmpty()
|
||||||
showNewContactAccountDialog.value = prefs.showNewContactAccountDialog
|
showNewContactAccountDialog.value = prefs.showNewContactAccountDialog
|
||||||
nativePresence.value = prefs.storePresenceInNativeContact
|
nativePresence.value = prefs.storePresenceInNativeContact
|
||||||
showOrganization.value = prefs.displayOrganization
|
showOrganization.value = prefs.displayOrganization
|
||||||
|
|
|
@ -61,11 +61,18 @@ class ContactLoader : LoaderManager.LoaderCallbacks<Cursor> {
|
||||||
override fun onCreateLoader(id: Int, args: Bundle?): Loader<Cursor> {
|
override fun onCreateLoader(id: Int, args: Bundle?): Loader<Cursor> {
|
||||||
Log.i("[Contacts Loader] Loader created")
|
Log.i("[Contacts Loader] Loader created")
|
||||||
coreContext.contactsManager.fetchInProgress.value = true
|
coreContext.contactsManager.fetchInProgress.value = true
|
||||||
|
|
||||||
|
val selection = if (corePreferences.fetchContactsFromDefaultDirectory) {
|
||||||
|
ContactsContract.Data.IN_DEFAULT_DIRECTORY + " == 1"
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
|
||||||
return CursorLoader(
|
return CursorLoader(
|
||||||
coreContext.context,
|
coreContext.context,
|
||||||
ContactsContract.Data.CONTENT_URI,
|
ContactsContract.Data.CONTENT_URI,
|
||||||
projection,
|
projection,
|
||||||
ContactsContract.Data.IN_DEFAULT_DIRECTORY + " == 1",
|
selection,
|
||||||
null,
|
null,
|
||||||
null
|
null
|
||||||
)
|
)
|
||||||
|
|
|
@ -425,16 +425,6 @@ class CoreContext(val context: Context, coreConfig: Config) : LifecycleOwner, Vi
|
||||||
Log.i("[Context] Account params have been updated, apply changes")
|
Log.i("[Context] Account params have been updated, apply changes")
|
||||||
account.params = params
|
account.params = params
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure LIME server URL is set if at least one sip.linphone.org proxy
|
|
||||||
if (core.limeX3DhAvailable()) {
|
|
||||||
var url: String? = core.limeX3DhServerUrl
|
|
||||||
if (url == null || url.isEmpty()) {
|
|
||||||
url = corePreferences.limeX3dhServerUrl
|
|
||||||
Log.i("[Context] Setting LIME X3Dh server url to default value: $url")
|
|
||||||
core.limeX3DhServerUrl = url
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -470,6 +460,30 @@ class CoreContext(val context: Context, coreConfig: Config) : LifecycleOwner, Vi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun newAccountConfigured(isLinphoneAccount: Boolean) {
|
||||||
|
Log.i("[Context] A new ${if (isLinphoneAccount) AppUtils.getString(R.string.app_name) else "third-party"} account has been configured")
|
||||||
|
|
||||||
|
if (isLinphoneAccount) {
|
||||||
|
core.config.setString("sip", "rls_uri", corePreferences.defaultRlsUri)
|
||||||
|
val rlsAddress = core.interpretUrl(corePreferences.defaultRlsUri)
|
||||||
|
if (rlsAddress != null) {
|
||||||
|
for (friendList in core.friendsLists) {
|
||||||
|
friendList.rlsAddress = rlsAddress
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (core.limeX3DhAvailable()) {
|
||||||
|
core.limeX3DhServerUrl = corePreferences.defaultLimeServerUrl
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Log.i("[Context] Background mode with foreground service automatically enabled")
|
||||||
|
corePreferences.keepServiceAlive = true
|
||||||
|
notificationsManager.startForeground()
|
||||||
|
}
|
||||||
|
|
||||||
|
contactsManager.updateLocalContacts()
|
||||||
|
}
|
||||||
|
|
||||||
/* Call related functions */
|
/* Call related functions */
|
||||||
|
|
||||||
fun initPhoneStateListener() {
|
fun initPhoneStateListener() {
|
||||||
|
|
|
@ -474,6 +474,9 @@ class CorePreferences constructor(private val context: Context) {
|
||||||
val defaultRlsUri: String
|
val defaultRlsUri: String
|
||||||
get() = config.getString("sip", "rls_uri", "sips:rls@sip.linphone.org")!!
|
get() = config.getString("sip", "rls_uri", "sips:rls@sip.linphone.org")!!
|
||||||
|
|
||||||
|
val defaultLimeServerUrl: String
|
||||||
|
get() = config.getString("lime", "lime_server_url", "https://lime.linphone.org/lime-server/lime-server.php")!!
|
||||||
|
|
||||||
val debugPopupCode: String
|
val debugPopupCode: String
|
||||||
get() = config.getString("app", "debug_popup_magic", "#1234#")!!
|
get() = config.getString("app", "debug_popup_magic", "#1234#")!!
|
||||||
|
|
||||||
|
@ -495,20 +498,6 @@ class CorePreferences constructor(private val context: Context) {
|
||||||
""
|
""
|
||||||
)!!
|
)!!
|
||||||
|
|
||||||
val limeX3dhServerUrl: String
|
|
||||||
get() = config.getString(
|
|
||||||
"app",
|
|
||||||
"default_lime_x3dh_server_url",
|
|
||||||
"https://lime.linphone.org/lime-server/lime-server.php"
|
|
||||||
)!!
|
|
||||||
|
|
||||||
val checkIfUpdateAvailableUrl: String?
|
|
||||||
get() = config.getString(
|
|
||||||
"misc",
|
|
||||||
"version_check_url_root",
|
|
||||||
"https://linphone.org/releases/android/RELEASE"
|
|
||||||
)
|
|
||||||
|
|
||||||
val checkUpdateAvailableInterval: Int
|
val checkUpdateAvailableInterval: Int
|
||||||
get() = config.getInt("app", "version_check_interval", 86400000)
|
get() = config.getInt("app", "version_check_interval", 86400000)
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@
|
||||||
linphone:title="@{@string/contacts_settings_friendlist_subscribe_title}"
|
linphone:title="@{@string/contacts_settings_friendlist_subscribe_title}"
|
||||||
linphone:listener="@{viewModel.friendListSubscribeListener}"
|
linphone:listener="@{viewModel.friendListSubscribeListener}"
|
||||||
linphone:checked="@={viewModel.friendListSubscribe}"
|
linphone:checked="@={viewModel.friendListSubscribe}"
|
||||||
linphone:enabled="@{viewModel.readContactsPermissionGranted}"/>
|
linphone:enabled="@{viewModel.readContactsPermissionGranted && viewModel.rlsAddressAvailable}"/>
|
||||||
|
|
||||||
<include
|
<include
|
||||||
layout="@layout/settings_widget_switch"
|
layout="@layout/settings_widget_switch"
|
||||||
|
|
Loading…
Reference in a new issue