Implemented version checking on files.js8call.com, a configuration option for doing that on startup, and a menu item in the Help menu for checking it at will.

This commit is contained in:
Jordan Sherer 2019-03-31 14:36:40 -04:00
parent 82a0cdd0cf
commit 0bd7a74103
6 changed files with 127 additions and 31 deletions

View File

@ -628,6 +628,7 @@ private:
qint32 RxBandwidth_; qint32 RxBandwidth_;
double degrade_; double degrade_;
double txDelay_; double txDelay_;
bool check_for_updates_;
bool id_after_73_; bool id_after_73_;
bool tx_qsy_allowed_; bool tx_qsy_allowed_;
bool spot_to_reporting_networks_; bool spot_to_reporting_networks_;
@ -750,6 +751,7 @@ qint32 Configuration::aggressive() const {return m_->aggressive_;}
double Configuration::degrade() const {return m_->degrade_;} double Configuration::degrade() const {return m_->degrade_;}
double Configuration::txDelay() const {return m_->txDelay_;} double Configuration::txDelay() const {return m_->txDelay_;}
qint32 Configuration::RxBandwidth() const {return m_->RxBandwidth_;} qint32 Configuration::RxBandwidth() const {return m_->RxBandwidth_;}
bool Configuration::check_for_updates() const { return m_->check_for_updates_; }
bool Configuration::id_after_73 () const {return m_->id_after_73_;} bool Configuration::id_after_73 () const {return m_->id_after_73_;}
bool Configuration::tx_qsy_allowed () const {return m_->tx_qsy_allowed_;} bool Configuration::tx_qsy_allowed () const {return m_->tx_qsy_allowed_;}
bool Configuration::spot_to_reporting_networks () const bool Configuration::spot_to_reporting_networks () const
@ -1400,6 +1402,7 @@ void Configuration::impl::initialize_models ()
ui_->sound_cq_path_display_label->setText(sound_cq_path_); ui_->sound_cq_path_display_label->setText(sound_cq_path_);
ui_->sound_dm_path_display_label->setText(sound_dm_path_); ui_->sound_dm_path_display_label->setText(sound_dm_path_);
ui_->sound_am_path_display_label->setText(sound_am_path_); ui_->sound_am_path_display_label->setText(sound_am_path_);
ui_->checkForUpdates_checkBox->setChecked (check_for_updates_);
ui_->CW_id_after_73_check_box->setChecked (id_after_73_); ui_->CW_id_after_73_check_box->setChecked (id_after_73_);
ui_->tx_qsy_check_box->setChecked (tx_qsy_allowed_); ui_->tx_qsy_check_box->setChecked (tx_qsy_allowed_);
ui_->psk_reporter_check_box->setChecked (spot_to_reporting_networks_); ui_->psk_reporter_check_box->setChecked (spot_to_reporting_networks_);
@ -1677,6 +1680,7 @@ void Configuration::impl::read_settings ()
monitor_off_at_startup_ = settings_->value ("MonitorOFF", false).toBool (); monitor_off_at_startup_ = settings_->value ("MonitorOFF", false).toBool ();
monitor_last_used_ = settings_->value ("MonitorLastUsed", false).toBool (); monitor_last_used_ = settings_->value ("MonitorLastUsed", false).toBool ();
spot_to_reporting_networks_ = settings_->value ("PSKReporter", true).toBool (); spot_to_reporting_networks_ = settings_->value ("PSKReporter", true).toBool ();
check_for_updates_ = settings_->value("CheckForUpdates", true).toBool();
id_after_73_ = settings_->value ("After73", false).toBool (); id_after_73_ = settings_->value ("After73", false).toBool ();
tx_qsy_allowed_ = settings_->value ("TxQSYAllowed", false).toBool (); tx_qsy_allowed_ = settings_->value ("TxQSYAllowed", false).toBool ();
use_dynamic_info_ = settings_->value ("AutoGrid", false).toBool (); use_dynamic_info_ = settings_->value ("AutoGrid", false).toBool ();
@ -1849,6 +1853,7 @@ void Configuration::impl::write_settings ()
settings_->setValue ("MonitorOFF", monitor_off_at_startup_); settings_->setValue ("MonitorOFF", monitor_off_at_startup_);
settings_->setValue ("MonitorLastUsed", monitor_last_used_); settings_->setValue ("MonitorLastUsed", monitor_last_used_);
settings_->setValue ("PSKReporter", spot_to_reporting_networks_); settings_->setValue ("PSKReporter", spot_to_reporting_networks_);
settings_->setValue ("CheckForUpdates", check_for_updates_);
settings_->setValue ("After73", id_after_73_); settings_->setValue ("After73", id_after_73_);
settings_->setValue ("TxQSYAllowed", tx_qsy_allowed_); settings_->setValue ("TxQSYAllowed", tx_qsy_allowed_);
settings_->setValue ("Macros", macros_.stringList ()); settings_->setValue ("Macros", macros_.stringList ());
@ -2381,6 +2386,7 @@ void Configuration::impl::accept ()
aggressive_ = ui_->sbAggressive->value (); aggressive_ = ui_->sbAggressive->value ();
degrade_ = ui_->sbDegrade->value (); degrade_ = ui_->sbDegrade->value ();
RxBandwidth_ = ui_->sbBandwidth->value (); RxBandwidth_ = ui_->sbBandwidth->value ();
check_for_updates_ = ui_->checkForUpdates_checkBox->isChecked();
id_after_73_ = ui_->CW_id_after_73_check_box->isChecked (); id_after_73_ = ui_->CW_id_after_73_check_box->isChecked ();
tx_qsy_allowed_ = ui_->tx_qsy_check_box->isChecked (); tx_qsy_allowed_ = ui_->tx_qsy_check_box->isChecked ();
transmit_directed_ = ui_->transmit_directed_check_box->isChecked(); transmit_directed_ = ui_->transmit_directed_check_box->isChecked();

