mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 11:19:04 +01:00
Merge branch 'social-backup-poc' of https://code.briarproject.org/briar/briar into social-backup-poc
* 'social-backup-poc' of https://code.briarproject.org/briar/briar: Inject social backup eager singletons when Briar core is created.
This commit is contained in:
@@ -48,7 +48,7 @@ import org.briarproject.briar.api.android.DozeWatchdog;
|
||||
import org.briarproject.briar.api.android.LockManager;
|
||||
import org.briarproject.briar.api.android.ScreenFilterMonitor;
|
||||
import org.briarproject.briar.api.test.TestAvatarCreator;
|
||||
import org.briarproject.briar.socialbackup.AndroidSocialBackupModule;
|
||||
import org.briarproject.briar.socialbackup.AndroidDarkCrystalModule;
|
||||
|
||||
import java.io.File;
|
||||
import java.security.GeneralSecurityException;
|
||||
@@ -83,7 +83,7 @@ import static org.briarproject.briar.android.TestingConstants.IS_DEBUG_BUILD;
|
||||
SettingsModule.class,
|
||||
DevReportModule.class,
|
||||
ContactListModule.class,
|
||||
AndroidSocialBackupModule.class,
|
||||
AndroidDarkCrystalModule.class,
|
||||
// below need to be within same scope as ViewModelProvider.Factory
|
||||
ForumModule.class,
|
||||
GroupListModule.class,
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.briarproject.briar.socialbackup;
|
||||
|
||||
import org.briarproject.briar.android.socialbackup.DarkCrystalImpl;
|
||||
import org.briarproject.briar.api.socialbackup.DarkCrystal;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
@Module
|
||||
public class AndroidDarkCrystalModule {
|
||||
|
||||
@Provides
|
||||
DarkCrystal darkCrystal(DarkCrystalImpl darkCrystal) {
|
||||
return darkCrystal;
|
||||
}
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
package org.briarproject.briar.socialbackup;
|
||||
|
||||
import org.briarproject.bramble.api.client.ClientHelper;
|
||||
import org.briarproject.bramble.api.contact.ContactManager;
|
||||
import org.briarproject.bramble.api.data.MetadataEncoder;
|
||||
import org.briarproject.bramble.api.lifecycle.LifecycleManager;
|
||||
import org.briarproject.bramble.api.sync.validation.ValidationManager;
|
||||
import org.briarproject.bramble.api.system.Clock;
|
||||
import org.briarproject.bramble.api.versioning.ClientVersioningManager;
|
||||
import org.briarproject.briar.android.socialbackup.DarkCrystalImpl;
|
||||
import org.briarproject.briar.api.conversation.ConversationManager;
|
||||
import org.briarproject.briar.api.socialbackup.DarkCrystal;
|
||||
import org.briarproject.briar.api.socialbackup.SocialBackupManager;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
import static org.briarproject.briar.api.socialbackup.SocialBackupManager.CLIENT_ID;
|
||||
import static org.briarproject.briar.api.socialbackup.SocialBackupManager.MAJOR_VERSION;
|
||||
import static org.briarproject.briar.api.socialbackup.SocialBackupManager.MINOR_VERSION;
|
||||
|
||||
@Module
|
||||
public class AndroidSocialBackupModule {
|
||||
|
||||
public static class EagerSingletons {
|
||||
@Inject
|
||||
SocialBackupManager socialBackupManager;
|
||||
@Inject
|
||||
SocialBackupValidator socialBackupValidator;
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
SocialBackupManager socialBackupManager(
|
||||
LifecycleManager lifecycleManager,
|
||||
ContactManager contactManager,
|
||||
ValidationManager validationManager,
|
||||
ClientVersioningManager clientVersioningManager,
|
||||
SocialBackupManagerImpl socialBackupManager,
|
||||
ConversationManager conversationManager) {
|
||||
lifecycleManager.registerOpenDatabaseHook(socialBackupManager);
|
||||
contactManager.registerContactHook(socialBackupManager);
|
||||
validationManager.registerIncomingMessageHook(CLIENT_ID,
|
||||
MAJOR_VERSION, socialBackupManager);
|
||||
clientVersioningManager.registerClient(CLIENT_ID, MAJOR_VERSION,
|
||||
MINOR_VERSION, socialBackupManager);
|
||||
conversationManager.registerConversationClient(socialBackupManager);
|
||||
return socialBackupManager;
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
SocialBackupValidator socialBackupValidator(
|
||||
ValidationManager validationManager,
|
||||
ClientHelper clientHelper,
|
||||
MetadataEncoder metadataEncoder,
|
||||
Clock clock) {
|
||||
SocialBackupValidator validator =
|
||||
new SocialBackupValidator(clientHelper, metadataEncoder, clock);
|
||||
validationManager.registerMessageValidator(CLIENT_ID, MAJOR_VERSION,
|
||||
validator);
|
||||
return validator;
|
||||
}
|
||||
|
||||
@Provides
|
||||
BackupMetadataParser backupMetadataParser(
|
||||
BackupMetadataParserImpl backupMetadataParser) {
|
||||
return backupMetadataParser;
|
||||
}
|
||||
|
||||
@Provides
|
||||
BackupMetadataEncoder backupMetadataEncoder(
|
||||
BackupMetadataEncoderImpl backupMetadataEncoder) {
|
||||
return backupMetadataEncoder;
|
||||
}
|
||||
|
||||
@Provides
|
||||
BackupPayloadEncoder backupPayloadEncoder(
|
||||
BackupPayloadEncoderImpl backupPayloadEncoder) {
|
||||
return backupPayloadEncoder;
|
||||
}
|
||||
|
||||
@Provides
|
||||
MessageEncoder messageEncoder(MessageEncoderImpl messageEncoder) {
|
||||
return messageEncoder;
|
||||
}
|
||||
|
||||
@Provides
|
||||
MessageParser messageParser(MessageParserImpl messageParser) {
|
||||
return messageParser;
|
||||
}
|
||||
|
||||
@Provides
|
||||
DarkCrystal darkCrystal(DarkCrystalImpl darkCrystal) {
|
||||
return darkCrystal;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user