Implemented function to download and install the WMA File Decoder. Support for WMA files has not been implemented yet though.

This commit is contained in:
LoRd_MuldeR 2010-12-12 01:49:07 +01:00
parent 4650e02aac
commit 640fa19f09
11 changed files with 126 additions and 8 deletions

View File

@ -1159,8 +1159,19 @@
<property name="title"> <property name="title">
<string>Tools</string> <string>Tools</string>
</property> </property>
<addaction name="actionDisableUpdateReminder"/> <widget class="QMenu" name="menuConfiguration">
<property name="title">
<string>Configuration</string>
</property>
<property name="icon">
<iconset resource="../res/Icons.qrc">
<normaloff>:/icons/wrench.png</normaloff>:/icons/wrench.png</iconset>
</property>
<addaction name="actionDisableSounds"/> <addaction name="actionDisableSounds"/>
<addaction name="actionDisableUpdateReminder"/>
</widget>
<addaction name="menuConfiguration"/>
<addaction name="actionInstallWMADecoder"/>
</widget> </widget>
<addaction name="menuFile"/> <addaction name="menuFile"/>
<addaction name="menuView"/> <addaction name="menuView"/>
@ -1332,6 +1343,15 @@
<string>Disable Sound Effects</string> <string>Disable Sound Effects</string>
</property> </property>
</action> </action>
<action name="actionInstallWMADecoder">
<property name="icon">
<iconset resource="../res/Icons.qrc">
<normaloff>:/icons/wma.png</normaloff>:/icons/wma.png</iconset>
</property>
<property name="text">
<string>Install WMA Decoder</string>
</property>
</action>
</widget> </widget>
<resources> <resources>
<include location="../res/Icons.qrc"/> <include location="../res/Icons.qrc"/>
@ -1421,6 +1441,8 @@
<include location="../res/Images.qrc"/> <include location="../res/Images.qrc"/>
<include location="../res/Icons.qrc"/> <include location="../res/Icons.qrc"/>
<include location="../res/Images.qrc"/> <include location="../res/Images.qrc"/>
<include location="../res/Icons.qrc"/>
<include location="../res/Images.qrc"/>
</resources> </resources>
<connections> <connections>
<connection> <connection>

View File

@ -64,7 +64,9 @@
<file>icons/transmit_blue.png</file> <file>icons/transmit_blue.png</file>
<file>icons/user.png</file> <file>icons/user.png</file>
<file>icons/user_suit.png</file> <file>icons/user_suit.png</file>
<file>icons/wma.png</file>
<file>icons/world.png</file> <file>icons/world.png</file>
<file>icons/wrench.png</file>
<file>icons/zoom.png</file> <file>icons/zoom.png</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -2,6 +2,7 @@
<RCC version="1.0"> <RCC version="1.0">
<qresource> <qresource>
<file>tools/alac.exe</file> <file>tools/alac.exe</file>
<file>tools/elevator.exe</file>
<file>tools/faad.exe</file> <file>tools/faad.exe</file>
<file>tools/flac.exe</file> <file>tools/flac.exe</file>
<file>tools/gpgv.exe</file> <file>tools/gpgv.exe</file>

BIN
res/icons/wma.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
res/tools/elevator.exe Normal file

Binary file not shown.

View File

