/// <summary> /// Loads all required resources. /// </summary> protected void Initialise() { EmbeddedResources.Load(); CreateNotifyIcon(); LoadConfigFile(); #if DEBUG Log.Initialise(); #else if (ConfigManager.Config.CreateLogFile) { Log.Initialise(); } #endif Log.Send("------------------------------"); Log.Send($"Starting pass-winmenu {Version}"); Log.Send("------------------------------"); AssignHotkeys(hotkeys); var gpg = new GPG(); gpg.FindGpgInstallation(ConfigManager.Config.Gpg.GpgPath); if (ConfigManager.Config.Gpg.GpgAgent.Config.AllowConfigManagement) { gpg.UpdateAgentConfig(ConfigManager.Config.Gpg.GpgAgent.Config.Keys); } passwordManager = new PasswordManager(ConfigManager.Config.PasswordStore.Location, EncryptedFileExtension, gpg); passwordManager.PinentryFixEnabled = ConfigManager.Config.Gpg.PinentryFix; if (ConfigManager.Config.Git.UseGit) { try { if (ConfigManager.Config.Git.SyncMode == SyncMode.NativeGit) { git = new Git(ConfigManager.Config.PasswordStore.Location, ConfigManager.Config.Git.GitPath); } else { git = new Git(ConfigManager.Config.PasswordStore.Location); } } catch (RepositoryNotFoundException) { // Password store doesn't appear to be a Git repository. // Git support will be disabled. } catch (TypeInitializationException e) when(e.InnerException is DllNotFoundException) { ShowErrorWindow("The git2 DLL could not be found. Git support will be disabled."); } catch (Exception e) { ShowErrorWindow($"Failed to open the password store Git repository ({e.GetType().Name}: {e.Message}). Git support will be disabled."); } } }
/// <summary> /// Loads all required resources. /// </summary> private void Initialise() { #if DEBUG Log.Initialise(); #else if (ConfigManager.Config.CreateLogFile) { Log.Initialise(); } #endif // Load compiled-in resources. EmbeddedResources.Load(); Log.Send("------------------------------"); Log.Send($"Starting pass-winmenu {Version}"); Log.Send("------------------------------"); // Set the security protocol to TLS 1.2 only. // We only use this for update checking (Git push over HTTPS is not handled by .NET). ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; // Create the notification service first, so it's available if initialisation fails. notificationService = Notifications.Create(); // Now load the configuration options that we'll need // to continue initialising the rest of the applications. LoadConfigFile(); // Create the GPG wrapper. gpg = new GPG(); gpg.FindGpgInstallation(ConfigManager.Config.Gpg.GpgPath); if (ConfigManager.Config.Gpg.GpgAgent.Config.AllowConfigManagement) { gpg.UpdateAgentConfig(ConfigManager.Config.Gpg.GpgAgent.Config.Keys); } // Create the Git wrapper, if enabled. InitialiseGit(ConfigManager.Config.Git, ConfigManager.Config.PasswordStore.Location); // Initialise the internal password manager. passwordManager = new PasswordManager(ConfigManager.Config.PasswordStore.Location, EncryptedFileExtension, gpg); passwordManager.PinentryFixEnabled = ConfigManager.Config.Gpg.PinentryFix; clipboard = new ClipboardHelper(); dialogCreator = new DialogCreator(notificationService, passwordManager, git, gpg); InitialiseUpdateChecker(); actionDispatcher = new ActionDispatcher(notificationService, passwordManager, dialogCreator, clipboard, git, updateChecker); notificationService.AddMenuActions(actionDispatcher); // Assign our hotkeys. hotkeys = new HotkeyManager(); AssignHotkeys(hotkeys); }