コード例 #1
0
 public TOTPEntryValidatorTests()
 {
     this._settingsMock = new Mock <ISettings>(MockBehavior.Strict);
     this._settingsMock.Setup(c => c.TOTPSettingsStringName).Returns("TOTP Settings");
     this._settingsMock.Setup(c => c.TOTPSeedStringName).Returns("TOTP Seed");
     this._sut   = new TOTPEntryValidator(_settingsMock.Object);
     this._entry = new PwEntry(true, false);
 }
コード例 #2
0
        /// <summary>
        /// Initialization of the plugin, adding menus, handlers and forms.
        /// </summary>
        /// <param name="host">Plugin host for access to KeePass functions.</param>
        /// <returns>Successful loading of the plugin, if not the plugin is removed.</returns>
        public override bool Initialize(IPluginHost host)
        {
            // Internalize Host Handle.
            if (host == null)
            {
                return(false);
            }

            PluginHost = host;

            Settings           = new Settings(host.CustomConfig);
            TOTPEntryValidator = new TOTPEntryValidator(Settings);

            _menuItemProvider = new MenuItemProvider(this, PluginHost);

            // Instantiate Help Form.
            _helpForm = new FormHelp();

            // Register events.
            PluginHost.MainWindow.Shown += MainWindow_Shown;

            // Register auto-type function.
            if (Settings.AutoTypeEnable)
            {
                SprEngine.FilterCompile += SprEngine_FilterCompile;
                SprEngine.FilterPlaceholderHints.Add(Settings.AutoTypeFieldName.ExtWithBrackets());
            }

            // List Column TOTP.
            columnProvider = new TrayTOTP_ColumnProvider(this);
            PluginHost.ColumnProviderPool.Add(columnProvider);

            // Refresh Timer.
            _liRefreshTimer.Interval = Settings.EntryListRefreshRate;
            _liRefreshTimer.Enabled  = true;
            _liRefreshTimer.Tick    += OnTimerTick;

            //Time Correction.
            TimeCorrectionProvider.Interval = Convert.ToInt16(Settings.TimeCorrectionRefreshTime);
            TimeCorrections = new TimeCorrectionCollection(Settings.TimeCorrectionEnable);
            TimeCorrections.AddRangeFromList(Settings.TimeCorrectionList);

            PluginHost.MainWindow.UIStateUpdated += MainWindow_UIStateUpdated;

            return(true);
        }