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_;
double degrade_;
double txDelay_;
bool check_for_updates_;
bool id_after_73_;
bool tx_qsy_allowed_;
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::txDelay() const {return m_->txDelay_;}
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::tx_qsy_allowed () const {return m_->tx_qsy_allowed_;}
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_dm_path_display_label->setText(sound_dm_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_->tx_qsy_check_box->setChecked (tx_qsy_allowed_);
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_last_used_ = settings_->value ("MonitorLastUsed", false).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 ();
tx_qsy_allowed_ = settings_->value ("TxQSYAllowed", 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 ("MonitorLastUsed", monitor_last_used_);
settings_->setValue ("PSKReporter", spot_to_reporting_networks_);
settings_->setValue ("CheckForUpdates", check_for_updates_);
settings_->setValue ("After73", id_after_73_);
settings_->setValue ("TxQSYAllowed", tx_qsy_allowed_);
settings_->setValue ("Macros", macros_.stringList ());
@ -2381,6 +2386,7 @@ void Configuration::impl::accept ()
aggressive_ = ui_->sbAggressive->value ();
degrade_ = ui_->sbDegrade->value ();
RxBandwidth_ = ui_->sbBandwidth->value ();
check_for_updates_ = ui_->checkForUpdates_checkBox->isChecked();
id_after_73_ = ui_->CW_id_after_73_check_box->isChecked ();
tx_qsy_allowed_ = ui_->tx_qsy_check_box->isChecked ();
transmit_directed_ = ui_->transmit_directed_check_box->isChecked();

View File

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

View File

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

View File

@ -12,6 +12,9 @@
#include <QRegExp>
#include <QRegularExpression>
#include <QDesktopServices>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QUrl>
#include <QStandardPaths>
#include <QDir>
@ -1638,15 +1641,81 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
if (!m_valid) throw std::runtime_error {"Fatal initialization exception"};
}
void MainWindow::checkVersion(){
auto m = new QNetworkAccessManager(this);
connect(m, &QNetworkAccessManager::finished, this, [this](QNetworkReply * reply){
if(reply->error()) return;
QPair<QPair<int, int>, int> splitVersion(QString v){
int hyphenPos = v.lastIndexOf("-");
if(hyphenPos >= 0){
v = v.left(hyphenPos);
}
QString content = reply->readAll();
qDebug() << "version" << content;
QVector<int> intSegs;
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");
QNetworkRequest r(url);
m->get(r);
@ -1654,7 +1723,9 @@ void MainWindow::checkVersion(){
void MainWindow::checkStartupWarnings ()
{
checkVersion();
if(m_config.check_for_updates()){
checkVersion(false);
}
ensureCallsignSet(false);
}
@ -2598,6 +2669,10 @@ void MainWindow::on_menuControl_aboutToShow(){
#endif
}
void MainWindow::on_actionCheck_for_Updates_triggered(){
checkVersion(true);
}
void MainWindow::on_actionEnable_Spotting_toggled(bool checked){
ui->spotButton->setChecked(checked);
}

View File

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

View File

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