@ -25,7 +25,7 @@
#define VER_LAMEXP_MAJOR 4 #define VER_LAMEXP_MAJOR 4
#define VER_LAMEXP_MINOR_HI 0 #define VER_LAMEXP_MINOR_HI 0
#define VER_LAMEXP_MINOR_LO 0 #define VER_LAMEXP_MINOR_LO 0
#define VER_LAMEXP_BUILD 142 #define VER_LAMEXP_BUILD 144
#define VER_LAMEXP_SUFFIX TechPreview #define VER_LAMEXP_SUFFIX TechPreview
/* /*

View File

@ -250,6 +250,7 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S
actionDisableSounds->setChecked(!m_settings->soundsEnabled()); actionDisableSounds->setChecked(!m_settings->soundsEnabled());
connect(actionDisableUpdateReminder, SIGNAL(triggered(bool)), this, SLOT(disableUpdateReminderActionTriggered(bool))); connect(actionDisableUpdateReminder, SIGNAL(triggered(bool)), this, SLOT(disableUpdateReminderActionTriggered(bool)));
connect(actionDisableSounds, SIGNAL(triggered(bool)), this, SLOT(disableSoundsActionTriggered(bool))); connect(actionDisableSounds, SIGNAL(triggered(bool)), this, SLOT(disableSoundsActionTriggered(bool)));
connect(actionInstallWMADecoder, SIGNAL(triggered(bool)), this, SLOT(installWMADecoderActionTriggered(bool)));
//Activate help menu actions //Activate help menu actions
connect(actionCheckUpdates, SIGNAL(triggered()), this, SLOT(checkUpdatesActionActivated())); connect(actionCheckUpdates, SIGNAL(triggered()), this, SLOT(checkUpdatesActionActivated()));
@ -1399,3 +1400,49 @@ void MainWindow::disableSoundsActionTriggered(bool checked)
actionDisableSounds->setChecked(!m_settings->soundsEnabled()); actionDisableSounds->setChecked(!m_settings->soundsEnabled());
} }
void MainWindow::installWMADecoderActionTriggered(bool checked)
{
static const char *download_url = "http://www.nch.com.au/components/wmawav.exe";
if(QMessageBox::question(this, "Install WMA Decoder", "Do you want to download and install the WMA File Deocder now?", "Download && Install", "Cancel") != 0)
{
return;
}
QString binaryWGet = lamexp_lookup_tool("wget.exe");
QString binaryElevator = lamexp_lookup_tool("elevator.exe");
if(binaryWGet.isEmpty() || binaryElevator.isEmpty())
{
throw "Required binary is not available!";
}
QString setupFile = QString("%1/%2.exe").arg(lamexp_temp_folder(), lamexp_rand_str());
QProcess process;
process.setWorkingDirectory(QFileInfo(setupFile).absolutePath());
QEventLoop loop;
connect(&process, SIGNAL(error(QProcess::ProcessError)), &loop, SLOT(quit()));
connect(&process, SIGNAL(finished(int, QProcess::ExitStatus)), &loop, SLOT(quit()));
process.start(binaryWGet, QStringList() << "-O" << QFileInfo(setupFile).fileName() << download_url);
m_banner->show("Downloading WMA Decoder Setup, please wait...", &loop);
if(process.exitCode() != 0 || QFileInfo(setupFile).size() < 10240)
{
QFile::remove(setupFile);
QMessageBox::critical(this, "Download Failed", "Failed to download the WMA Decoder. Check your internet connection!");
return;
}
QApplication::setOverrideCursor(Qt::WaitCursor);
process.start(binaryElevator, QStringList() << QString("/exec=%1").arg(setupFile));
loop.exec(QEventLoop::ExcludeUserInputEvents);
QFile::remove(setupFile);
QApplication::restoreOverrideCursor();
QMessageBox::information(this, "WMA Decoder", "The WMA Decoder has been installed. Please restart LameXP now!");
}

View File

@ -87,6 +87,7 @@ private slots:
void disableSoundsActionTriggered(bool checked); void disableSoundsActionTriggered(bool checked);
void outputFolderContextMenu(const QPoint &pos); void outputFolderContextMenu(const QPoint &pos);
void showFolderContextActionTriggered(void); void showFolderContextActionTriggered(void);
void installWMADecoderActionTriggered(bool checked);
protected: protected:
void showEvent(QShowEvent *event); void showEvent(QShowEvent *event);

View File

@ -114,6 +114,26 @@ void WorkingBanner::show(const QString &text, QThread *thread)
this->close(); this->close();
} }
void WorkingBanner::show(const QString &text, QEventLoop *loop)
{
//Show splash
this->show(text);
//Set taskbar state
WinSevenTaskbar::setOverlayIcon(dynamic_cast<QWidget*>(this->parent()), &QIcon(":/icons/hourglass.png"));
WinSevenTaskbar::setTaskbarState(dynamic_cast<QWidget*>(this->parent()), WinSevenTaskbar::WinSevenTaskbarIndeterminateState);
//Loop while thread is running
loop->exec(QEventLoop::ExcludeUserInputEvents);
//Set taskbar state
WinSevenTaskbar::setTaskbarState(dynamic_cast<QWidget*>(this->parent()), WinSevenTaskbar::WinSevenTaskbarNoState);
WinSevenTaskbar::setOverlayIcon(dynamic_cast<QWidget*>(this->parent()), NULL);
//Hide splash
this->close();
}
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// EVENTS // EVENTS
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////

View File

@ -37,6 +37,7 @@ public:
void show(const QString &text); void show(const QString &text);
void show(const QString &text, QThread *thread); void show(const QString &text, QThread *thread);
void show(const QString &text, QEventLoop *loop);
void close(void); void close(void);
private: private:

View File

@ -27,6 +27,8 @@
#include <QFileInfo> #include <QFileInfo>
#include <QCoreApplication> #include <QCoreApplication>
#include <QProcess> #include <QProcess>
#include <QMap>
#include <QDir>
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// TOOLS // TOOLS
@ -41,6 +43,7 @@ struct lamexp_tool_t
static const struct lamexp_tool_t g_lamexp_tools[] = static const struct lamexp_tool_t g_lamexp_tools[] =
{ {
{"153f4274702f3629093b561a31dbf50e2c146305", "alac.exe"}, {"153f4274702f3629093b561a31dbf50e2c146305", "alac.exe"},
{"4ecc017a66fe43092110f11494f384e57d99280d", "elevator.exe"},
{"097dd004f44dbda57dbaeb5f15b34a220724ad60", "faad.exe"}, {"097dd004f44dbda57dbaeb5f15b34a220724ad60", "faad.exe"},
{"070bf98f78e572a97e4703ef5720c682567a6a56", "flac.exe"}, {"070bf98f78e572a97e4703ef5720c682567a6a56", "flac.exe"},
{"cf379081035ae6bfb6f7bc22f13bfb7ac6302ac5", "gpgv.exe"}, {"cf379081035ae6bfb6f7bc22f13bfb7ac6302ac5", "gpgv.exe"},
@ -85,19 +88,34 @@ void InitializationThread::run()
m_bSuccess = false; m_bSuccess = false;
delay(); delay();
//Extract all files QMap<QString,QString> checksum;
//Init checksums
for(int i = 0; i < INT_MAX; i++) for(int i = 0; i < INT_MAX; i++)
{ {
if(!g_lamexp_tools[i].pcName || !g_lamexp_tools[i].pcHash) if(g_lamexp_tools[i].pcName && g_lamexp_tools[i].pcHash)
{ {
checksum.insert(QString::fromLatin1(g_lamexp_tools[i].pcName), QString::fromLatin1(g_lamexp_tools[i].pcHash));
continue;
}
break; break;
} }
QDir toolsDir(":/tools/");
QList<QFileInfo> toolsList = toolsDir.entryInfoList(QStringList("*.*"), QDir::Files, QDir::Name);
//Extract all files
for(int i = 0; i < toolsList.count(); i++)
{
try try
{ {
qDebug("Extracting file: %s", g_lamexp_tools[i].pcName); qDebug("Extracting file: %s", g_lamexp_tools[i].pcName);
QString toolName = QString::fromLatin1(g_lamexp_tools[i].pcName); QString toolName = toolsList.at(i).fileName();
QByteArray toolHash = QString::fromLatin1(g_lamexp_tools[i].pcHash).toLatin1(); QByteArray toolHash = checksum.take(toolName).toLatin1();
if(toolHash.size() != 40)
{
throw "The required checksum is missing, take care!";
}
LockedFile *lockedFile = new LockedFile(QString(":/tools/%1").arg(toolName), QString(lamexp_temp_folder()).append(QString("/tool_%1").arg(toolName)), toolHash); LockedFile *lockedFile = new LockedFile(QString(":/tools/%1").arg(toolName), QString(lamexp_temp_folder()).append(QString("/tool_%1").arg(toolName)), toolHash);
lamexp_register_tool(toolName, lockedFile); lamexp_register_tool(toolName, lockedFile);
} }
@ -108,6 +126,12 @@ void InitializationThread::run()
} }
} }
if(!checksum.isEmpty())
{
qFatal("At least one required tool could not be found:\n%s", toolsDir.filePath(checksum.keys().first()).toLatin1().constData());
return;
}
qDebug("All extracted.\n"); qDebug("All extracted.\n");
//Look for Nero encoder //Look for Nero encoder