private void entryContextMenu_Opening(object sender, CancelEventArgs e) { PwEntry[] selectedEntries = this.host.MainWindow.GetSelectedEntries(); bool selectedOne = selectedEntries != null && selectedEntries.Length == 1; if (selectedOne) { bool configured = OtpAuthUtils.checkEntry(selectedEntries[0]); this.EntryContextMenuCopySubItem.Enabled = configured; this.EntryContextMenuShowOtpSubItem.Enabled = configured; } this.EntryContextMenuCopyItem.Enabled = this.EntryContextMenuMainItem.Enabled = this.EntryContextMenuConfigureSubItem.Enabled = this.EntryContextMenuCopySubItem.Enabled = this.EntryContextMenuShowOtpSubItem.Enabled = selectedOne; }
// 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); } } } } } }