mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-02-02 20:26:47 +01:00
Crypto: expose cryptoService by a getter, removing the session implementation delegation
This commit is contained in:
parent
a305ce302e
commit
e349a35419
@ -111,15 +111,15 @@ class RxSession(private val session: Session) {
|
||||
}
|
||||
|
||||
fun liveUserCryptoDevices(userId: String): Observable<List<CryptoDeviceInfo>> {
|
||||
return session.getLiveCryptoDeviceInfo(userId).asObservable().startWithCallable {
|
||||
session.getCryptoDeviceInfo(userId)
|
||||
return session.cryptoService().getLiveCryptoDeviceInfo(userId).asObservable().startWithCallable {
|
||||
session.cryptoService().getCryptoDeviceInfo(userId)
|
||||
}
|
||||
}
|
||||
|
||||
fun liveCrossSigningInfo(userId: String): Observable<Optional<MXCrossSigningInfo>> {
|
||||
return session.getCrossSigningService().getLiveCrossSigningKeys(userId).asObservable()
|
||||
return session.cryptoService().crossSigningService().getLiveCrossSigningKeys(userId).asObservable()
|
||||
.startWithCallable {
|
||||
session.getCrossSigningService().getUserCrossSigningKeys(userId).toOptional()
|
||||
session.cryptoService().crossSigningService().getUserCrossSigningKeys(userId).toOptional()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,7 @@ import im.vector.matrix.android.api.session.signout.SignOutService
|
||||
import im.vector.matrix.android.api.session.sync.FilterService
|
||||
import im.vector.matrix.android.api.session.sync.SyncState
|
||||
import im.vector.matrix.android.api.session.user.UserService
|
||||
import im.vector.matrix.android.internal.crypto.DefaultCryptoService
|
||||
|
||||
/**
|
||||
* This interface defines interactions with a session.
|
||||
@ -49,7 +50,6 @@ interface Session :
|
||||
RoomDirectoryService,
|
||||
GroupService,
|
||||
UserService,
|
||||
CryptoService,
|
||||
CacheService,
|
||||
SignOutService,
|
||||
FilterService,
|
||||
@ -139,6 +139,11 @@ interface Session :
|
||||
*/
|
||||
fun contentUploadProgressTracker(): ContentUploadStateTracker
|
||||
|
||||
/**
|
||||
* Returns the cryptoService associated with the session
|
||||
*/
|
||||
fun cryptoService(): CryptoService
|
||||
|
||||
/**
|
||||
* Add a listener to the session.
|
||||
* @param listener the listener to add.
|
||||
|
@ -40,6 +40,12 @@ import im.vector.matrix.android.internal.crypto.model.rest.RoomKeyRequestBody
|
||||
|
||||
interface CryptoService {
|
||||
|
||||
fun verificationService(): VerificationService
|
||||
|
||||
fun crossSigningService(): CrossSigningService
|
||||
|
||||
fun keysBackupService(): KeysBackupService
|
||||
|
||||
fun setDeviceName(deviceId: String, deviceName: String, callback: MatrixCallback<Unit>)
|
||||
|
||||
fun deleteDevice(deviceId: String, callback: MatrixCallback<Unit>)
|
||||
@ -50,12 +56,6 @@ interface CryptoService {
|
||||
|
||||
fun isCryptoEnabled(): Boolean
|
||||
|
||||
fun getVerificationService(): VerificationService
|
||||
|
||||
fun getCrossSigningService(): CrossSigningService
|
||||
|
||||
fun getKeysBackupService(): KeysBackupService
|
||||
|
||||
fun isRoomBlacklistUnverifiedDevices(roomId: String?): Boolean
|
||||
|
||||
fun setWarnOnUnknownDevices(warn: Boolean)
|
||||
|
@ -340,14 +340,14 @@ internal class DefaultCryptoService @Inject constructor(
|
||||
/**
|
||||
* @return the Keys backup Service
|
||||
*/
|
||||
override fun getKeysBackupService() = keysBackup
|
||||
override fun keysBackupService() = keysBackup
|
||||
|
||||
/**
|
||||
* @return the VerificationService
|
||||
*/
|
||||
override fun getVerificationService() = verificationService
|
||||
override fun verificationService() = verificationService
|
||||
|
||||
override fun getCrossSigningService() = crossSigningService
|
||||
override fun crossSigningService() = crossSigningService
|
||||
|
||||
/**
|
||||
* A sync response has been received
|
||||
|
@ -88,7 +88,6 @@ internal class DefaultSession @Inject constructor(
|
||||
private val syncThreadProvider: Provider<SyncThread>,
|
||||
private val contentUrlResolver: ContentUrlResolver,
|
||||
private val syncTokenStore: SyncTokenStore,
|
||||
private val syncTaskSequencer: SyncTaskSequencer,
|
||||
private val sessionParamsStore: SessionParamsStore,
|
||||
private val contentUploadProgressTracker: ContentUploadStateTracker,
|
||||
private val initialSyncProgressService: Lazy<InitialSyncProgressService>,
|
||||
@ -101,7 +100,6 @@ internal class DefaultSession @Inject constructor(
|
||||
RoomDirectoryService by roomDirectoryService.get(),
|
||||
GroupService by groupService.get(),
|
||||
UserService by userService.get(),
|
||||
CryptoService by cryptoService.get(),
|
||||
SignOutService by signOutService.get(),
|
||||
FilterService by filterService.get(),
|
||||
PushRuleService by pushRuleService.get(),
|
||||
@ -170,7 +168,6 @@ internal class DefaultSession @Inject constructor(
|
||||
cryptoService.get().close()
|
||||
isOpen = false
|
||||
eventBus.unregister(this)
|
||||
syncTaskSequencer.close()
|
||||
shieldTrustUpdater.stop()
|
||||
}
|
||||
|
||||
@ -212,6 +209,8 @@ internal class DefaultSession @Inject constructor(
|
||||
|
||||
override fun contentUploadProgressTracker() = contentUploadProgressTracker
|
||||
|
||||
override fun cryptoService(): CryptoService = cryptoService.get()
|
||||
|
||||
override fun addListener(listener: Session.Listener) {
|
||||
sessionListeners.addListener(listener)
|
||||
}
|
||||
|
@ -66,6 +66,6 @@ fun Session.startSyncing(context: Context) {
|
||||
* Tell is the session has unsaved e2e keys in the backup
|
||||
*/
|
||||
fun Session.hasUnsavedKeys(): Boolean {
|
||||
return inboundGroupSessionsCount(false) > 0
|
||||
&& getKeysBackupService().state != KeysBackupState.ReadyToBackUp
|
||||
return cryptoService().inboundGroupSessionsCount(false) > 0
|
||||
&& cryptoService().keysBackupService().state != KeysBackupState.ReadyToBackUp
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ class KeysExporter(private val session: Session) {
|
||||
fun export(context: Context, password: String, callback: MatrixCallback<String>) {
|
||||
GlobalScope.launch(Dispatchers.Main) {
|
||||
runCatching {
|
||||
val data = awaitCallback<ByteArray> { session.exportRoomKeys(password, it) }
|
||||
val data = awaitCallback<ByteArray> { session.cryptoService().exportRoomKeys(password, it) }
|
||||
withContext(Dispatchers.IO) {
|
||||
val parentDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)
|
||||
val file = File(parentDir, "riotx-keys-" + System.currentTimeMillis() + ".txt")
|
||||
|
@ -59,7 +59,7 @@ class KeysImporter(private val session: Session) {
|
||||
}
|
||||
|
||||
awaitCallback<ImportRoomKeysResult> {
|
||||
session.importRoomKeys(data, password, null, it)
|
||||
session.cryptoService().importRoomKeys(data, password, null, it)
|
||||
}
|
||||
}
|
||||
}.foldToCallback(callback)
|
||||
|
@ -47,7 +47,7 @@ class KeysBackupRestoreFromKeyViewModel @Inject constructor() : ViewModel() {
|
||||
|
||||
fun recoverKeys(context: Context, sharedViewModel: KeysBackupRestoreSharedViewModel) {
|
||||
val session = sharedViewModel.session
|
||||
val keysBackup = session.getKeysBackupService()
|
||||
val keysBackup = session.cryptoService().keysBackupService()
|
||||
|
||||
recoveryCodeErrorText.value = null
|
||||
val recoveryKey = recoveryCode.value!!
|
||||
|
@ -63,7 +63,7 @@ class KeysBackupRestoreSharedViewModel @Inject constructor() : ViewModel() {
|
||||
}
|
||||
|
||||
fun getLatestVersion(context: Context) {
|
||||
val keysBackup = session.getKeysBackupService()
|
||||
val keysBackup = session.cryptoService().keysBackupService()
|
||||
|
||||
loadingEvent.value = WaitingViewData(context.getString(R.string.keys_backup_restore_is_getting_backup_version))
|
||||
|
||||
|
@ -119,8 +119,8 @@ class KeysBackupSettingsRecyclerViewController @Inject constructor(private val s
|
||||
style(GenericItem.STYLE.BIG_TEXT)
|
||||
hasIndeterminateProcess(true)
|
||||
|
||||
val totalKeys = session.inboundGroupSessionsCount(false)
|
||||
val backedUpKeys = session.inboundGroupSessionsCount(true)
|
||||
val totalKeys = session.cryptoService().inboundGroupSessionsCount(false)
|
||||
val backedUpKeys = session.cryptoService().inboundGroupSessionsCount(true)
|
||||
|
||||
val remainingKeysToBackup = totalKeys - backedUpKeys
|
||||
|
||||
|
@ -47,13 +47,13 @@ class KeysBackupSettingsViewModel @AssistedInject constructor(@Assisted initialS
|
||||
}
|
||||
}
|
||||
|
||||
private var keysBackupService: KeysBackupService = session.getKeysBackupService()
|
||||
private val keysBackupService: KeysBackupService = session.cryptoService().keysBackupService()
|
||||
|
||||
init {
|
||||
setState {
|
||||
this.copy(
|
||||
keysBackupState = session.getKeysBackupService().state,
|
||||
keysBackupVersion = session.getKeysBackupService().keysBackupVersion
|
||||
keysBackupState = keysBackupService.state,
|
||||
keysBackupVersion = keysBackupService.keysBackupVersion
|
||||
)
|
||||
}
|
||||
keysBackupService.addListener(this)
|
||||
|
@ -102,7 +102,7 @@ class KeysBackupSetupSharedViewModel @Inject constructor() : ViewModel() {
|
||||
session.let { mxSession ->
|
||||
val requestedId = currentRequestId.value!!
|
||||
|
||||
mxSession.getKeysBackupService().prepareKeysBackupVersion(withPassphrase,
|
||||
mxSession.cryptoService().keysBackupService().prepareKeysBackupVersion(withPassphrase,
|
||||
object : ProgressListener {
|
||||
override fun onProgress(progress: Int, total: Int) {
|
||||
if (requestedId != currentRequestId.value) {
|
||||
@ -125,7 +125,7 @@ class KeysBackupSetupSharedViewModel @Inject constructor() : ViewModel() {
|
||||
megolmBackupCreationInfo = data
|
||||
copyHasBeenMade = false
|
||||
|
||||
val keyBackup = session.getKeysBackupService()
|
||||
val keyBackup = session.cryptoService().keysBackupService()
|
||||
createKeysBackup(context, keyBackup)
|
||||
}
|
||||
|
||||
@ -145,14 +145,14 @@ class KeysBackupSetupSharedViewModel @Inject constructor() : ViewModel() {
|
||||
}
|
||||
|
||||
fun forceCreateKeyBackup(context: Context) {
|
||||
val keyBackup = session.getKeysBackupService()
|
||||
val keyBackup = session.cryptoService().keysBackupService()
|
||||
createKeysBackup(context, keyBackup, true)
|
||||
}
|
||||
|
||||
fun stopAndKeepAfterDetectingExistingOnServer() {
|
||||
loadingStatus.value = null
|
||||
navigateEvent.value = LiveEvent(NAVIGATE_FINISH)
|
||||
session.getKeysBackupService().checkAndStartKeysBackup()
|
||||
session.cryptoService().keysBackupService().checkAndStartKeysBackup()
|
||||
}
|
||||
|
||||
private fun createKeysBackup(context: Context, keysBackup: KeysBackupService, forceOverride: Boolean = false) {
|
||||
|
@ -64,13 +64,13 @@ class KeyRequestHandler @Inject constructor(private val context: Context)
|
||||
|
||||
fun start(session: Session) {
|
||||
this.session = session
|
||||
session.getVerificationService().addListener(this)
|
||||
session.addRoomKeysRequestListener(this)
|
||||
session.cryptoService().verificationService().addListener(this)
|
||||
session.cryptoService().addRoomKeysRequestListener(this)
|
||||
}
|
||||
|
||||
fun stop() {
|
||||
session?.getVerificationService()?.removeListener(this)
|
||||
session?.removeRoomKeysRequestListener(this)
|
||||
session?.cryptoService()?.verificationService()?.removeListener(this)
|
||||
session?.cryptoService()?.removeRoomKeysRequestListener(this)
|
||||
session = null
|
||||
}
|
||||
|
||||
@ -100,7 +100,7 @@ class KeyRequestHandler @Inject constructor(private val context: Context)
|
||||
alertsToRequests[mappingKey] = ArrayList<IncomingRoomKeyRequest>().apply { this.add(request) }
|
||||
|
||||
// Add a notification for every incoming request
|
||||
session?.downloadKeys(listOf(userId), false, object : MatrixCallback<MXUsersDevicesMap<CryptoDeviceInfo>> {
|
||||
session?.cryptoService()?.downloadKeys(listOf(userId), false, object : MatrixCallback<MXUsersDevicesMap<CryptoDeviceInfo>> {
|
||||
override fun onSuccess(data: MXUsersDevicesMap<CryptoDeviceInfo>) {
|
||||
val deviceInfo = data.getObject(userId, deviceId)
|
||||
|
||||
@ -111,12 +111,12 @@ class KeyRequestHandler @Inject constructor(private val context: Context)
|
||||
}
|
||||
|
||||
if (deviceInfo.isUnknown) {
|
||||
session?.setDeviceVerification(DeviceTrustLevel(false, false), userId, deviceId)
|
||||
session?.cryptoService()?.setDeviceVerification(DeviceTrustLevel(false, false), userId, deviceId)
|
||||
|
||||
deviceInfo.trustLevel = DeviceTrustLevel(false, false)
|
||||
|
||||
// can we get more info on this device?
|
||||
session?.getDevicesList(object : MatrixCallback<DevicesListResponse> {
|
||||
session?.cryptoService()?.getDevicesList(object : MatrixCallback<DevicesListResponse> {
|
||||
override fun onSuccess(data: DevicesListResponse) {
|
||||
data.devices?.find { it.deviceId == deviceId }?.let {
|
||||
postAlert(context, userId, deviceId, true, deviceInfo, it)
|
||||
|
@ -40,11 +40,11 @@ class IncomingVerificationRequestHandler @Inject constructor(private val context
|
||||
|
||||
fun start(session: Session) {
|
||||
this.session = session
|
||||
session.getVerificationService().addListener(this)
|
||||
session.cryptoService().verificationService().addListener(this)
|
||||
}
|
||||
|
||||
fun stop() {
|
||||
session?.getVerificationService()?.removeListener(this)
|
||||
session?.cryptoService()?.verificationService()?.removeListener(this)
|
||||
this.session = null
|
||||
}
|
||||
|
||||
@ -139,7 +139,7 @@ class IncomingVerificationRequestHandler @Inject constructor(private val context
|
||||
}
|
||||
}
|
||||
dismissedAction = Runnable {
|
||||
session?.getVerificationService()?.declineVerificationRequestInDMs(pr.otherUserId,
|
||||
session?.cryptoService()?.verificationService()?.declineVerificationRequestInDMs(pr.otherUserId,
|
||||
pr.transactionId ?: "",
|
||||
pr.roomId ?: ""
|
||||
)
|
||||
|
@ -63,7 +63,7 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(@Assisted ini
|
||||
VerificationService.Listener {
|
||||
|
||||
init {
|
||||
session.getVerificationService().addListener(this)
|
||||
session.cryptoService().verificationService().addListener(this)
|
||||
|
||||
val userItem = session.getUser(args.otherUserId)
|
||||
|
||||
@ -73,7 +73,7 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(@Assisted ini
|
||||
val pr = if (isWaitingForOtherMode) {
|
||||
// See if active tx for this user and take it
|
||||
|
||||
session.getVerificationService().getExistingVerificationRequest(args.otherUserId)
|
||||
session.cryptoService().verificationService().getExistingVerificationRequest(args.otherUserId)
|
||||
?.lastOrNull { !it.isFinished }
|
||||
?.also { verificationRequest ->
|
||||
if (verificationRequest.isIncoming && !verificationRequest.isReady) {
|
||||
@ -82,15 +82,15 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(@Assisted ini
|
||||
}
|
||||
}
|
||||
} else {
|
||||
session.getVerificationService().getExistingVerificationRequest(args.otherUserId, args.verificationId)
|
||||
session.cryptoService().verificationService().getExistingVerificationRequest(args.otherUserId, args.verificationId)
|
||||
}
|
||||
|
||||
val sasTx = (pr?.transactionId ?: args.verificationId)?.let {
|
||||
session.getVerificationService().getExistingTransaction(args.otherUserId, it) as? SasVerificationTransaction
|
||||
session.cryptoService().verificationService().getExistingTransaction(args.otherUserId, it) as? SasVerificationTransaction
|
||||
}
|
||||
|
||||
val qrTx = (pr?.transactionId ?: args.verificationId)?.let {
|
||||
session.getVerificationService().getExistingTransaction(args.otherUserId, it) as? QrCodeVerificationTransaction
|
||||
session.cryptoService().verificationService().getExistingTransaction(args.otherUserId, it) as? QrCodeVerificationTransaction
|
||||
}
|
||||
|
||||
setState {
|
||||
@ -108,7 +108,7 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(@Assisted ini
|
||||
|
||||
if (autoReady) {
|
||||
// TODO, can I be here in DM mode? in this case should test if roomID is null?
|
||||
session.getVerificationService()
|
||||
session.cryptoService().verificationService()
|
||||
.readyPendingVerification(supportedVerificationMethods,
|
||||
pr!!.otherUserId,
|
||||
pr.transactionId ?: "")
|
||||
@ -116,7 +116,7 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(@Assisted ini
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
session.getVerificationService().removeListener(this)
|
||||
session.cryptoService().verificationService().removeListener(this)
|
||||
super.onCleared()
|
||||
}
|
||||
|
||||
@ -164,7 +164,8 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(@Assisted ini
|
||||
roomId = data,
|
||||
pendingRequest = Success(
|
||||
session
|
||||
.getVerificationService()
|
||||
.cryptoService()
|
||||
.verificationService()
|
||||
.requestKeyVerificationInDMs(supportedVerificationMethods, otherUserId, data, pendingLocalId)
|
||||
)
|
||||
)
|
||||
@ -181,7 +182,8 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(@Assisted ini
|
||||
setState {
|
||||
copy(
|
||||
pendingRequest = Success(session
|
||||
.getVerificationService()
|
||||
.cryptoService()
|
||||
.verificationService()
|
||||
.requestKeyVerificationInDMs(supportedVerificationMethods, otherUserId, roomId)
|
||||
)
|
||||
)
|
||||
@ -190,18 +192,18 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(@Assisted ini
|
||||
Unit
|
||||
}
|
||||
is VerificationAction.StartSASVerification -> {
|
||||
val request = session.getVerificationService().getExistingVerificationRequest(otherUserId, action.pendingRequestTransactionId)
|
||||
val request = session.cryptoService().verificationService().getExistingVerificationRequest(otherUserId, action.pendingRequestTransactionId)
|
||||
?: return@withState
|
||||
val otherDevice = if (request.isIncoming) request.requestInfo?.fromDevice else request.readyInfo?.fromDevice
|
||||
if (roomId == null) {
|
||||
session.getVerificationService().beginKeyVerification(
|
||||
session.cryptoService().verificationService().beginKeyVerification(
|
||||
VerificationMethod.SAS,
|
||||
otherUserId = request.otherUserId,
|
||||
otherDeviceId = otherDevice ?: "",
|
||||
transactionId = action.pendingRequestTransactionId
|
||||
)
|
||||
} else {
|
||||
session.getVerificationService().beginKeyVerificationInDMs(
|
||||
session.cryptoService().verificationService().beginKeyVerificationInDMs(
|
||||
VerificationMethod.SAS,
|
||||
transactionId = action.pendingRequestTransactionId,
|
||||
roomId = roomId,
|
||||
@ -213,7 +215,7 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(@Assisted ini
|
||||
Unit
|
||||
}
|
||||
is VerificationAction.RemoteQrCodeScanned -> {
|
||||
val existingTransaction = session.getVerificationService()
|
||||
val existingTransaction = session.cryptoService().verificationService()
|
||||
.getExistingTransaction(action.otherUserId, action.transactionId) as? QrCodeVerificationTransaction
|
||||
existingTransaction
|
||||
?.userHasScannedOtherQrCode(action.scannedData)
|
||||
@ -221,7 +223,7 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(@Assisted ini
|
||||
is VerificationAction.OtherUserScannedSuccessfully -> {
|
||||
val transactionId = state.transactionId ?: return@withState
|
||||
|
||||
val existingTransaction = session.getVerificationService()
|
||||
val existingTransaction = session.cryptoService().verificationService()
|
||||
.getExistingTransaction(otherUserId, transactionId) as? QrCodeVerificationTransaction
|
||||
existingTransaction
|
||||
?.otherUserScannedMyQrCode()
|
||||
@ -229,18 +231,18 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(@Assisted ini
|
||||
is VerificationAction.OtherUserDidNotScanned -> {
|
||||
val transactionId = state.transactionId ?: return@withState
|
||||
|
||||
val existingTransaction = session.getVerificationService()
|
||||
val existingTransaction = session.cryptoService().verificationService()
|
||||
.getExistingTransaction(otherUserId, transactionId) as? QrCodeVerificationTransaction
|
||||
existingTransaction
|
||||
?.otherUserDidNotScannedMyQrCode()
|
||||
}
|
||||
is VerificationAction.SASMatchAction -> {
|
||||
(session.getVerificationService()
|
||||
(session.cryptoService().verificationService()
|
||||
.getExistingTransaction(action.otherUserId, action.sasTransactionId)
|
||||
as? SasVerificationTransaction)?.userHasVerifiedShortCode()
|
||||
}
|
||||
is VerificationAction.SASDoNotMatchAction -> {
|
||||
(session.getVerificationService()
|
||||
(session.cryptoService().verificationService()
|
||||
.getExistingTransaction(action.otherUserId, action.sasTransactionId)
|
||||
as? SasVerificationTransaction)
|
||||
?.shortCodeDoesNotMatch()
|
||||
@ -312,7 +314,7 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(@Assisted ini
|
||||
if (!pr.isReady) {
|
||||
// auto ready in this case, as we are waiting
|
||||
// TODO, can I be here in DM mode? in this case should test if roomID is null?
|
||||
session.getVerificationService()
|
||||
session.cryptoService().verificationService()
|
||||
.readyPendingVerification(supportedVerificationMethods,
|
||||
pr.otherUserId,
|
||||
pr.transactionId ?: "")
|
||||
|
@ -62,7 +62,7 @@ class VerificationChooseMethodViewModel @AssistedInject constructor(
|
||||
}
|
||||
|
||||
override fun verificationRequestUpdated(pr: PendingVerificationRequest) = withState { state ->
|
||||
val pvr = session.getVerificationService().getExistingVerificationRequest(state.otherUserId, state.transactionId)
|
||||
val pvr = session.cryptoService().verificationService().getExistingVerificationRequest(state.otherUserId, state.transactionId)
|
||||
|
||||
setState {
|
||||
copy(
|
||||
@ -79,12 +79,12 @@ class VerificationChooseMethodViewModel @AssistedInject constructor(
|
||||
}
|
||||
|
||||
init {
|
||||
session.getVerificationService().addListener(this)
|
||||
session.cryptoService().verificationService().addListener(this)
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
super.onCleared()
|
||||
session.getVerificationService().removeListener(this)
|
||||
session.cryptoService().verificationService().removeListener(this)
|
||||
}
|
||||
|
||||
companion object : MvRxViewModelFactory<VerificationChooseMethodViewModel, VerificationChooseMethodViewState> {
|
||||
@ -96,10 +96,10 @@ class VerificationChooseMethodViewModel @AssistedInject constructor(
|
||||
override fun initialState(viewModelContext: ViewModelContext): VerificationChooseMethodViewState? {
|
||||
val args: VerificationBottomSheet.VerificationArgs = viewModelContext.args()
|
||||
val session = (viewModelContext.activity as HasScreenInjector).injector().activeSessionHolder().getActiveSession()
|
||||
val pvr = session.getVerificationService().getExistingVerificationRequest(args.otherUserId, args.verificationId)
|
||||
val pvr = session.cryptoService().verificationService().getExistingVerificationRequest(args.otherUserId, args.verificationId)
|
||||
|
||||
// Get the QR code now, because transaction is already created, so transactionCreated() will not be called
|
||||
val qrCodeVerificationTransaction = session.getVerificationService().getExistingTransaction(args.otherUserId, args.verificationId ?: "")
|
||||
val qrCodeVerificationTransaction = session.cryptoService().verificationService().getExistingTransaction(args.otherUserId, args.verificationId ?: "")
|
||||
|
||||
return VerificationChooseMethodViewState(otherUserId = args.otherUserId,
|
||||
transactionId = args.verificationId ?: "",
|
||||
|
@ -56,16 +56,16 @@ class VerificationEmojiCodeViewModel @AssistedInject constructor(
|
||||
|
||||
init {
|
||||
withState { state ->
|
||||
refreshStateFromTx(session.getVerificationService()
|
||||
refreshStateFromTx(session.cryptoService().verificationService()
|
||||
.getExistingTransaction(state.otherUser?.id ?: "", state.transactionId
|
||||
?: "") as? SasVerificationTransaction)
|
||||
}
|
||||
|
||||
session.getVerificationService().addListener(this)
|
||||
session.cryptoService().verificationService().addListener(this)
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
session.getVerificationService().removeListener(this)
|
||||
session.cryptoService().verificationService().removeListener(this)
|
||||
super.onCleared()
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable {
|
||||
if (sharedActionViewModel.hasDisplayedCompleteSecurityPrompt) return
|
||||
|
||||
// ensure keys are downloaded
|
||||
session.downloadKeys(listOf(session.myUserId), true, object : MatrixCallback<MXUsersDevicesMap<CryptoDeviceInfo>> {
|
||||
session.cryptoService().downloadKeys(listOf(session.myUserId), true, object : MatrixCallback<MXUsersDevicesMap<CryptoDeviceInfo>> {
|
||||
override fun onSuccess(data: MXUsersDevicesMap<CryptoDeviceInfo>) {
|
||||
runOnUiThread {
|
||||
alertCompleteSecurity(session)
|
||||
@ -140,7 +140,7 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable {
|
||||
}
|
||||
|
||||
private fun alertCompleteSecurity(session: Session) {
|
||||
val myCrossSigningKeys = session.getCrossSigningService()
|
||||
val myCrossSigningKeys = session.cryptoService().crossSigningService()
|
||||
.getMyCrossSigningKeys()
|
||||
val crossSigningEnabledOnAccount = myCrossSigningKeys != null
|
||||
|
||||
|
@ -420,7 +420,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
||||
popDraft()
|
||||
}
|
||||
is ParsedCommand.VerifyUser -> {
|
||||
session.getVerificationService().requestKeyVerificationInDMs(supportedVerificationMethods, slashCommandResult.userId, room.roomId)
|
||||
session.cryptoService().verificationService().requestKeyVerificationInDMs(supportedVerificationMethods, slashCommandResult.userId, room.roomId)
|
||||
_viewEvents.post(RoomDetailViewEvents.SlashCommandHandled())
|
||||
popDraft()
|
||||
}
|
||||
@ -826,7 +826,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
||||
|
||||
private fun handleAcceptVerification(action: RoomDetailAction.AcceptVerificationRequest) {
|
||||
Timber.v("## SAS handleAcceptVerification ${action.otherUserId}, roomId:${room.roomId}, txId:${action.transactionId}")
|
||||
if (session.getVerificationService().readyPendingVerificationInDMs(
|
||||
if (session.cryptoService().verificationService().readyPendingVerificationInDMs(
|
||||
supportedVerificationMethods,
|
||||
action.otherUserId,
|
||||
room.roomId,
|
||||
@ -838,7 +838,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
||||
}
|
||||
|
||||
private fun handleDeclineVerification(action: RoomDetailAction.DeclineVerificationRequest) {
|
||||
session.getVerificationService().declineVerificationRequestInDMs(
|
||||
session.cryptoService().verificationService().declineVerificationRequestInDMs(
|
||||
action.otherUserId,
|
||||
action.transactionId,
|
||||
room.roomId)
|
||||
@ -851,7 +851,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
||||
|
||||
private fun handleResumeRequestVerification(action: RoomDetailAction.ResumeVerification) {
|
||||
// Check if this request is still active and handled by me
|
||||
session.getVerificationService().getExistingVerificationRequestInRoom(room.roomId, action.transactionId)?.let {
|
||||
session.cryptoService().verificationService().getExistingVerificationRequestInRoom(room.roomId, action.transactionId)?.let {
|
||||
if (it.handledByOtherSession) return
|
||||
if (!it.isFinished) {
|
||||
_viewEvents.post(RoomDetailViewEvents.ActionSuccess(action.copy(
|
||||
|
@ -100,7 +100,7 @@ class ViewEditHistoryViewModel @AssistedInject constructor(@Assisted
|
||||
if (it.isEncrypted() && it.mxDecryptionResult == null) {
|
||||
// for now decrypt sync
|
||||
try {
|
||||
val result = session.decryptEvent(it, timelineID)
|
||||
val result = session.cryptoService().decryptEvent(it, timelineID)
|
||||
it.mxDecryptionResult = OlmDecryptionResult(
|
||||
payload = result.clearEvent,
|
||||
senderKey = result.senderCurve25519Key,
|
||||
|
@ -66,7 +66,7 @@ class DefaultNavigator @Inject constructor(
|
||||
|
||||
override fun performDeviceVerification(context: Context, otherUserId: String, sasTransationId: String) {
|
||||
val session = sessionHolder.getSafeActiveSession() ?: return
|
||||
val tx = session.getVerificationService().getExistingTransaction(otherUserId, sasTransationId) ?: return
|
||||
val tx = session.cryptoService().verificationService().getExistingTransaction(otherUserId, sasTransationId) ?: return
|
||||
(tx as? IncomingSasVerificationTransaction)?.performAccept()
|
||||
if (context is VectorBaseActivity) {
|
||||
VerificationBottomSheet.withArgs(
|
||||
@ -79,10 +79,10 @@ class DefaultNavigator @Inject constructor(
|
||||
|
||||
override fun requestSessionVerification(context: Context) {
|
||||
val session = sessionHolder.getSafeActiveSession() ?: return
|
||||
val pr = session.getVerificationService().requestKeyVerification(
|
||||
val pr = session.cryptoService().verificationService().requestKeyVerification(
|
||||
listOf(VerificationMethod.SAS, VerificationMethod.QR_CODE_SCAN, VerificationMethod.QR_CODE_SHOW),
|
||||
session.myUserId,
|
||||
session.getUserDevices(session.myUserId).map { it.deviceId })
|
||||
session.cryptoService().getUserDevices(session.myUserId).map { it.deviceId })
|
||||
if (context is VectorBaseActivity) {
|
||||
VerificationBottomSheet.withArgs(
|
||||
roomId = null,
|
||||
|
@ -114,7 +114,7 @@ class NotifiableEventResolver @Inject constructor(private val stringProvider: St
|
||||
// TODO use a global event decryptor? attache to session and that listen to new sessionId?
|
||||
// for now decrypt sync
|
||||
try {
|
||||
val result = session.decryptEvent(event.root, event.root.roomId + UUID.randomUUID().toString())
|
||||
val result = session.cryptoService().decryptEvent(event.root, event.root.roomId + UUID.randomUUID().toString())
|
||||
event.root.mxDecryptionResult = OlmDecryptionResult(
|
||||
payload = result.clearEvent,
|
||||
senderKey = result.senderCurve25519Key,
|
||||
|
@ -211,7 +211,7 @@ class BugReporter @Inject constructor(private val activeSessionHolder: ActiveSes
|
||||
activeSessionHolder.getSafeActiveSession()?.let { session ->
|
||||
userId = session.myUserId
|
||||
deviceId = session.sessionParams.credentials.deviceId ?: "undefined"
|
||||
olmVersion = session.getCryptoVersion(context, true)
|
||||
olmVersion = session.cryptoService().getCryptoVersion(context, true)
|
||||
}
|
||||
|
||||
if (!mIsCancelled) {
|
||||
|
@ -148,7 +148,7 @@ class RoomMemberProfileViewModel @AssistedInject constructor(@Assisted private v
|
||||
// ok, let's find or create the DM room
|
||||
_viewEvents.post(RoomMemberProfileViewEvents.StartVerification(
|
||||
userId = state.userId,
|
||||
canCrossSign = session.getCrossSigningService().canCrossSign()
|
||||
canCrossSign = session.cryptoService().crossSigningService().canCrossSign()
|
||||
))
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ class DeviceListBottomSheetViewModel @AssistedInject constructor(@Assisted priva
|
||||
}
|
||||
|
||||
private fun manuallyVerify(action: DeviceListAction.ManuallyVerify) {
|
||||
session.getVerificationService().beginKeyVerification(VerificationMethod.SAS, userId, action.deviceId, null)?.let { txID ->
|
||||
session.cryptoService().verificationService().beginKeyVerification(VerificationMethod.SAS, userId, action.deviceId, null)?.let { txID ->
|
||||
_viewEvents.post(DeviceListBottomSheetViewEvents.Verify(userId, txID))
|
||||
}
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ class RoomMemberListViewModel @AssistedInject constructor(@Assisted initialState
|
||||
room.rx().liveRoomMembers(roomMemberQueryParams)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.switchMap { membersSummary ->
|
||||
session.getLiveCryptoDeviceInfo(membersSummary.map { it.userId })
|
||||
session.cryptoService().getLiveCryptoDeviceInfo(membersSummary.map { it.userId })
|
||||
.asObservable()
|
||||
.doOnError { Timber.e(it) }
|
||||
.map { deviceList ->
|
||||
@ -104,7 +104,7 @@ class RoomMemberListViewModel @AssistedInject constructor(@Assisted initialState
|
||||
val allDeviceTrusted = it.value.fold(it.value.isNotEmpty()) { prev, next ->
|
||||
prev && next.trustLevel?.isCrossSigningVerified().orFalse()
|
||||
}
|
||||
if (session.getCrossSigningService().getUserCrossSigningKeys(it.key)?.isTrusted().orFalse()) {
|
||||
if (session.cryptoService().crossSigningService().getUserCrossSigningKeys(it.key)?.isTrusted().orFalse()) {
|
||||
if (allDeviceTrusted) RoomEncryptionTrustLevel.Trusted else RoomEncryptionTrustLevel.Warning
|
||||
} else {
|
||||
RoomEncryptionTrustLevel.Default
|
||||
|
@ -77,7 +77,7 @@ class VectorSettingsHelpAboutFragment @Inject constructor(
|
||||
|
||||
// olm version
|
||||
findPreference<VectorPreference>(VectorPreferences.SETTINGS_OLM_VERSION_PREFERENCE_KEY)!!
|
||||
.summary = session.getCryptoVersion(requireContext(), false)
|
||||
.summary = session.cryptoService().getCryptoVersion(requireContext(), false)
|
||||
|
||||
// copyright
|
||||
findPreference<VectorPreference>(VectorPreferences.SETTINGS_COPYRIGHT_PREFERENCE_KEY)!!
|
||||
|
@ -37,7 +37,7 @@ class VectorSettingsLabsFragment @Inject constructor(
|
||||
// val useCryptoPref = findPreference(VectorPreferences.SETTINGS_ROOM_SETTINGS_LABS_END_TO_END_PREFERENCE_KEY) as SwitchPreference
|
||||
// val cryptoIsEnabledPref = findPreference(VectorPreferences.SETTINGS_ROOM_SETTINGS_LABS_END_TO_END_IS_ACTIVE_PREFERENCE_KEY)
|
||||
|
||||
if (session.isCryptoEnabled()) {
|
||||
if (session.cryptoService().isCryptoEnabled()) {
|
||||
// mLabsCategory.removePreference(useCryptoPref)
|
||||
//
|
||||
// cryptoIsEnabledPref.isEnabled = false
|
||||
|
@ -134,10 +134,10 @@ class VectorSettingsSecurityPrivacyFragment @Inject constructor(
|
||||
|
||||
private fun refreshXSigningStatus() {
|
||||
if (vectorPreferences.developerMode()) {
|
||||
val crossSigningKeys = session.getCrossSigningService().getMyCrossSigningKeys()
|
||||
val crossSigningKeys = session.cryptoService().crossSigningService().getMyCrossSigningKeys()
|
||||
val xSigningIsEnableInAccount = crossSigningKeys != null
|
||||
val xSigningKeysAreTrusted = session.getCrossSigningService().checkUserTrust(session.myUserId).isVerified()
|
||||
val xSigningKeyCanSign = session.getCrossSigningService().canCrossSign()
|
||||
val xSigningKeysAreTrusted = session.cryptoService().crossSigningService().checkUserTrust(session.myUserId).isVerified()
|
||||
val xSigningKeyCanSign = session.cryptoService().crossSigningService().canCrossSign()
|
||||
|
||||
if (xSigningKeyCanSign) {
|
||||
mCrossSigningStatePreference.setIcon(R.drawable.ic_shield_trusted)
|
||||
@ -412,10 +412,10 @@ class VectorSettingsSecurityPrivacyFragment @Inject constructor(
|
||||
|
||||
sendToUnverifiedDevicesPref.isChecked = false
|
||||
|
||||
sendToUnverifiedDevicesPref.isChecked = session.getGlobalBlacklistUnverifiedDevices()
|
||||
sendToUnverifiedDevicesPref.isChecked = session.cryptoService().getGlobalBlacklistUnverifiedDevices()
|
||||
|
||||
sendToUnverifiedDevicesPref.onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
||||
session.setGlobalBlacklistUnverifiedDevices(sendToUnverifiedDevicesPref.isChecked)
|
||||
session.cryptoService().setGlobalBlacklistUnverifiedDevices(sendToUnverifiedDevicesPref.isChecked)
|
||||
|
||||
true
|
||||
}
|
||||
@ -426,7 +426,7 @@ class VectorSettingsSecurityPrivacyFragment @Inject constructor(
|
||||
// ==============================================================================================================
|
||||
|
||||
private fun refreshMyDevice() {
|
||||
session.getUserDevices(session.myUserId).map {
|
||||
session.cryptoService().getUserDevices(session.myUserId).map {
|
||||
DeviceInfo(
|
||||
user_id = session.myUserId,
|
||||
deviceId = it.deviceId,
|
||||
@ -436,7 +436,7 @@ class VectorSettingsSecurityPrivacyFragment @Inject constructor(
|
||||
refreshCryptographyPreference(it)
|
||||
}
|
||||
// TODO Move to a ViewModel...
|
||||
session.getDevicesList(object : MatrixCallback<DevicesListResponse> {
|
||||
session.cryptoService().getDevicesList(object : MatrixCallback<DevicesListResponse> {
|
||||
override fun onSuccess(data: DevicesListResponse) {
|
||||
if (isAdded) {
|
||||
refreshCryptographyPreference(data.devices ?: emptyList())
|
||||
|
@ -57,8 +57,8 @@ class CrossSigningSettingsViewModel @AssistedInject constructor(@Assisted privat
|
||||
.execute {
|
||||
val crossSigningKeys = it.invoke()?.getOrNull()
|
||||
val xSigningIsEnableInAccount = crossSigningKeys != null
|
||||
val xSigningKeysAreTrusted = session.getCrossSigningService().checkUserTrust(session.myUserId).isVerified()
|
||||
val xSigningKeyCanSign = session.getCrossSigningService().canCrossSign()
|
||||
val xSigningKeysAreTrusted = session.cryptoService().crossSigningService().checkUserTrust(session.myUserId).isVerified()
|
||||
val xSigningKeyCanSign = session.cryptoService().crossSigningService().canCrossSign()
|
||||
copy(
|
||||
crossSigningInfo = crossSigningKeys,
|
||||
xSigningIsEnableInAccount = xSigningIsEnableInAccount,
|
||||
@ -97,7 +97,7 @@ class CrossSigningSettingsViewModel @AssistedInject constructor(@Assisted privat
|
||||
setState {
|
||||
copy(isUploadingKeys = true)
|
||||
}
|
||||
session.getCrossSigningService().initializeCrossSigning(auth, object : MatrixCallback<Unit> {
|
||||
session.cryptoService().crossSigningService().initializeCrossSigning(auth, object : MatrixCallback<Unit> {
|
||||
override fun onSuccess(data: Unit) {
|
||||
_pendingSession = null
|
||||
|
||||
|
@ -63,7 +63,7 @@ class DeviceVerificationInfoBottomSheetViewModel @AssistedInject constructor(@As
|
||||
setState {
|
||||
copy(deviceInfo = Loading())
|
||||
}
|
||||
session.getDeviceInfo(deviceId, object : MatrixCallback<DeviceInfo> {
|
||||
session.cryptoService().getDeviceInfo(deviceId, object : MatrixCallback<DeviceInfo> {
|
||||
override fun onSuccess(data: DeviceInfo) {
|
||||
setState {
|
||||
copy(deviceInfo = Success(data))
|
||||
|
@ -74,7 +74,7 @@ class DevicesViewModel @AssistedInject constructor(@Assisted initialState: Devic
|
||||
|
||||
init {
|
||||
refreshDevicesList()
|
||||
session.getVerificationService().addListener(this)
|
||||
session.cryptoService().verificationService().addListener(this)
|
||||
|
||||
session.rx().liveUserCryptoDevices(session.myUserId)
|
||||
.execute {
|
||||
@ -85,7 +85,7 @@ class DevicesViewModel @AssistedInject constructor(@Assisted initialState: Devic
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
session.getVerificationService().removeListener(this)
|
||||
session.cryptoService().verificationService().removeListener(this)
|
||||
super.onCleared()
|
||||
}
|
||||
|
||||
@ -103,7 +103,7 @@ class DevicesViewModel @AssistedInject constructor(@Assisted initialState: Devic
|
||||
private fun refreshDevicesList() {
|
||||
if (!session.sessionParams.credentials.deviceId.isNullOrEmpty()) {
|
||||
// display something asap
|
||||
val localKnown = session.getUserDevices(session.myUserId).map {
|
||||
val localKnown = session.cryptoService().getUserDevices(session.myUserId).map {
|
||||
DeviceInfo(
|
||||
user_id = session.myUserId,
|
||||
deviceId = it.deviceId,
|
||||
@ -118,7 +118,7 @@ class DevicesViewModel @AssistedInject constructor(@Assisted initialState: Devic
|
||||
)
|
||||
}
|
||||
|
||||
session.getDevicesList(object : MatrixCallback<DevicesListResponse> {
|
||||
session.cryptoService().getDevicesList(object : MatrixCallback<DevicesListResponse> {
|
||||
override fun onSuccess(data: DevicesListResponse) {
|
||||
setState {
|
||||
copy(
|
||||
@ -141,16 +141,16 @@ class DevicesViewModel @AssistedInject constructor(@Assisted initialState: Devic
|
||||
setState {
|
||||
copy(
|
||||
myDeviceId = session.sessionParams.credentials.deviceId ?: "",
|
||||
cryptoDevices = Success(session.getUserDevices(session.myUserId))
|
||||
cryptoDevices = Success(session.cryptoService().getUserDevices(session.myUserId))
|
||||
)
|
||||
}
|
||||
|
||||
// then force download
|
||||
session.downloadKeys(listOf(session.myUserId), true, object : MatrixCallback<MXUsersDevicesMap<CryptoDeviceInfo>> {
|
||||
session.cryptoService().downloadKeys(listOf(session.myUserId), true, object : MatrixCallback<MXUsersDevicesMap<CryptoDeviceInfo>> {
|
||||
override fun onSuccess(data: MXUsersDevicesMap<CryptoDeviceInfo>) {
|
||||
setState {
|
||||
copy(
|
||||
cryptoDevices = Success(session.getUserDevices(session.myUserId))
|
||||
cryptoDevices = Success(session.cryptoService().getUserDevices(session.myUserId))
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -172,7 +172,7 @@ class DevicesViewModel @AssistedInject constructor(@Assisted initialState: Devic
|
||||
}
|
||||
|
||||
private fun handleVerify(action: DevicesAction.VerifyMyDevice) {
|
||||
val txID = session.getVerificationService().requestKeyVerification(supportedVerificationMethods, session.myUserId, listOf(action.deviceId))
|
||||
val txID = session.cryptoService().verificationService().requestKeyVerification(supportedVerificationMethods, session.myUserId, listOf(action.deviceId))
|
||||
_viewEvents.post(DevicesViewEvents.ShowVerifyDevice(
|
||||
session.myUserId,
|
||||
txID.transactionId
|
||||
@ -187,7 +187,7 @@ class DevicesViewModel @AssistedInject constructor(@Assisted initialState: Devic
|
||||
}
|
||||
|
||||
private fun handleRename(action: DevicesAction.Rename) {
|
||||
session.setDeviceName(action.deviceId, action.newName, object : MatrixCallback<Unit> {
|
||||
session.cryptoService().setDeviceName(action.deviceId, action.newName, object : MatrixCallback<Unit> {
|
||||
override fun onSuccess(data: Unit) {
|
||||
setState {
|
||||
copy(
|
||||
@ -222,7 +222,7 @@ class DevicesViewModel @AssistedInject constructor(@Assisted initialState: Devic
|
||||
)
|
||||
}
|
||||
|
||||
session.deleteDevice(deviceId, object : MatrixCallback<Unit> {
|
||||
session.cryptoService().deleteDevice(deviceId, object : MatrixCallback<Unit> {
|
||||
override fun onFailure(failure: Throwable) {
|
||||
var isPasswordRequestFound = false
|
||||
|
||||
@ -284,7 +284,7 @@ class DevicesViewModel @AssistedInject constructor(@Assisted initialState: Devic
|
||||
)
|
||||
}
|
||||
|
||||
session.deleteDeviceWithUserPassword(currentDeviceId, _currentSession, action.password, object : MatrixCallback<Unit> {
|
||||
session.cryptoService().deleteDeviceWithUserPassword(currentDeviceId, _currentSession, action.password, object : MatrixCallback<Unit> {
|
||||
override fun onSuccess(data: Unit) {
|
||||
_currentDeviceId = null
|
||||
_currentSession = null
|
||||
|
@ -30,36 +30,36 @@ class SignOutViewModel @Inject constructor(private val session: Session) : ViewM
|
||||
var keysBackupState = MutableLiveData<KeysBackupState>()
|
||||
|
||||
init {
|
||||
session.getKeysBackupService().addListener(this)
|
||||
session.cryptoService().keysBackupService().addListener(this)
|
||||
|
||||
keysBackupState.value = session.getKeysBackupService().state
|
||||
keysBackupState.value = session.cryptoService().keysBackupService().state
|
||||
}
|
||||
|
||||
/**
|
||||
* Safe way to get the current KeysBackup version
|
||||
*/
|
||||
fun getCurrentBackupVersion(): String {
|
||||
return session.getKeysBackupService().currentBackupVersion ?: ""
|
||||
return session.cryptoService().keysBackupService().currentBackupVersion ?: ""
|
||||
}
|
||||
|
||||
/**
|
||||
* Safe way to get the number of keys to backup
|
||||
*/
|
||||
fun getNumberOfKeysToBackup(): Int {
|
||||
return session.inboundGroupSessionsCount(false)
|
||||
return session.cryptoService().inboundGroupSessionsCount(false)
|
||||
}
|
||||
|
||||
/**
|
||||
* Safe way to tell if there are more keys on the server
|
||||
*/
|
||||
fun canRestoreKeys(): Boolean {
|
||||
return session.getKeysBackupService().canRestoreKeys()
|
||||
return session.cryptoService().keysBackupService().canRestoreKeys()
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
super.onCleared()
|
||||
|
||||
session.getKeysBackupService().removeListener(this)
|
||||
session.cryptoService().keysBackupService().removeListener(this)
|
||||
}
|
||||
|
||||
override fun onStateChange(newState: KeysBackupState) {
|
||||
@ -68,7 +68,7 @@ class SignOutViewModel @Inject constructor(private val session: Session) : ViewM
|
||||
|
||||
fun refreshRemoteStateIfNeeded() {
|
||||
if (keysBackupState.value == KeysBackupState.Disabled) {
|
||||
session.getKeysBackupService().checkAndStartKeysBackup()
|
||||
session.cryptoService().keysBackupService().checkAndStartKeysBackup()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user