|
|
@@ -275,16 +275,26 @@ void MainWindow::closeUpdatesWaitDialog()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QString MainWindow::seekCodeString(const QByteArray & qba, const QString & label)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int posLabel = qba.indexOf(label);
|
|
|
|
|
|
|
|
if (posLabel < 0)
|
|
|
|
|
|
|
|
return QString::null;
|
|
|
|
|
|
|
|
int start = qba.indexOf("\"", posLabel + label.length());
|
|
|
|
|
|
|
|
if (start < 0)
|
|
|
|
|
|
|
|
return QString::null;
|
|
|
|
|
|
|
|
int end = qba.indexOf("\"", start + 1);
|
|
|
|
|
|
|
|
if (end < 0)
|
|
|
|
|
|
|
|
return QString::null;
|
|
|
|
|
|
|
|
return qba.mid(start + 1, end - start - 1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::checkForCompanionUpdateFinished(QNetworkReply * reply)
|
|
|
|
void MainWindow::checkForCompanionUpdateFinished(QNetworkReply * reply)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QByteArray qba = reply->readAll();
|
|
|
|
QByteArray qba = reply->readAll();
|
|
|
|
int i = qba.indexOf("VERSION");
|
|
|
|
QString version = seekCodeString(qba, "VERSION");
|
|
|
|
if (i>0) {
|
|
|
|
if (version.isNull())
|
|
|
|
QString version = qba.mid(i+14, qba.indexOf("\"", i+14)-i-14);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (version.isNull()) {
|
|
|
|
|
|
|
|
return onUpdatesError();
|
|
|
|
return onUpdatesError();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int vnum = version2index(version);
|
|
|
|
int vnum = version2index(version);
|
|
|
|
|
|
|
|
|
|
|
@@ -317,10 +327,6 @@ void MainWindow::checkForCompanionUpdateFinished(QNetworkReply * reply)
|
|
|
|
QMessageBox::information(this, "Companion", tr("No updates available at this time."));
|
|
|
|
QMessageBox::information(this, "Companion", tr("No updates available at this time."));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
return onUpdatesError();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
checkForUpdates();
|
|
|
|
checkForUpdates();
|
|
|
|
}
|
|
|
|
}
|
|
|
@@ -388,21 +394,17 @@ void MainWindow::checkForFirmwareUpdateFinished(QNetworkReply * reply)
|
|
|
|
bool ignore = false;
|
|
|
|
bool ignore = false;
|
|
|
|
|
|
|
|
|
|
|
|
QByteArray qba = reply->readAll();
|
|
|
|
QByteArray qba = reply->readAll();
|
|
|
|
|
|
|
|
QString versionString = seekCodeString(qba, "VERSION");
|
|
|
|
|
|
|
|
QString dateString = seekCodeString(qba, "DATE");
|
|
|
|
|
|
|
|
if (versionString.isNull() || dateString.isNull())
|
|
|
|
|
|
|
|
return onUpdatesError();
|
|
|
|
|
|
|
|
|
|
|
|
long version = 0;
|
|
|
|
long version = version2index(versionString);
|
|
|
|
|
|
|
|
if (version <= 0)
|
|
|
|
|
|
|
|
return onUpdatesError();
|
|
|
|
|
|
|
|
|
|
|
|
int versionIndex = qba.indexOf("VERS_STR");
|
|
|
|
QString fullVersionString = QString("%1 (%2)").arg(versionString).arg(dateString);
|
|
|
|
int dateIndex = qba.indexOf("DATE_STR");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QString versionString;
|
|
|
|
|
|
|
|
if (versionIndex > 0 && dateIndex > 0) {
|
|
|
|
|
|
|
|
firmwareVersionString = qba.mid(versionIndex+10, qba.indexOf("\"", versionIndex+10)-versionIndex-10);
|
|
|
|
|
|
|
|
QString dateString = qba.mid(dateIndex+10, 10);
|
|
|
|
|
|
|
|
version = version2index(firmwareVersionString);
|
|
|
|
|
|
|
|
versionString = QString("%1 (%2)").arg(firmwareVersionString).arg(dateString);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (version > 0) {
|
|
|
|
|
|
|
|
if (checkForUpdatesState & AUTOMATIC_DOWNLOAD) {
|
|
|
|
if (checkForUpdatesState & AUTOMATIC_DOWNLOAD) {
|
|
|
|
checkForUpdatesState -= AUTOMATIC_DOWNLOAD;
|
|
|
|
checkForUpdatesState -= AUTOMATIC_DOWNLOAD;
|
|
|
|
download = true;
|
|
|
|
download = true;
|
|
|
@@ -420,7 +422,7 @@ void MainWindow::checkForFirmwareUpdateFinished(QNetworkReply * reply)
|
|
|
|
if (currentVersion == 0) {
|
|
|
|
if (currentVersion == 0) {
|
|
|
|
QString rn = GetCurrentFirmware()->getReleaseNotesUrl();
|
|
|
|
QString rn = GetCurrentFirmware()->getReleaseNotesUrl();
|
|
|
|
QAbstractButton *rnButton = NULL;
|
|
|
|
QAbstractButton *rnButton = NULL;
|
|
|
|
msgBox.setText(tr("Firmware %1 does not seem to have ever been downloaded.\nRelease %2 is available.\nDo you want to download it now?\n\nWe recommend you view the release notes using the button below to learn about any changes that may be important to you.").arg(current_firmware_variant->getId()).arg(versionString));
|
|
|
|
msgBox.setText(tr("Firmware %1 does not seem to have ever been downloaded.\nRelease %2 is available.\nDo you want to download it now?\n\nWe recommend you view the release notes using the button below to learn about any changes that may be important to you.").arg(current_firmware_variant->getId()).arg(fullVersionString));
|
|
|
|
QAbstractButton *YesButton = msgBox.addButton(trUtf8("Yes"), QMessageBox::YesRole);
|
|
|
|
QAbstractButton *YesButton = msgBox.addButton(trUtf8("Yes"), QMessageBox::YesRole);
|
|
|
|
msgBox.addButton(trUtf8("No"), QMessageBox::NoRole);
|
|
|
|
msgBox.addButton(trUtf8("No"), QMessageBox::NoRole);
|
|
|
|
if (!rn.isEmpty()) {
|
|
|
|
if (!rn.isEmpty()) {
|
|
|
@@ -432,7 +434,7 @@ void MainWindow::checkForFirmwareUpdateFinished(QNetworkReply * reply)
|
|
|
|
if (msgBox.clickedButton() == rnButton) {
|
|
|
|
if (msgBox.clickedButton() == rnButton) {
|
|
|
|
ReleaseNotesFirmwareDialog * dialog = new ReleaseNotesFirmwareDialog(this, rn);
|
|
|
|
ReleaseNotesFirmwareDialog * dialog = new ReleaseNotesFirmwareDialog(this, rn);
|
|
|
|
dialog->exec();
|
|
|
|
dialog->exec();
|
|
|
|
int ret2 = QMessageBox::question(this, "Companion", tr("Do you want to download release %1 now ?").arg(versionString), QMessageBox::Yes | QMessageBox::No);
|
|
|
|
int ret2 = QMessageBox::question(this, "Companion", tr("Do you want to download release %1 now ?").arg(fullVersionString), QMessageBox::Yes | QMessageBox::No);
|
|
|
|
if (ret2 == QMessageBox::Yes)
|
|
|
|
if (ret2 == QMessageBox::Yes)
|
|
|
|
download = true;
|
|
|
|
download = true;
|
|
|
|
else
|
|
|
|
else
|
|
|
@@ -448,7 +450,7 @@ void MainWindow::checkForFirmwareUpdateFinished(QNetworkReply * reply)
|
|
|
|
else if (version > currentVersion) {
|
|
|
|
else if (version > currentVersion) {
|
|
|
|
QString rn = GetCurrentFirmware()->getReleaseNotesUrl();
|
|
|
|
QString rn = GetCurrentFirmware()->getReleaseNotesUrl();
|
|
|
|
QAbstractButton *rnButton = NULL;
|
|
|
|
QAbstractButton *rnButton = NULL;
|
|
|
|
msgBox.setText(tr("A new version of %1 firmware is available:\n - current is %2\n - newer is %3\n\nDo you want to download it now?\n\nWe recommend you view the release notes using the button below to learn about any changes that may be important to you.").arg(current_firmware_variant->getId()).arg(currentVersionString).arg(versionString));
|
|
|
|
msgBox.setText(tr("A new version of %1 firmware is available:\n - current is %2\n - newer is %3\n\nDo you want to download it now?\n\nWe recommend you view the release notes using the button below to learn about any changes that may be important to you.").arg(current_firmware_variant->getId()).arg(currentVersionString).arg(fullVersionString));
|
|
|
|
QAbstractButton *YesButton = msgBox.addButton(trUtf8("Yes"), QMessageBox::YesRole);
|
|
|
|
QAbstractButton *YesButton = msgBox.addButton(trUtf8("Yes"), QMessageBox::YesRole);
|
|
|
|
msgBox.addButton(trUtf8("No"), QMessageBox::NoRole);
|
|
|
|
msgBox.addButton(trUtf8("No"), QMessageBox::NoRole);
|
|
|
|
if (!rn.isEmpty()) {
|
|
|
|
if (!rn.isEmpty()) {
|
|
|
@@ -460,7 +462,7 @@ void MainWindow::checkForFirmwareUpdateFinished(QNetworkReply * reply)
|
|
|
|
if( msgBox.clickedButton() == rnButton ) {
|
|
|
|
if( msgBox.clickedButton() == rnButton ) {
|
|
|
|
ReleaseNotesFirmwareDialog * dialog = new ReleaseNotesFirmwareDialog(this, rn);
|
|
|
|
ReleaseNotesFirmwareDialog * dialog = new ReleaseNotesFirmwareDialog(this, rn);
|
|
|
|
dialog->exec();
|
|
|
|
dialog->exec();
|
|
|
|
int ret2 = QMessageBox::question(this, "Companion", tr("Do you want to download release %1 now ?").arg(versionString),
|
|
|
|
int ret2 = QMessageBox::question(this, "Companion", tr("Do you want to download release %1 now ?").arg(fullVersionString),
|
|
|
|
QMessageBox::Yes | QMessageBox::No);
|
|
|
|
QMessageBox::Yes | QMessageBox::No);
|
|
|
|
if (ret2 == QMessageBox::Yes) {
|
|
|
|
if (ret2 == QMessageBox::Yes) {
|
|
|
|
download = true;
|
|
|
|
download = true;
|
|
|
@@ -484,7 +486,7 @@ void MainWindow::checkForFirmwareUpdateFinished(QNetworkReply * reply)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (ignore) {
|
|
|
|
if (ignore) {
|
|
|
|
int res = QMessageBox::question(this, "Companion", tr("Ignore this release %1?").arg(versionString), QMessageBox::Yes | QMessageBox::No);
|
|
|
|
int res = QMessageBox::question(this, "Companion", tr("Ignore this release %1?").arg(fullVersionString), QMessageBox::Yes | QMessageBox::No);
|
|
|
|
if (res==QMessageBox::Yes) {
|
|
|
|
if (res==QMessageBox::Yes) {
|
|
|
|
g.fwRev.set(current_firmware_variant->getId(), version);
|
|
|
|
g.fwRev.set(current_firmware_variant->getId(), version);
|
|
|
|
}
|
|
|
|
}
|
|
|
@@ -492,11 +494,6 @@ void MainWindow::checkForFirmwareUpdateFinished(QNetworkReply * reply)
|
|
|
|
else if (download == true) {
|
|
|
|
else if (download == true) {
|
|
|
|
startFirmwareDownload();
|
|
|
|
startFirmwareDownload();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
// TODO remove serverFails config?
|
|
|
|
|
|
|
|
return onUpdatesError();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
checkForUpdates();
|
|
|
|
checkForUpdates();
|
|
|
|
}
|
|
|
|
}
|
|
|
|