From 386c03ec6d663c39f697ce4f5387e57c3a1d94b3 Mon Sep 17 00:00:00 2001 From: Jordan Sherer Date: Fri, 1 Feb 2019 19:29:52 -0500 Subject: [PATCH] Added callsign blacklist to complement the whitelist --- Configuration.cpp | 9 +++++++++ Configuration.hpp | 1 + Configuration.ui | 14 ++++++++++++-- mainwindow.cpp | 7 +++++++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/Configuration.cpp b/Configuration.cpp index d6d9572..764866c 100644 --- a/Configuration.cpp +++ b/Configuration.cpp @@ -590,6 +590,7 @@ private: QString my_grid_; QStringList my_groups_; QStringList auto_whitelist_; + QStringList auto_blacklist_; QString my_qth_; QString cq_; QString reply_; @@ -971,6 +972,10 @@ QSet Configuration::auto_whitelist() const { return QSet::fromList(m_->auto_whitelist_); } +QSet Configuration::auto_blacklist() const { + return QSet::fromList(m_->auto_blacklist_); +} + QString Configuration::my_qth() const { auto qth = m_->my_qth_; @@ -1359,6 +1364,7 @@ void Configuration::impl::initialize_models () ui_->activity_aging_spin_box->setValue(activity_aging_); ui_->groups_line_edit->setText(my_groups_.join(", ")); ui_->auto_whitelist_line_edit->setText(auto_whitelist_.join(", ")); + ui_->auto_blacklist_line_edit->setText(auto_blacklist_.join(", ")); ui_->qth_message_line_edit->setText (my_qth_.toUpper()); ui_->cq_message_line_edit->setText(cq_.toUpper()); ui_->reply_message_line_edit->setText (reply_.toUpper()); @@ -1503,6 +1509,7 @@ void Configuration::impl::read_settings () my_grid_ = settings_->value ("MyGrid", QString {}).toString (); my_groups_ = settings_->value("MyGroups", QStringList{}).toStringList(); auto_whitelist_ = settings_->value("AutoWhitelist", QStringList{}).toStringList(); + auto_blacklist_ = settings_->value("AutoBlacklist", QStringList{}).toStringList(); callsign_aging_ = settings_->value ("CallsignAging", 0).toInt (); activity_aging_ = settings_->value ("ActivityAging", 2).toInt (); my_qth_ = settings_->value("MyQTH", QString {}).toString(); @@ -1763,6 +1770,7 @@ void Configuration::impl::write_settings () settings_->setValue ("MyGrid", my_grid_); settings_->setValue ("MyGroups", my_groups_); settings_->setValue ("AutoWhitelist", auto_whitelist_); + settings_->setValue ("AutoBlacklist", auto_blacklist_); settings_->setValue ("MyQTH", my_qth_); settings_->setValue ("CQMessage", cq_); settings_->setValue ("Reply", reply_); @@ -2354,6 +2362,7 @@ void Configuration::impl::accept () my_grid_ = ui_->grid_line_edit->text ().toUpper(); my_groups_ = splitGroups(ui_->groups_line_edit->text().toUpper().trimmed(), true); auto_whitelist_ = splitCalls(ui_->auto_whitelist_line_edit->text().toUpper().trimmed()); + auto_blacklist_ = splitCalls(ui_->auto_blacklist_line_edit->text().toUpper().trimmed()); cq_ = ui_->cq_message_line_edit->text().toUpper(); reply_ = ui_->reply_message_line_edit->text().toUpper(); my_qth_ = ui_->qth_message_line_edit->text().toUpper(); diff --git a/Configuration.hpp b/Configuration.hpp index 56119af..d0ae899 100644 --- a/Configuration.hpp +++ b/Configuration.hpp @@ -101,6 +101,7 @@ public: void addGroup(QString const &group); void removeGroup(QString const &group); QSet auto_whitelist() const; + QSet auto_blacklist() const; int activity_aging() const; int callsign_aging() const; QString my_qth () const; diff --git a/Configuration.ui b/Configuration.ui index 21364b0..85e7048 100644 --- a/Configuration.ui +++ b/Configuration.ui @@ -277,9 +277,9 @@ 0 - -133 + 0 724 - 586 + 617 @@ -567,6 +567,16 @@ text message. + + + + Never autoreply to these callsigns (comma separated): + + + + + + diff --git a/mainwindow.cpp b/mainwindow.cpp index a0fdc62..e5d531f 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -9730,6 +9730,13 @@ void MainWindow::processCommandActivity() { continue; } + // we'll never reply to a blacklisted callsign or base callsign + auto blacklist = m_config.auto_blacklist(); + if(!blacklist.isEmpty() && (blacklist.contains(d.from) || blacklist.contains(Radio::base_callsign(d.from)))){ + qDebug() << "skipping command for blacklist" << d.from; + continue; + } + // if this is an allcall, check to make sure we haven't replied to their allcall recently (in the past ten minutes) // that way we never get spammed by allcalls at too high of a frequency if (isAllCall && m_txAllcallCommandCache.contains(d.from) && m_txAllcallCommandCache[d.from]->secsTo(now) / 60 < 10) {