public static void loadConfig() { registerHotKey(); if (OtpTime.getTimeType() == OtpTimeType.CustomNtpServer) { OtpTime.pollCustomNtpServer(); } }
private void loadConfig() { textBoxHotKeySequence.Text = KeeOtp2Config.HotKeySequence; Keys hotKey = KeeOtp2Config.HotKeyKeys; hotKeyControlExGlobalHotkey.HotKey = hotKey; if (KeeOtp2Config.UseHotKey && hotKey != Keys.None) { checkBoxUseHotkey.Checked = true; textBoxHotKeySequence.Enabled = true; hotKeyControlExGlobalHotkey.Enabled = true; } else { checkBoxUseHotkey.Checked = false; textBoxHotKeySequence.Enabled = false; hotKeyControlExGlobalHotkey.Enabled = false; } radioButtonSystemTime.Checked = radioButtonFixedTimeOffset.Checked = numericUpDownFixedTimeOffset.Enabled = radioButtonCustomNtpServer.Checked = textBoxCustomNTPServerAddress.Enabled = false; switch (OtpTime.getTimeType()) { case OtpTimeType.SystemTime: radioButtonSystemTime.Checked = true; break; case OtpTimeType.FixedOffset: radioButtonFixedTimeOffset.Checked = true; numericUpDownFixedTimeOffset.Enabled = true; break; case OtpTimeType.CustomNtpServer: radioButtonCustomNtpServer.Checked = true; textBoxCustomNTPServerAddress.Enabled = true; OtpTime.pollCustomNtpServer(); break; default: radioButtonSystemTime.Checked = true; break; } numericUpDownFixedTimeOffset.Value = OtpTime.getFixedTimeOffset(); textBoxCustomNTPServerAddress.Text = OtpTime.getCustomNtpServer(); checkBoxOverrideBuiltInTime.Checked = OtpTime.getOverrideBuiltInTime(); }
// If built-in {TIMEOTP} placeholder is used, but KeeOtp1 Save Mode is used private void SprEngine_FilterCompilePre(object sender, SprEventArgs e) { if ((e.Context.Flags & SprCompileFlags.ExtActive) == SprCompileFlags.ExtActive) { string currentPlaceHolder = null; if (e.Text.IndexOf(BuiltInTotpPlaceHolder, StringComparison.InvariantCultureIgnoreCase) >= 0) { currentPlaceHolder = BuiltInTotpPlaceHolder; } else if (e.Text.IndexOf(BuiltInHotpPlaceHolder, StringComparison.InvariantCultureIgnoreCase) >= 0) { currentPlaceHolder = BuiltInHotpPlaceHolder; } if (!string.IsNullOrEmpty(currentPlaceHolder)) { PwEntry entry = e.Context.Entry; OtpAuthData data = OtpAuthUtils.loadData(entry); if (data != null) { if (!OtpAuthUtils.checkBuiltInMode(entry) || (OtpAuthUtils.checkEntry(entry) && OtpTime.getOverrideBuiltInTime() && (OtpTime.getTimeType() == OtpTimeType.FixedOffset || OtpTime.getTimeType() == OtpTimeType.CustomNtpServer)) || !data.Proprietary) { OtpBase otp = OtpAuthUtils.getOtp(data); if (data.Type == OtpType.Totp || data.Type == OtpType.Steam) { e.Text = StrUtil.ReplaceCaseInsensitive(e.Text, currentPlaceHolder, otp.getTotpString(OtpTime.getTime())); } else if (data.Type == OtpType.Hotp) { e.Text = StrUtil.ReplaceCaseInsensitive(e.Text, currentPlaceHolder, otp.getHotpString(data.Counter)); OtpAuthUtils.increaseHotpCounter(host, data, entry); } } } } } }