mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Fixed IM encryption mandatory setting that wasn't having any effect anymore
This commit is contained in:
parent
51d9b18c1c
commit
6280ed5f3d
9 changed files with 25 additions and 22 deletions
|
|
@ -56,7 +56,6 @@ import org.linphone.ui.call.model.CallMediaEncryptionModel
|
|||
import org.linphone.ui.call.model.CallStatsModel
|
||||
import org.linphone.ui.main.contacts.model.ContactAvatarModel
|
||||
import org.linphone.ui.main.history.model.NumpadModel
|
||||
import org.linphone.ui.main.model.isEndToEndEncryptionMandatory
|
||||
import org.linphone.utils.AppUtils
|
||||
import org.linphone.utils.AudioUtils
|
||||
import org.linphone.utils.Event
|
||||
|
|
@ -1311,9 +1310,7 @@ class CurrentCallViewModel @UiThread constructor() : GenericViewModel() {
|
|||
val localAddress = call.callLog.localAddress
|
||||
val remoteAddress = call.remoteAddress
|
||||
val core = call.core
|
||||
val account = core.accountList.find {
|
||||
it.params.identityAddress?.weakEqual(localAddress) == true
|
||||
} ?: LinphoneUtils.getDefaultAccount() ?: return null
|
||||
val account = LinphoneUtils.getAccountForAddress(localAddress) ?: LinphoneUtils.getDefaultAccount() ?: return null
|
||||
|
||||
val params: ChatRoomParams = core.createDefaultChatRoomParams()
|
||||
params.isGroupEnabled = false
|
||||
|
|
@ -1321,13 +1318,13 @@ class CurrentCallViewModel @UiThread constructor() : GenericViewModel() {
|
|||
params.ephemeralLifetime = 0 // Make sure ephemeral is disabled by default
|
||||
|
||||
val sameDomain = remoteAddress.domain == corePreferences.defaultDomain && remoteAddress.domain == account.params.domain
|
||||
if (isEndToEndEncryptionMandatory() && sameDomain) {
|
||||
if (account.params.instantMessagingEncryptionMandatory && sameDomain) {
|
||||
Log.i(
|
||||
"$TAG Account is in secure mode & domain matches, requesting E2E encryption"
|
||||
)
|
||||
params.backend = ChatRoom.Backend.FlexisipChat
|
||||
params.isEncryptionEnabled = true
|
||||
} else if (!isEndToEndEncryptionMandatory()) {
|
||||
} else if (!account.params.instantMessagingEncryptionMandatory) {
|
||||
if (LinphoneUtils.isEndToEndEncryptedChatAvailable(core)) {
|
||||
Log.i(
|
||||
"$TAG Account is in interop mode but LIME is available, requesting E2E encryption"
|
||||
|
|
|
|||
|
|
@ -55,7 +55,6 @@ import org.linphone.core.Player
|
|||
import org.linphone.core.PlayerListener
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.main.contacts.model.ContactAvatarModel
|
||||
import org.linphone.ui.main.model.isEndToEndEncryptionMandatory
|
||||
import org.linphone.utils.AppUtils
|
||||
import org.linphone.utils.AudioUtils
|
||||
import org.linphone.utils.Event
|
||||
|
|
@ -103,7 +102,11 @@ class MessageModel @WorkerThread constructor(
|
|||
val time = TimestampUtils.toString(timestamp)
|
||||
|
||||
val chatRoomIsReadOnly = chatMessage.chatRoom.isReadOnly ||
|
||||
(!chatMessage.chatRoom.hasCapability(ChatRoom.Capabilities.Encrypted.toInt()) && isEndToEndEncryptionMandatory())
|
||||
(
|
||||
!chatMessage.chatRoom.hasCapability(ChatRoom.Capabilities.Encrypted.toInt()) && LinphoneUtils.getAccountForAddress(
|
||||
chatMessage.chatRoom.localAddress
|
||||
)?.params?.instantMessagingEncryptionMandatory == true
|
||||
)
|
||||
|
||||
val avatarModel = MutableLiveData<ContactAvatarModel>()
|
||||
|
||||
|
|
|
|||
|
|
@ -209,11 +209,11 @@ class ConversationForwardMessageViewModel @UiThread constructor() : AddressSelec
|
|||
params.ephemeralLifetime = 0 // Make sure ephemeral is disabled by default
|
||||
|
||||
val sameDomain = remote.domain == corePreferences.defaultDomain && remote.domain == account.params.domain
|
||||
if (isEndToEndEncryptionMandatory() && sameDomain) {
|
||||
if (account.params.instantMessagingEncryptionMandatory && sameDomain) {
|
||||
Log.i("$TAG Account is in secure mode & domain matches, creating a E2E conversation")
|
||||
params.backend = ChatRoom.Backend.FlexisipChat
|
||||
params.isEncryptionEnabled = true
|
||||
} else if (!isEndToEndEncryptionMandatory()) {
|
||||
} else if (!account.params.instantMessagingEncryptionMandatory) {
|
||||
if (LinphoneUtils.isEndToEndEncryptedChatAvailable(core)) {
|
||||
Log.i(
|
||||
"$TAG Account is in interop mode but LIME is available, creating a E2E conversation"
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@ import org.linphone.ui.main.chat.model.EventLogModel
|
|||
import org.linphone.ui.main.chat.model.FileModel
|
||||
import org.linphone.ui.main.chat.model.MessageModel
|
||||
import org.linphone.ui.main.contacts.model.ContactAvatarModel
|
||||
import org.linphone.ui.main.model.isEndToEndEncryptionMandatory
|
||||
import org.linphone.utils.AppUtils
|
||||
import org.linphone.utils.Event
|
||||
import org.linphone.utils.FileUtils
|
||||
|
|
@ -548,7 +547,7 @@ class ConversationViewModel @UiThread constructor() : AbstractConversationViewMo
|
|||
@WorkerThread
|
||||
fun checkIfConversationShouldBeDisabledForSecurityReasons() {
|
||||
if (!chatRoom.hasCapability(ChatRoom.Capabilities.Encrypted.toInt())) {
|
||||
if (isEndToEndEncryptionMandatory()) {
|
||||
if (LinphoneUtils.getAccountForAddress(chatRoom.localAddress)?.params?.instantMessagingEncryptionMandatory == true) {
|
||||
Log.w(
|
||||
"$TAG Conversation with subject [${chatRoom.subject}] has been disabled because it isn't encrypted and default account is in secure mode"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ import org.linphone.core.ChatRoom
|
|||
import org.linphone.core.ChatRoomListenerStub
|
||||
import org.linphone.core.ChatRoomParams
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.main.model.isEndToEndEncryptionMandatory
|
||||
import org.linphone.ui.main.viewmodel.AddressSelectionViewModel
|
||||
import org.linphone.utils.AppUtils
|
||||
import org.linphone.utils.Event
|
||||
|
|
@ -193,11 +192,11 @@ class StartConversationViewModel @UiThread constructor() : AddressSelectionViewM
|
|||
params.ephemeralLifetime = 0 // Make sure ephemeral is disabled by default
|
||||
|
||||
val sameDomain = remote.domain == corePreferences.defaultDomain && remote.domain == account.params.domain
|
||||
if (isEndToEndEncryptionMandatory() && sameDomain) {
|
||||
if (account.params.instantMessagingEncryptionMandatory && sameDomain) {
|
||||
Log.i("$TAG Account is in secure mode & domain matches, creating a E2E conversation")
|
||||
params.backend = ChatRoom.Backend.FlexisipChat
|
||||
params.isEncryptionEnabled = true
|
||||
} else if (!isEndToEndEncryptionMandatory()) {
|
||||
} else if (!account.params.instantMessagingEncryptionMandatory) {
|
||||
if (LinphoneUtils.isEndToEndEncryptedChatAvailable(core)) {
|
||||
Log.i(
|
||||
"$TAG Account is in interop mode but LIME is available, creating a E2E conversation"
|
||||
|
|
|
|||
|
|
@ -555,13 +555,13 @@ class ContactViewModel @UiThread constructor() : GenericViewModel() {
|
|||
params.ephemeralLifetime = 0 // Make sure ephemeral is disabled by default
|
||||
|
||||
val sameDomain = remote.domain == corePreferences.defaultDomain && remote.domain == account.params.domain
|
||||
if (isEndToEndEncryptionMandatory() && sameDomain) {
|
||||
if (account.params.instantMessagingEncryptionMandatory && sameDomain) {
|
||||
Log.i(
|
||||
"$TAG Account is in secure mode & domain matches, creating a E2E conversation"
|
||||
)
|
||||
params.backend = ChatRoom.Backend.FlexisipChat
|
||||
params.isEncryptionEnabled = true
|
||||
} else if (!isEndToEndEncryptionMandatory()) {
|
||||
} else if (!account.params.instantMessagingEncryptionMandatory) {
|
||||
if (LinphoneUtils.isEndToEndEncryptedChatAvailable(core)) {
|
||||
Log.i(
|
||||
"$TAG Account is in interop mode but LIME is available, creating a E2E conversation"
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ import org.linphone.core.tools.Log
|
|||
import org.linphone.ui.GenericViewModel
|
||||
import org.linphone.ui.main.history.model.CallLogHistoryModel
|
||||
import org.linphone.ui.main.history.model.CallLogModel
|
||||
import org.linphone.ui.main.model.isEndToEndEncryptionMandatory
|
||||
import org.linphone.utils.AppUtils
|
||||
import org.linphone.utils.Event
|
||||
import org.linphone.utils.LinphoneUtils
|
||||
|
|
@ -189,13 +188,13 @@ class HistoryViewModel @UiThread constructor() : GenericViewModel() {
|
|||
params.ephemeralLifetime = 0 // Make sure ephemeral is disabled by default
|
||||
|
||||
val sameDomain = remote.domain == corePreferences.defaultDomain && remote.domain == account.params.domain
|
||||
if (isEndToEndEncryptionMandatory() && sameDomain) {
|
||||
if (account.params.instantMessagingEncryptionMandatory && sameDomain) {
|
||||
Log.i(
|
||||
"$TAG Account is in secure mode & domain matches, creating a E2E conversation"
|
||||
)
|
||||
params.backend = ChatRoom.Backend.FlexisipChat
|
||||
params.isEncryptionEnabled = true
|
||||
} else if (!isEndToEndEncryptionMandatory()) {
|
||||
} else if (!account.params.instantMessagingEncryptionMandatory) {
|
||||
if (LinphoneUtils.isEndToEndEncryptedChatAvailable(core)) {
|
||||
Log.i(
|
||||
"$TAG Account is in interop mode but LIME is available, creating a E2E conversation"
|
||||
|
|
|
|||
|
|
@ -55,6 +55,13 @@ class LinphoneUtils {
|
|||
return coreContext.core.defaultAccount ?: coreContext.core.accountList.firstOrNull()
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
fun getAccountForAddress(address: Address): Account? {
|
||||
return coreContext.core.accountList.find {
|
||||
it.params.identityAddress?.weakEqual(address) == true
|
||||
}
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
fun applyInternationalPrefix(account: Account? = null): Boolean {
|
||||
return account?.params?.useInternationalPrefixForCallsAndChats
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ import org.linphone.core.ChatRoom
|
|||
import org.linphone.core.tools.Log
|
||||
import org.linphone.mediastream.Version
|
||||
import org.linphone.ui.main.MainActivity
|
||||
import org.linphone.ui.main.model.isEndToEndEncryptionMandatory
|
||||
|
||||
class ShortcutUtils {
|
||||
companion object {
|
||||
|
|
@ -66,7 +65,7 @@ class ShortcutUtils {
|
|||
|
||||
var count = 0
|
||||
for (chatRoom in defaultAccount.chatRooms) {
|
||||
if (isEndToEndEncryptionMandatory() && !chatRoom.currentParams.isEncryptionEnabled) {
|
||||
if (defaultAccount.params.instantMessagingEncryptionMandatory && !chatRoom.currentParams.isEncryptionEnabled) {
|
||||
Log.w(
|
||||
"$TAG Account is in secure mode, skipping not encrypted conversation [${LinphoneUtils.getChatRoomId(
|
||||
chatRoom
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue