2010-11-27 19:41:58 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// LameXP - Audio Encoder Front-End
|
2013-02-08 23:50:51 +01:00
|
|
|
// Copyright (C) 2004-2013 LoRd_MuldeR <MuldeR2@GMX.de>
|
2010-11-27 19:41:58 +01:00
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or
|
2013-10-23 20:56:57 +02:00
|
|
|
// (at your option) any later version, but always including the *additional*
|
|
|
|
// restrictions defined in the "License.txt" file.
|
2010-11-27 19:41:58 +01:00
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License along
|
|
|
|
// with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
//
|
|
|
|
// http://www.gnu.org/licenses/gpl-2.0.txt
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "Dialog_Update.h"
|
|
|
|
|
2012-12-09 22:39:17 +01:00
|
|
|
//UIC includes
|
|
|
|
#include "..\tmp\UIC_UpdateDialog.h"
|
|
|
|
|
|
|
|
//LameXP includes
|
2010-11-28 22:18:07 +01:00
|
|
|
#include "Global.h"
|
2013-11-17 21:53:28 +01:00
|
|
|
#include "Thread_CheckUpdate.h"
|
2010-11-29 20:36:27 +01:00
|
|
|
#include "Dialog_LogView.h"
|
|
|
|
#include "Model_Settings.h"
|
2011-02-25 13:40:45 +01:00
|
|
|
#include "WinSevenTaskbar.h"
|
2010-11-28 22:18:07 +01:00
|
|
|
|
2012-12-09 22:39:17 +01:00
|
|
|
//Qt includes
|
2010-11-27 19:41:58 +01:00
|
|
|
#include <QClipboard>
|
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QTimer>
|
2010-11-28 22:18:07 +01:00
|
|
|
#include <QProcess>
|
|
|
|
#include <QDesktopServices>
|
|
|
|
#include <QUrl>
|
|
|
|
#include <QCloseEvent>
|
2011-03-24 15:37:49 +01:00
|
|
|
#include <QMovie>
|
2013-12-16 18:07:45 +01:00
|
|
|
#include <QMessageBox>
|
2010-12-06 18:29:34 +01:00
|
|
|
|
2010-11-28 22:18:07 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2013-11-17 21:53:28 +01:00
|
|
|
/*
|
2013-10-19 16:00:13 +02:00
|
|
|
template <class T>
|
|
|
|
T DO_ASYNC(T (*functionPointer)())
|
|
|
|
{
|
|
|
|
QFutureWatcher<T> watcher; QEventLoop loop;
|
|
|
|
QObject::connect(&watcher, SIGNAL(finished()), &loop, SLOT(quit()));
|
|
|
|
watcher.setFuture(QtConcurrent::run(functionPointer));
|
|
|
|
loop.exec(QEventLoop::ExcludeUserInputEvents);
|
|
|
|
return watcher.result();
|
|
|
|
}
|
2013-11-17 21:53:28 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define SHOW_HINT(TEXT, ICON) do \
|
|
|
|
{ \
|
|
|
|
ui->hintLabel->setText((TEXT)); \
|
|
|
|
ui->hintIcon->setPixmap(QIcon((ICON)).pixmap(16,16)); \
|
|
|
|
ui->hintIcon->show(); \
|
|
|
|
ui->hintLabel->show(); \
|
|
|
|
} \
|
|
|
|
while(0)
|
|
|
|
|
|
|
|
#define UPDATE_TASKBAR(STATE, ICON) do \
|
|
|
|
{ \
|
|
|
|
WinSevenTaskbar::setTaskbarState(this->parentWidget(), (STATE)); \
|
|
|
|
WinSevenTaskbar::setOverlayIcon(this->parentWidget(), &QIcon((ICON))); \
|
|
|
|
} \
|
|
|
|
while(0)
|
2010-11-28 22:18:07 +01:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2010-11-29 20:36:27 +01:00
|
|
|
UpdateDialog::UpdateDialog(SettingsModel *settings, QWidget *parent)
|
2010-11-27 19:41:58 +01:00
|
|
|
:
|
2010-11-28 22:18:07 +01:00
|
|
|
QDialog(parent),
|
2012-12-09 22:39:17 +01:00
|
|
|
ui(new Ui::UpdateDialog),
|
2013-11-17 21:53:28 +01:00
|
|
|
m_thread(NULL),
|
2010-11-29 20:36:27 +01:00
|
|
|
m_settings(settings),
|
|
|
|
m_logFile(new QStringList()),
|
2011-05-03 14:28:06 +02:00
|
|
|
m_betaUpdates(settings ? (settings->autoUpdateCheckBeta() || lamexp_version_demo()) : lamexp_version_demo()),
|
2011-02-18 00:53:36 +01:00
|
|
|
m_success(false),
|
2012-04-11 00:44:40 +02:00
|
|
|
m_firstShow(true),
|
2012-01-24 02:46:29 +01:00
|
|
|
m_updateReadyToInstall(false),
|
2013-11-17 21:53:28 +01:00
|
|
|
m_updaterProcess(NULL),
|
2013-11-29 01:18:36 +01:00
|
|
|
m_binaryUpdater(lamexp_lookup_tool("wupdate.exe")),
|
|
|
|
m_binaryWGet(lamexp_lookup_tool("wget.exe")),
|
|
|
|
m_binaryGnuPG(lamexp_lookup_tool("gpgv.exe")),
|
|
|
|
m_binaryKeys(lamexp_lookup_tool("gpgv.gpg"))
|
2010-11-27 19:41:58 +01:00
|
|
|
{
|
2013-11-17 21:53:28 +01:00
|
|
|
if(m_binaryUpdater.isEmpty())
|
2010-11-28 22:18:07 +01:00
|
|
|
{
|
2013-10-18 21:37:40 +02:00
|
|
|
THROW("Tools not initialized correctly!");
|
2010-11-28 22:18:07 +01:00
|
|
|
}
|
2013-11-17 21:53:28 +01:00
|
|
|
|
2010-11-27 19:41:58 +01:00
|
|
|
//Init the dialog, from the .ui file
|
2012-12-09 22:39:17 +01:00
|
|
|
ui->setupUi(this);
|
2010-11-27 19:41:58 +01:00
|
|
|
setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint);
|
|
|
|
|
|
|
|
//Disable "X" button
|
2013-10-07 00:01:15 +02:00
|
|
|
lamexp_enable_close_button(this, false);
|
2010-11-27 19:41:58 +01:00
|
|
|
|
2011-03-24 15:37:49 +01:00
|
|
|
//Init animation
|
|
|
|
m_animator = new QMovie(":/images/Loading3.gif");
|
2012-12-09 22:39:17 +01:00
|
|
|
ui->labelAnimationCenter->setMovie(m_animator);
|
2011-03-24 15:37:49 +01:00
|
|
|
m_animator->start();
|
|
|
|
|
2011-05-07 00:50:18 +02:00
|
|
|
//Indicate beta updates
|
|
|
|
if(m_betaUpdates)
|
|
|
|
{
|
|
|
|
setWindowTitle(windowTitle().append(" [Beta]"));
|
|
|
|
}
|
|
|
|
|
2010-11-28 22:18:07 +01:00
|
|
|
//Enable button
|
2012-12-09 22:39:17 +01:00
|
|
|
connect(ui->retryButton, SIGNAL(clicked()), this, SLOT(checkForUpdates()));
|
|
|
|
connect(ui->installButton, SIGNAL(clicked()), this, SLOT(applyUpdate()));
|
|
|
|
connect(ui->infoLabel, SIGNAL(linkActivated(QString)), this, SLOT(linkActivated(QString)));
|
|
|
|
connect(ui->logButton, SIGNAL(clicked()), this, SLOT(logButtonClicked()));
|
2011-02-25 13:40:45 +01:00
|
|
|
|
|
|
|
//Enable progress bar
|
2012-12-09 22:39:17 +01:00
|
|
|
connect(ui->progressBar, SIGNAL(valueChanged(int)), this, SLOT(progressBarValueChanged(int)));
|
2010-11-27 19:41:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
UpdateDialog::~UpdateDialog(void)
|
|
|
|
{
|
2013-11-17 21:53:28 +01:00
|
|
|
if(m_animator)
|
|
|
|
{
|
|
|
|
m_animator->stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
if(m_thread)
|
|
|
|
{
|
|
|
|
if(!m_thread->wait(1000))
|
|
|
|
{
|
|
|
|
m_thread->terminate();
|
|
|
|
m_thread->wait();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
LAMEXP_DELETE(m_thread);
|
2010-11-29 20:36:27 +01:00
|
|
|
LAMEXP_DELETE(m_logFile);
|
2011-03-24 15:37:49 +01:00
|
|
|
LAMEXP_DELETE(m_animator);
|
2011-02-25 13:40:45 +01:00
|
|
|
|
|
|
|
WinSevenTaskbar::setTaskbarState(this->parentWidget(), WinSevenTaskbar::WinSevenTaskbarNoState);
|
|
|
|
WinSevenTaskbar::setOverlayIcon(this->parentWidget(), NULL);
|
2012-12-09 22:39:17 +01:00
|
|
|
|
|
|
|
LAMEXP_DELETE(ui);
|
2010-11-27 19:41:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateDialog::showEvent(QShowEvent *event)
|
|
|
|
{
|
2010-11-28 22:18:07 +01:00
|
|
|
QDialog::showEvent(event);
|
|
|
|
|
2012-04-11 00:44:40 +02:00
|
|
|
if(m_firstShow)
|
|
|
|
{
|
2013-11-17 21:53:28 +01:00
|
|
|
if(!m_thread)
|
|
|
|
{
|
2013-11-29 01:18:36 +01:00
|
|
|
m_thread = new UpdateCheckThread(m_binaryWGet, m_binaryGnuPG, m_binaryKeys, m_betaUpdates);
|
2013-11-17 21:53:28 +01:00
|
|
|
connect(m_thread, SIGNAL(statusChanged(int)), this, SLOT(threadStatusChanged(int)));
|
|
|
|
connect(m_thread, SIGNAL(progressChanged(int)), this, SLOT(threadProgressChanged(int)));
|
|
|
|
connect(m_thread, SIGNAL(messageLogged(QString)), this, SLOT(threadMessageLogged(QString)));
|
|
|
|
connect(m_thread, SIGNAL(finished()), this, SLOT(threadFinished()));
|
|
|
|
connect(m_thread, SIGNAL(terminated()), this, SLOT(threadFinished()));
|
|
|
|
}
|
|
|
|
|
|
|
|
threadStatusChanged(m_thread->getUpdateStatus());
|
2012-12-09 22:39:17 +01:00
|
|
|
ui->labelVersionInstalled->setText(QString("%1 %2 (%3)").arg(tr("Build"), QString::number(lamexp_version_build()), lamexp_version_date().toString(Qt::ISODate)));
|
|
|
|
ui->labelVersionLatest->setText(QString("(%1)").arg(tr("Unknown")));
|
|
|
|
|
|
|
|
ui->installButton->setEnabled(false);
|
|
|
|
ui->closeButton->setEnabled(false);
|
|
|
|
ui->retryButton->setEnabled(false);
|
|
|
|
ui->logButton->setEnabled(false);
|
|
|
|
ui->retryButton->hide();
|
|
|
|
ui->logButton->hide();
|
|
|
|
ui->infoLabel->hide();
|
|
|
|
ui->hintLabel->hide();
|
|
|
|
ui->hintIcon->hide();
|
|
|
|
ui->frameAnimation->hide();
|
2010-11-28 22:18:07 +01:00
|
|
|
|
2013-11-17 21:53:28 +01:00
|
|
|
ui->progressBar->setMaximum(m_thread->getMaximumProgress());
|
2012-12-09 22:39:17 +01:00
|
|
|
ui->progressBar->setValue(0);
|
2011-11-11 18:08:22 +01:00
|
|
|
|
2012-04-11 00:44:40 +02:00
|
|
|
m_updaterProcess = NULL;
|
2012-01-24 02:46:29 +01:00
|
|
|
|
2012-04-11 00:44:40 +02:00
|
|
|
QTimer::singleShot(0, this, SLOT(updateInit()));
|
|
|
|
m_firstShow = false;
|
|
|
|
}
|
2010-11-28 22:18:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateDialog::closeEvent(QCloseEvent *event)
|
|
|
|
{
|
2012-12-09 22:39:17 +01:00
|
|
|
if(!ui->closeButton->isEnabled())
|
2011-02-25 13:40:45 +01:00
|
|
|
{
|
|
|
|
event->ignore();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WinSevenTaskbar::setTaskbarState(this->parentWidget(), WinSevenTaskbar::WinSevenTaskbarNoState);
|
|
|
|
WinSevenTaskbar::setOverlayIcon(this->parentWidget(), NULL);
|
|
|
|
}
|
2010-11-27 19:41:58 +01:00
|
|
|
}
|
|
|
|
|
2010-12-08 20:52:18 +01:00
|
|
|
void UpdateDialog::keyPressEvent(QKeyEvent *e)
|
|
|
|
{
|
|
|
|
if(e->key() == Qt::Key_F11)
|
|
|
|
{
|
2012-12-09 22:39:17 +01:00
|
|
|
if(ui->closeButton->isEnabled()) logButtonClicked();
|
2010-12-08 20:52:18 +01:00
|
|
|
}
|
2011-12-01 22:16:06 +01:00
|
|
|
else if((e->key() == Qt::Key_F12) && e->modifiers().testFlag(Qt::ControlModifier))
|
|
|
|
{
|
2013-11-17 21:53:28 +01:00
|
|
|
if(ui->closeButton->isEnabled()) testKnownHosts();
|
2011-12-01 22:16:06 +01:00
|
|
|
}
|
2010-12-08 20:52:18 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
QDialog::keyPressEvent(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-24 02:46:29 +01:00
|
|
|
bool UpdateDialog::event(QEvent *e)
|
|
|
|
{
|
|
|
|
if((e->type() == QEvent::ActivationChange) && (m_updaterProcess != NULL))
|
|
|
|
{
|
2013-10-07 00:01:15 +02:00
|
|
|
lamexp_bring_process_to_front(m_updaterProcess);
|
2012-01-24 02:46:29 +01:00
|
|
|
}
|
|
|
|
return QDialog::event(e);
|
|
|
|
}
|
|
|
|
|
2011-11-07 17:13:41 +01:00
|
|
|
bool UpdateDialog::winEvent(MSG *message, long *result)
|
|
|
|
{
|
|
|
|
return WinSevenTaskbar::handleWinEvent(message, result);
|
|
|
|
}
|
|
|
|
|
2010-11-28 22:18:07 +01:00
|
|
|
void UpdateDialog::updateInit(void)
|
2010-11-27 19:41:58 +01:00
|
|
|
{
|
2010-11-28 22:18:07 +01:00
|
|
|
setMinimumSize(size());
|
|
|
|
setMaximumHeight(height());
|
2013-12-16 18:07:45 +01:00
|
|
|
QTimer::singleShot(0, this, SLOT(checkForUpdates()));
|
2010-11-28 22:18:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateDialog::checkForUpdates(void)
|
|
|
|
{
|
2013-11-17 21:53:28 +01:00
|
|
|
if(m_thread->isRunning())
|
|
|
|
{
|
|
|
|
qWarning("Update in progress, cannot check for updates now!");
|
|
|
|
}
|
2010-11-28 22:18:07 +01:00
|
|
|
|
2013-12-16 18:07:45 +01:00
|
|
|
if(!lamexp_user_is_admin())
|
|
|
|
{
|
|
|
|
qWarning("User is not in the \"admin\" group, cannot update!");
|
|
|
|
QString message;
|
|
|
|
message += QString("<nobr>%1</nobr><br>").arg(tr("Sorry, but only users in the \"Administrators\" group can install updates."));
|
|
|
|
message += QString("<nobr>%1</nobr>").arg(tr("Please start application from an administrator account and try again!"));
|
|
|
|
if(QMessageBox::critical(this, this->windowTitle(), message, tr("Discard"), tr("Ignore")) != 1)
|
|
|
|
{
|
|
|
|
ui->closeButton->setEnabled(true);
|
|
|
|
close(); return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-25 13:40:45 +01:00
|
|
|
WinSevenTaskbar::setTaskbarState(this->parentWidget(), WinSevenTaskbar::WinSevenTaskbarNormalState);
|
|
|
|
WinSevenTaskbar::setOverlayIcon(this->parentWidget(), &QIcon(":/icons/transmit_blue.png"));
|
2013-11-17 21:53:28 +01:00
|
|
|
|
|
|
|
ui->progressBar->setValue(0);
|
2012-12-09 22:39:17 +01:00
|
|
|
ui->installButton->setEnabled(false);
|
|
|
|
ui->closeButton->setEnabled(false);
|
|
|
|
ui->retryButton->setEnabled(false);
|
|
|
|
ui->logButton->setEnabled(false);
|
|
|
|
if(ui->infoLabel->isVisible()) ui->infoLabel->hide();
|
|
|
|
if(ui->hintLabel->isVisible()) ui->hintLabel->hide();
|
|
|
|
if(ui->hintIcon->isVisible()) ui->hintIcon->hide();
|
|
|
|
ui->frameAnimation->show();
|
2010-11-28 22:18:07 +01:00
|
|
|
|
2013-10-19 16:00:13 +02:00
|
|
|
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
|
2010-11-28 22:18:07 +01:00
|
|
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
|
|
|
|
2010-11-29 20:36:27 +01:00
|
|
|
m_logFile->clear();
|
2013-11-17 21:53:28 +01:00
|
|
|
m_thread->start();
|
|
|
|
}
|
2010-11-29 20:36:27 +01:00
|
|
|
|
2013-11-17 21:53:28 +01:00
|
|
|
void UpdateDialog::threadStatusChanged(const int status)
|
|
|
|
{
|
|
|
|
switch(status)
|
|
|
|
{
|
|
|
|
case UpdateCheckThread::UpdateStatus_NotStartedYet:
|
|
|
|
ui->statusLabel->setText(tr("Initializing, please wait..."));
|
|
|
|
break;
|
|
|
|
case UpdateCheckThread::UpdateStatus_CheckingConnection:
|
|
|
|
ui->statusLabel->setText(tr("Testing your internet connection, please wait..."));
|
|
|
|
break;
|
|
|
|
case UpdateCheckThread::UpdateStatus_FetchingUpdates:
|
|
|
|
ui->statusLabel->setText(tr("Checking for new updates online, please wait..."));
|
|
|
|
break;
|
|
|
|
case UpdateCheckThread::UpdateStatus_CompletedUpdateAvailable:
|
2012-12-09 22:39:17 +01:00
|
|
|
ui->statusLabel->setText(tr("A new version of LameXP is available!"));
|
2013-11-17 21:53:28 +01:00
|
|
|
SHOW_HINT(tr("We highly recommend all users to install this update as soon as possible."), ":/icons/shield_exclamation.png");
|
|
|
|
UPDATE_TASKBAR(WinSevenTaskbar::WinSevenTaskbarNormalState, ":/icons/shield_exclamation.png");
|
|
|
|
break;
|
|
|
|
case UpdateCheckThread::UpdateStatus_CompletedNoUpdates:
|
2012-12-09 22:39:17 +01:00
|
|
|
ui->statusLabel->setText(tr("No new updates available at this time."));
|
2013-11-17 21:53:28 +01:00
|
|
|
SHOW_HINT(tr("Your version of LameXP is still up-to-date. Please check for updates regularly!"), ":/icons/shield_green.png");
|
|
|
|
UPDATE_TASKBAR(WinSevenTaskbar::WinSevenTaskbarNormalState, ":/icons/shield_green.png");
|
|
|
|
break;
|
|
|
|
case UpdateCheckThread::UpdateStatus_CompletedNewVersionOlder:
|
2012-12-09 22:39:17 +01:00
|
|
|
ui->statusLabel->setText(tr("Your version appears to be newer than the latest release."));
|
2013-12-16 18:07:45 +01:00
|
|
|
SHOW_HINT(tr("This usually indicates your are currently using a pre-release version of LameXP."), ":/icons/shield_blue.png");
|
2013-11-17 21:53:28 +01:00
|
|
|
UPDATE_TASKBAR(WinSevenTaskbar::WinSevenTaskbarNormalState, ":/icons/shield_error.png");
|
|
|
|
break;
|
|
|
|
case UpdateCheckThread::UpdateStatus_ErrorNoConnection:
|
|
|
|
ui->statusLabel->setText(tr("It appears that the computer currently is offline!"));
|
|
|
|
SHOW_HINT(tr("Please make sure your computer is connected to the internet and try again."), ":/icons/network_error.png");
|
|
|
|
UPDATE_TASKBAR(WinSevenTaskbar::WinSevenTaskbarErrorState, ":/icons/exclamation.png");
|
|
|
|
break;
|
|
|
|
case UpdateCheckThread::UpdateStatus_ErrorConnectionTestFailed:
|
|
|
|
ui->statusLabel->setText(tr("Network connectivity test has failed!"));
|
|
|
|
SHOW_HINT(tr("Please make sure your computer is connected to the internet and try again."), ":/icons/network_error.png");
|
|
|
|
UPDATE_TASKBAR(WinSevenTaskbar::WinSevenTaskbarErrorState, ":/icons/exclamation.png");
|
|
|
|
break;
|
|
|
|
case UpdateCheckThread::UpdateStatus_ErrorFetchUpdateInfo:
|
|
|
|
ui->statusLabel->setText(tr("Failed to fetch update information from server!"));
|
|
|
|
SHOW_HINT(tr("Sorry, the update server might be busy at this time. Plase try again later."), ":/icons/server_error.png");
|
|
|
|
UPDATE_TASKBAR(WinSevenTaskbar::WinSevenTaskbarErrorState, ":/icons/exclamation.png");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
qWarning("Unknown status %d !!!", int(status));
|
2010-11-28 22:18:07 +01:00
|
|
|
}
|
2010-11-27 19:41:58 +01:00
|
|
|
}
|
|
|
|
|
2013-11-17 21:53:28 +01:00
|
|
|
void UpdateDialog::threadProgressChanged(const int progress)
|
2010-11-28 22:18:07 +01:00
|
|
|
{
|
2013-11-17 21:53:28 +01:00
|
|
|
ui->progressBar->setValue(progress);
|
2010-11-28 22:18:07 +01:00
|
|
|
}
|
|
|
|
|
2013-11-17 21:53:28 +01:00
|
|
|
void UpdateDialog::threadMessageLogged(const QString &message)
|
2010-11-28 22:18:07 +01:00
|
|
|
{
|
2013-11-17 21:53:28 +01:00
|
|
|
(*m_logFile) << message;
|
2010-11-28 22:18:07 +01:00
|
|
|
}
|
|
|
|
|
2013-11-17 21:53:28 +01:00
|
|
|
void UpdateDialog::threadFinished(void)
|
2010-11-28 22:18:07 +01:00
|
|
|
{
|
2013-11-17 21:53:28 +01:00
|
|
|
const bool bSuccess = m_thread->getSuccess();
|
2010-11-28 22:18:07 +01:00
|
|
|
|
2013-11-17 21:53:28 +01:00
|
|
|
ui->closeButton->setEnabled(true);
|
|
|
|
if(ui->frameAnimation->isVisible()) ui->frameAnimation->hide();
|
|
|
|
ui->progressBar->setValue(ui->progressBar->maximum());
|
2010-11-28 22:18:07 +01:00
|
|
|
|
2013-11-17 21:53:28 +01:00
|
|
|
if(!bSuccess)
|
2010-11-28 22:18:07 +01:00
|
|
|
{
|
2013-12-03 22:19:11 +01:00
|
|
|
if(m_settings->soundsEnabled()) lamexp_play_sound("error", true);
|
2010-11-28 22:18:07 +01:00
|
|
|
}
|
2013-11-17 21:53:28 +01:00
|
|
|
else
|
2010-11-28 22:18:07 +01:00
|
|
|
{
|
2013-11-17 21:53:28 +01:00
|
|
|
const bool bHaveUpdate = (m_thread->getUpdateStatus() == UpdateCheckThread::UpdateStatus_CompletedUpdateAvailable);
|
|
|
|
ui->installButton->setEnabled(bHaveUpdate);
|
|
|
|
lamexp_beep(bHaveUpdate ? lamexp_beep_info : lamexp_beep_warning);
|
2010-11-28 22:18:07 +01:00
|
|
|
|
2013-11-17 21:53:28 +01:00
|
|
|
if(const UpdateInfo *const updateInfo = m_thread->getUpdateInfo())
|
2010-11-28 22:18:07 +01:00
|
|
|
{
|
2013-11-17 21:53:28 +01:00
|
|
|
ui->infoLabel->setText(QString("%1<br><a href=\"%2\">%2</a>").arg(tr("More information available at:"), updateInfo->m_downloadSite));
|
|
|
|
ui->labelVersionLatest->setText(QString("%1 %2 (%3)").arg(tr("Build"), QString::number(updateInfo->m_buildNo), updateInfo->m_buildDate.toString(Qt::ISODate)));
|
|
|
|
ui->infoLabel->show();
|
2010-11-28 22:18:07 +01:00
|
|
|
}
|
|
|
|
|
2013-11-17 21:53:28 +01:00
|
|
|
m_success = true;
|
2011-02-12 22:17:42 +01:00
|
|
|
}
|
2010-11-28 22:18:07 +01:00
|
|
|
|
2013-11-17 21:53:28 +01:00
|
|
|
ui->retryButton->setVisible(!bSuccess);
|
|
|
|
ui->logButton->setVisible(!bSuccess);
|
|
|
|
ui->retryButton->setEnabled(!bSuccess);
|
|
|
|
ui->logButton->setEnabled(!bSuccess);
|
|
|
|
|
|
|
|
QApplication::restoreOverrideCursor();
|
2010-11-28 22:18:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateDialog::linkActivated(const QString &link)
|
|
|
|
{
|
|
|
|
QDesktopServices::openUrl(QUrl(link));
|
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateDialog::applyUpdate(void)
|
|
|
|
{
|
2012-12-09 22:39:17 +01:00
|
|
|
ui->installButton->setEnabled(false);
|
|
|
|
ui->closeButton->setEnabled(false);
|
|
|
|
ui->retryButton->setEnabled(false);
|
2010-11-28 22:18:07 +01:00
|
|
|
|
2013-11-17 21:53:28 +01:00
|
|
|
if(const UpdateInfo *updateInfo = m_thread->getUpdateInfo())
|
2010-11-28 22:18:07 +01:00
|
|
|
{
|
2012-12-09 22:39:17 +01:00
|
|
|
ui->statusLabel->setText(tr("Update is being downloaded, please be patient..."));
|
|
|
|
ui->frameAnimation->show();
|
|
|
|
if(ui->hintLabel->isVisible()) ui->hintLabel->hide();
|
|
|
|
if(ui->hintIcon->isVisible()) ui->hintIcon->hide();
|
|
|
|
int oldMax = ui->progressBar->maximum();
|
|
|
|
int oldMin = ui->progressBar->minimum();
|
|
|
|
ui->progressBar->setRange(0, 0);
|
2013-10-19 16:00:13 +02:00
|
|
|
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
|
2010-11-28 22:18:07 +01:00
|
|
|
|
|
|
|
QProcess process;
|
|
|
|
QStringList args;
|
|
|
|
QEventLoop loop;
|
|
|
|
|
2013-11-25 02:20:44 +01:00
|
|
|
lamexp_init_process(process, QFileInfo(m_binaryUpdater).absolutePath(), false);
|
2013-10-29 02:05:43 +01:00
|
|
|
|
2010-11-28 22:18:07 +01:00
|
|
|
connect(&process, SIGNAL(error(QProcess::ProcessError)), &loop, SLOT(quit()));
|
|
|
|
connect(&process, SIGNAL(finished(int,QProcess::ExitStatus)), &loop, SLOT(quit()));
|
|
|
|
|
2013-11-17 21:53:28 +01:00
|
|
|
args << QString("/Location=%1").arg(updateInfo->m_downloadAddress);
|
|
|
|
args << QString("/Filename=%1").arg(updateInfo->m_downloadFilename);
|
|
|
|
args << QString("/TicketID=%1").arg(updateInfo->m_downloadFilecode);
|
2011-01-25 00:11:28 +01:00
|
|
|
args << QString("/ToFolder=%1").arg(QDir::toNativeSeparators(QDir(QApplication::applicationDirPath()).canonicalPath()));
|
|
|
|
args << QString("/ToExFile=%1.exe").arg(QFileInfo(QFileInfo(QApplication::applicationFilePath()).canonicalFilePath()).completeBaseName());
|
2013-11-17 21:53:28 +01:00
|
|
|
args << QString("/AppTitle=LameXP (Build #%1)").arg(QString::number(updateInfo->m_buildNo));
|
2010-11-28 22:18:07 +01:00
|
|
|
|
|
|
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
2013-11-17 21:53:28 +01:00
|
|
|
UPDATE_TASKBAR(WinSevenTaskbar::WinSevenTaskbarIndeterminateState, ":/icons/transmit_blue.png");
|
2011-02-25 13:40:45 +01:00
|
|
|
|
2010-11-28 22:18:07 +01:00
|
|
|
process.start(m_binaryUpdater, args);
|
2012-01-24 02:46:29 +01:00
|
|
|
bool updateStarted = process.waitForStarted();
|
|
|
|
if(updateStarted)
|
|
|
|
{
|
2013-10-07 00:01:15 +02:00
|
|
|
m_updaterProcess = lamexp_process_id(&process);
|
2013-10-29 02:05:43 +01:00
|
|
|
loop.exec(QEventLoop::ExcludeUserInputEvents);
|
2012-01-24 02:46:29 +01:00
|
|
|
}
|
2013-11-25 02:20:44 +01:00
|
|
|
|
2012-01-24 02:46:29 +01:00
|
|
|
m_updaterProcess = NULL;
|
2010-11-28 22:18:07 +01:00
|
|
|
QApplication::restoreOverrideCursor();
|
2011-02-25 13:40:45 +01:00
|
|
|
|
2012-12-09 22:39:17 +01:00
|
|
|
ui->hintLabel->show();
|
|
|
|
ui->hintIcon->show();
|
|
|
|
ui->progressBar->setRange(oldMin, oldMax);
|
|
|
|
ui->progressBar->setValue(oldMax);
|
|
|
|
ui->frameAnimation->hide();
|
2011-03-25 15:18:13 +01:00
|
|
|
|
2012-01-24 02:46:29 +01:00
|
|
|
if(updateStarted && (process.exitCode() == 0))
|
2010-11-28 22:18:07 +01:00
|
|
|
{
|
2012-12-09 22:39:17 +01:00
|
|
|
ui->statusLabel->setText(tr("Update ready to install. Applicaion will quit..."));
|
2011-02-18 00:53:36 +01:00
|
|
|
m_updateReadyToInstall = true;
|
2011-02-25 13:40:45 +01:00
|
|
|
WinSevenTaskbar::setTaskbarState(this->parentWidget(), WinSevenTaskbar::WinSevenTaskbarNoState);
|
|
|
|
WinSevenTaskbar::setOverlayIcon(this->parentWidget(), NULL);
|
2010-11-29 20:36:27 +01:00
|
|
|
accept();
|
2010-11-28 22:18:07 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-12-09 22:39:17 +01:00
|
|
|
ui->statusLabel->setText(tr("Update failed. Please try again or download manually!"));
|
2011-02-25 13:40:45 +01:00
|
|
|
WinSevenTaskbar::setTaskbarState(this->parentWidget(), WinSevenTaskbar::WinSevenTaskbarErrorState);
|
|
|
|
WinSevenTaskbar::setOverlayIcon(this->parentWidget(), &QIcon(":/icons/exclamation.png"));
|
|
|
|
WinSevenTaskbar::setTaskbarProgress(this->parentWidget(), 100, 100);
|
2010-11-28 22:18:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-09 22:39:17 +01:00
|
|
|
ui->installButton->setEnabled(true);
|
|
|
|
ui->closeButton->setEnabled(true);
|
2010-11-28 22:18:07 +01:00
|
|
|
}
|
2010-11-29 20:36:27 +01:00
|
|
|
|
|
|
|
void UpdateDialog::logButtonClicked(void)
|
|
|
|
{
|
|
|
|
LogViewDialog *logView = new LogViewDialog(this);
|
|
|
|
logView->exec(*m_logFile);
|
|
|
|
LAMEXP_DELETE(logView);
|
|
|
|
}
|
2011-02-25 13:40:45 +01:00
|
|
|
|
|
|
|
void UpdateDialog::progressBarValueChanged(int value)
|
|
|
|
{
|
2012-12-09 22:39:17 +01:00
|
|
|
WinSevenTaskbar::setTaskbarProgress(this->parentWidget(), value, ui->progressBar->maximum());
|
2011-02-25 13:40:45 +01:00
|
|
|
}
|
2011-12-01 22:16:06 +01:00
|
|
|
|
2013-11-17 21:53:28 +01:00
|
|
|
void UpdateDialog::testKnownHosts(void)
|
2011-12-01 22:16:06 +01:00
|
|
|
{
|
2012-12-09 22:39:17 +01:00
|
|
|
ui->statusLabel->setText("Testing all known hosts, this may take a few minutes...");
|
2011-12-01 22:16:06 +01:00
|
|
|
|
2013-11-29 01:18:36 +01:00
|
|
|
if(UpdateCheckThread *testThread = new UpdateCheckThread(m_binaryWGet, m_binaryGnuPG, m_binaryKeys, m_betaUpdates, true))
|
2011-12-01 22:16:06 +01:00
|
|
|
{
|
2013-11-17 21:53:28 +01:00
|
|
|
QEventLoop loop;
|
|
|
|
m_logFile->clear();
|
2011-12-01 22:16:06 +01:00
|
|
|
|
2013-11-17 21:53:28 +01:00
|
|
|
connect(testThread, SIGNAL(messageLogged(QString)), this, SLOT(threadMessageLogged(QString)));
|
|
|
|
connect(testThread, SIGNAL(finished()), &loop, SLOT(quit()));
|
|
|
|
connect(testThread, SIGNAL(terminated()), &loop, SLOT(quit()));
|
2011-12-02 22:40:12 +01:00
|
|
|
|
2013-11-17 21:53:28 +01:00
|
|
|
testThread->start();
|
|
|
|
while(testThread->isRunning())
|
2011-12-01 22:16:06 +01:00
|
|
|
{
|
2013-11-17 21:53:28 +01:00
|
|
|
QTimer::singleShot(5000, &loop, SLOT(quit()));
|
|
|
|
loop.exec(QEventLoop::ExcludeUserInputEvents);
|
2011-12-01 22:16:06 +01:00
|
|
|
}
|
|
|
|
|
2013-11-17 21:53:28 +01:00
|
|
|
LAMEXP_DELETE(testThread);
|
|
|
|
logButtonClicked();
|
2011-12-01 22:16:06 +01:00
|
|
|
}
|
|
|
|
|
2012-12-09 22:39:17 +01:00
|
|
|
ui->statusLabel->setText("Test completed.");
|
2013-10-07 00:01:15 +02:00
|
|
|
lamexp_beep(lamexp_beep_info);
|
2011-12-01 22:16:06 +01:00
|
|
|
}
|