/// <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); }