From b94485be758b90be8c88bf441ea6f466fa6054c7 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 18 Apr 2019 10:40:57 -0400 Subject: [PATCH] register services on android --- src/Android/MainApplication.cs | 20 ++++++++++------- src/Core/Utilities/ServiceContainer.cs | 30 +++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/src/Android/MainApplication.cs b/src/Android/MainApplication.cs index 638550c8f..8deb40488 100644 --- a/src/Android/MainApplication.cs +++ b/src/Android/MainApplication.cs @@ -42,17 +42,21 @@ namespace Bit.Droid var liteDbStorage = new LiteDbStorageService(Path.Combine(documentsPath, "bitwarden.db")); var deviceActionService = new DeviceActionService(); var localizeService = new LocalizeService(); + var messagingService = new MobileMessagingService(); + var i18nService = new MobileI18nService(localizeService.GetCurrentCultureInfo()); + var secureStorageService = new SecureStorageService(); + var cryptoPrimitiveService = new CryptoPrimitiveService(); + var mobileStorageService = new MobileStorageService(preferencesStorage, liteDbStorage); + var platformUtilsService = new MobilePlatformUtilsService(deviceActionService); + ServiceContainer.Register("messagingService", messagingService); ServiceContainer.Register("localizeService", localizeService); - ServiceContainer.Register("i18nService", - new MobileI18nService(localizeService.GetCurrentCultureInfo())); - ServiceContainer.Register("cryptoPrimitiveService", new CryptoPrimitiveService()); - ServiceContainer.Register("storageService", - new MobileStorageService(preferencesStorage, liteDbStorage)); - ServiceContainer.Register("secureStorageService", new SecureStorageService()); + ServiceContainer.Register("i18nService", i18nService); + ServiceContainer.Register("cryptoPrimitiveService", cryptoPrimitiveService); + ServiceContainer.Register("storageService", mobileStorageService); + ServiceContainer.Register("secureStorageService", secureStorageService); ServiceContainer.Register("deviceActionService", deviceActionService); - ServiceContainer.Register("platformUtilsService", - new MobilePlatformUtilsService(deviceActionService)); + ServiceContainer.Register("platformUtilsService", platformUtilsService); } } } \ No newline at end of file diff --git a/src/Core/Utilities/ServiceContainer.cs b/src/Core/Utilities/ServiceContainer.cs index e9d276aed..74e90a56c 100644 --- a/src/Core/Utilities/ServiceContainer.cs +++ b/src/Core/Utilities/ServiceContainer.cs @@ -23,6 +23,8 @@ namespace Bit.Core.Utilities var storageService = Resolve("storageService"); var secureStorageService = Resolve("secureStorageService"); var cryptoPrimitiveService = Resolve("cryptoPrimitiveService"); + var i18nService = Resolve("i18nService"); + var messagingService = Resolve("messagingService"); var stateService = new StateService(); var cryptoFunctionService = new PclCryptoFunctionService(cryptoPrimitiveService); @@ -31,14 +33,40 @@ namespace Bit.Core.Utilities var apiService = new ApiService(tokenService, platformUtilsService, (bool expired) => Task.FromResult(0)); var appIdService = new AppIdService(storageService); var userService = new UserService(storageService, tokenService); + var settingsService = new SettingsService(userService, storageService); + var cipherService = new CipherService(cryptoService, userService, settingsService, apiService, + storageService, i18nService); + var folderService = new FolderService(cryptoService, userService, apiService, storageService, + i18nService, cipherService); + var collectionService = new CollectionService(cryptoService, userService, storageService, i18nService); + // TODO: lock service + var syncService = new SyncService(userService, apiService, settingsService, folderService, + cipherService, cryptoService, collectionService, storageService, messagingService); + var passwordGenerationService = new PasswordGenerationService(cryptoService, storageService, + cryptoFunctionService); + var totpService = new TotpService(storageService, cryptoFunctionService); + var authService = new AuthService(cryptoService, apiService, userService, tokenService, appIdService, + i18nService, platformUtilsService, messagingService); + // TODO: export service + var auditService = new AuditService(cryptoFunctionService, apiService); + // TODO: notification and env services Register("stateService", stateService); Register("cryptoFunctionService", cryptoFunctionService); Register("cryptoService", cryptoService); Register("tokenService", tokenService); - Register("apiService", apiService); // TODO: interface + Register("apiService", apiService); Register("appIdService", appIdService); Register("userService", userService); + Register("settingsService", settingsService); + Register("cipherService", cipherService); + Register("folderService", folderService); + Register("collectionService", collectionService); + Register("syncService", syncService); + Register("passwordGenerationService", passwordGenerationService); + Register("totpService", totpService); + Register("authService", authService); + Register("auditService", auditService); } public static void Register(string serviceName, T obj)