Skip to content
Snippets Groups Projects
Commit 749372bd authored by Kamal Bramwell's avatar Kamal Bramwell
Browse files

Move CrustDataSource to BackupService interface

parent 03a1fef7
No related branches found
No related tags found
No related merge requests found
package io.xxlabs.messenger.backup.bindings
import bindings.UserDiscovery
import io.xxlabs.messenger.backup.cloud.crust.CrustDataSource
import io.xxlabs.messenger.backup.data.restore.RestoreLogger
import io.xxlabs.messenger.bindings.wrapper.contact.ContactWrapperBase
interface BackupService {
fun initializeCrustIntegration(userDiscovery: UserDiscovery, receptionRsaPrivKey: ByteArray)
/**
* Exposes upload and restore functions to/from Crust storage.
*/
val crustApi: CrustDataSource
val backupFilePath: String
/**
......@@ -13,6 +17,8 @@ interface BackupService {
*/
val restoreLogger: RestoreLogger
fun initializeCrustIntegration(userDiscovery: UserDiscovery, receptionRsaPrivKey: ByteArray)
/**
* Set a [BackupTaskCallback] to be notified whenever a new backup file is created.
*/
......
package io.xxlabs.messenger.backup.bindings
import bindings.UserDiscovery
import io.xxlabs.messenger.backup.cloud.crust.BindingsCrustMediator
import io.xxlabs.messenger.backup.data.restore.RestoreLogger
import io.xxlabs.messenger.bindings.listeners.MessageReceivedListener
import io.xxlabs.messenger.bindings.wrapper.contact.ContactWrapperBase
......@@ -29,11 +30,16 @@ class BindingsBackupMediator @Inject constructor(
private val restoreHandler =
BindingsRestoreHandler(preferences, daoRepo, messageReceivedListener, backupHandler)
override val crustApi = BindingsCrustMediator()
override fun initializeCrustIntegration(
userDiscovery: UserDiscovery,
receptionRsaPrivKey: ByteArray
) {
crustApi.apply {
udManager = userDiscovery
receptionRsaPrivateKey = receptionRsaPrivKey
}
}
override val backupFilePath: String
......
......@@ -13,7 +13,6 @@ class BindingsCrustMediator(
var receptionRsaPrivateKey: ByteArray = byteArrayOf()
) : CrustDataSource {
override suspend fun uploadBackup(path: String): Result<ByteArray> {
return try {
udManager?.let {
......
......@@ -14,12 +14,10 @@ abstract class BackupLocationRepository(
backupService: BackupService,
) : AccountBackupDataSource {
protected val crustApi = BindingsCrustMediator()
protected val googleDrive = GoogleDrive.getInstance(backupService, preferences)
protected val dropbox = Dropbox.getInstance(backupService, preferences)
protected val sftp = Sftp.getInstance(backupService, preferences)
protected val crust = Crust.getInstance(backupService, preferences, crustApi)
protected val crust = Crust.getInstance(backupService, preferences, backupService.crustApi)
override val locations: List<AccountBackup> = listOf(
googleDrive,
......
package io.xxlabs.messenger.backup.data.backup
import bindings.UserDiscovery
import io.xxlabs.messenger.backup.bindings.BackupService
import io.xxlabs.messenger.backup.data.BackupLocationRepository
import io.xxlabs.messenger.backup.model.AccountBackup
......@@ -16,16 +15,6 @@ class BackupMediator @Inject constructor(
BackupService by backupService,
BackupTaskPublisher by backupTaskPublisher
{
override fun initializeCrustIntegration(
userDiscovery: UserDiscovery,
receptionRsaPrivKey: ByteArray
) {
crustApi.apply {
udManager = userDiscovery
receptionRsaPrivateKey = receptionRsaPrivKey
}
}
private val settingsHandler: BackupPreferencesDelegate by lazy {
BackupPreferencesDelegate(preferences, this)
}
......
package io.xxlabs.messenger.backup.data.backup
interface BackupPreferencesRepository {
var name: String
var isBackupEnabled: Boolean
var isGoogleDriveEnabled: Boolean
var isDropboxEnabled: Boolean
......
......@@ -27,7 +27,6 @@ abstract class BasePreferences : BackupPreferencesRepository, NotificationPrefer
abstract var currentNotificationsTokenId: String
abstract var notificationsTokenId: String
abstract var userId: String
abstract var name: String
//Settings
abstract var areNotificationsOn: Boolean
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment