Implement update reminder + added options to disable the update reminder and/or the sound effects + improved installer
This commit is contained in:
parent
00a05d44c2
commit
53a1bf6e38
@ -1,13 +1,38 @@
|
||||
; ///////////////////////////////////////////////////////////////////////////////
|
||||
; // LameXP - Audio Encoder Front-End
|
||||
; // Copyright (C) 2004-2010 LoRd_MuldeR <MuldeR2@GMX.de>
|
||||
; //
|
||||
; // 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
|
||||
; // (at your option) any later version.
|
||||
; //
|
||||
; // 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
|
||||
; ///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
RequestExecutionLevel user
|
||||
BrandingText `Date created: ${LAMEXP_DATE}`
|
||||
ShowInstDetails show
|
||||
|
||||
!define ZIP2EXE_NAME `LameXP v${LAMEXP_VERSION} ${LAMEXP_SUFFIX} [Build #${LAMEXP_BUILD}]`
|
||||
!define ZIP2EXE_OUTFILE `${LAMEXP_OUTPUT_FILE}`
|
||||
!define ZIP2EXE_COMPRESSOR_LZMA
|
||||
!define ZIP2EXE_COMPRESSOR_SOLID
|
||||
!define ZIP2EXE_INSTALLDIR `$PROGRAMFILES\${ZIP2EXE_NAME}`
|
||||
|
||||
RequestExecutionLevel user
|
||||
BrandingText `Date created: ${LAMEXP_DATE}`
|
||||
ShowInstDetails show
|
||||
|
||||
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\orange-install.ico"
|
||||
!define MUI_WELCOMEFINISHPAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Wizard\orange.bmp"
|
||||
!define MUI_HEADERIMAGE
|
||||
!define MUI_HEADERIMAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Header\orange.bmp"
|
||||
!define MUI_PAGE_CUSTOMFUNCTION_SHOW CheckForUpdate
|
||||
|
||||
!include `UAC.nsh`
|
||||
@ -23,10 +48,10 @@ Function .onInit
|
||||
${IfThen} $1 = 1 ${|} Quit ${|}
|
||||
${IfThen} $3 <> 0 ${|} ${Break} ${|}
|
||||
${If} $1 = 3
|
||||
MessageBox MB_ICONEXCLAMATION|MB_TOPMOST|MB_SETFOREGROUND "This installer requires admin access, please try again!" /SD IDNO IDOK UAC_TryAgain IDNO 0
|
||||
MessageBox MB_ICONEXCLAMATION|MB_TOPMOST|MB_SETFOREGROUND|MB_OKCANCEL "This installer requires admin access, please try again!" /SD IDCANCEL IDOK UAC_TryAgain
|
||||
${EndIf}
|
||||
${Case} 1223
|
||||
MessageBox MB_ICONEXCLAMATION|MB_TOPMOST|MB_SETFOREGROUND "This installer requires admin privileges, please try again!" /SD IDNO IDOK UAC_TryAgain IDNO 0
|
||||
MessageBox MB_ICONEXCLAMATION|MB_TOPMOST|MB_SETFOREGROUND|MB_OKCANCEL "This installer requires admin privileges, please try again!" /SD IDCANCEL IDOK UAC_TryAgain
|
||||
Quit
|
||||
${Case} 1062
|
||||
MessageBox MB_ICONSTOP|MB_TOPMOST|MB_SETFOREGROUND "Logon service not running, aborting!"
|
||||
|
@ -1133,8 +1133,16 @@
|
||||
<addaction name="separator"/>
|
||||
<addaction name="menuStyle"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuTools">
|
||||
<property name="title">
|
||||
<string>Tools</string>
|
||||
</property>
|
||||
<addaction name="actionDisableUpdateReminder"/>
|
||||
<addaction name="actionDisableSounds"/>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
<addaction name="menuView"/>
|
||||
<addaction name="menuTools"/>
|
||||
<addaction name="menuHelp"/>
|
||||
</widget>
|
||||
<action name="actionAbout">
|
||||
@ -1286,6 +1294,22 @@
|
||||
<string>Windows XP ("Luna")</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDisableUpdateReminder">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Disable Update Reminder</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDisableSounds">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Disable Sound Effects</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../res/Icons.qrc"/>
|
||||
@ -1361,6 +1385,12 @@
|
||||
<include location="../res/Images.qrc"/>
|
||||
<include location="../res/Icons.qrc"/>
|
||||
<include location="../res/Images.qrc"/>
|
||||
<include location="../res/Icons.qrc"/>
|
||||
<include location="../res/Images.qrc"/>
|
||||
<include location="../res/Icons.qrc"/>
|
||||
<include location="../res/Images.qrc"/>
|
||||
<include location="../res/Icons.qrc"/>
|
||||
<include location="../res/Images.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
|
@ -13,6 +13,10 @@
|
||||
<property name="windowTitle">
|
||||
<string>LameXP Update Manager</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../res/Icons.qrc">
|
||||
<normaloff>:/icons/transmit_blue.png</normaloff>:/icons/transmit_blue.png</iconset>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
@ -335,6 +339,23 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="logButton">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show Log</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../res/Icons.qrc">
|
||||
<normaloff>:/icons/application_view_list.png</normaloff>:/icons/application_view_list.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_6">
|
||||
<property name="orientation">
|
||||
@ -484,6 +505,8 @@
|
||||
<include location="../res/Images.qrc"/>
|
||||
<include location="../res/Images.qrc"/>
|
||||
<include location="../res/Images.qrc"/>
|
||||
<include location="../res/Images.qrc"/>
|
||||
<include location="../res/Images.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
|
@ -25,7 +25,7 @@
|
||||
#define VER_LAMEXP_MAJOR 4
|
||||
#define VER_LAMEXP_MINOR_HI 0
|
||||
#define VER_LAMEXP_MINOR_LO 0
|
||||
#define VER_LAMEXP_BUILD 99
|
||||
#define VER_LAMEXP_BUILD 103
|
||||
#define VER_LAMEXP_SUFFIX TechPreview
|
||||
|
||||
/*
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include "Global.h"
|
||||
#include "Resource.h"
|
||||
#include "Model_Settings.h"
|
||||
|
||||
//Qt includes
|
||||
#include <QDate>
|
||||
@ -46,8 +47,10 @@ const char *AboutDialog::neroAacUrl = "http://www.nero.com/eng/technologies-aac-
|
||||
// Constructor
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
AboutDialog::AboutDialog(QWidget *parent, bool firstStart)
|
||||
: QMessageBox(parent)
|
||||
AboutDialog::AboutDialog(SettingsModel *settings, QWidget *parent, bool firstStart)
|
||||
:
|
||||
QMessageBox(parent),
|
||||
m_settings(settings)
|
||||
{
|
||||
QString aboutText;
|
||||
|
||||
@ -125,7 +128,10 @@ AboutDialog::~AboutDialog(void)
|
||||
|
||||
int AboutDialog::exec()
|
||||
{
|
||||
PlaySound(MAKEINTRESOURCE(IDR_WAVE_ABOUT), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC);
|
||||
if(m_settings->soundsEnabled())
|
||||
{
|
||||
PlaySound(MAKEINTRESOURCE(IDR_WAVE_ABOUT), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC);
|
||||
}
|
||||
|
||||
switch(QMessageBox::exec())
|
||||
{
|
||||
|
@ -20,14 +20,17 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
class SettingsModel;
|
||||
|
||||
class AboutDialog : public QMessageBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AboutDialog(QWidget *parent = 0, bool firstStart = false);
|
||||
AboutDialog(SettingsModel *settings, QWidget *parent = 0, bool firstStart = false);
|
||||
~AboutDialog(void);
|
||||
|
||||
static const char *neroAacUrl;
|
||||
@ -44,4 +47,5 @@ protected:
|
||||
|
||||
private:
|
||||
bool m_firstShow;
|
||||
SettingsModel *m_settings;
|
||||
};
|
||||
|
@ -240,6 +240,12 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S
|
||||
connect(m_styleActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(styleActionActivated(QAction*)));
|
||||
styleActionActivated(NULL);
|
||||
|
||||
//Activate tools menu actions
|
||||
actionDisableUpdateReminder->setChecked(!m_settings->autoUpdateEnabled());
|
||||
actionDisableSounds->setChecked(!m_settings->soundsEnabled());
|
||||
connect(actionDisableUpdateReminder, SIGNAL(triggered(bool)), this, SLOT(disableUpdateReminderActionTriggered(bool)));
|
||||
connect(actionDisableSounds, SIGNAL(triggered(bool)), this, SLOT(disableSoundsActionTriggered(bool)));
|
||||
|
||||
//Activate help menu actions
|
||||
connect(actionCheckUpdates, SIGNAL(triggered()), this, SLOT(checkUpdatesActionActivated()));
|
||||
connect(actionVisitHomepage, SIGNAL(triggered()), this, SLOT(visitHomepageActionActivated()));
|
||||
@ -435,13 +441,14 @@ void MainWindow::windowShown(void)
|
||||
{
|
||||
QStringList arguments = QApplication::arguments();
|
||||
|
||||
//Check license
|
||||
if(m_settings->licenseAccepted() <= 0)
|
||||
{
|
||||
int iAccepted = -1;
|
||||
|
||||
if(m_settings->licenseAccepted() == 0)
|
||||
{
|
||||
AboutDialog *about = new AboutDialog(this, true);
|
||||
AboutDialog *about = new AboutDialog(m_settings, this, true);
|
||||
iAccepted = about->exec();
|
||||
LAMEXP_DELETE(about);
|
||||
}
|
||||
@ -457,6 +464,48 @@ void MainWindow::windowShown(void)
|
||||
m_settings->licenseAccepted(1);
|
||||
}
|
||||
|
||||
//Check for expiration
|
||||
if(lamexp_version_demo())
|
||||
{
|
||||
QDate expireDate = lamexp_version_date().addDays(14);
|
||||
if(QDate::currentDate() >= expireDate)
|
||||
{
|
||||
qWarning("Binary has expired !!!");
|
||||
if(QMessageBox::warning(this, "LameXP - Expired", QString("This demo (pre-release) version of LameXP has expired at %1.\nLameXP is free software and release versions won't expire.").arg(expireDate.toString(Qt::ISODate)), "Check for Updates", "Exit Program") == 0)
|
||||
{
|
||||
checkUpdatesActionActivated();
|
||||
}
|
||||
QApplication::quit();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//Update reminder
|
||||
if(QDate::currentDate() >= lamexp_version_date().addYears(1))
|
||||
{
|
||||
qWarning("Binary is more than a year old, time to update!");
|
||||
if(QMessageBox::warning(this, "Urgent Update", "Your version of LameXP is more than a year old. Time for an update!", "Check for Updates", "Exit Program") == 0)
|
||||
{
|
||||
checkUpdatesActionActivated();
|
||||
}
|
||||
else
|
||||
{
|
||||
QApplication::quit();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(m_settings->autoUpdateEnabled())
|
||||
{
|
||||
QDate lastUpdateCheck = QDate::fromString(m_settings->autoUpdateLastCheck(), Qt::ISODate);
|
||||
if(!lastUpdateCheck.isValid() || QDate::currentDate() >= lastUpdateCheck.addDays(14))
|
||||
{
|
||||
if(QMessageBox::information(this, "Update Reminer", "Your last update check was more than 14 days ago. Check for updates now?", "Check for Updates", "Defer") == 0)
|
||||
{
|
||||
checkUpdatesActionActivated();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Check for AAC support
|
||||
if(lamexp_check_tool("neroAacEnc.exe") && lamexp_check_tool("neroAacDec.exe") && lamexp_check_tool("neroAacTag.exe"))
|
||||
{
|
||||
@ -504,7 +553,7 @@ void MainWindow::windowShown(void)
|
||||
void MainWindow::aboutButtonClicked(void)
|
||||
{
|
||||
ABORT_IF_BUSY;
|
||||
AboutDialog *aboutBox = new AboutDialog(this);
|
||||
AboutDialog *aboutBox = new AboutDialog(m_settings, this);
|
||||
aboutBox->exec();
|
||||
LAMEXP_DELETE(aboutBox);
|
||||
}
|
||||
@ -855,36 +904,15 @@ void MainWindow::checkUpdatesActionActivated(void)
|
||||
{
|
||||
ABORT_IF_BUSY;
|
||||
|
||||
UpdateDialog *updateDialog = new UpdateDialog(this);
|
||||
UpdateDialog *updateDialog = new UpdateDialog(m_settings, this);
|
||||
|
||||
updateDialog->exec();
|
||||
if(updateDialog->getSuccess())
|
||||
{
|
||||
m_settings->autoUpdateLastCheck(QDate::currentDate().toString(Qt::ISODate));
|
||||
}
|
||||
|
||||
LAMEXP_DELETE(updateDialog);
|
||||
|
||||
//m_banner->show("Checking for updates, please be patient...");
|
||||
//
|
||||
//for(int i = 0; i < 300; i++)
|
||||
//{
|
||||
// QApplication::processEvents();
|
||||
// Sleep(5);
|
||||
//}
|
||||
//
|
||||
//QNetworkAccessManager networkMgr;
|
||||
//QNetworkReply *reply = networkMgr.get(QNetworkRequest(QUrl( "http://mulder.dummwiedeutsch.de/update.ver")));
|
||||
|
||||
//QEventLoop loop;
|
||||
//connect(reply, SIGNAL(readyRead()), &loop, SLOT(quit()));
|
||||
//connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), &loop, SLOT(quit()));
|
||||
//connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
|
||||
|
||||
//while(!reply->isFinished())
|
||||
//{
|
||||
// loop.exec(QEventLoop::ExcludeUserInputEvents);
|
||||
// QByteArray buffer = reply->readAll();
|
||||
// qDebug("%s", buffer.constData());
|
||||
//}
|
||||
|
||||
//m_banner->close();
|
||||
//
|
||||
//QMessageBox::information(this, "Update Check", "Your version of LameXP is still up-to-date. There are no updates available.\nPlease remember to check for updates at regular intervals!");
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1247,3 +1275,55 @@ void MainWindow::findFileContextActionTriggered(void)
|
||||
QProcess::execute("explorer.exe", QStringList() << "/select," << QDir::toNativeSeparators(m_fileListModel->getFile(index).filePath()));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Disable update reminder action
|
||||
*/
|
||||
void MainWindow::disableUpdateReminderActionTriggered(bool checked)
|
||||
{
|
||||
if(checked)
|
||||
{
|
||||
if(QMessageBox::Yes == QMessageBox::question(this, "Disable Update Reminder", "Do you really want to disable the update reminder?", QMessageBox::Yes | QMessageBox::No, QMessageBox::No))
|
||||
{
|
||||
QMessageBox::information(this, "Update Reminder", "The update reminder has been disabled.<br>Please remember to check for updates at regular intervals!");
|
||||
m_settings->autoUpdateEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_settings->autoUpdateEnabled(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::information(this, "Update Reminder", "The update reminder has been re-enabled.");
|
||||
m_settings->autoUpdateEnabled(true);
|
||||
}
|
||||
|
||||
actionDisableUpdateReminder->setChecked(!m_settings->autoUpdateEnabled());
|
||||
}
|
||||
|
||||
/*
|
||||
* Disable sound effects action
|
||||
*/
|
||||
void MainWindow::disableSoundsActionTriggered(bool checked)
|
||||
{
|
||||
if(checked)
|
||||
{
|
||||
if(QMessageBox::Yes == QMessageBox::question(this, "Disable Sound Effects", "Do you really want to disable all sound effects?", QMessageBox::Yes | QMessageBox::No, QMessageBox::No))
|
||||
{
|
||||
QMessageBox::information(this, "Sound Effects", "All sound effects have been disabled.");
|
||||
m_settings->soundsEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_settings->soundsEnabled(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::information(this, "Sound Effects", "The sound effects have been re-enabled.");
|
||||
m_settings->soundsEnabled(true);
|
||||
}
|
||||
|
||||
actionDisableSounds->setChecked(!m_settings->soundsEnabled());
|
||||
}
|
||||
|
@ -83,6 +83,8 @@ private slots:
|
||||
void sourceFilesContextMenu(const QPoint &pos);
|
||||
void previewContextActionTriggered(void);
|
||||
void findFileContextActionTriggered(void);
|
||||
void disableUpdateReminderActionTriggered(bool checked);
|
||||
void disableSoundsActionTriggered(bool checked);
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *event);
|
||||
|
@ -269,7 +269,7 @@ void ProcessingDialog::doneEncoding(void)
|
||||
{
|
||||
label_progress->setText((m_succeededFiles > 0) ? QString("Process was aborted by the user after %1 file(s)!").arg(QString::number(m_succeededFiles)) : "Process was aborted prematurely by the user!");
|
||||
QApplication::processEvents();
|
||||
PlaySound(MAKEINTRESOURCE(IDR_WAVE_ABORTED), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
|
||||
if(m_settings->soundsEnabled()) PlaySound(MAKEINTRESOURCE(IDR_WAVE_ABORTED), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -277,13 +277,13 @@ void ProcessingDialog::doneEncoding(void)
|
||||
{
|
||||
label_progress->setText(QString("Error: %1 of %2 files failed. Double-click failed items for detailed information!").arg(QString::number(m_failedFiles), QString::number(m_failedFiles + m_succeededFiles)));
|
||||
QApplication::processEvents();
|
||||
PlaySound(MAKEINTRESOURCE(IDR_WAVE_ERROR), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
|
||||
if(m_settings->soundsEnabled()) PlaySound(MAKEINTRESOURCE(IDR_WAVE_ERROR), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
|
||||
}
|
||||
else
|
||||
{
|
||||
label_progress->setText("Alle files completed successfully.");
|
||||
QApplication::processEvents();
|
||||
PlaySound(MAKEINTRESOURCE(IDR_WAVE_SUCCESS), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
|
||||
if(m_settings->soundsEnabled()) PlaySound(MAKEINTRESOURCE(IDR_WAVE_SUCCESS), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,8 @@
|
||||
|
||||
#include "Global.h"
|
||||
#include "Resource.h"
|
||||
#include "Dialog_LogView.h"
|
||||
#include "Model_Settings.h"
|
||||
|
||||
#include <QClipboard>
|
||||
#include <QFileDialog>
|
||||
@ -79,14 +81,17 @@ public:
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
UpdateDialog::UpdateDialog(QWidget *parent)
|
||||
UpdateDialog::UpdateDialog(SettingsModel *settings, QWidget *parent)
|
||||
:
|
||||
QDialog(parent),
|
||||
m_binaryWGet(lamexp_lookup_tool("wget.exe")),
|
||||
m_binaryGnuPG(lamexp_lookup_tool("gpgv.exe")),
|
||||
m_binaryUpdater(lamexp_lookup_tool("wupdate.exe")),
|
||||
m_binaryKeys(lamexp_lookup_tool("gpgv.gpg")),
|
||||
m_updateInfo(NULL)
|
||||
m_updateInfo(NULL),
|
||||
m_settings(settings),
|
||||
m_logFile(new QStringList()),
|
||||
m_success(false)
|
||||
{
|
||||
if(m_binaryWGet.isEmpty() || m_binaryGnuPG.isEmpty() || m_binaryUpdater.isEmpty() || m_binaryKeys.isEmpty())
|
||||
{
|
||||
@ -105,11 +110,13 @@ UpdateDialog::UpdateDialog(QWidget *parent)
|
||||
connect(retryButton, SIGNAL(clicked()), this, SLOT(checkForUpdates()));
|
||||
connect(installButton, SIGNAL(clicked()), this, SLOT(applyUpdate()));
|
||||
connect(infoLabel, SIGNAL(linkActivated(QString)), this, SLOT(linkActivated(QString)));
|
||||
connect(logButton, SIGNAL(clicked()), this, SLOT(logButtonClicked()));
|
||||
}
|
||||
|
||||
UpdateDialog::~UpdateDialog(void)
|
||||
{
|
||||
LAMEXP_DELETE(m_updateInfo);
|
||||
LAMEXP_DELETE(m_logFile);
|
||||
}
|
||||
|
||||
void UpdateDialog::showEvent(QShowEvent *event)
|
||||
@ -124,7 +131,9 @@ void UpdateDialog::showEvent(QShowEvent *event)
|
||||
installButton->setEnabled(false);
|
||||
closeButton->setEnabled(false);
|
||||
retryButton->setEnabled(false);
|
||||
logButton->setEnabled(false);
|
||||
retryButton->hide();
|
||||
logButton->hide();
|
||||
infoLabel->hide();
|
||||
|
||||
for(int i = 0; mirrors[i]; i++)
|
||||
@ -157,11 +166,15 @@ void UpdateDialog::checkForUpdates(void)
|
||||
installButton->setEnabled(false);
|
||||
closeButton->setEnabled(false);
|
||||
retryButton->setEnabled(false);
|
||||
logButton->setEnabled(false);
|
||||
if(infoLabel->isVisible()) infoLabel->hide();
|
||||
|
||||
QApplication::processEvents();
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
|
||||
m_logFile->clear();
|
||||
m_logFile->append("Checking for updates online...");
|
||||
|
||||
for(int i = 0; mirrors[i]; i++)
|
||||
{
|
||||
progressBar->setValue(i+1);
|
||||
@ -177,15 +190,17 @@ void UpdateDialog::checkForUpdates(void)
|
||||
if(!success)
|
||||
{
|
||||
if(!retryButton->isVisible()) retryButton->show();
|
||||
if(!logButton->isVisible()) logButton->show();
|
||||
closeButton->setEnabled(true);
|
||||
retryButton->setEnabled(true);
|
||||
statusLabel->setText("Failed to fetch update information. Check internet connection!");
|
||||
logButton->setEnabled(true);
|
||||
statusLabel->setText("Failed to fetch update information. Check your internet connection!");
|
||||
progressBar->setValue(progressBar->maximum());
|
||||
LAMEXP_DELETE(m_updateInfo);
|
||||
PlaySound(MAKEINTRESOURCE(IDR_WAVE_ERROR), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC);
|
||||
if(m_settings->soundsEnabled()) PlaySound(MAKEINTRESOURCE(IDR_WAVE_ERROR), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
labelVersionLatest->setText(QString("Build %1 (%2)").arg(QString::number(m_updateInfo->m_buildNo), m_updateInfo->m_buildDate.toString(Qt::ISODate)));
|
||||
infoLabel->show();
|
||||
infoLabel->setText(QString("More information available at:<br><a href=\"%1\">%1</a>").arg(m_updateInfo->m_downloadSite));
|
||||
@ -210,39 +225,43 @@ void UpdateDialog::checkForUpdates(void)
|
||||
|
||||
closeButton->setEnabled(true);
|
||||
if(retryButton->isVisible()) retryButton->hide();
|
||||
if(logButton->isVisible()) logButton->hide();
|
||||
progressBar->setValue(progressBar->maximum());
|
||||
|
||||
m_success = true;
|
||||
}
|
||||
|
||||
bool UpdateDialog::tryUpdateMirror(UpdateInfo *updateInfo, const QString &url)
|
||||
{
|
||||
bool success = false;
|
||||
m_logFile->append(QStringList() << "" << "Trying mirror:" << url);
|
||||
|
||||
QUuid uuid = QUuid::createUuid();
|
||||
QString outFileVersionInfo = QString("%1/%2.ver").arg(QDir::tempPath(), uuid.toString());
|
||||
QString outFileSignature = QString("%1/%2.sig").arg(QDir::tempPath(), uuid.toString());
|
||||
|
||||
qDebug("\nDownloading update info:");
|
||||
m_logFile->append(QStringList() << "" << "Downloading update info:");
|
||||
bool ok1 = getFile(QString("%1%2").arg(url,mirror_url_postfix), outFileVersionInfo);
|
||||
|
||||
qDebug("\nDownloading signature file:");
|
||||
m_logFile->append(QStringList() << "" << "Downloading signature:");
|
||||
bool ok2 = getFile(QString("%1%2.sig").arg(url,mirror_url_postfix), outFileSignature);
|
||||
|
||||
if(ok1 && ok2)
|
||||
{
|
||||
qDebug("\nDownload okay, checking signature:");
|
||||
m_logFile->append(QStringList() << "" << "Download okay, checking signature:");
|
||||
if(checkSignature(outFileVersionInfo, outFileSignature))
|
||||
{
|
||||
qDebug("\nSignature okay, parsing info:");
|
||||
m_logFile->append(QStringList() << "" << "Signature okay, parsing info:");
|
||||
success = parseVersionInfo(outFileVersionInfo, updateInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug("\nBad signature, take care!");
|
||||
m_logFile->append(QStringList() << "" << "Bad signature, take care!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug("\nDownload has failed!");
|
||||
m_logFile->append(QStringList() << "" << "Download has failed!");
|
||||
}
|
||||
|
||||
QFile::remove(outFileVersionInfo);
|
||||
@ -286,11 +305,11 @@ bool UpdateDialog::getFile(const QString &url, const QString &outFile)
|
||||
loop.exec();
|
||||
while(process.canReadLine())
|
||||
{
|
||||
qDebug("WGet: %s", QString::fromLatin1(process.readLine()).simplified().toLatin1().constData());
|
||||
m_logFile->append(QString::fromLatin1(process.readLine()).simplified());
|
||||
}
|
||||
}
|
||||
|
||||
qDebug("WGet: Exited with code %d", process.exitCode());
|
||||
m_logFile->append(QString().sprintf("Exited with code %d", process.exitCode()));
|
||||
return (process.exitCode() == 0) && output.exists() && output.isFile();
|
||||
}
|
||||
|
||||
@ -317,11 +336,11 @@ bool UpdateDialog::checkSignature(const QString &file, const QString &signature)
|
||||
loop.exec();
|
||||
while(process.canReadLine())
|
||||
{
|
||||
qDebug("GnuPG: %s", QString::fromLatin1(process.readLine()).simplified().toLatin1().constData());
|
||||
m_logFile->append(QString::fromLatin1(process.readLine()).simplified());
|
||||
}
|
||||
}
|
||||
|
||||
qDebug("GnuPG: Exited with code %d", process.exitCode());
|
||||
m_logFile->append(QString().sprintf("Exited with code %d", process.exitCode()));
|
||||
return (process.exitCode() == 0);
|
||||
}
|
||||
|
||||
@ -345,13 +364,13 @@ bool UpdateDialog::parseVersionInfo(const QString &file, UpdateInfo *updateInfo)
|
||||
QString line = QString::fromLatin1(data.readLine()).trimmed();
|
||||
if(section.indexIn(line) >= 0)
|
||||
{
|
||||
qDebug("Section: '%s'", section.cap(1).toLatin1().constData());
|
||||
m_logFile->append(QString("[%1]").arg(section.cap(1)));
|
||||
inSection = (section.cap(1).compare(section_id, Qt::CaseInsensitive) == 0);
|
||||
continue;
|
||||
}
|
||||
if(inSection && value.indexIn(line) >= 0)
|
||||
{
|
||||
qDebug("Value: '%s' ==> '%s'", value.cap(1).toLatin1().constData(), value.cap(2).toLatin1().constData());
|
||||
m_logFile->append(QString("'%1' ==> '%2").arg(value.cap(1), value.cap(2)));
|
||||
if(value.cap(1).compare("BuildNo", Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
bool ok = false;
|
||||
@ -432,6 +451,7 @@ void UpdateDialog::applyUpdate(void)
|
||||
{
|
||||
statusLabel->setText("Update ready to install. Applicaion will quit...");
|
||||
QApplication::quit();
|
||||
accept();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -442,3 +462,10 @@ void UpdateDialog::applyUpdate(void)
|
||||
installButton->setEnabled(true);
|
||||
closeButton->setEnabled(true);
|
||||
}
|
||||
|
||||
void UpdateDialog::logButtonClicked(void)
|
||||
{
|
||||
LogViewDialog *logView = new LogViewDialog(this);
|
||||
logView->exec(*m_logFile);
|
||||
LAMEXP_DELETE(logView);
|
||||
}
|
||||
|
@ -26,20 +26,24 @@
|
||||
#include <QDialog>
|
||||
|
||||
class UpdateInfo;
|
||||
class SettingsModel;
|
||||
|
||||
class UpdateDialog : public QDialog, private Ui::UpdateDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
UpdateDialog(QWidget *parent = 0);
|
||||
UpdateDialog(SettingsModel *settings, QWidget *parent = 0);
|
||||
~UpdateDialog(void);
|
||||
|
||||
bool getSuccess(void) { return m_success; }
|
||||
|
||||
private slots:
|
||||
void updateInit(void);
|
||||
void checkForUpdates(void);
|
||||
void linkActivated(const QString &link);
|
||||
void applyUpdate(void);
|
||||
void logButtonClicked(void);
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *event);
|
||||
@ -52,9 +56,13 @@ private:
|
||||
bool parseVersionInfo(const QString &file, UpdateInfo *updateInfo);
|
||||
|
||||
UpdateInfo *m_updateInfo;
|
||||
QStringList *m_logFile;
|
||||
SettingsModel *m_settings;
|
||||
|
||||
const QString m_binaryWGet;
|
||||
const QString m_binaryGnuPG;
|
||||
const QString m_binaryUpdater;
|
||||
const QString m_binaryKeys;
|
||||
|
||||
bool m_success;
|
||||
};
|
||||
|
@ -80,12 +80,6 @@ int lamexp_main(int argc, char* argv[])
|
||||
{
|
||||
QDate expireDate = lamexp_version_date().addDays(14);
|
||||
qWarning(QString("Note: This demo (pre-release) version of LameXP will expire at %1.\n").arg(expireDate.toString(Qt::ISODate)).toLatin1().constData());
|
||||
if(QDate::currentDate() >= expireDate)
|
||||
{
|
||||
qWarning("Binary has expired !!!");
|
||||
QMessageBox::warning(NULL, "LameXP - Expired", QString("This demo (pre-release) version of LameXP has expired at %1.\nLameXP is free software and release versions won't expire.").arg(expireDate.toString()), "Exit Program");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//Check for multiple instances of LameXP
|
||||
|
@ -38,8 +38,11 @@ static const char *g_settingsId_compressionRCMode = "Compression/RCMode";
|
||||
static const char *g_settingsId_compressionBitrate = "Compression/Bitrate";
|
||||
static const char *g_settingsId_outputDir = "OutputDirectory/SelectedPath";
|
||||
static const char *g_settingsId_outputToSourceDir = "OutputDirectory/OutputToSourceFolder";
|
||||
static const char *g_settingsId_writeMetaTags = "WriteMetaTags";
|
||||
static const char *g_settingsId_createPlaylist = "AutoCreatePlaylist";
|
||||
static const char *g_settingsId_writeMetaTags = "Flags/WriteMetaTags";
|
||||
static const char *g_settingsId_createPlaylist = "Flags/AutoCreatePlaylist";
|
||||
static const char *g_settingsId_autoUpdateLastCheck = "AutoUpdate/LastCheck";
|
||||
static const char *g_settingsId_autoUpdateEnabled = "AutoUpdate/Enabled";
|
||||
static const char *g_settingsId_soundsEnabled = "Flags/EnableSounds";
|
||||
|
||||
//Macros
|
||||
#define MAKE_OPTION1(OPT,DEF) \
|
||||
@ -116,3 +119,6 @@ MAKE_OPTION2(outputDir, QString())
|
||||
MAKE_OPTION3(outputToSourceDir, false)
|
||||
MAKE_OPTION3(writeMetaTags, true)
|
||||
MAKE_OPTION3(createPlaylist, true)
|
||||
MAKE_OPTION2(autoUpdateLastCheck, "Never")
|
||||
MAKE_OPTION3(autoUpdateEnabled, true)
|
||||
MAKE_OPTION3(soundsEnabled, true)
|
||||
|
@ -71,6 +71,9 @@ public:
|
||||
MAKE_OPTION_DEC3(outputToSourceDir);
|
||||
MAKE_OPTION_DEC3(writeMetaTags);
|
||||
MAKE_OPTION_DEC3(createPlaylist);
|
||||
MAKE_OPTION_DEC2(autoUpdateLastCheck);
|
||||
MAKE_OPTION_DEC3(autoUpdateEnabled);
|
||||
MAKE_OPTION_DEC3(soundsEnabled);
|
||||
|
||||
//Misc
|
||||
void validate(void);
|
||||
|
Loading…
Reference in New Issue
Block a user