private void RegisterLocalServices() { ServiceContainer.Register <ILogService>("logService", new AndroidLogService()); // Note: This might cause a race condition. Investigate more. Task.Run(() => { FFImageLoading.Forms.Platform.CachedImageRenderer.Init(true); FFImageLoading.ImageService.Instance.Initialize(new FFImageLoading.Config.Configuration { FadeAnimationEnabled = false, FadeAnimationForCachedImages = false }); ZXing.Net.Mobile.Forms.Android.Platform.Init(); }); CrossFingerprint.SetCurrentActivityResolver(() => CrossCurrentActivity.Current.Activity); var preferencesStorage = new PreferencesStorageService(null); var documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); var liteDbStorage = new LiteDbStorageService(Path.Combine(documentsPath, "bitwarden.db")); var localizeService = new LocalizeService(); var broadcasterService = new BroadcasterService(); var messagingService = new MobileBroadcasterMessagingService(broadcasterService); var i18nService = new MobileI18nService(localizeService.GetCurrentCultureInfo()); var secureStorageService = new SecureStorageService(); var cryptoPrimitiveService = new CryptoPrimitiveService(); var mobileStorageService = new MobileStorageService(preferencesStorage, liteDbStorage); var deviceActionService = new DeviceActionService(mobileStorageService, messagingService, broadcasterService, () => ServiceContainer.Resolve <IEventService>("eventService")); var platformUtilsService = new MobilePlatformUtilsService(deviceActionService, messagingService, broadcasterService); var biometricService = new BiometricService(); ServiceContainer.Register <IBroadcasterService>("broadcasterService", broadcasterService); ServiceContainer.Register <IMessagingService>("messagingService", messagingService); ServiceContainer.Register <ILocalizeService>("localizeService", localizeService); ServiceContainer.Register <II18nService>("i18nService", i18nService); ServiceContainer.Register <ICryptoPrimitiveService>("cryptoPrimitiveService", cryptoPrimitiveService); ServiceContainer.Register <IStorageService>("storageService", mobileStorageService); ServiceContainer.Register <IStorageService>("secureStorageService", secureStorageService); ServiceContainer.Register <IDeviceActionService>("deviceActionService", deviceActionService); ServiceContainer.Register <IPlatformUtilsService>("platformUtilsService", platformUtilsService); ServiceContainer.Register <IBiometricService>("biometricService", biometricService); // Push #if FDROID ServiceContainer.Register <IPushNotificationListenerService>( "pushNotificationListenerService", new NoopPushNotificationListenerService()); ServiceContainer.Register <IPushNotificationService>( "pushNotificationService", new NoopPushNotificationService()); #else var notificationListenerService = new PushNotificationListenerService(); ServiceContainer.Register <IPushNotificationListenerService>( "pushNotificationListenerService", notificationListenerService); var androidPushNotificationService = new AndroidPushNotificationService( mobileStorageService, notificationListenerService); ServiceContainer.Register <IPushNotificationService>( "pushNotificationService", androidPushNotificationService); #endif }
public static void RegisterLocalServices() { if (ServiceContainer.Resolve <ILogService>("logService", true) == null) { ServiceContainer.Register <ILogService>("logService", new ConsoleLogService()); } var preferencesStorage = new PreferencesStorageService(AppGroupId); var appGroupContainer = new NSFileManager().GetContainerUrl(AppGroupId); var liteDbStorage = new LiteDbStorageService( Path.Combine(appGroupContainer.Path, "Library", "bitwarden.db")); liteDbStorage.InitAsync(); var localizeService = new LocalizeService(); var broadcasterService = new BroadcasterService(); var messagingService = new MobileBroadcasterMessagingService(broadcasterService); var i18nService = new MobileI18nService(localizeService.GetCurrentCultureInfo()); var secureStorageService = new KeyChainStorageService(AppId, AccessGroup, () => ServiceContainer.Resolve <IAppIdService>("appIdService").GetAppIdAsync()); var cryptoPrimitiveService = new CryptoPrimitiveService(); var mobileStorageService = new MobileStorageService(preferencesStorage, liteDbStorage); var deviceActionService = new DeviceActionService(mobileStorageService, messagingService); var platformUtilsService = new MobilePlatformUtilsService(deviceActionService, messagingService, broadcasterService); ServiceContainer.Register <IBroadcasterService>("broadcasterService", broadcasterService); ServiceContainer.Register <IMessagingService>("messagingService", messagingService); ServiceContainer.Register <ILocalizeService>("localizeService", localizeService); ServiceContainer.Register <II18nService>("i18nService", i18nService); ServiceContainer.Register <ICryptoPrimitiveService>("cryptoPrimitiveService", cryptoPrimitiveService); ServiceContainer.Register <IStorageService>("storageService", mobileStorageService); ServiceContainer.Register <IStorageService>("secureStorageService", secureStorageService); ServiceContainer.Register <IDeviceActionService>("deviceActionService", deviceActionService); ServiceContainer.Register <IPlatformUtilsService>("platformUtilsService", platformUtilsService); }
public Transaction[] TryBroadcast() { uint256[] knownBroadcasted = null; List <Transaction> broadcasted = new List <Transaction>(); try { broadcasted.AddRange(BroadcasterService.TryBroadcast(ref knownBroadcasted)); } catch (Exception ex) { Logs.Broadcasters.LogError("Exception on Broadcaster"); Logs.Broadcasters.LogError(ex.ToString()); } try { broadcasted.AddRange(TrustedBroadcasterService.TryBroadcast(ref knownBroadcasted)); } catch (Exception ex) { Logs.Broadcasters.LogError("Exception on TrustedBroadcaster"); Logs.Broadcasters.LogError(ex.ToString()); } return(broadcasted.ToArray()); }
static void InitServiceContainer() { var localizeService = new LocalizeService(); var i18nService = new CliI18nService(localizeService.GetCurrentCultureInfo()); ServiceContainer.Register <ILocalizeService>(nameof(localizeService), localizeService); ServiceContainer.Register <II18nService>(nameof(i18nService), i18nService); var broadcasterService = new BroadcasterService(); var messagingService = new CliBroadcasterMessagingService(broadcasterService); ServiceContainer.Register <IBroadcasterService>(nameof(broadcasterService), broadcasterService); ServiceContainer.Register <IMessagingService> (nameof(messagingService), messagingService); var platformUtilsService = new PlatformUtilsService(IdentityClientId); ServiceContainer.Register <IPlatformUtilsService>(nameof(platformUtilsService), platformUtilsService); //var storageService = new LiteDbStorageService("bwcli.db"); var storageService = new InsecureStorageService(); ServiceContainer.Register <IStorageService>(nameof(storageService), storageService); var secureStorageService = new SecureStorageService(); ServiceContainer.Register <IStorageService>(nameof(secureStorageService), secureStorageService); var cryptoPrimitiveService = new CryptoPrimitiveService(); ServiceContainer.Register <ICryptoPrimitiveService>(nameof(cryptoPrimitiveService), cryptoPrimitiveService); ServiceContainer.Init(CustomUserAgent); }
public static void RegisterLocalServices() { if (ServiceContainer.Resolve <INativeLogService>("nativeLogService", true) == null) { ServiceContainer.Register <INativeLogService>("nativeLogService", new ConsoleLogService()); } ILogger logger = null; if (ServiceContainer.Resolve <ILogger>("logger", true) == null) { #if DEBUG logger = DebugLogger.Instance; #else logger = Logger.Instance; #endif ServiceContainer.Register("logger", logger); } var preferencesStorage = new PreferencesStorageService(AppGroupId); var appGroupContainer = new NSFileManager().GetContainerUrl(AppGroupId); var liteDbStorage = new LiteDbStorageService( Path.Combine(appGroupContainer.Path, "Library", "bitwarden.db")); var localizeService = new LocalizeService(); var broadcasterService = new BroadcasterService(logger); var messagingService = new MobileBroadcasterMessagingService(broadcasterService); var i18nService = new MobileI18nService(localizeService.GetCurrentCultureInfo()); var secureStorageService = new KeyChainStorageService(AppId, AccessGroup, () => ServiceContainer.Resolve <IAppIdService>("appIdService").GetAppIdAsync()); var cryptoPrimitiveService = new CryptoPrimitiveService(); var mobileStorageService = new MobileStorageService(preferencesStorage, liteDbStorage); var stateService = new StateService(mobileStorageService, secureStorageService, messagingService); var stateMigrationService = new StateMigrationService(liteDbStorage, preferencesStorage, secureStorageService); var deviceActionService = new DeviceActionService(stateService, messagingService); var clipboardService = new ClipboardService(stateService); var platformUtilsService = new MobilePlatformUtilsService(deviceActionService, clipboardService, messagingService, broadcasterService); var biometricService = new BiometricService(mobileStorageService); var cryptoFunctionService = new PclCryptoFunctionService(cryptoPrimitiveService); var cryptoService = new CryptoService(stateService, cryptoFunctionService); var passwordRepromptService = new MobilePasswordRepromptService(platformUtilsService, cryptoService); ServiceContainer.Register <IBroadcasterService>("broadcasterService", broadcasterService); ServiceContainer.Register <IMessagingService>("messagingService", messagingService); ServiceContainer.Register <ILocalizeService>("localizeService", localizeService); ServiceContainer.Register <II18nService>("i18nService", i18nService); ServiceContainer.Register <ICryptoPrimitiveService>("cryptoPrimitiveService", cryptoPrimitiveService); ServiceContainer.Register <IStorageService>("storageService", mobileStorageService); ServiceContainer.Register <IStorageService>("secureStorageService", secureStorageService); ServiceContainer.Register <IStateService>("stateService", stateService); ServiceContainer.Register <IStateMigrationService>("stateMigrationService", stateMigrationService); ServiceContainer.Register <IDeviceActionService>("deviceActionService", deviceActionService); ServiceContainer.Register <IClipboardService>("clipboardService", clipboardService); ServiceContainer.Register <IPlatformUtilsService>("platformUtilsService", platformUtilsService); ServiceContainer.Register <IBiometricService>("biometricService", biometricService); ServiceContainer.Register <ICryptoFunctionService>("cryptoFunctionService", cryptoFunctionService); ServiceContainer.Register <ICryptoService>("cryptoService", cryptoService); ServiceContainer.Register <IPasswordRepromptService>("passwordRepromptService", passwordRepromptService); }
public void Start(CancellationToken cancellation) { _Stop = cancellation; new Thread(() => { while (true) { try { int lastHeight = 0; while (true) { _Stop.WaitHandle.WaitOne(5000); _Stop.ThrowIfCancellationRequested(); var height = BlockExplorerService.GetCurrentHeight(); if (height == lastHeight) { continue; } lastHeight = height; try { var transactions = BroadcasterService.TryBroadcast(); foreach (var tx in transactions) { Logger.LogInformation("Broadcaster broadcasted " + tx.GetHash()); } } catch (Exception ex) { Logger.LogError("Error while running Broadcaster: " + ex.Message); Logger.LogDebug(ex.StackTrace); } try { var transactions = TrustedBroadcasterService.TryBroadcast(); foreach (var tx in transactions) { Logger.LogInformation("TrustedBroadcaster broadcasted " + tx.GetHash()); } } catch (Exception ex) { Logger.LogError("Error while running TrustedBroadcaster: " + ex.Message); Logger.LogDebug(ex.StackTrace); } } } catch (OperationCanceledException) { return; } catch (Exception ex) { Logger.LogError("Uncatched exception in BroadcasterJob: " + ex.Message); Logger.LogDebug(ex.StackTrace); } } }).Start(); }
private void RegisterLocalServices() { Refractored.FabControl.Droid.FloatingActionButtonViewRenderer.Init(); // Note: This might cause a race condition. Investigate more. Task.Run(() => { FFImageLoading.Forms.Platform.CachedImageRenderer.Init(true); ZXing.Net.Mobile.Forms.Android.Platform.Init(); }); CrossFingerprint.SetCurrentActivityResolver(() => CrossCurrentActivity.Current.Activity); var preferencesStorage = new PreferencesStorageService(null); var documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); var liteDbStorage = new LiteDbStorageService(Path.Combine(documentsPath, "bitwarden.db")); liteDbStorage.InitAsync(); var localizeService = new LocalizeService(); var broadcasterService = new BroadcasterService(); var messagingService = new MobileBroadcasterMessagingService(broadcasterService); var i18nService = new MobileI18nService(localizeService.GetCurrentCultureInfo()); var secureStorageService = new SecureStorageService(); var cryptoPrimitiveService = new CryptoPrimitiveService(); var mobileStorageService = new MobileStorageService(preferencesStorage, liteDbStorage); var deviceActionService = new DeviceActionService(mobileStorageService, messagingService, broadcasterService); var platformUtilsService = new MobilePlatformUtilsService(deviceActionService, messagingService, broadcasterService); ServiceContainer.Register <IBroadcasterService>("broadcasterService", broadcasterService); ServiceContainer.Register <IMessagingService>("messagingService", messagingService); ServiceContainer.Register <ILocalizeService>("localizeService", localizeService); ServiceContainer.Register <II18nService>("i18nService", i18nService); ServiceContainer.Register <ICryptoPrimitiveService>("cryptoPrimitiveService", cryptoPrimitiveService); ServiceContainer.Register <IStorageService>("storageService", mobileStorageService); ServiceContainer.Register <IStorageService>("secureStorageService", secureStorageService); ServiceContainer.Register <IDeviceActionService>("deviceActionService", deviceActionService); ServiceContainer.Register <IPlatformUtilsService>("platformUtilsService", platformUtilsService); // Push #if FDROID container.RegisterSingleton <IPushNotificationListener, NoopPushNotificationListener>(); container.RegisterSingleton <IPushNotificationService, NoopPushNotificationService>(); #else var notificationListenerService = new PushNotificationListenerService(); ServiceContainer.Register <IPushNotificationListenerService>( "pushNotificationListenerService", notificationListenerService); var androidPushNotificationService = new AndroidPushNotificationService( mobileStorageService, notificationListenerService); ServiceContainer.Register <IPushNotificationService>( "pushNotificationService", androidPushNotificationService); #endif }
private void RegisterLocalServices() { ServiceContainer.Register <INativeLogService>("nativeLogService", new AndroidLogService()); #if FDROID var logger = new StubLogger(); #elif DEBUG var logger = DebugLogger.Instance; #else var logger = Logger.Instance; #endif ServiceContainer.Register("logger", logger); // Note: This might cause a race condition. Investigate more. Task.Run(() => { FFImageLoading.Forms.Platform.CachedImageRenderer.Init(true); FFImageLoading.ImageService.Instance.Initialize(new FFImageLoading.Config.Configuration { FadeAnimationEnabled = false, FadeAnimationForCachedImages = false, HttpClient = new HttpClient(new AndroidClientHandler() { AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate }) }); ZXing.Net.Mobile.Forms.Android.Platform.Init(); }); CrossFingerprint.SetCurrentActivityResolver(() => CrossCurrentActivity.Current.Activity); var preferencesStorage = new PreferencesStorageService(null); var documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); var liteDbStorage = new LiteDbStorageService(Path.Combine(documentsPath, "bitwarden.db")); var localizeService = new LocalizeService(); var broadcasterService = new BroadcasterService(logger); var messagingService = new MobileBroadcasterMessagingService(broadcasterService); var i18nService = new MobileI18nService(localizeService.GetCurrentCultureInfo()); var secureStorageService = new SecureStorageService(); var cryptoPrimitiveService = new CryptoPrimitiveService(); var mobileStorageService = new MobileStorageService(preferencesStorage, liteDbStorage); var stateService = new StateService(mobileStorageService, secureStorageService, messagingService); var stateMigrationService = new StateMigrationService(liteDbStorage, preferencesStorage, secureStorageService); var clipboardService = new ClipboardService(stateService); var deviceActionService = new DeviceActionService(clipboardService, stateService, messagingService, broadcasterService, () => ServiceContainer.Resolve <IEventService>("eventService")); var platformUtilsService = new MobilePlatformUtilsService(deviceActionService, clipboardService, messagingService, broadcasterService); var biometricService = new BiometricService(); var cryptoFunctionService = new PclCryptoFunctionService(cryptoPrimitiveService); var cryptoService = new CryptoService(stateService, cryptoFunctionService); var passwordRepromptService = new MobilePasswordRepromptService(platformUtilsService, cryptoService); ServiceContainer.Register <IBroadcasterService>("broadcasterService", broadcasterService); ServiceContainer.Register <IMessagingService>("messagingService", messagingService); ServiceContainer.Register <ILocalizeService>("localizeService", localizeService); ServiceContainer.Register <II18nService>("i18nService", i18nService); ServiceContainer.Register <ICryptoPrimitiveService>("cryptoPrimitiveService", cryptoPrimitiveService); ServiceContainer.Register <IStorageService>("storageService", mobileStorageService); ServiceContainer.Register <IStorageService>("secureStorageService", secureStorageService); ServiceContainer.Register <IStateService>("stateService", stateService); ServiceContainer.Register <IStateMigrationService>("stateMigrationService", stateMigrationService); ServiceContainer.Register <IClipboardService>("clipboardService", clipboardService); ServiceContainer.Register <IDeviceActionService>("deviceActionService", deviceActionService); ServiceContainer.Register <IPlatformUtilsService>("platformUtilsService", platformUtilsService); ServiceContainer.Register <IBiometricService>("biometricService", biometricService); ServiceContainer.Register <ICryptoFunctionService>("cryptoFunctionService", cryptoFunctionService); ServiceContainer.Register <ICryptoService>("cryptoService", cryptoService); ServiceContainer.Register <IPasswordRepromptService>("passwordRepromptService", passwordRepromptService); ServiceContainer.Register <IAvatarImageSourcePool>("avatarImageSourcePool", new AvatarImageSourcePool()); // Push #if FDROID ServiceContainer.Register <IPushNotificationListenerService>( "pushNotificationListenerService", new NoopPushNotificationListenerService()); ServiceContainer.Register <IPushNotificationService>( "pushNotificationService", new NoopPushNotificationService()); #else var notificationListenerService = new PushNotificationListenerService(); ServiceContainer.Register <IPushNotificationListenerService>( "pushNotificationListenerService", notificationListenerService); var androidPushNotificationService = new AndroidPushNotificationService( stateService, notificationListenerService); ServiceContainer.Register <IPushNotificationService>( "pushNotificationService", androidPushNotificationService); #endif }
private void RegisterLocalServices() { ServiceContainer.Register <ILogService>("logService", new AndroidLogService()); ServiceContainer.Register("settingsShim", new App.Migration.SettingsShim()); if (App.Migration.MigrationHelpers.NeedsMigration()) { ServiceContainer.Register <App.Migration.Abstractions.IOldSecureStorageService>( "oldSecureStorageService", new Migration.AndroidKeyStoreStorageService()); } Refractored.FabControl.Droid.FloatingActionButtonViewRenderer.Init(); // Note: This might cause a race condition. Investigate more. Task.Run(() => { FFImageLoading.Forms.Platform.CachedImageRenderer.Init(true); FFImageLoading.ImageService.Instance.Initialize(new FFImageLoading.Config.Configuration { FadeAnimationEnabled = false, FadeAnimationForCachedImages = false }); ZXing.Net.Mobile.Forms.Android.Platform.Init(); }); CrossFingerprint.SetCurrentActivityResolver(() => CrossCurrentActivity.Current.Activity); CrossFingerprint.SetDialogFragmentType <CustomFingerprintDialogFragment>(); var preferencesStorage = new PreferencesStorageService(null); var documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); var liteDbStorage = new LiteDbStorageService(Path.Combine(documentsPath, "bitwarden.db")); liteDbStorage.InitAsync(); var localizeService = new LocalizeService(); var broadcasterService = new BroadcasterService(); var messagingService = new MobileBroadcasterMessagingService(broadcasterService); var i18nService = new MobileI18nService(localizeService.GetCurrentCultureInfo()); var secureStorageService = new SecureStorageService(); var cryptoPrimitiveService = new CryptoPrimitiveService(); var mobileStorageService = new MobileStorageService(preferencesStorage, liteDbStorage); var deviceActionService = new DeviceActionService(mobileStorageService, messagingService, broadcasterService); var platformUtilsService = new MobilePlatformUtilsService(deviceActionService, messagingService, broadcasterService); ServiceContainer.Register <IBroadcasterService>("broadcasterService", broadcasterService); ServiceContainer.Register <IMessagingService>("messagingService", messagingService); ServiceContainer.Register <ILocalizeService>("localizeService", localizeService); ServiceContainer.Register <II18nService>("i18nService", i18nService); ServiceContainer.Register <ICryptoPrimitiveService>("cryptoPrimitiveService", cryptoPrimitiveService); ServiceContainer.Register <IStorageService>("storageService", mobileStorageService); ServiceContainer.Register <IStorageService>("secureStorageService", secureStorageService); ServiceContainer.Register <IDeviceActionService>("deviceActionService", deviceActionService); ServiceContainer.Register <IPlatformUtilsService>("platformUtilsService", platformUtilsService); // Push #if FDROID ServiceContainer.Register <IPushNotificationListenerService>( "pushNotificationListenerService", new NoopPushNotificationListenerService()); ServiceContainer.Register <IPushNotificationService>( "pushNotificationService", new NoopPushNotificationService()); #else var notificationListenerService = new PushNotificationListenerService(); ServiceContainer.Register <IPushNotificationListenerService>( "pushNotificationListenerService", notificationListenerService); var androidPushNotificationService = new AndroidPushNotificationService( mobileStorageService, notificationListenerService); ServiceContainer.Register <IPushNotificationService>( "pushNotificationService", androidPushNotificationService); #endif }