Added callsign blacklist to complement the whitelist

This commit is contained in:
Jordan Sherer 2019-02-01 19:29:52 -05:00
parent 11bced9372
commit 386c03ec6d
4 changed files with 29 additions and 2 deletions

View File

@ -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<QString> Configuration::auto_whitelist() const {
return QSet<QString>::fromList(m_->auto_whitelist_);
}
QSet<QString> Configuration::auto_blacklist() const {
return QSet<QString>::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();

View File

@ -101,6 +101,7 @@ public:
void addGroup(QString const &group);
void removeGroup(QString const &group);
QSet<QString> auto_whitelist() const;
QSet<QString> auto_blacklist() const;
int activity_aging() const;
int callsign_aging() const;
QString my_qth () const;

View File

@ -277,9 +277,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-133</y>
<y>0</y>
<width>724</width>
<height>586</height>
<height>617</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_26">
@ -567,6 +567,16 @@ text message.</string>
<item row="2" column="1">
<widget class="QLineEdit" name="auto_whitelist_line_edit"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Never autoreply to these callsigns (comma separated):</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="auto_blacklist_line_edit"/>
</item>
</layout>
</widget>
</item>

View File

@ -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) {