VoIP: clean after PR's review

This commit is contained in:
ganfra 2021-01-29 16:34:30 +01:00
parent 1ef9ed5202
commit 191cef6fff
10 changed files with 34 additions and 15 deletions

View File

@ -73,8 +73,7 @@ interface Session :
HomeServerCapabilitiesService,
SecureStorageService,
AccountDataService,
AccountService,
ThirdPartyService {
AccountService {
/**
* The params associated to the session
@ -214,6 +213,11 @@ interface Session :
*/
fun searchService(): SearchService
/**
* Returns the third party service associated with the session
*/
fun thirdPartyService(): ThirdPartyService
/**
* Add a listener to the session.
* @param listener the listener to add.

View File

@ -19,6 +19,9 @@ package org.matrix.android.sdk.api.session.thirdparty
import org.matrix.android.sdk.api.session.room.model.thirdparty.ThirdPartyProtocol
import org.matrix.android.sdk.api.session.thirdparty.model.ThirdPartyUser
/**
* See https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-thirdparty-protocols
*/
interface ThirdPartyService {
/**

View File

@ -114,7 +114,7 @@ internal class DefaultSession @Inject constructor(
private val accountService: Lazy<AccountService>,
private val defaultIdentityService: DefaultIdentityService,
private val integrationManagerService: IntegrationManagerService,
private val thirdPartyService: ThirdPartyService,
private val thirdPartyService: Lazy<ThirdPartyService>,
private val callSignalingService: Lazy<CallSignalingService>,
@UnauthenticatedWithCertificate
private val unauthenticatedWithCertificateOkHttpClient: Lazy<OkHttpClient>,
@ -135,7 +135,6 @@ internal class DefaultSession @Inject constructor(
ProfileService by profileService.get(),
AccountDataService by accountDataService.get(),
AccountService by accountService.get(),
ThirdPartyService by thirdPartyService,
GlobalErrorHandler.Listener {
override val sharedSecretStorageService: SharedSecretStorageService
@ -260,6 +259,8 @@ internal class DefaultSession @Inject constructor(
override fun searchService(): SearchService = searchService.get()
override fun thirdPartyService(): ThirdPartyService = thirdPartyService.get()
override fun getOkHttpClient(): OkHttpClient {
return unauthenticatedWithCertificateOkHttpClient.get()
}

View File

@ -385,6 +385,11 @@ SOFTWARE.
<br/>
Copyright 2016 JetRadar
</li>
<li>
<b>dialogs / android-dialer</b>
<br/>
Copyright (c) 2017-present, dialog LLC <info@dlg.im>
</li>
</ul>
<pre>
Apache License

View File

@ -33,7 +33,7 @@ class DialPadLookup @Inject constructor(val session: Session,
suspend fun lookupPhoneNumber(phoneNumber: String): Result {
val supportedProtocolKey = callManager.supportedPSTNProtocol ?: throw Failure()
val thirdPartyUser = tryOrNull {
session.getThirdPartyUser(supportedProtocolKey, fields = mapOf(
session.thirdPartyService().getThirdPartyUser(supportedProtocolKey, fields = mapOf(
"m.id.phone" to phoneNumber
)).firstOrNull()
} ?: throw Failure()

View File

@ -80,9 +80,9 @@ class CallTransferActivity : VectorBaseActivity<ActivityCallTransferBinding>(),
waitingView = views.waitingView.waitingView
callTransferViewModel.observeViewEvents {
when (it) {
is CallTransferViewEvents.Dismiss -> finish()
CallTransferViewEvents.Loading -> showWaitingView()
when (it) {
is CallTransferViewEvents.Dismiss -> finish()
CallTransferViewEvents.Loading -> showWaitingView()
is CallTransferViewEvents.FailToTransfer -> showSnackbar(getString(R.string.call_transfer_failure))
}
}

View File

@ -25,7 +25,7 @@ private const val PSTN_MATRIX_KEY = "m.protocol.pstn"
suspend fun Session.getSupportedPSTN(maxTries: Int): String? {
val thirdPartyProtocols: Map<String, ThirdPartyProtocol> = try {
getThirdPartyProtocols()
thirdPartyService().getThirdPartyProtocols()
} catch (failure: Throwable) {
if (maxTries == 1) {
return null

View File

@ -118,7 +118,9 @@ class WebRtcCallManager @Inject constructor(
GlobalScope.launch {
supportedPSTNProtocol = currentSession?.getSupportedPSTN(3)
if (supportedPSTNProtocol != null) {
pstnSupportListeners.forEach { it.onPSTNSupportUpdated() }
pstnSupportListeners.forEach {
tryOrNull { it.onPSTNSupportUpdated() }
}
}
}
}

View File

@ -75,8 +75,8 @@ class MatrixToBottomSheetViewModel @AssistedInject constructor(
return
}
when (permalinkData) {
is PermalinkData.UserLink -> {
when (permalinkData) {
is PermalinkData.UserLink -> {
val user = resolveUser(permalinkData.userId)
setState {
copy(
@ -85,11 +85,11 @@ class MatrixToBottomSheetViewModel @AssistedInject constructor(
)
}
}
is PermalinkData.RoomLink -> {
is PermalinkData.RoomLink -> {
// not yet supported
_viewEvents.post(MatrixToViewEvents.Dismiss)
}
is PermalinkData.GroupLink -> {
is PermalinkData.GroupLink -> {
// not yet supported
_viewEvents.post(MatrixToViewEvents.Dismiss)
}

View File

@ -19,6 +19,7 @@ package im.vector.app.features.roomdirectory.picker
import androidx.lifecycle.viewModelScope
import com.airbnb.mvrx.Fail
import com.airbnb.mvrx.FragmentViewModelContext
import com.airbnb.mvrx.Loading
import com.airbnb.mvrx.MvRxViewModelFactory
import com.airbnb.mvrx.Success
import com.airbnb.mvrx.ViewModelContext
@ -53,8 +54,11 @@ class RoomDirectoryPickerViewModel @AssistedInject constructor(@Assisted initial
private fun load() {
viewModelScope.launch {
setState {
copy(asyncThirdPartyRequest = Loading())
}
try {
val thirdPartyProtocols = session.getThirdPartyProtocols()
val thirdPartyProtocols = session.thirdPartyService().getThirdPartyProtocols()
setState {
copy(asyncThirdPartyRequest = Success(thirdPartyProtocols))
}