mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-01-01 13:58:32 +03:00
Small cleanup and format
This commit is contained in:
parent
d4090c4b0a
commit
54c3b4192e
1 changed files with 47 additions and 57 deletions
|
@ -228,6 +228,7 @@ internal class DefaultCryptoService @Inject constructor(
|
||||||
private val isStarted = AtomicBoolean(false)
|
private val isStarted = AtomicBoolean(false)
|
||||||
|
|
||||||
private var olmMachine: OlmMachine? = null
|
private var olmMachine: OlmMachine? = null
|
||||||
|
|
||||||
// The verification service.
|
// The verification service.
|
||||||
private var verificationService: RustVerificationService? = null
|
private var verificationService: RustVerificationService? = null
|
||||||
|
|
||||||
|
@ -361,7 +362,7 @@ internal class DefaultCryptoService @Inject constructor(
|
||||||
* devices.
|
* devices.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
suspend fun start() {
|
fun start() {
|
||||||
internalStart()
|
internalStart()
|
||||||
// Just update
|
// Just update
|
||||||
fetchDevicesList(NoOpMatrixCallback())
|
fetchDevicesList(NoOpMatrixCallback())
|
||||||
|
@ -383,7 +384,7 @@ internal class DefaultCryptoService @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun internalStart() {
|
private fun internalStart() {
|
||||||
if (isStarted.get() || isStarting.get()) {
|
if (isStarted.get() || isStarting.get()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -392,8 +393,8 @@ internal class DefaultCryptoService @Inject constructor(
|
||||||
try {
|
try {
|
||||||
setRustLogger()
|
setRustLogger()
|
||||||
val machine = OlmMachine(userId, deviceId!!, dataDir, deviceObserver)
|
val machine = OlmMachine(userId, deviceId!!, dataDir, deviceObserver)
|
||||||
this.olmMachine = machine
|
olmMachine = machine
|
||||||
this.verificationService = RustVerificationService(machine, this.sender)
|
verificationService = RustVerificationService(machine, this.sender)
|
||||||
Timber.v(
|
Timber.v(
|
||||||
"## CRYPTO | Successfully started up an Olm machine for " +
|
"## CRYPTO | Successfully started up an Olm machine for " +
|
||||||
"${userId}, ${deviceId}, identity keys: ${this.olmMachine?.identityKeys()}")
|
"${userId}, ${deviceId}, identity keys: ${this.olmMachine?.identityKeys()}")
|
||||||
|
@ -404,18 +405,8 @@ internal class DefaultCryptoService @Inject constructor(
|
||||||
// Open the store
|
// Open the store
|
||||||
cryptoStore.open()
|
cryptoStore.open()
|
||||||
|
|
||||||
runCatching {
|
|
||||||
}.fold(
|
|
||||||
{
|
|
||||||
isStarting.set(false)
|
isStarting.set(false)
|
||||||
isStarted.set(true)
|
isStarted.set(true)
|
||||||
},
|
|
||||||
{
|
|
||||||
isStarting.set(false)
|
|
||||||
isStarted.set(false)
|
|
||||||
Timber.e(it, "Start failed")
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -456,10 +447,8 @@ internal class DefaultCryptoService @Inject constructor(
|
||||||
// Let's initialize here as a workaround until we figure out if the
|
// Let's initialize here as a workaround until we figure out if the
|
||||||
// above conclusion is correct.
|
// above conclusion is correct.
|
||||||
if (verificationService == null) {
|
if (verificationService == null) {
|
||||||
runBlocking {
|
|
||||||
internalStart()
|
internalStart()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return verificationService!!
|
return verificationService!!
|
||||||
}
|
}
|
||||||
|
@ -800,7 +789,8 @@ internal class DefaultCryptoService @Inject constructor(
|
||||||
is Request.KeysClaim -> {
|
is Request.KeysClaim -> {
|
||||||
claimKeys(request)
|
claimKeys(request)
|
||||||
}
|
}
|
||||||
else -> {}
|
else -> {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1022,7 +1012,7 @@ internal class DefaultCryptoService @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
when(request) {
|
when (request) {
|
||||||
is Request.ToDevice -> {
|
is Request.ToDevice -> {
|
||||||
sendToDevice(request)
|
sendToDevice(request)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue