Add initial Steam TOTP support
* Add the concept of custom TOTP encoders, each with potential for custom code alphabet, length, step interval and code direction (i.e. reversed) * Select custom encoder via overload of the digits field of a loaded entry * Allow selection of custom encoders via the "TOTP Settings" field's size, as currently done by KeeTrayTOTP for Steam. Use "S" for the short name of the Steam custom encoder * Allow selection of custom encoders via the "otp" field by appending a "&encoder=<name>" field to the URL query. For example, "&encoder=steam" * Update TOTP set-up dialog to permit selection between (default, steam, custom) settings.
This commit is contained in:
@@ -35,7 +35,9 @@ SetupTotpDialog::SetupTotpDialog(DatabaseWidget* parent, Entry* entry)
|
||||
|
||||
connect(m_ui->buttonBox, SIGNAL(rejected()), SLOT(close()));
|
||||
connect(m_ui->buttonBox, SIGNAL(accepted()), SLOT(setupTotp()));
|
||||
connect(m_ui->customSettingsCheckBox, SIGNAL(toggled(bool)), SLOT(toggleCustom(bool)));
|
||||
connect(m_ui->radioDefault, SIGNAL(toggled(bool)), SLOT(toggleDefault(bool)));
|
||||
connect(m_ui->radioSteam, SIGNAL(toggled(bool)), SLOT(toggleSteam(bool)));
|
||||
connect(m_ui->radioCustom, SIGNAL(toggled(bool)), SLOT(toggleCustom(bool)));
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +45,9 @@ void SetupTotpDialog::setupTotp()
|
||||
{
|
||||
quint8 digits;
|
||||
|
||||
if (m_ui->radio8Digits->isChecked()) {
|
||||
if (m_ui->radioSteam->isChecked()) {
|
||||
digits = QTotp::ENCODER_STEAM;
|
||||
} else if (m_ui->radio8Digits->isChecked()) {
|
||||
digits = 8;
|
||||
} else {
|
||||
digits = 6;
|
||||
@@ -56,6 +60,22 @@ void SetupTotpDialog::setupTotp()
|
||||
close();
|
||||
}
|
||||
|
||||
void SetupTotpDialog::toggleDefault(bool status)
|
||||
{
|
||||
if (status) {
|
||||
setStep(QTotp::defaultStep);
|
||||
setDigits(QTotp::defaultDigits);
|
||||
}
|
||||
}
|
||||
|
||||
void SetupTotpDialog::toggleSteam(bool status)
|
||||
{
|
||||
if (status) {
|
||||
setStep(QTotp::defaultStep);
|
||||
setDigits(QTotp::ENCODER_STEAM);
|
||||
}
|
||||
}
|
||||
|
||||
void SetupTotpDialog::toggleCustom(bool status)
|
||||
{
|
||||
m_ui->digitsLabel->setEnabled(status);
|
||||
@@ -72,13 +92,25 @@ void SetupTotpDialog::setSeed(QString value)
|
||||
m_ui->seedEdit->setText(value);
|
||||
}
|
||||
|
||||
void SetupTotpDialog::setSettings(quint8 digits) {
|
||||
quint8 step = m_ui->stepSpinBox->value();
|
||||
|
||||
bool isDefault = ((step == QTotp::defaultStep) &&
|
||||
(digits == QTotp::defaultDigits));
|
||||
bool isSteam = (digits == QTotp::ENCODER_STEAM);
|
||||
|
||||
if (isSteam) {
|
||||
m_ui->radioSteam->setChecked(true);
|
||||
} else if (isDefault) {
|
||||
m_ui->radioDefault->setChecked(true);
|
||||
} else {
|
||||
m_ui->radioCustom->setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
void SetupTotpDialog::setStep(quint8 step)
|
||||
{
|
||||
m_ui->stepSpinBox->setValue(step);
|
||||
|
||||
if (step != QTotp::defaultStep) {
|
||||
m_ui->customSettingsCheckBox->setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
void SetupTotpDialog::setDigits(quint8 digits)
|
||||
@@ -90,13 +122,8 @@ void SetupTotpDialog::setDigits(quint8 digits)
|
||||
m_ui->radio6Digits->setChecked(true);
|
||||
m_ui->radio8Digits->setChecked(false);
|
||||
}
|
||||
|
||||
if (digits != QTotp::defaultDigits) {
|
||||
m_ui->customSettingsCheckBox->setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SetupTotpDialog::~SetupTotpDialog()
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user