summaryrefslogtreecommitdiff
path: root/Configuration.cpp
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2024-09-30 22:36:11 +0200
committerChristoph Berg <myon@debian.org>2024-09-30 22:36:11 +0200
commit4320ce238aae1fe87fc9f379cdd816e9317885fa (patch)
treeb9d97364486fc8b7f79e8e877d5d491bb061740f /Configuration.cpp
parentfbaeaa72f63f22bf0b53d634f6809cbdfbb46c9f (diff)
New upstream version 2.7.0~rc7+repackupstream/2.7.0_rc7+repack
Diffstat (limited to 'Configuration.cpp')
-rwxr-xr-xConfiguration.cpp162
1 files changed, 139 insertions, 23 deletions
diff --git a/Configuration.cpp b/Configuration.cpp
index b1c3b80f..8ab99258 100755
--- a/Configuration.cpp
+++ b/Configuration.cpp
@@ -193,6 +193,7 @@
#include "models/FrequencyList.hpp"
#include "models/StationList.hpp"
#include "Network/NetworkServerLookup.hpp"
+#include "Network/FoxVerifier.hpp"
#include "widgets/MessageBox.hpp"
#include "validators/MaidenheadLocatorValidator.hpp"
#include "validators/CallsignValidator.hpp"
@@ -596,6 +597,9 @@ private:
Q_SLOT void on_rbARRL_Digi_clicked (bool);
Q_SLOT void on_cbSuperFox_clicked (bool);
Q_SLOT void on_cbContestName_clicked (bool);
+ Q_SLOT void on_cbOTP_clicked (bool);
+ Q_SLOT void on_cbShowOTP_clicked (bool);
+
void error_during_hamlib_download (QString const& reason);
void after_hamlib_downloaded();
void display_file_information();
@@ -607,7 +611,8 @@ private:
Q_SLOT void on_cbAutoLog_clicked(bool);
Q_SLOT void on_Field_Day_Exchange_textEdited (QString const&);
Q_SLOT void on_RTTY_Exchange_textEdited (QString const&);
- Q_SLOT void on_FoxKey_textEdited (QString const&);
+ Q_SLOT void on_OTPUrl_textEdited (QString const&);
+ Q_SLOT void on_OTPSeed_textEdited (QString const&);
Q_SLOT void on_Contest_Name_textEdited (QString const&);
// typenames used as arguments must match registered type names :(
@@ -706,7 +711,12 @@ private:
QString RTTY_exchange_;
QString Contest_Name_;
QString hamlib_backed_up_;
- QString FoxKey_;
+
+ QString OTPUrl_;
+ QString OTPSeed_;
+ bool OTPEnabled_;
+ bool ShowOTP_;
+ qint32 OTPinterval_;
qint32 id_interval_;
qint32 ntrials_;
@@ -978,6 +988,26 @@ void Configuration::invalidate_audio_output_device (QString /* error */)
m_->audio_output_device_ = QAudioDeviceInfo {};
}
+// OTP seed can be empty, in which case it is not used, or a valid 16 character base32 string.
+bool Configuration::validate_otp_seed(QString seed)
+{
+ if (seed.isEmpty())
+ {
+ return true;
+ }
+ if (seed.size() != 16)
+ {
+ return false;
+ }
+ for (QChar c: seed)
+ {
+ if (!QString(BASE32_CHARSET).contains(c))
+ {
+ return false;
+ }
+ }
+ return true;
+}
bool Configuration::valid_n1mm_info () const
{
// do very rudimentary checking on the n1mm server name and port number.
@@ -1016,11 +1046,6 @@ QString Configuration::RTTY_Exchange() const
return m_->RTTY_exchange_;
}
-QString Configuration::FoxKey() const
-{
- return m_->FoxKey_;
-}
-
QString Configuration::Contest_Name() const
{
return m_->Contest_Name_;
@@ -1084,6 +1109,31 @@ void Configuration::toggle_SF()
m_->write_settings();
}
+QString Configuration::OTPSeed() const
+{
+ return m_->OTPSeed_;
+}
+
+QString Configuration::OTPUrl() const
+{
+ return m_->OTPUrl_;
+}
+
+unsigned int Configuration::OTPinterval() const
+{
+ return m_->OTPinterval_;
+}
+
+bool Configuration::OTPEnabled() const
+{
+ return m_->OTPSeed_.size() == 16 && m_->OTPEnabled_;
+}
+
+bool Configuration::ShowOTP () const
+{
+ return m_->ShowOTP_;
+}
+
namespace
{
#if defined (Q_OS_MAC)
@@ -1254,6 +1304,8 @@ Configuration::impl::impl (Configuration * self, QNetworkAccessManager * network
ui_->add_macro_line_edit->setValidator (new QRegularExpressionValidator {message_alphabet, this});
ui_->Field_Day_Exchange->setValidator (new QRegularExpressionValidator {field_day_exchange_re, this});
ui_->RTTY_Exchange->setValidator (new QRegularExpressionValidator {RTTY_roundup_exchange_re, this});
+ QRegularExpression b32(QString("(^[") + QString(BASE32_CHARSET)+QString(BASE32_CHARSET).toLower() + QString("]{16}$)|(^$)"));
+ ui_->OTPSeed->setValidator(new QRegularExpressionValidator(b32, this));
//
// assign ids to radio buttons
@@ -1611,14 +1663,25 @@ void Configuration::impl::read_settings ()
my_grid_ = settings_->value ("MyGrid", QString {}).toString ();
FD_exchange_ = settings_->value ("Field_Day_Exchange",QString {}).toString ();
RTTY_exchange_ = settings_->value ("RTTY_Exchange",QString {}).toString ();
- FoxKey_ = settings_->value ("FoxKey",QString {}).toString ();
Contest_Name_ = settings_->value ("Contest_Name",QString {}).toString ();
ui_->Field_Day_Exchange->setText(FD_exchange_);
ui_->RTTY_Exchange->setText(RTTY_exchange_);
- ui_->FoxKey->setText(FoxKey_);
ui_->Contest_Name->setText(Contest_Name_);
hamlib_backed_up_ = settings_->value ("HamlibBackedUp",QString {}).toString ();
+ OTPinterval_ = settings_->value ("OTPinterval", 1).toUInt ();
+ OTPUrl_ = settings_->value ("OTPUrl", FoxVerifier::default_url()).toString ();
+ OTPSeed_ = settings_->value ("OTPSeed", QString {}).toString ();
+ OTPEnabled_ = settings_->value ("OTPEnabled", false).toBool ();
+ ShowOTP_ = settings_->value ("ShowOTP", false).toBool ();
+
+ ui_->sbOTPinterval->setValue(OTPinterval_);
+ ui_->OTPUrl->setText(OTPUrl_);
+ ui_->OTPSeed->setText(OTPSeed_);
+ ui_->cbOTP->setChecked(OTPEnabled_);
+ ui_->cbShowOTP->setChecked(ShowOTP_);
+
+
if (next_font_.fromString (settings_->value ("Font", QGuiApplication::font ().toString ()).toString ())
&& next_font_ != font_)
{
@@ -1844,7 +1907,6 @@ void Configuration::impl::write_settings ()
settings_->setValue ("MyGrid", my_grid_);
settings_->setValue ("Field_Day_Exchange", FD_exchange_);
settings_->setValue ("RTTY_Exchange", RTTY_exchange_);
- settings_->setValue ("FoxKey", FoxKey_);
settings_->setValue ("Contest_Name", Contest_Name_);
settings_->setValue ("Font", font_.toString ());
settings_->setValue ("DecodedTextFont", decoded_text_font_.toString ());
@@ -1945,6 +2007,11 @@ void Configuration::impl::write_settings ()
settings_->setValue ("AutoGrid", use_dynamic_grid_);
settings_->setValue ("highlight_DXcall", highlight_DXcall_);
settings_->setValue ("highlight_DXgrid", highlight_DXgrid_);
+ settings_->setValue ("OTPinterval", OTPinterval_);
+ settings_->setValue ("OTPUrl", OTPUrl_);
+ settings_->setValue ("OTPSeed", OTPSeed_);
+ settings_->setValue ("OTPEnabled", OTPEnabled_);
+ settings_->setValue ("ShowOTP", ShowOTP_);
settings_->sync ();
}
@@ -2312,7 +2379,6 @@ void Configuration::impl::accept ()
my_grid_ = ui_->grid_line_edit->text ();
FD_exchange_= ui_->Field_Day_Exchange->text ().toUpper ();
RTTY_exchange_= ui_->RTTY_Exchange->text ().toUpper ();
- FoxKey_= ui_->FoxKey->text().toUpper();
Contest_Name_= ui_->Contest_Name->text ().toUpper ();
spot_to_psk_reporter_ = ui_->psk_reporter_check_box->isChecked ();
psk_reporter_tcpip_ = ui_->psk_reporter_tcpip_check_box->isChecked ();
@@ -2362,6 +2428,11 @@ void Configuration::impl::accept ()
pwrBandTxMemory_ = ui_->checkBoxPwrBandTxMemory->isChecked ();
pwrBandTuneMemory_ = ui_->checkBoxPwrBandTuneMemory->isChecked ();
opCall_=ui_->opCallEntry->text();
+ OTPinterval_=ui_->sbOTPinterval->value();
+ OTPSeed_=ui_->OTPSeed->text();
+ OTPUrl_=ui_->OTPUrl->text();
+ OTPEnabled_=ui_->cbOTP->isChecked();
+ ShowOTP_=ui_->cbShowOTP->isChecked();
auto new_server = ui_->udp_server_line_edit->text ().trimmed ();
auto new_interfaces = get_selected_network_interfaces (ui_->udp_interfaces_combo_box);
@@ -3211,15 +3282,18 @@ void Configuration::impl::on_cbContestName_clicked (bool)
check_visibility ();
}
+void Configuration::impl::on_cbOTP_clicked(bool)
+{
+ check_visibility();
+}
+
+void Configuration::impl::on_cbShowOTP_clicked(bool)
+{
+ check_visibility();
+}
+
void Configuration::impl::check_visibility ()
{
- if (ui_->rbFox->isChecked() and ui_->cbSuperFox->isChecked() and ui_->gbSpecialOpActivity->isChecked()) {
- ui_->sfkey_label->setEnabled (true);
- ui_->FoxKey->setEnabled (true);
- } else {
- ui_->sfkey_label->setEnabled (false);
- ui_->FoxKey->setEnabled (false);
- }
if (ui_->rbField_Day->isChecked() and ui_->gbSpecialOpActivity->isChecked()) {
ui_->labFD->setEnabled (true);
ui_->Field_Day_Exchange->setEnabled (true);
@@ -3244,8 +3318,11 @@ void Configuration::impl::check_visibility ()
}
if ((ui_->rbFox->isChecked() or ui_->rbHound->isChecked()) and ui_->gbSpecialOpActivity->isChecked()) {
ui_->cbSuperFox->setEnabled (true);
+ ui_->cbOTP->setEnabled (true);
} else {
ui_->cbSuperFox->setEnabled (false);
+ ui_->cbOTP->setEnabled (false);
+ ui_->cbShowOTP->setEnabled(false);
}
if (!ui_->rbFox->isChecked() and !ui_->rbHound->isChecked() and !ui_->rbQ65pileup->isChecked()
and ui_->gbSpecialOpActivity->isChecked()) {
@@ -3253,6 +3330,50 @@ void Configuration::impl::check_visibility ()
} else {
ui_->cbContestName->setEnabled (false);
}
+ if (!ui_->cbOTP->isChecked() or !ui_->gbSpecialOpActivity->isChecked()) {
+ ui_->OTPSeed->setEnabled(false);
+ ui_->OTPUrl->setEnabled(false);
+ ui_->sbOTPinterval->setEnabled(false);
+ ui_->lblOTPSeed->setEnabled(false);
+ ui_->lblOTPUrl->setEnabled(false);
+ ui_->lblOTPEvery->setEnabled(false);
+ ui_->cbShowOTP->setEnabled(false);
+ } else {
+ if (ui_->rbHound->isChecked()) {
+ if (ui_->OTPUrl->text().isEmpty())
+ {
+ ui_->OTPUrl->setText(FoxVerifier::default_url());
+ }
+ ui_->OTPUrl->setEnabled(true);
+ ui_->lblOTPUrl->setEnabled(true);
+ ui_->cbShowOTP->setEnabled(true);
+ } else {
+ ui_->OTPUrl->setEnabled(false);
+ ui_->lblOTPUrl->setEnabled(false);
+ }
+ if (ui_->rbFox->isChecked()) {
+ ui_->sbOTPinterval->setEnabled(true);
+ ui_->OTPSeed->setEnabled(true);
+ ui_->lblOTPSeed->setEnabled(true);
+ ui_->lblOTPEvery->setEnabled(true);
+ ui_->cbShowOTP->setEnabled(false);
+ } else {
+ ui_->OTPSeed->setEnabled(false);
+ ui_->lblOTPSeed->setEnabled(false);
+ ui_->lblOTPEvery->setEnabled(false);
+ ui_->sbOTPinterval->setEnabled(false);
+ }
+ }
+}
+void Configuration::impl::on_OTPUrl_textEdited (QString const& url){
+ auto text = url;
+ if (text.size() == 0)
+ {
+ ui_->OTPUrl->setText(FoxVerifier::default_url());
+ }
+}
+void Configuration::impl::on_OTPSeed_textEdited (QString const& url){
+ ui_->OTPSeed->setText(url.toUpper());
}
void Configuration::impl::on_Field_Day_Exchange_textEdited (QString const& exchange)
@@ -3271,11 +3392,6 @@ void Configuration::impl::on_RTTY_Exchange_textEdited (QString const& exchange)
ui_->RTTY_Exchange->setText (exchange.toUpper ());
}
-void Configuration::impl::on_FoxKey_textEdited (QString const& ckey)
-{
- ui_->FoxKey->setText (ckey.toUpper ());
-}
-
void Configuration::impl::on_Contest_Name_textEdited (QString const& exchange)
{
ui_->Contest_Name->setText (exchange.toUpper ());