View File

@ -118,6 +118,7 @@ public:
qint32 RxBandwidth() const; qint32 RxBandwidth() const;
double degrade() const; double degrade() const;
double txDelay() const; double txDelay() const;
bool check_for_updates() const;
bool id_after_73 () const; bool id_after_73 () const;
bool tx_qsy_allowed () const; bool tx_qsy_allowed () const;
bool spot_to_reporting_networks () const; bool spot_to_reporting_networks () const;

View File

@ -23,7 +23,7 @@
<string>Select tab to change configuration parameters.</string> <string>Select tab to change configuration parameters.</string>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>3</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="general_tab"> <widget class="QWidget" name="general_tab">
<attribute name="title"> <attribute name="title">
@ -63,7 +63,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>738</width> <width>738</width>
<height>453</height> <height>448</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
@ -278,8 +278,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>615</width> <width>726</width>
<height>646</height> <height>631</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_26"> <layout class="QVBoxLayout" name="verticalLayout_26">
@ -394,6 +394,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="checkForUpdates_checkBox">
<property name="text">
<string>Check for software updates at startup</string>
</property>
</widget>
</item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_9"> <layout class="QHBoxLayout" name="horizontalLayout_9">
<item> <item>
@ -918,8 +925,8 @@ text message.</string>
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>718</width> <width>285</width>
<height>435</height> <height>397</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_27"> <layout class="QVBoxLayout" name="verticalLayout_27">
@ -1339,8 +1346,8 @@ a few, particularly some Kenwood rigs, require it).</string>
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>237</width> <width>257</width>
<height>467</height> <height>427</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_28"> <layout class="QVBoxLayout" name="verticalLayout_28">
@ -1767,8 +1774,8 @@ radio interface behave as expected.</string>
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>760</width> <width>267</width>
<height>502</height> <height>302</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_29"> <layout class="QVBoxLayout" name="verticalLayout_29">
@ -2080,8 +2087,8 @@ both here.</string>
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>746</width> <width>572</width>
<height>525</height> <height>498</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_30"> <layout class="QVBoxLayout" name="verticalLayout_30">
@ -2543,8 +2550,8 @@ for assessing propagation and system performance.</string>
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>760</width> <width>498</width>
<height>502</height> <height>321</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_31"> <layout class="QVBoxLayout" name="verticalLayout_31">
@ -3121,8 +3128,8 @@ QListView::item:hover {
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>738</width> <width>280</width>
<height>378</height> <height>201</height>
</rect> </rect>
</property> </property>
<layout class="QGridLayout" name="gridLayout_15"> <layout class="QGridLayout" name="gridLayout_15">
@ -3376,8 +3383,8 @@ QListView::item:hover {
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>233</width> <width>236</width>
<height>253</height> <height>258</height>
</rect> </rect>
</property> </property>
<layout class="QGridLayout" name="gridLayout_5"> <layout class="QGridLayout" name="gridLayout_5">
@ -3580,8 +3587,8 @@ QListView::item:hover {
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>277</width> <width>288</width>
<height>93</height> <height>96</height>
</rect> </rect>
</property> </property>
<layout class="QGridLayout" name="gridLayout_8"> <layout class="QGridLayout" name="gridLayout_8">
@ -4190,11 +4197,11 @@ soundcard changes</string>
</connections> </connections>
<buttongroups> <buttongroups>
<buttongroup name="CAT_stop_bits_button_group"/> <buttongroup name="CAT_stop_bits_button_group"/>
<buttongroup name="CAT_data_bits_button_group"/>
<buttongroup name="TX_mode_button_group"/> <buttongroup name="TX_mode_button_group"/>
<buttongroup name="CAT_handshake_button_group"/> <buttongroup name="CAT_handshake_button_group"/>
<buttongroup name="split_mode_button_group"/>
<buttongroup name="PTT_method_button_group"/> <buttongroup name="PTT_method_button_group"/>
<buttongroup name="TX_audio_source_button_group"/> <buttongroup name="TX_audio_source_button_group"/>
<buttongroup name="CAT_data_bits_button_group"/>
<buttongroup name="split_mode_button_group"/>
</buttongroups> </buttongroups>
</ui> </ui>

View File

@ -12,6 +12,9 @@
#include <QRegExp> #include <QRegExp>
#include <QRegularExpression> #include <QRegularExpression>
#include <QDesktopServices> #include <QDesktopServices>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QUrl> #include <QUrl>
#include <QStandardPaths> #include <QStandardPaths>
#include <QDir> #include <QDir>
@ -1638,15 +1641,81 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
if (!m_valid) throw std::runtime_error {"Fatal initialization exception"}; if (!m_valid) throw std::runtime_error {"Fatal initialization exception"};
} }
void MainWindow::checkVersion(){ QPair<QPair<int, int>, int> splitVersion(QString v){
auto m = new QNetworkAccessManager(this); int hyphenPos = v.lastIndexOf("-");
connect(m, &QNetworkAccessManager::finished, this, [this](QNetworkReply * reply){ if(hyphenPos >= 0){
if(reply->error()) return; v = v.left(hyphenPos);
}
QString content = reply->readAll(); QVector<int> intSegs;
qDebug() << "version" << content; foreach(QString seg, v.split(".")){
bool ok = false;
int i = seg.toInt(&ok);
if(!ok){
break;
}
intSegs.append(i);
}
int len = intSegs.count();
QPair<QPair<int, int>, int> tuple;
if(len > 0){
tuple.first.first = intSegs.at(0);
}
if(len > 1){
tuple.first.second = intSegs.at(1);
}
if(len > 2){
tuple.second = intSegs.at(2);
}
return tuple;
}
void MainWindow::checkVersion(bool alertOnUpToDate){
auto m = new QNetworkAccessManager(this);
connect(m, &QNetworkAccessManager::finished, this, [this, alertOnUpToDate](QNetworkReply * reply){
if(reply->error()){
qDebug() << "Checking for Updates Error:" << reply->errorString();
return;
}
QString content = reply->readAll().trimmed();
auto currentVersion = splitVersion(version());
auto networkVersion = splitVersion(content);
qDebug() << "Checking Version" << currentVersion << "with" << networkVersion;
if(currentVersion < networkVersion){
SelfDestructMessageBox * m = new SelfDestructMessageBox(60,
"New Updates Available",
QString("A new version (%1) of JS8Call is now available. Please see js8call.com for more details.").arg(content),
QMessageBox::Information,
QMessageBox::Ok,
QMessageBox::Ok,
false,
this);
m->show();
} else if(alertOnUpToDate){
SelfDestructMessageBox * m = new SelfDestructMessageBox(60,
"No Updates Available",
QString("Your version (%1) of JS8Call is up-to-date.").arg(version()),
QMessageBox::Information,
QMessageBox::Ok,
QMessageBox::Ok,
false,
this);
m->show();
}
}); });
qDebug() << "Checking for Updates...";
QUrl url("http://files.js8call.com/version.txt"); QUrl url("http://files.js8call.com/version.txt");
QNetworkRequest r(url); QNetworkRequest r(url);
m->get(r); m->get(r);
@ -1654,7 +1723,9 @@ void MainWindow::checkVersion(){
void MainWindow::checkStartupWarnings () void MainWindow::checkStartupWarnings ()
{ {
checkVersion(); if(m_config.check_for_updates()){
checkVersion(false);
}
ensureCallsignSet(false); ensureCallsignSet(false);
} }
@ -2598,6 +2669,10 @@ void MainWindow::on_menuControl_aboutToShow(){
#endif #endif
} }
void MainWindow::on_actionCheck_for_Updates_triggered(){
checkVersion(true);
}
void MainWindow::on_actionEnable_Spotting_toggled(bool checked){ void MainWindow::on_actionEnable_Spotting_toggled(bool checked){
ui->spotButton->setChecked(checked); ui->spotButton->setChecked(checked);
} }

View File

@ -177,6 +177,7 @@ private slots:
void on_tx5_currentTextChanged (QString const&); void on_tx5_currentTextChanged (QString const&);
void on_tx6_editingFinished(); void on_tx6_editingFinished();
void on_menuControl_aboutToShow(); void on_menuControl_aboutToShow();
void on_actionCheck_for_Updates_triggered();
void on_actionEnable_Spotting_toggled(bool checked); void on_actionEnable_Spotting_toggled(bool checked);
void on_actionEnable_Auto_Reply_toggled(bool checked); void on_actionEnable_Auto_Reply_toggled(bool checked);
void on_menuWindow_aboutToShow(); void on_menuWindow_aboutToShow();
@ -413,7 +414,7 @@ private slots:
void on_cbCQTx_toggled(bool b); void on_cbCQTx_toggled(bool b);
void splash_done (); void splash_done ();
void on_measure_check_box_stateChanged (int); void on_measure_check_box_stateChanged (int);
void checkVersion(); void checkVersion(bool alertOnUpToDate);
void checkStartupWarnings (); void checkStartupWarnings ();
void clearCallsignSelected(); void clearCallsignSelected();
void refreshTextDisplay(); void refreshTextDisplay();

View File

@ -4613,7 +4613,7 @@ list. The list can be maintained in Settings (F2).</string>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>994</width> <width>994</width>
<height>22</height> <height>25</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuFile"> <widget class="QMenu" name="menuFile">
@ -4688,6 +4688,7 @@ list. The list can be maintained in Settings (F2).</string>
<addaction name="actionShort_list_of_add_on_prefixes_and_suffixes"/> <addaction name="actionShort_list_of_add_on_prefixes_and_suffixes"/>
<addaction name="actionCopyright_Notice"/> <addaction name="actionCopyright_Notice"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionCheck_for_Updates"/>
<addaction name="actionAbout"/> <addaction name="actionAbout"/>
</widget> </widget>
<widget class="QMenu" name="menuMode"> <widget class="QMenu" name="menuMode">
@ -5677,6 +5678,11 @@ list. The list can be maintained in Settings (F2).</string>
<string>Show Message Inbox...</string> <string>Show Message Inbox...</string>
</property> </property>
</action> </action>
<action name="actionCheck_for_Updates">
<property name="text">
<string>Check for Updates</string>
</property>
</action>
</widget> </widget>
<layoutdefault spacing="6" margin="11"/> <layoutdefault spacing="6" margin="11"/>
<customwidgets> <customwidgets>