Removed now deprecated APIs and use new one instead
This commit is contained in:
parent
a106da7cc5
commit
d12ff2b81a
5 changed files with 41 additions and 62 deletions
|
@ -202,7 +202,7 @@ class MasterChatRoomsFragment : MasterFragment() {
|
|||
arguments?.clear()
|
||||
val localAddress = Factory.instance().createAddress(localSipUri)
|
||||
val remoteSipAddress = Factory.instance().createAddress(remoteSipUri)
|
||||
val chatRoom = coreContext.core.getChatRoom(remoteSipAddress, localAddress)
|
||||
val chatRoom = coreContext.core.searchChatRoom(null, localAddress, arrayOf(remoteSipAddress))
|
||||
if (chatRoom != null) {
|
||||
Log.i("[Chat] Found matching chat room $chatRoom")
|
||||
chatRoom.markAsRead()
|
||||
|
|
|
@ -147,56 +147,44 @@ class ChatRoomCreationViewModel : ErrorReportingViewModel() {
|
|||
val defaultProxyConfig = coreContext.core.defaultProxyConfig
|
||||
var room: ChatRoom?
|
||||
|
||||
if (defaultProxyConfig == null) {
|
||||
val address = searchResult.address ?: coreContext.core.interpretUrl(searchResult.phoneNumber)
|
||||
if (address == null) {
|
||||
Log.e("[Chat Room Creation] Can't get a valid address from search result $searchResult")
|
||||
onErrorEvent.value = Event(R.string.chat_room_creation_failed_snack)
|
||||
waitForChatRoomCreation.value = false
|
||||
return
|
||||
}
|
||||
|
||||
Log.w("[Chat Room Creation] No default proxy config found, creating basic chat room without local identity with ${address.asStringUriOnly()}")
|
||||
room = coreContext.core.getChatRoom(address)
|
||||
if (room != null) {
|
||||
chatRoomCreatedEvent.value = Event(room)
|
||||
} else {
|
||||
Log.e("[Chat Room Creation] Couldn't create chat room with remote ${address.asStringUriOnly()}")
|
||||
}
|
||||
val address = searchResult.address ?: coreContext.core.interpretUrl(searchResult.phoneNumber)
|
||||
if (address == null) {
|
||||
Log.e("[Chat Room Creation] Can't get a valid address from search result $searchResult")
|
||||
onErrorEvent.value = Event(R.string.chat_room_creation_failed_snack)
|
||||
waitForChatRoomCreation.value = false
|
||||
return
|
||||
}
|
||||
|
||||
val encrypted = isEncrypted.value == true
|
||||
room = coreContext.core.findOneToOneChatRoom(defaultProxyConfig.identityAddress, searchResult.address, encrypted)
|
||||
val params: ChatRoomParams = coreContext.core.createDefaultChatRoomParams()
|
||||
params.backend = ChatRoomBackend.Basic
|
||||
params.enableGroup(false)
|
||||
if (encrypted) {
|
||||
params.enableEncryption(true)
|
||||
params.backend = ChatRoomBackend.FlexisipChat
|
||||
params.subject = AppUtils.getString(R.string.chat_room_dummy_subject)
|
||||
}
|
||||
|
||||
val participants = arrayOf(searchResult.address)
|
||||
|
||||
// Use proxy config contact instead of identity because we need GRUU if FlexisipChat backend
|
||||
room = coreContext.core.searchChatRoom(params, defaultProxyConfig.contact, participants)
|
||||
if (room == null) {
|
||||
Log.w("[Chat Room Creation] Couldn't find existing 1-1 chat room with remote ${searchResult.address.asStringUriOnly()}, encryption=$encrypted and local identity ${defaultProxyConfig.identityAddress.asStringUriOnly()}")
|
||||
Log.w("[Chat Room Creation] Couldn't find existing 1-1 chat room with remote ${searchResult.address.asStringUriOnly()}, encryption=$encrypted and local identity ${defaultProxyConfig.contact.asStringUriOnly()}")
|
||||
// Use proxy config contact instead of identity because we need GRUU if FlexisipChat backend
|
||||
room = coreContext.core.createChatRoom(params, defaultProxyConfig.contact, participants)
|
||||
if (encrypted) {
|
||||
val params: ChatRoomParams = coreContext.core.createDefaultChatRoomParams()
|
||||
// This will set the backend to FlexisipChat automatically
|
||||
params.enableEncryption(true)
|
||||
params.enableGroup(false)
|
||||
|
||||
val participants = arrayOfNulls<Address>(1)
|
||||
participants[0] = searchResult.address
|
||||
|
||||
room = coreContext.core.createChatRoom(
|
||||
params,
|
||||
AppUtils.getString(R.string.chat_room_dummy_subject),
|
||||
participants
|
||||
)
|
||||
room?.addListener(listener)
|
||||
} else {
|
||||
room = coreContext.core.getChatRoom(searchResult.address, defaultProxyConfig.identityAddress)
|
||||
if (room != null) {
|
||||
chatRoomCreatedEvent.value = Event(room)
|
||||
} else {
|
||||
Log.e("[Chat Room Creation] Couldn't create chat room with remote ${searchResult.address.asStringUriOnly()} and local identity ${defaultProxyConfig.identityAddress.asStringUriOnly()}")
|
||||
Log.e("[Chat Room Creation] Couldn't create chat room with remote ${searchResult.address.asStringUriOnly()} and local identity ${defaultProxyConfig.contact.asStringUriOnly()}")
|
||||
}
|
||||
waitForChatRoomCreation.value = false
|
||||
}
|
||||
} else {
|
||||
Log.i("[Chat Room Creation] Found existing 1-1 chat room with remote ${searchResult.address.asStringUriOnly()}, encryption=$encrypted and local identity ${defaultProxyConfig.identityAddress.asStringUriOnly()}")
|
||||
Log.i("[Chat Room Creation] Found existing 1-1 chat room with remote ${searchResult.address.asStringUriOnly()}, encryption=$encrypted and local identity ${defaultProxyConfig.contact.asStringUriOnly()}")
|
||||
chatRoomCreatedEvent.value = Event(room)
|
||||
waitForChatRoomCreation.value = false
|
||||
}
|
||||
|
|
|
@ -113,6 +113,7 @@ class GroupInfoViewModel(val chatRoom: ChatRoom?) : ErrorReportingViewModel() {
|
|||
val params: ChatRoomParams = coreContext.core.createDefaultChatRoomParams()
|
||||
params.enableEncryption(isEncrypted.value == true)
|
||||
params.enableGroup(true)
|
||||
params.subject = subject.value
|
||||
|
||||
val addresses = arrayOfNulls<Address>(participants.value.orEmpty().size)
|
||||
var index = 0
|
||||
|
@ -122,8 +123,14 @@ class GroupInfoViewModel(val chatRoom: ChatRoom?) : ErrorReportingViewModel() {
|
|||
index += 1
|
||||
}
|
||||
|
||||
val chatRoom: ChatRoom? = coreContext.core.createChatRoom(params, subject.value, addresses)
|
||||
// Use proxy config contact instead of identity because we need GRUU
|
||||
val chatRoom: ChatRoom? = coreContext.core.createChatRoom(params, coreContext.core.defaultProxyConfig?.contact, addresses)
|
||||
chatRoom?.addListener(listener)
|
||||
if (chatRoom == null) {
|
||||
Log.e("[Chat Room Group Info] Couldn't create chat room!")
|
||||
waitForChatRoomCreation.value = false
|
||||
onErrorEvent.value = Event(R.string.chat_room_creation_failed_snack)
|
||||
}
|
||||
}
|
||||
|
||||
fun updateRoom() {
|
||||
|
|
|
@ -49,7 +49,7 @@ class NotificationBroadcastReceiver : BroadcastReceiver() {
|
|||
return
|
||||
}
|
||||
|
||||
val room = core.getChatRoom(remoteAddress, localAddress)
|
||||
val room = core.searchChatRoom(null, localAddress, arrayOf(remoteAddress))
|
||||
if (room == null) {
|
||||
Log.e("[Notification Broadcast Receiver] Couldn't find chat room for remote address $remoteSipAddress and local address $localIdentity")
|
||||
return
|
||||
|
|
|
@ -54,32 +54,16 @@ class LinphoneUtils {
|
|||
val core: Core = coreContext.core
|
||||
val defaultProxyConfig = core.defaultProxyConfig
|
||||
|
||||
if (defaultProxyConfig != null) {
|
||||
val room = core.findOneToOneChatRoom(defaultProxyConfig.identityAddress, participant, isSecured)
|
||||
if (room != null) {
|
||||
return room
|
||||
} else {
|
||||
return if (defaultProxyConfig.conferenceFactoryUri != null && isSecured /*|| !LinphonePreferences.instance().useBasicChatRoomFor1To1()*/) {
|
||||
val params = core.createDefaultChatRoomParams()
|
||||
params.enableEncryption(isSecured)
|
||||
params.enableGroup(false)
|
||||
// We don't want a basic chat room, so if isSecured is false we have to set this manually
|
||||
params.backend = ChatRoomBackend.FlexisipChat
|
||||
val params = core.createDefaultChatRoomParams()
|
||||
params.enableEncryption(isSecured)
|
||||
params.enableGroup(false)
|
||||
params.backend = if (isSecured) ChatRoomBackend.FlexisipChat else ChatRoomBackend.Basic
|
||||
params.subject = AppUtils.getString(R.string.chat_room_dummy_subject)
|
||||
|
||||
val participants = arrayOfNulls<Address>(1)
|
||||
participants[0] = participant
|
||||
core.createChatRoom(params, AppUtils.getString(R.string.chat_room_dummy_subject), participants)
|
||||
} else {
|
||||
core.getChatRoom(participant)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (isSecured) {
|
||||
Log.e("[Linphone Utils] Can't create a secured chat room without proxy config")
|
||||
return null
|
||||
}
|
||||
return core.getChatRoom(participant)
|
||||
}
|
||||
val participants = arrayOf(participant)
|
||||
|
||||
return core.searchChatRoom(params, defaultProxyConfig?.identityAddress, participants)
|
||||
?: core.createChatRoom(params, defaultProxyConfig?.identityAddress, participants)
|
||||
}
|
||||
|
||||
fun deleteFilesAttachedToEventLog(eventLog: EventLog) {
|
||||
|
|
Loading…
Reference in a new issue