mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-02-04 13:07:31 +01:00
VoIP: clean after PR's review
This commit is contained in:
parent
1ef9ed5202
commit
191cef6fff
@ -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.
|
||||||
|
@ -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 {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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()
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
@ -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()
|
||||||
|
@ -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
|
||||||
|
@ -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() }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user