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, HomeServerCapabilitiesService,
SecureStorageService, SecureStorageService,
AccountDataService, AccountDataService,
AccountService, AccountService {
ThirdPartyService {
/** /**
* The params associated to the session * The params associated to the session
@ -214,6 +213,11 @@ interface Session :
*/ */
fun searchService(): SearchService fun searchService(): SearchService
/**
* Returns the third party service associated with the session
*/
fun thirdPartyService(): ThirdPartyService
/** /**
* Add a listener to the session. * Add a listener to the session.
* @param listener the listener to add. * @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.room.model.thirdparty.ThirdPartyProtocol
import org.matrix.android.sdk.api.session.thirdparty.model.ThirdPartyUser 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 { interface ThirdPartyService {
/** /**

View File

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

View File

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

View File

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

View File

@ -80,9 +80,9 @@ class CallTransferActivity : VectorBaseActivity<ActivityCallTransferBinding>(),
waitingView = views.waitingView.waitingView waitingView = views.waitingView.waitingView
callTransferViewModel.observeViewEvents { callTransferViewModel.observeViewEvents {
when (it) { when (it) {
is CallTransferViewEvents.Dismiss -> finish() is CallTransferViewEvents.Dismiss -> finish()
CallTransferViewEvents.Loading -> showWaitingView() CallTransferViewEvents.Loading -> showWaitingView()
is CallTransferViewEvents.FailToTransfer -> showSnackbar(getString(R.string.call_transfer_failure)) 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? { suspend fun Session.getSupportedPSTN(maxTries: Int): String? {
val thirdPartyProtocols: Map<String, ThirdPartyProtocol> = try { val thirdPartyProtocols: Map<String, ThirdPartyProtocol> = try {
getThirdPartyProtocols() thirdPartyService().getThirdPartyProtocols()
} catch (failure: Throwable) { } catch (failure: Throwable) {
if (maxTries == 1) { if (maxTries == 1) {
return null return null

View File

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

View File

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

View File

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