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()
|
arguments?.clear()
|
||||||
val localAddress = Factory.instance().createAddress(localSipUri)
|
val localAddress = Factory.instance().createAddress(localSipUri)
|
||||||
val remoteSipAddress = Factory.instance().createAddress(remoteSipUri)
|
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) {
|
if (chatRoom != null) {
|
||||||
Log.i("[Chat] Found matching chat room $chatRoom")
|
Log.i("[Chat] Found matching chat room $chatRoom")
|
||||||
chatRoom.markAsRead()
|
chatRoom.markAsRead()
|
||||||
|
|
|
@ -147,7 +147,6 @@ class ChatRoomCreationViewModel : ErrorReportingViewModel() {
|
||||||
val defaultProxyConfig = coreContext.core.defaultProxyConfig
|
val defaultProxyConfig = coreContext.core.defaultProxyConfig
|
||||||
var room: ChatRoom?
|
var room: ChatRoom?
|
||||||
|
|
||||||
if (defaultProxyConfig == null) {
|
|
||||||
val address = searchResult.address ?: coreContext.core.interpretUrl(searchResult.phoneNumber)
|
val address = searchResult.address ?: coreContext.core.interpretUrl(searchResult.phoneNumber)
|
||||||
if (address == null) {
|
if (address == null) {
|
||||||
Log.e("[Chat Room Creation] Can't get a valid address from search result $searchResult")
|
Log.e("[Chat Room Creation] Can't get a valid address from search result $searchResult")
|
||||||
|
@ -156,47 +155,36 @@ class ChatRoomCreationViewModel : ErrorReportingViewModel() {
|
||||||
return
|
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()}")
|
|
||||||
}
|
|
||||||
waitForChatRoomCreation.value = false
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
val encrypted = isEncrypted.value == true
|
val encrypted = isEncrypted.value == true
|
||||||
room = coreContext.core.findOneToOneChatRoom(defaultProxyConfig.identityAddress, searchResult.address, encrypted)
|
|
||||||
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()}")
|
|
||||||
if (encrypted) {
|
|
||||||
val params: ChatRoomParams = coreContext.core.createDefaultChatRoomParams()
|
val params: ChatRoomParams = coreContext.core.createDefaultChatRoomParams()
|
||||||
// This will set the backend to FlexisipChat automatically
|
params.backend = ChatRoomBackend.Basic
|
||||||
params.enableEncryption(true)
|
|
||||||
params.enableGroup(false)
|
params.enableGroup(false)
|
||||||
|
if (encrypted) {
|
||||||
|
params.enableEncryption(true)
|
||||||
|
params.backend = ChatRoomBackend.FlexisipChat
|
||||||
|
params.subject = AppUtils.getString(R.string.chat_room_dummy_subject)
|
||||||
|
}
|
||||||
|
|
||||||
val participants = arrayOfNulls<Address>(1)
|
val participants = arrayOf(searchResult.address)
|
||||||
participants[0] = searchResult.address
|
|
||||||
|
|
||||||
room = coreContext.core.createChatRoom(
|
// Use proxy config contact instead of identity because we need GRUU if FlexisipChat backend
|
||||||
params,
|
room = coreContext.core.searchChatRoom(params, defaultProxyConfig.contact, participants)
|
||||||
AppUtils.getString(R.string.chat_room_dummy_subject),
|
if (room == null) {
|
||||||
participants
|
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) {
|
||||||
room?.addListener(listener)
|
room?.addListener(listener)
|
||||||
} else {
|
} else {
|
||||||
room = coreContext.core.getChatRoom(searchResult.address, defaultProxyConfig.identityAddress)
|
|
||||||
if (room != null) {
|
if (room != null) {
|
||||||
chatRoomCreatedEvent.value = Event(room)
|
chatRoomCreatedEvent.value = Event(room)
|
||||||
} else {
|
} 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
|
waitForChatRoomCreation.value = false
|
||||||
}
|
}
|
||||||
} else {
|
} 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)
|
chatRoomCreatedEvent.value = Event(room)
|
||||||
waitForChatRoomCreation.value = false
|
waitForChatRoomCreation.value = false
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,6 +113,7 @@ class GroupInfoViewModel(val chatRoom: ChatRoom?) : ErrorReportingViewModel() {
|
||||||
val params: ChatRoomParams = coreContext.core.createDefaultChatRoomParams()
|
val params: ChatRoomParams = coreContext.core.createDefaultChatRoomParams()
|
||||||
params.enableEncryption(isEncrypted.value == true)
|
params.enableEncryption(isEncrypted.value == true)
|
||||||
params.enableGroup(true)
|
params.enableGroup(true)
|
||||||
|
params.subject = subject.value
|
||||||
|
|
||||||
val addresses = arrayOfNulls<Address>(participants.value.orEmpty().size)
|
val addresses = arrayOfNulls<Address>(participants.value.orEmpty().size)
|
||||||
var index = 0
|
var index = 0
|
||||||
|
@ -122,8 +123,14 @@ class GroupInfoViewModel(val chatRoom: ChatRoom?) : ErrorReportingViewModel() {
|
||||||
index += 1
|
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)
|
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() {
|
fun updateRoom() {
|
||||||
|
|
|
@ -49,7 +49,7 @@ class NotificationBroadcastReceiver : BroadcastReceiver() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val room = core.getChatRoom(remoteAddress, localAddress)
|
val room = core.searchChatRoom(null, localAddress, arrayOf(remoteAddress))
|
||||||
if (room == null) {
|
if (room == null) {
|
||||||
Log.e("[Notification Broadcast Receiver] Couldn't find chat room for remote address $remoteSipAddress and local address $localIdentity")
|
Log.e("[Notification Broadcast Receiver] Couldn't find chat room for remote address $remoteSipAddress and local address $localIdentity")
|
||||||
return
|
return
|
||||||
|
|
|
@ -54,32 +54,16 @@ class LinphoneUtils {
|
||||||
val core: Core = coreContext.core
|
val core: Core = coreContext.core
|
||||||
val defaultProxyConfig = core.defaultProxyConfig
|
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()
|
val params = core.createDefaultChatRoomParams()
|
||||||
params.enableEncryption(isSecured)
|
params.enableEncryption(isSecured)
|
||||||
params.enableGroup(false)
|
params.enableGroup(false)
|
||||||
// We don't want a basic chat room, so if isSecured is false we have to set this manually
|
params.backend = if (isSecured) ChatRoomBackend.FlexisipChat else ChatRoomBackend.Basic
|
||||||
params.backend = ChatRoomBackend.FlexisipChat
|
params.subject = AppUtils.getString(R.string.chat_room_dummy_subject)
|
||||||
|
|
||||||
val participants = arrayOfNulls<Address>(1)
|
val participants = arrayOf(participant)
|
||||||
participants[0] = participant
|
|
||||||
core.createChatRoom(params, AppUtils.getString(R.string.chat_room_dummy_subject), participants)
|
return core.searchChatRoom(params, defaultProxyConfig?.identityAddress, participants)
|
||||||
} else {
|
?: core.createChatRoom(params, defaultProxyConfig?.identityAddress, participants)
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun deleteFilesAttachedToEventLog(eventLog: EventLog) {
|
fun deleteFilesAttachedToEventLog(eventLog: EventLog) {
|
||||||
|
|
Loading…
Reference in a new issue