/// <summary> /// Tells KeePass what to display in the column. /// </summary> /// <param name="columnName"></param> /// <param name="pe"></param> /// <returns>String displayed in the columns.</returns> public override string GetCellData(string columnName, PwEntry pe) { if (columnName == null) { throw new ArgumentNullException("columnName"); } if (pe == null) { throw new ArgumentNullException("pe"); } if (_plugin.SettingsCheck(pe) && _plugin.SeedCheck(pe)) { bool validInterval; bool validLength; bool validUrl; if (_plugin.SettingsValidate(pe, out validInterval, out validLength, out validUrl)) { string[] settings = _plugin.SettingsGet(pe); TOTPProvider totpGenerator = new TOTPProvider(settings, ref _plugin.TimeCorrections); if (_plugin.SeedValidate(pe)) { return(totpGenerator.GenerateByByte(Base32.Decode(_plugin.SeedGet(pe).ReadString().ExtWithoutSpaces())) + (_pluginHost.CustomConfig.GetBool(KeeTrayTOTPExt.setname_bool_TOTPColumnTimer_Visible, true) ? totpGenerator.Timer.ToString().ExtWithParenthesis().ExtWithSpaceBefore() : string.Empty)); } return(Localization.Strings.ErrorBadSeed); } return(Localization.Strings.ErrorBadSettings); } return(_plugin.SettingsCheck(pe) || _plugin.SeedCheck(pe) ? Localization.Strings.ErrorStorage : string.Empty); }
/// <summary> /// Tells KeePass what to display in the column. /// </summary> /// <param name="strColumnName"></param> /// <param name="pe"></param> /// <returns>String displayed in the columns.</returns> public override string GetCellData(string strColumnName, PwEntry pe) { if (strColumnName == null) { throw new ArgumentNullException("strColumnName"); } if (pe == null) { throw new ArgumentNullException("pe"); } if (plugin.SettingsCheck(pe) && plugin.SeedCheck(pe)) { bool ValidInterval; bool ValidLength; bool ValidUrl; if (plugin.SettingsValidate(pe, out ValidInterval, out ValidLength, out ValidUrl)) { string[] Settings = plugin.SettingsGet(pe); TOTPProvider TOTPGenerator = new TOTPProvider(Settings, ref plugin.TimeCorrections); if (plugin.SeedValidate(pe)) { return(TOTPGenerator.GenerateByByte( Base32.Decode(plugin.SeedGet(pe).ReadString().ExtWithoutSpaces())) + (m_host.CustomConfig.GetBool(setname_bool_TOTPColumnTimer_Visible, true) ? TOTPGenerator.Timer.ToString().ExtWithParenthesis().ExtWithSpaceBefore() : string.Empty)); } return(TrayTOTP_CustomColumn_Localization.strWarningBadSeed); } return(TrayTOTP_CustomColumn_Localization.strWarningBadSet); } return(plugin.SettingsCheck(pe) || plugin.SeedCheck(pe) ? TrayTOTP_CustomColumn_Localization.strWarningStorage : string.Empty); }
private void SetupTOTP_Load(object sender, EventArgs e) { GlobalWindowManager.AddWindow(this); Text = Localization.Strings.Setup + " - " + Localization.Strings.TrayTOTPPlugin; //Set form's name using constants. if (_plugin.SettingsCheck(_entry) || _plugin.SeedCheck(_entry)) //Checks the the totp settings exists. { string[] settings = _plugin.SettingsGet(_entry); //Gets the the existing totp settings. bool validInterval; bool validLength; bool validUrl; _plugin.SettingsValidate(_entry, out validInterval, out validLength, out validUrl); //Validates the settings value. if (validInterval) { NumericIntervalSetup.Value = Convert.ToDecimal(settings[0]); //Checks if interval is valid and sets interval numeric to the setting value. } if (validLength) //Checks if length is valid. { // Select the correct radio button RadioButtonLength6Setup.Checked = settings[1] == "6"; RadioButtonLength7Setup.Checked = settings[1] == "7"; RadioButtonLength8Setup.Checked = settings[1] == "8"; RadioButtonSteamFormatSetup.Checked = settings[1] == "S"; } if (validUrl) { ComboBoxTimeCorrectionSetup.Text = settings[2]; //Checks if url is valid and sets time correction textbox to the setting value. } DeleteSetupButton.Visible = true; //Shows the back button. HelpProviderSetup.SetHelpString(DeleteSetupButton, Localization.Strings.SetupDelete); } else { DeleteSetupButton.Visible = false; //Hides the back button. } if (_plugin.SeedCheck(_entry)) { TextBoxSeedSetup.Text = _plugin.SeedGet(_entry).ReadString(); //Checks if the seed exists and sets seed textbox to the seed value. } ComboBoxTimeCorrectionSetup.Items.AddRange(_plugin.TimeCorrections.ToComboBox()); //Gets existings time corrections and adds them in the combobox. HelpProviderSetup.SetHelpString(FinishSetupButton, Localization.Strings.SetupFinish); ErrorProviderSetup.SetError(TextBoxSeedSetup, string.Empty); ErrorProviderSetup.SetError(NumericIntervalSetup, string.Empty); ErrorProviderSetup.SetError(RadioButtonLength8Setup, string.Empty); ErrorProviderSetup.SetError(ComboBoxTimeCorrectionSetup, string.Empty); }
private void SetupTOTP_Load(object sender, EventArgs e) { Text = TrayTOTP_Plugin_Localization.strSetup + TrayTOTP_Plugin_Localization.strSpaceDashSpace + TrayTOTP_Plugin_Localization.strTrayTOTPPlugin; //Set form's name using constants. if (_plugin.SettingsCheck(entry) || _plugin.SeedCheck(entry)) //Checks the the totp settings exists. { string[] Settings = _plugin.SettingsGet(entry); //Gets the the existing totp settings. bool ValidInterval = false; bool ValidLength = false; bool ValidUrl = false; _plugin.SettingsValidate(entry, out ValidInterval, out ValidLength, out ValidUrl); //Validates the settings value. if (ValidInterval) { NumericIntervalSetup.Value = Convert.ToDecimal(Settings[0]); //Checks if interval is valid and sets interval numeric to the setting value. } if (ValidLength) //Checks if length is valid. { RadioButtonLength6Setup.Checked = Settings[1] == "6"; //Sets length radio 6 to checked if the setting value is 6. RadioButtonLength8Setup.Checked = Settings[1] == "8"; //Sets length radio 8 to checked if the setting value is 8. RadioButtonSteamFormatSetup.Checked = Settings[1] == "S"; //Sets format Steam to checked if the setting value is S. } if (ValidUrl) { ComboBoxTimeCorrectionSetup.Text = Settings[2]; //Checks if url is valid and sets time correction textbox to the setting value. } DeleteSetupButton.Visible = true; //Shows the back button. HelpProviderSetup.SetHelpString(DeleteSetupButton, SetupTOTP_Localization.SetupDelete); } else { DeleteSetupButton.Visible = false; //Hides the back button. } if (_plugin.SeedCheck(entry)) { TextBoxSeedSetup.Text = _plugin.SeedGet(entry).ReadString(); //Checks if the seed exists and sets seed textbox to the seed value. } ComboBoxTimeCorrectionSetup.Items.AddRange(_plugin.TimeCorrections.ToComboBox()); //Gets existings time corrections and adds them in the combobox. HelpProviderSetup.SetHelpString(FinishSetupButton, SetupTOTP_Localization.SetupFinnish); ErrorProviderSetup.SetError(TextBoxSeedSetup, string.Empty); ErrorProviderSetup.SetError(NumericIntervalSetup, string.Empty); ErrorProviderSetup.SetError(RadioButtonLength8Setup, string.Empty); ErrorProviderSetup.SetError(ComboBoxTimeCorrectionSetup, string.Empty); }