Fixed #178: include callsign by default for all messages, including standard messages. Added an option in the configuration to revert to the original behavior of no identification

This commit is contained in:
Jordan Sherer 2019-05-27 11:30:30 -04:00
parent 6439395833
commit ce0aceb33c
6 changed files with 70 additions and 42 deletions

View File

@ -649,6 +649,7 @@ private:
bool clear_callsign_;
bool miles_;
bool hold_ptt_;
bool avoid_forced_identify_;
bool avoid_allcall_;
bool spellcheck_;
bool quick_call_;
@ -791,6 +792,7 @@ bool Configuration::ppfx() const {return m_->ppfx_;}
bool Configuration::clear_callsign () const {return m_->clear_callsign_;}
bool Configuration::miles () const {return m_->miles_;}
bool Configuration::hold_ptt() const {return m_->hold_ptt_;}
bool Configuration::avoid_forced_identify() const {return m_->avoid_forced_identify_;}
bool Configuration::avoid_allcall () const {return m_->avoid_allcall_;}
bool Configuration::set_avoid_allcall(bool avoid) {
if(m_->avoid_allcall_ != avoid){
@ -1434,7 +1436,8 @@ void Configuration::impl::initialize_models ()
ui_->clear_callsign_check_box->setChecked (clear_callsign_);
ui_->miles_check_box->setChecked (miles_);
ui_->hold_ptt_check_box->setChecked(hold_ptt_);
ui_->avoid_allcall_checkbox->setChecked(avoid_allcall_);
ui_->avoid_forced_identify_check_box->setChecked(avoid_forced_identify_);
ui_->avoid_allcall_check_box->setChecked(avoid_allcall_);
ui_->spellcheck_check_box->setChecked(spellcheck_);
ui_->quick_call_check_box->setChecked (quick_call_);
ui_->disable_TX_on_73_check_box->setChecked (disable_TX_on_73_);
@ -1752,6 +1755,7 @@ void Configuration::impl::read_settings ()
clear_callsign_ = settings_->value ("ClearCallGrid", false).toBool ();
miles_ = settings_->value ("Miles", false).toBool ();
hold_ptt_ = settings_->value ("HoldPTT", false).toBool();
avoid_forced_identify_ = settings_->value ("AvoidForcedIdentify", false).toBool ();
avoid_allcall_ = settings_->value ("AvoidAllcall", false).toBool ();
spellcheck_ = settings_->value ("Spellcheck", true).toBool();
quick_call_ = settings_->value ("QuickCall", false).toBool ();
@ -1895,6 +1899,7 @@ void Configuration::impl::write_settings ()
settings_->setValue ("ClearCallGrid", clear_callsign_);
settings_->setValue ("Miles", miles_);
settings_->setValue ("HoldPTT", hold_ptt_);
settings_->setValue ("AvoidForcedIdentify", avoid_forced_identify_);
settings_->setValue ("AvoidAllcall", avoid_allcall_);
settings_->setValue ("Spellcheck", spellcheck_);
settings_->setValue ("QuickCall", quick_call_);
@ -2428,7 +2433,8 @@ void Configuration::impl::accept ()
clear_callsign_ = ui_->clear_callsign_check_box->isChecked ();
miles_ = ui_->miles_check_box->isChecked ();
hold_ptt_ = ui_->hold_ptt_check_box->isChecked();
avoid_allcall_ = ui_->avoid_allcall_checkbox->isChecked();
avoid_forced_identify_ = ui_->avoid_forced_identify_check_box->isChecked();
avoid_allcall_ = ui_->avoid_allcall_check_box->isChecked();
spellcheck_ = ui_->spellcheck_check_box->isChecked();
quick_call_ = ui_->quick_call_check_box->isChecked ();
disable_TX_on_73_ = ui_->disable_TX_on_73_check_box->isChecked ();

View File

@ -140,6 +140,7 @@ public:
bool clear_callsign () const;
bool miles () const;
bool hold_ptt() const;
bool avoid_forced_identify() const;
bool avoid_allcall () const;
bool set_avoid_allcall (bool avoid);
bool spellcheck() const;

View File

@ -23,7 +23,7 @@
<string>Select tab to change configuration parameters.</string>
</property>
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="general_tab">
<attribute name="title">
@ -146,7 +146,7 @@
</widget>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="avoid_allcall_checkbox">
<widget class="QCheckBox" name="avoid_allcall_check_box">
<property name="text">
<string>Do not participate in the @ALLCALL group</string>
</property>
@ -278,8 +278,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>615</width>
<height>750</height>
<width>724</width>
<height>779</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_26">
@ -387,6 +387,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="avoid_forced_identify_check_box">
<property name="text">
<string>Allow sending standard messages without callsign</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="spellcheck_check_box">
<property name="text">
@ -1429,9 +1436,9 @@ a few, particularly some Kenwood rigs, require it).</string>
<property name="geometry">
<rect>
<x>0</x>
<y>-102</y>
<y>0</y>
<width>718</width>
<height>496</height>
<height>490</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_28">
@ -4059,7 +4066,7 @@ soundcard changes</string>
<tabstop>callsign_line_edit</tabstop>
<tabstop>grid_line_edit</tabstop>
<tabstop>groups_line_edit</tabstop>
<tabstop>avoid_allcall_checkbox</tabstop>
<tabstop>avoid_allcall_check_box</tabstop>
<tabstop>cq_message_line_edit</tabstop>
<tabstop>reply_message_line_edit</tabstop>
<tabstop>info_message_line_edit</tabstop>

View File

@ -6279,11 +6279,14 @@ QList<QPair<QString, int>> MainWindow::buildMessageFrames(const QString &text){
QString mycall = m_config.my_callsign();
QString mygrid = m_config.my_grid().left(4);
bool forceIdentify = !m_config.avoid_forced_identify();
auto frames = Varicode::buildMessageFrames(
mycall,
mygrid,
selectedCall,
text);
text,
forceIdentify);
#if 0
qDebug() << "frames:";
@ -9382,24 +9385,18 @@ void MainWindow::refreshTextDisplay(){
#else
// prepare selected callsign for directed message
QString selectedCall = callsignSelected();
//qDebug() << "selected callsign for directed" << selectedCall;
// prepare compound
//bool compound = Varicode::isCompoundCallsign(/*Radio::is_compound_callsign(*/m_config.my_callsign());
QString mycall = m_config.my_callsign();
QString mygrid = m_config.my_grid().left(4);
//QString basecall = Radio::base_callsign(m_config.my_callsign());
//if(basecall != mycall){
// basecall = "<....>";
//}
bool forceIdentify = !m_config.avoid_forced_identify();
BuildMessageFramesThread *t = new BuildMessageFramesThread(
mycall,
//basecall,
mygrid,
//compound,
selectedCall,
text
text,
forceIdentify
);
connect(t, &BuildMessageFramesThread::finished, t, &QObject::deleteLater);

View File

@ -1733,19 +1733,23 @@ QList<QPair<QString, int>> Varicode::buildMessageFrames(
QString const& mycall,
QString const& mygrid,
QString const& selectedCall,
QString const& text
QString const& text,
bool forceIdentify
){
#define ALLOW_SEND_COMPOUND 1
#define ALLOW_SEND_COMPOUND_DIRECTED 1
#define AUTO_PREPEND_DIRECTED 1
#define AUTO_REMOVE_MYCALL 1
#define AUTO_PREPEND_DIRECTED_ALLOW_TEXT_CALLSIGNS 1
#define ALLOW_FORCE_IDENTIFY 1
bool mycallCompound = Varicode::isCompoundCallsign(mycall);
QList<QPair<QString, int>> frames;
QList<QPair<QString, int>> allFrames;
foreach(QString line, text.split(QRegExp("[\\r\\n]"), QString::SkipEmptyParts)){
QList<QPair<QString, int>> lineFrames;
// once we find a directed call, data encode the rest of the line.
bool hasDirected = false;
@ -1824,6 +1828,13 @@ QList<QPair<QString, int>> Varicode::buildMessageFrames(
qDebug() << "directed message to field is compound" << dirTo;
}
#if ALLOW_FORCE_IDENTIFY
// if we're sending a data message, then ensure our callsign is included automatically
bool isLikelyDataFrame = lineFrames.isEmpty() && selectedCall.isEmpty() && dirTo.isEmpty() && l == 0 && o == 0;
if(forceIdentify && isLikelyDataFrame && !line.contains(mycall)){
line = QString("%1: %2").arg(mycall).arg(line);
}
#endif
int m = 0;
QString datFrame = Varicode::packDataMessage(line, &m);
@ -1857,13 +1868,13 @@ QList<QPair<QString, int>> Varicode::buildMessageFrames(
}
if(useBcn){
frames.append({ frame, Varicode::JS8Call });
lineFrames.append({ frame, Varicode::JS8Call });
line = line.mid(l);
}
#if ALLOW_SEND_COMPOUND
if(useCmp){
frames.append({ frame, Varicode::JS8Call });
lineFrames.append({ frame, Varicode::JS8Call });
line = line.mid(o);
}
#endif
@ -1897,14 +1908,14 @@ QList<QPair<QString, int>> Varicode::buildMessageFrames(
QString deCompoundMessage = QString("`%1 %2").arg(mycall).arg(mygrid);
QString deCompoundFrame = Varicode::packCompoundMessage(deCompoundMessage, nullptr);
if(!deCompoundFrame.isEmpty()){
frames.append({ deCompoundFrame, Varicode::JS8Call });
lineFrames.append({ deCompoundFrame, Varicode::JS8Call });
}
// Followed, by a standard OR compound directed message...
QString dirCompoundMessage = QString("`%1%2%3").arg(dirTo).arg(dirCmd).arg(dirNum);
QString dirCompoundFrame = Varicode::packCompoundMessage(dirCompoundMessage, nullptr);
if(!dirCompoundFrame.isEmpty()){
frames.append({ dirCompoundFrame, Varicode::JS8Call });
lineFrames.append({ dirCompoundFrame, Varicode::JS8Call });
}
shouldUseStandardFrame = false;
}
@ -1912,7 +1923,7 @@ QList<QPair<QString, int>> Varicode::buildMessageFrames(
if(shouldUseStandardFrame) {
// otherwise, just send the standard directed frame
frames.append({ frame, Varicode::JS8Call });
lineFrames.append({ frame, Varicode::JS8Call });
}
line = line.mid(n);
@ -1940,30 +1951,34 @@ QList<QPair<QString, int>> Varicode::buildMessageFrames(
}
if(useDat){
frames.append({ frame, Varicode::JS8Call });
lineFrames.append({ frame, Varicode::JS8Call });
line = line.mid(m);
}
}
if(!lineFrames.isEmpty()){
lineFrames.first().second |= Varicode::JS8CallFirst;
lineFrames.last().second |= Varicode::JS8CallLast;
}
allFrames.append(lineFrames);
}
if(!frames.isEmpty()){
frames.first().second |= Varicode::JS8CallFirst;
frames.last().second |= Varicode::JS8CallLast;
}
return frames;
return allFrames;
}
BuildMessageFramesThread::BuildMessageFramesThread(
const QString &mycall,
BuildMessageFramesThread::BuildMessageFramesThread(const QString &mycall,
const QString &mygrid,
const QString &selectedCall,
const QString &text, QObject *parent):
const QString &text,
bool forceIdentify,
QObject *parent):
QThread(parent),
m_mycall{mycall},
m_mygrid{mygrid},
m_selectedCall{selectedCall},
m_text{text}
m_text{text},
m_forceIdentify{forceIdentify}
{
}
@ -1972,7 +1987,8 @@ void BuildMessageFramesThread::run(){
m_mycall,
m_mygrid,
m_selectedCall,
m_text
m_text,
m_forceIdentify
);
// TODO: jsherer - we wouldn't normally use decodedtext.h here... but it's useful for computing the actual frames transmitted.

View File

@ -156,12 +156,11 @@ public:
static QString packDataMessage(QString const& text, int *n);
static QString unpackDataMessage(QString const& text);
static QList<QPair<QString, int>> buildMessageFrames(
QString const& mycall,
static QList<QPair<QString, int>> buildMessageFrames(QString const& mycall,
QString const& mygrid,
QString const& selectedCall,
QString const& text
);
QString const& text,
bool forceIdentify);
};
@ -173,6 +172,7 @@ public:
QString const& mygrid,
QString const& selectedCall,
QString const& text,
bool forceIdentify,
QObject *parent=nullptr);
void run() override;
signals:
@ -183,6 +183,7 @@ private:
QString m_mygrid;
QString m_selectedCall;
QString m_text;
bool m_forceIdentify;
};
#endif // VARICODE_H