Detect WMA File Decoder component at runtime + suggest download if not installed.
This commit is contained in:
parent
640fa19f09
commit
c931b92a8e
@ -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 144
|
#define VER_LAMEXP_BUILD 145
|
||||||
#define VER_LAMEXP_SUFFIX TechPreview
|
#define VER_LAMEXP_SUFFIX TechPreview
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -56,6 +56,7 @@
|
|||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
#include <QProcessEnvironment>
|
#include <QProcessEnvironment>
|
||||||
|
#include <QCryptographicHash>
|
||||||
|
|
||||||
//Win32 includes
|
//Win32 includes
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
@ -538,6 +539,16 @@ void MainWindow::windowShown(void)
|
|||||||
QMessageBox::information(this, "AAC Support Disabled", messageText);
|
QMessageBox::information(this, "AAC Support Disabled", messageText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Check for WMA support
|
||||||
|
if(!lamexp_check_tool("wmawav.exe"))
|
||||||
|
{
|
||||||
|
QString messageText;
|
||||||
|
messageText += "<nobr>LameXP has detected that the WMA File Decoder component is not currently installed on your system.<br>";
|
||||||
|
messageText += "You won't be able to process WMA files as input unless the WMA File Decoder component is installed!</nobr>";
|
||||||
|
QMessageBox::information(this, "WMA Decoder Missing", messageText);
|
||||||
|
installWMADecoderActionTriggered(rand() % 2);
|
||||||
|
}
|
||||||
|
|
||||||
//Add files from the command-line
|
//Add files from the command-line
|
||||||
for(int i = 0; i < arguments.count() - 1; i++)
|
for(int i = 0; i < arguments.count() - 1; i++)
|
||||||
{
|
{
|
||||||
@ -1404,8 +1415,9 @@ void MainWindow::disableSoundsActionTriggered(bool checked)
|
|||||||
void MainWindow::installWMADecoderActionTriggered(bool checked)
|
void MainWindow::installWMADecoderActionTriggered(bool checked)
|
||||||
{
|
{
|
||||||
static const char *download_url = "http://www.nch.com.au/components/wmawav.exe";
|
static const char *download_url = "http://www.nch.com.au/components/wmawav.exe";
|
||||||
|
static const char *download_hash = "52a3b0e6690faf3f830c336d3c0eadfb7a4e9bc6";
|
||||||
|
|
||||||
if(QMessageBox::question(this, "Install WMA Decoder", "Do you want to download and install the WMA File Deocder now?", "Download && Install", "Cancel") != 0)
|
if(QMessageBox::question(this, "Install WMA Decoder", "Do you want to download and install the WMA File Decoder component now?", "Download && Install", "Cancel") != 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1418,6 +1430,8 @@ void MainWindow::installWMADecoderActionTriggered(bool checked)
|
|||||||
throw "Required binary is not available!";
|
throw "Required binary is not available!";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while(true)
|
||||||
|
{
|
||||||
QString setupFile = QString("%1/%2.exe").arg(lamexp_temp_folder(), lamexp_rand_str());
|
QString setupFile = QString("%1/%2.exe").arg(lamexp_temp_folder(), lamexp_rand_str());
|
||||||
|
|
||||||
QProcess process;
|
QProcess process;
|
||||||
@ -1433,7 +1447,31 @@ void MainWindow::installWMADecoderActionTriggered(bool checked)
|
|||||||
if(process.exitCode() != 0 || QFileInfo(setupFile).size() < 10240)
|
if(process.exitCode() != 0 || QFileInfo(setupFile).size() < 10240)
|
||||||
{
|
{
|
||||||
QFile::remove(setupFile);
|
QFile::remove(setupFile);
|
||||||
QMessageBox::critical(this, "Download Failed", "Failed to download the WMA Decoder. Check your internet connection!");
|
if(QMessageBox::critical(this, "Download Failed", "Failed to download the WMA Decoder setup. Check your internet connection!", "Try Again", "Cancel") == 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QFile setupFileContent(setupFile);
|
||||||
|
QCryptographicHash setupFileHash(QCryptographicHash::Sha1);
|
||||||
|
|
||||||
|
setupFileContent.open(QIODevice::ReadOnly);
|
||||||
|
if(setupFileContent.isOpen() && setupFileContent.isReadable())
|
||||||
|
{
|
||||||
|
setupFileHash.addData(setupFileContent.readAll());
|
||||||
|
setupFileContent.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(_stricmp(setupFileHash.result().toHex().constData(), download_hash))
|
||||||
|
{
|
||||||
|
qWarning("Hash miscompare:\n Expected %s\n Detected %s\n", download_hash, setupFileHash.result().toHex().constData());
|
||||||
|
QFile::remove(setupFile);
|
||||||
|
if(QMessageBox::critical(this, "Download Failed", "The download seems to be corrupted. Please try again!", "Try Again", "Cancel") == 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1443,6 +1481,8 @@ void MainWindow::installWMADecoderActionTriggered(bool checked)
|
|||||||
QFile::remove(setupFile);
|
QFile::remove(setupFile);
|
||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
|
|
||||||
QMessageBox::information(this, "WMA Decoder", "The WMA Decoder has been installed. Please restart LameXP now!");
|
QMessageBox::information(this, "WMA Decoder", "The WMA File Decoder has been installed. Please restart LameXP now!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -611,10 +611,10 @@ const QString &lamexp_temp_folder(void)
|
|||||||
typedef HRESULT (WINAPI *SHGetKnownFolderPathFun)(__in const GUID &rfid, __in DWORD dwFlags, __in HANDLE hToken, __out PWSTR *ppszPath);
|
typedef HRESULT (WINAPI *SHGetKnownFolderPathFun)(__in const GUID &rfid, __in DWORD dwFlags, __in HANDLE hToken, __out PWSTR *ppszPath);
|
||||||
typedef HRESULT (WINAPI *SHGetFolderPathFun)(__in HWND hwndOwner, __in int nFolder, __in HANDLE hToken, __in DWORD dwFlags, __out LPWSTR pszPath);
|
typedef HRESULT (WINAPI *SHGetFolderPathFun)(__in HWND hwndOwner, __in int nFolder, __in HANDLE hToken, __in DWORD dwFlags, __out LPWSTR pszPath);
|
||||||
|
|
||||||
const char *TEMP_STR = "Temp";
|
static const char *TEMP_STR = "Temp";
|
||||||
const int CSIDL_LOCAL_APPDATA = 0x001c;
|
static const int CSIDL_LOCAL_APPDATA = 0x001c;
|
||||||
const GUID LocalAppDataID={0xF1B32785,0x6FBA,0x4FCF,{0x9D,0x55,0x7B,0x8E,0x7F,0x15,0x70,0x91}};
|
static const GUID LocalAppDataID={0xF1B32785,0x6FBA,0x4FCF,{0x9D,0x55,0x7B,0x8E,0x7F,0x15,0x70,0x91}};
|
||||||
const GUID LocalAppDataLowID={0xA520A1A4,0x1780,0x4FF6,{0xBD,0x18,0x16,0x73,0x43,0xC5,0xAF,0x16}};
|
static const GUID LocalAppDataLowID={0xA520A1A4,0x1780,0x4FF6,{0xBD,0x18,0x16,0x73,0x43,0xC5,0xAF,0x16}};
|
||||||
|
|
||||||
if(g_lamexp_temp_folder.isEmpty())
|
if(g_lamexp_temp_folder.isEmpty())
|
||||||
{
|
{
|
||||||
|
@ -29,6 +29,9 @@
|
|||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QLibrary>
|
||||||
|
|
||||||
|
#include <Windows.h>
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// TOOLS
|
// TOOLS
|
||||||
@ -137,6 +140,9 @@ void InitializationThread::run()
|
|||||||
//Look for Nero encoder
|
//Look for Nero encoder
|
||||||
initNeroAac();
|
initNeroAac();
|
||||||
|
|
||||||
|
//Look for WMA File decoder
|
||||||
|
initWmaDec();
|
||||||
|
|
||||||
delay();
|
delay();
|
||||||
m_bSuccess = true;
|
m_bSuccess = true;
|
||||||
}
|
}
|
||||||
@ -260,6 +266,54 @@ void InitializationThread::initNeroAac(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void InitializationThread::initWmaDec(void)
|
||||||
|
{
|
||||||
|
typedef HRESULT (WINAPI *SHGetFolderPathFun)(__in HWND hwndOwner, __in int nFolder, __in HANDLE hToken, __in DWORD dwFlags, __out LPWSTR pszPath);
|
||||||
|
static const char* wmaDecoderComponentPath = "NCH Software/Components/wmawav/wmawav.exe";
|
||||||
|
static const int CSIDL_PROGRAM_FILES = 0x0026;
|
||||||
|
|
||||||
|
QLibrary Kernel32Lib("shell32.dll");
|
||||||
|
SHGetFolderPathFun SHGetFolderPathPtr = (SHGetFolderPathFun) Kernel32Lib.resolve("SHGetFolderPathW");
|
||||||
|
QDir programFilesDir = QDir::temp();
|
||||||
|
|
||||||
|
if(SHGetFolderPathPtr)
|
||||||
|
{
|
||||||
|
WCHAR *programFilesPath = new WCHAR[4096];
|
||||||
|
if(SHGetFolderPathPtr(NULL, CSIDL_PROGRAM_FILES, NULL, NULL, programFilesPath) == S_OK)
|
||||||
|
{
|
||||||
|
programFilesDir.setPath(QDir::fromNativeSeparators(QString::fromUtf16(reinterpret_cast<const unsigned short*>(programFilesPath))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LockedFile *wmaFileBin = NULL;
|
||||||
|
QFileInfo wmaFileInfo = QFileInfo(QString("%1/%2").arg(programFilesDir.absolutePath(), wmaDecoderComponentPath));
|
||||||
|
|
||||||
|
//Lock the WMA Decoder binaries
|
||||||
|
if(!wmaFileInfo.exists())
|
||||||
|
{
|
||||||
|
qDebug("WMA File Decoder not found -> WMA decoding support will be disabled!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug("Found WMA File Decoder binary:\n%s\n", wmaFileInfo.canonicalFilePath().toUtf8().constData());
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
wmaFileBin = new LockedFile(wmaFileInfo.canonicalFilePath());
|
||||||
|
}
|
||||||
|
catch(...)
|
||||||
|
{
|
||||||
|
qWarning("Failed to get excluive lock to WMA File Decoder binary -> WMA decoding support will be disabled!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(wmaFileBin)
|
||||||
|
{
|
||||||
|
lamexp_register_tool(wmaFileInfo.fileName(), wmaFileBin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// EVENTS
|
// EVENTS
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -39,6 +39,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
void delay(void);
|
void delay(void);
|
||||||
void initNeroAac(void);
|
void initNeroAac(void);
|
||||||
|
void initWmaDec(void);
|
||||||
|
|
||||||
bool m_bSuccess;
|
bool m_bSuccess;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user