More code refactoring and clean-up.

This commit is contained in:
LoRd_MuldeR 2014-12-19 23:49:11 +01:00
parent cc45c1a904
commit 537ade07f6
46 changed files with 208 additions and 241 deletions

View File

@ -35,7 +35,7 @@
#define VER_LAMEXP_MINOR_LO 1
#define VER_LAMEXP_TYPE Beta
#define VER_LAMEXP_PATCH 9
#define VER_LAMEXP_BUILD 1636
#define VER_LAMEXP_BUILD 1638
#define VER_LAMEXP_CONFG 1558
///////////////////////////////////////////////////////////////////////////////

View File

@ -35,7 +35,7 @@
AACDecoder::AACDecoder(void)
:
m_binary(lamexp_lookup_tool("faad.exe"))
m_binary(lamexp_tool_lookup("faad.exe"))
{
if(m_binary.isEmpty())
{

View File

@ -35,7 +35,7 @@
AC3Decoder::AC3Decoder(void)
:
m_binary(lamexp_lookup_tool("valdec.exe"))
m_binary(lamexp_tool_lookup("valdec.exe"))
{
if(m_binary.isEmpty())
{

View File

@ -35,7 +35,7 @@
ADPCMDecoder::ADPCMDecoder(void)
:
m_binary(lamexp_lookup_tool("sox.exe"))
m_binary(lamexp_tool_lookup("sox.exe"))
{
if(m_binary.isEmpty())
{

View File

@ -36,7 +36,7 @@
ALACDecoder::ALACDecoder(void)
:
m_binary(lamexp_lookup_tool("refalac.exe"))
m_binary(lamexp_tool_lookup("refalac.exe"))
{
if(m_binary.isEmpty())
{

View File

@ -36,7 +36,7 @@
AvisynthDecoder::AvisynthDecoder(void)
:
m_binary(lamexp_lookup_tool("avs2wav.exe"))
m_binary(lamexp_tool_lookup("avs2wav.exe"))
{
if(m_binary.isEmpty())
{

View File

@ -35,7 +35,7 @@
FLACDecoder::FLACDecoder(void)
:
m_binary(lamexp_lookup_tool("flac.exe"))
m_binary(lamexp_tool_lookup("flac.exe"))
{
if(m_binary.isEmpty())
{

View File

@ -35,7 +35,7 @@
MACDecoder::MACDecoder(void)
:
m_binary(lamexp_lookup_tool("mac.exe"))
m_binary(lamexp_tool_lookup("mac.exe"))
{
if(m_binary.isEmpty())
{

View File

@ -35,7 +35,7 @@
MP3Decoder::MP3Decoder(void)
:
m_binary(lamexp_lookup_tool("mpg123.exe"))
m_binary(lamexp_tool_lookup("mpg123.exe"))
{
if(m_binary.isEmpty())
{

View File

@ -36,7 +36,7 @@
MusepackDecoder::MusepackDecoder(void)
:
m_binary(lamexp_lookup_tool("mpcdec.exe"))
m_binary(lamexp_tool_lookup("mpcdec.exe"))
{
if(m_binary.isEmpty())
{

View File

@ -38,7 +38,7 @@ bool OpusDecoder::m_disableResampling = false;
OpusDecoder::OpusDecoder(void)
:
m_binary(lamexp_lookup_tool("opusdec.exe"))
m_binary(lamexp_tool_lookup("opusdec.exe"))
{
if(m_binary.isEmpty())
{

View File

@ -36,7 +36,7 @@
ShortenDecoder::ShortenDecoder(void)
:
m_binary(lamexp_lookup_tool("shorten.exe"))
m_binary(lamexp_tool_lookup("shorten.exe"))
{
if(m_binary.isEmpty())
{

View File

@ -35,7 +35,7 @@
SpeexDecoder::SpeexDecoder(void)
:
m_binary(lamexp_lookup_tool("speexdec.exe"))
m_binary(lamexp_tool_lookup("speexdec.exe"))
{
if(m_binary.isEmpty())
{

View File

@ -36,7 +36,7 @@
TTADecoder::TTADecoder(void)
:
m_binary(lamexp_lookup_tool("tta.exe"))
m_binary(lamexp_tool_lookup("tta.exe"))
{
if(m_binary.isEmpty())
{

View File

@ -35,7 +35,7 @@
VorbisDecoder::VorbisDecoder(void)
:
m_binary(lamexp_lookup_tool("oggdec.exe"))
m_binary(lamexp_tool_lookup("oggdec.exe"))
{
if(m_binary.isEmpty())
{

View File

@ -37,7 +37,7 @@
WMADecoder::WMADecoder(void)
:
m_binary(lamexp_lookup_tool("wma2wav.exe"))
m_binary(lamexp_tool_lookup("wma2wav.exe"))
{
if(m_binary.isEmpty())
{

View File

@ -35,7 +35,7 @@
WavPackDecoder::WavPackDecoder(void)
:
m_binary(lamexp_lookup_tool("wvunpack.exe"))
m_binary(lamexp_tool_lookup("wvunpack.exe"))
{
if(m_binary.isEmpty())
{

View File

@ -155,7 +155,7 @@ int CueImportDialog::exec(void)
QStringList codecList;
codecList.append(systemDefault);
codecList.append(lamexp_available_codepages());
codecList.append(MUtils::available_codepages());
QInputDialog *input = new QInputDialog(progress);
input->setLabelText(EXPAND(tr("Select ANSI Codepage for Cue Sheet file:")));

View File

@ -625,7 +625,7 @@ MainWindow::MainWindow(MUtils::IPCChannel *const ipcChannel, FileListModel *cons
ui->actionDisableNeroAacNotifications->setChecked(!m_settings->neroAacNotificationsEnabled());
ui->actionDisableSlowStartupNotifications->setChecked(!m_settings->antivirNotificationsEnabled());
ui->actionDisableShellIntegration->setChecked(!m_settings->shellIntegrationEnabled());
ui->actionDisableShellIntegration->setDisabled(lamexp_portable_mode() && ui->actionDisableShellIntegration->isChecked());
ui->actionDisableShellIntegration->setDisabled(lamexp_version_portable() && ui->actionDisableShellIntegration->isChecked());
ui->actionCheckForBetaUpdates->setChecked(m_settings->autoUpdateCheckBeta() || lamexp_version_demo());
ui->actionCheckForBetaUpdates->setEnabled(!lamexp_version_demo());
ui->actionHibernateComputer->setChecked(m_settings->hibernateComputer());
@ -2178,7 +2178,7 @@ void MainWindow::disableShellIntegrationActionTriggered(bool checked)
ui->actionDisableShellIntegration->setChecked(!m_settings->shellIntegrationEnabled());
if(lamexp_portable_mode() && ui->actionDisableShellIntegration->isChecked())
if(lamexp_version_portable() && ui->actionDisableShellIntegration->isChecked())
{
ui->actionDisableShellIntegration->setEnabled(false);
}
@ -4012,7 +4012,7 @@ void MainWindow::customParamsHelpRequested(QWidget *obj, QEvent *event)
*/
void MainWindow::showCustomParamsHelpScreen(const QString &toolName, const QString &command)
{
const QString binary = lamexp_lookup_tool(toolName);
const QString binary = lamexp_tool_lookup(toolName);
if(binary.isEmpty())
{
MUtils::Sound::beep(MUtils::Sound::BEEP_ERR);

View File

@ -82,10 +82,10 @@ UpdateDialog::UpdateDialog(const SettingsModel *const settings, QWidget *parent)
m_firstShow(true),
m_updateReadyToInstall(false),
m_updaterProcess(NULL),
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"))
m_binaryUpdater(lamexp_tool_lookup("wupdate.exe")),
m_binaryWGet(lamexp_tool_lookup("wget.exe")),
m_binaryGnuPG(lamexp_tool_lookup("gpgv.exe")),
m_binaryKeys(lamexp_tool_lookup("gpgv.gpg"))
{
if(m_binaryUpdater.isEmpty())
{

View File

@ -117,9 +117,9 @@ static const g_aacEncoderInfo;
AACEncoder::AACEncoder(void)
:
m_binary_enc(lamexp_lookup_tool("neroAacEnc.exe")),
m_binary_tag(lamexp_lookup_tool("neroAacTag.exe")),
m_binary_sox(lamexp_lookup_tool("sox.exe"))
m_binary_enc(lamexp_tool_lookup("neroAacEnc.exe")),
m_binary_tag(lamexp_tool_lookup("neroAacTag.exe")),
m_binary_sox(lamexp_tool_lookup("sox.exe"))
{
if(m_binary_enc.isEmpty() || m_binary_tag.isEmpty() || m_binary_sox.isEmpty())
{

View File

@ -120,8 +120,8 @@ static const g_fhgAacEncoderInfo;
FHGAACEncoder::FHGAACEncoder(void)
:
m_binary_enc(lamexp_lookup_tool("fhgaacenc.exe")),
m_binary_dll(lamexp_lookup_tool("enc_fhgaac.dll"))
m_binary_enc(lamexp_tool_lookup("fhgaacenc.exe")),
m_binary_dll(lamexp_tool_lookup("enc_fhgaac.dll"))
{
if(m_binary_enc.isEmpty() || m_binary_dll.isEmpty())
{

View File

@ -128,9 +128,9 @@ static const g_qaacEncoderInfo;
QAACEncoder::QAACEncoder(void)
:
m_binary_qaac(lamexp_lookup_tool("qaac.exe")),
m_binary_soxr(lamexp_lookup_tool("libsoxr.dll")),
m_binary_soxc(lamexp_lookup_tool("libsoxconvolver.dll"))
m_binary_qaac(lamexp_tool_lookup("qaac.exe")),
m_binary_soxr(lamexp_tool_lookup("libsoxr.dll")),
m_binary_soxc(lamexp_tool_lookup("libsoxconvolver.dll"))
{
if(m_binary_qaac.isEmpty() || m_binary_soxr.isEmpty() || m_binary_soxc.isEmpty())
{

View File

@ -116,7 +116,7 @@ static const g_aftenEncoderInfo;
AC3Encoder::AC3Encoder(void)
:
m_binary(lamexp_lookup_tool("aften.exe"))
m_binary(lamexp_tool_lookup("aften.exe"))
{
if(m_binary.isEmpty())
{

View File

@ -118,7 +118,7 @@ static const g_dcaEncoderInfo;
DCAEncoder::DCAEncoder(void)
:
m_binary(lamexp_lookup_tool("dcaenc.exe"))
m_binary(lamexp_tool_lookup("dcaenc.exe"))
{
if(m_binary.isEmpty())
{

View File

@ -112,7 +112,7 @@ static const g_flacEncoderInfo;
FLACEncoder::FLACEncoder(void)
:
m_binary(lamexp_lookup_tool("flac.exe"))
m_binary(lamexp_tool_lookup("flac.exe"))
{
if(m_binary.isEmpty())
{

View File

@ -112,8 +112,8 @@ static const g_macEncoderInfo;
MACEncoder::MACEncoder(void)
:
m_binary_enc(lamexp_lookup_tool("mac.exe")),
m_binary_tag(lamexp_lookup_tool("tag.exe"))
m_binary_enc(lamexp_tool_lookup("mac.exe")),
m_binary_tag(lamexp_tool_lookup("tag.exe"))
{
if(m_binary_enc.isEmpty() || m_binary_tag.isEmpty())
{

View File

@ -117,7 +117,7 @@ static const g_mp3EncoderInfo;
MP3Encoder::MP3Encoder(void)
:
m_binary(lamexp_lookup_tool("lame.exe"))
m_binary(lamexp_tool_lookup("lame.exe"))
{
if(m_binary.isEmpty())
{

View File

@ -107,7 +107,7 @@ static const g_opusEncoderInfo;
OpusEncoder::OpusEncoder(void)
:
m_binary(lamexp_lookup_tool("opusenc.exe"))
m_binary(lamexp_tool_lookup("opusenc.exe"))
{
if(m_binary.isEmpty())
{

View File

@ -114,7 +114,7 @@ static const g_vorbisEncoderInfo;
VorbisEncoder::VorbisEncoder(void)
:
m_binary(lamexp_lookup_tool("oggenc2.exe"))
m_binary(lamexp_tool_lookup("oggenc2.exe"))
{
if(m_binary.isEmpty())
{

View File

@ -37,7 +37,7 @@
DownmixFilter::DownmixFilter(void)
:
m_binary(lamexp_lookup_tool("sox.exe"))
m_binary(lamexp_tool_lookup("sox.exe"))
{
if(m_binary.isEmpty())
{

View File

@ -35,7 +35,7 @@
NormalizeFilter::NormalizeFilter(int peakVolume, int equalizationMode)
:
m_binary(lamexp_lookup_tool("sox.exe"))
m_binary(lamexp_tool_lookup("sox.exe"))
{
if(m_binary.isEmpty())
{

View File

@ -41,7 +41,7 @@ static __inline int multipleOf(int value, int base)
ResampleFilter::ResampleFilter(int samplingRate, int bitDepth)
:
m_binary(lamexp_lookup_tool("sox.exe"))
m_binary(lamexp_tool_lookup("sox.exe"))
{
if(m_binary.isEmpty())
{

View File

@ -36,7 +36,7 @@
ToneAdjustFilter::ToneAdjustFilter(int bass, int treble)
:
m_binary(lamexp_lookup_tool("sox.exe"))
m_binary(lamexp_tool_lookup("sox.exe"))
{
if(m_binary.isEmpty())
{

View File

@ -22,22 +22,23 @@
#pragma once
#ifdef _MSC_VER
#define _CRT_RAND_S
#endif
#include <cstdlib>
#include <QtGlobal>
//Forward declarations
class QString;
class QStringList;
class QDate;
class QTime;
class QStringList;
class QIcon;
class QWidget;
class QProcess;
class QColor;
class LockedFile;
enum QtMsgType;
//Variables
///////////////////////////////////////////////////////////////////////////////
// GLOBAL CONSTANTS
///////////////////////////////////////////////////////////////////////////////
extern const char* LAMEXP_DEFAULT_LANGID;
extern const char* LAMEXP_DEFAULT_TRANSLATION;
@ -45,38 +46,61 @@ extern const char* LAMEXP_DEFAULT_TRANSLATION;
// GLOBAL FUNCTIONS
///////////////////////////////////////////////////////////////////////////////
const QIcon &lamexp_app_icon(void);
QStringList lamexp_available_codepages(bool noAliases = true);
bool lamexp_check_tool(const QString &toolName);
void lamexp_finalization(void);
bool lamexp_install_translator(const QString &language);
bool lamexp_install_translator_from_file(const QString &qmFile);
const QString lamexp_lookup_tool(const QString &toolName);
const char *lamexp_mulders_url(void);
bool lamexp_portable_mode(void);
/*
* Translation Support
*/
QStringList lamexp_query_translations(void);
void lamexp_register_tool(const QString &toolName, LockedFile *file, unsigned int version = 0, const QString *tag = NULL);
const char *lamexp_support_url(void);
unsigned int lamexp_tool_version(const QString &toolName, QString *tag = NULL);
unsigned int lamexp_toolver_coreaudio(void);
unsigned int lamexp_toolver_fhgaacenc(void);
unsigned int lamexp_toolver_neroaac(void);
unsigned int lamexp_toolver_qaacenc(void);
const char *lamexp_tracker_url(void);
unsigned int lamexp_translation_country(const QString &langId);
bool lamexp_translation_init(void);
QString lamexp_translation_name(const QString &language);
bool lamexp_translation_register(const QString &langId, const QString &qmFile, const QString &langName, unsigned int &systemId, unsigned int &country);
unsigned int lamexp_translation_sysid(const QString &langId);
const QString lamexp_version2string(const QString &pattern, unsigned int version, const QString &defaultText, const QString *tag = NULL);
unsigned int lamexp_version_build(void);
unsigned int lamexp_version_confg(void);
bool lamexp_version_demo(void);
QDate lamexp_version_expires(void);
bool lamexp_install_translator(const QString &language);
bool lamexp_install_translator_from_file(const QString &qmFile);
/*
* Tools Support
*/
bool lamexp_tool_check (const QString &toolName);
const QString& lamexp_tool_lookup (const QString &toolName);
void lamexp_tool_register(const QString &toolName, LockedFile *file, unsigned int version = 0, const QString *tag = NULL);
unsigned int lamexp_tool_version (const QString &toolName, QString *tag = NULL);
/*
* Version getters
*/
unsigned int lamexp_version_major (void);
unsigned int lamexp_version_minor (void);
unsigned int lamexp_version_build (void);
unsigned int lamexp_version_confg (void);
const char* lamexp_version_release (void);
bool lamexp_version_portable (void);
bool lamexp_version_demo (void);
QDate& lamexp_version_expires (void);
unsigned int lamexp_toolver_neroaac (void);
unsigned int lamexp_toolver_fhgaacenc(void);
unsigned int lamexp_toolver_qaacenc (void);
unsigned int lamexp_toolver_coreaudio(void);
/*
* URL getters
*/
const char *lamexp_website_url(void);
const char *lamexp_mulders_url(void);
const char *lamexp_support_url(void);
const char *lamexp_tracker_url(void);
/*
* Misc Functions
*/
const QIcon& lamexp_app_icon(void);
const QString lamexp_version2string(const QString &pattern, unsigned int version, const QString &defaultText, const QString *tag = NULL);
/*
* Finalization
*/
void lamexp_finalization(void);
///////////////////////////////////////////////////////////////////////////////
// HELPER MACROS

View File

@ -73,6 +73,9 @@ static struct
}
g_lamexp_currentTranslator;
//Null String
static const QString g_null;
///////////////////////////////////////////////////////////////////////////////
// GLOBAL FUNCTIONS
///////////////////////////////////////////////////////////////////////////////
@ -80,7 +83,7 @@ g_lamexp_currentTranslator;
/*
* Register tool
*/
void lamexp_register_tool(const QString &toolName, LockedFile *file, unsigned int version, const QString *tag)
void lamexp_tool_register(const QString &toolName, LockedFile *file, unsigned int version, const QString *tag)
{
QWriteLocker writeLock(&g_lamexp_tools.lock);
@ -101,7 +104,7 @@ void lamexp_register_tool(const QString &toolName, LockedFile *file, unsigned in
/*
* Check for tool
*/
bool lamexp_check_tool(const QString &toolName)
bool lamexp_tool_check(const QString &toolName)
{
QReadLocker readLock(&g_lamexp_tools.lock);
return (g_lamexp_tools.registry) ? g_lamexp_tools.registry->contains(toolName.toLower()) : false;
@ -110,7 +113,7 @@ bool lamexp_check_tool(const QString &toolName)
/*
* Lookup tool path
*/
const QString lamexp_lookup_tool(const QString &toolName)
const QString &lamexp_tool_lookup(const QString &toolName)
{
QReadLocker readLock(&g_lamexp_tools.lock);
@ -122,12 +125,12 @@ const QString lamexp_lookup_tool(const QString &toolName)
}
else
{
return QString();
return g_null;
}
}
else
{
return QString();
return g_null;
}
}

View File

@ -47,46 +47,13 @@
// GLOBAL VARS
///////////////////////////////////////////////////////////////////////////////
static struct
{
QIcon *appIcon;
QReadWriteLock lock;
}
g_lamexp_app_icon;
static QScopedPointer<QIcon> g_lamexp_icon_data;
static QReadWriteLock g_lamexp_icon_lock;
///////////////////////////////////////////////////////////////////////////////
// GLOBAL FUNCTIONS
///////////////////////////////////////////////////////////////////////////////
/*
* Get a list of all available Qt Text Codecs
*/
QStringList lamexp_available_codepages(bool noAliases)
{
QStringList codecList;
QList<QByteArray> availableCodecs = QTextCodec::availableCodecs();
while(!availableCodecs.isEmpty())
{
QByteArray current = availableCodecs.takeFirst();
if(!(current.startsWith("system") || current.startsWith("System")))
{
codecList << QString::fromLatin1(current.constData(), current.size());
if(noAliases)
{
if(QTextCodec *currentCodec = QTextCodec::codecForName(current.constData()))
{
QList<QByteArray> aliases = currentCodec->aliases();
while(!aliases.isEmpty()) availableCodecs.removeAll(aliases.takeFirst());
}
}
}
}
return codecList;
}
/*
* Computus according to H. Lichtenberg
*/
@ -140,66 +107,47 @@ static bool lamexp_thanksgiving(const QDate &date)
*/
const QIcon &lamexp_app_icon(void)
{
QReadLocker readLock(&g_lamexp_app_icon.lock);
QReadLocker readLock(&g_lamexp_icon_lock);
//Already initialized?
if(g_lamexp_app_icon.appIcon)
if(!g_lamexp_icon_data.isNull())
{
return *g_lamexp_app_icon.appIcon;
return *g_lamexp_icon_data;
}
readLock.unlock();
QWriteLocker writeLock(&g_lamexp_app_icon.lock);
QWriteLocker writeLock(&g_lamexp_icon_lock);
while(!g_lamexp_app_icon.appIcon)
while(g_lamexp_icon_data.isNull())
{
QDate currentDate = QDate::currentDate();
QTime currentTime = QTime::currentTime();
if(lamexp_thanksgiving(currentDate))
{
g_lamexp_app_icon.appIcon = new QIcon(":/MainIcon6.png");
g_lamexp_icon_data.reset(new QIcon(":/MainIcon6.png"));
}
else if(((currentDate.month() == 12) && (currentDate.day() == 31) && (currentTime.hour() >= 20)) || ((currentDate.month() == 1) && (currentDate.day() == 1) && (currentTime.hour() <= 19)))
{
g_lamexp_app_icon.appIcon = new QIcon(":/MainIcon5.png");
g_lamexp_icon_data.reset(new QIcon(":/MainIcon5.png"));
}
else if(((currentDate.month() == 10) && (currentDate.day() == 31) && (currentTime.hour() >= 12)) || ((currentDate.month() == 11) && (currentDate.day() == 1) && (currentTime.hour() <= 11)))
{
g_lamexp_app_icon.appIcon = new QIcon(":/MainIcon4.png");
g_lamexp_icon_data.reset(new QIcon(":/MainIcon4.png"));
}
else if((currentDate.month() == 12) && (currentDate.day() >= 24) && (currentDate.day() <= 26))
{
g_lamexp_app_icon.appIcon = new QIcon(":/MainIcon3.png");
g_lamexp_icon_data.reset(new QIcon(":/MainIcon3.png"));
}
else if(lamexp_computus(currentDate))
{
g_lamexp_app_icon.appIcon = new QIcon(":/MainIcon2.png");
g_lamexp_icon_data.reset(new QIcon(":/MainIcon2.png"));
}
else
{
g_lamexp_app_icon.appIcon = new QIcon(":/MainIcon1.png");
g_lamexp_icon_data.reset(new QIcon(":/MainIcon1.png"));
}
}
return *g_lamexp_app_icon.appIcon;
}
///////////////////////////////////////////////////////////////////////////////
// INITIALIZATION
///////////////////////////////////////////////////////////////////////////////
extern "C" void _lamexp_global_init_utils(void)
{
MUTILS_ZERO_MEMORY(g_lamexp_app_icon);
}
///////////////////////////////////////////////////////////////////////////////
// FINALIZATION
///////////////////////////////////////////////////////////////////////////////
extern "C" void _lamexp_global_free_utils(void)
{
//Free memory
MUTILS_DELETE(g_lamexp_app_icon.appIcon);
return *g_lamexp_icon_data;
}

View File

@ -40,32 +40,23 @@
// GLOBAL VARS
///////////////////////////////////////////////////////////////////////////////
static QReadWriteLock g_lamexp_version_lock;
//Build version
static const struct
{
unsigned int ver_major;
unsigned int ver_minor;
unsigned int ver_build;
unsigned int ver_confg;
char *ver_release_name;
}
g_lamexp_version =
{
VER_LAMEXP_MAJOR,
(10 * VER_LAMEXP_MINOR_HI) + VER_LAMEXP_MINOR_LO,
VER_LAMEXP_BUILD,
VER_LAMEXP_CONFG,
VER_LAMEXP_RNAME,
};
static const unsigned int g_lamexp_version_major = VER_LAMEXP_MAJOR;
static const unsigned int g_lamexp_version_minor = (10 * VER_LAMEXP_MINOR_HI) + VER_LAMEXP_MINOR_LO;
static const unsigned int g_lamexp_version_build = VER_LAMEXP_BUILD;
static const unsigned int g_lamexp_version_confg = VER_LAMEXP_CONFG;
static const char* g_lamexp_version_rname = VER_LAMEXP_RNAME;
//Demo Version
static int g_lamexp_demo = -1;
//Portable Mode
static struct
{
bool bInitialized;
bool bPortableModeEnabled;
QReadWriteLock lock;
}
g_lamexp_portable;
static int g_lamexp_portable = -1;
//Expiration date
static QScopedPointer<QDate> g_lamexp_expiration_date;
//Official web-site URL
static const char *g_lamexp_website_url = "http://lamexp.sourceforge.net/";
@ -86,11 +77,11 @@ static const unsigned int g_lamexp_toolver_coreaudio = VER_LAMEXP_TOOL_COREAUDIO
/*
* Version getters
*/
unsigned int lamexp_version_major(void) { return g_lamexp_version.ver_major; }
unsigned int lamexp_version_minor(void) { return g_lamexp_version.ver_minor; }
unsigned int lamexp_version_build(void) { return g_lamexp_version.ver_build; }
unsigned int lamexp_version_confg(void) { return g_lamexp_version.ver_confg; }
const char* lamexp_version_release(void) { return g_lamexp_version.ver_release_name; }
unsigned int lamexp_version_major(void) { return g_lamexp_version_major; }
unsigned int lamexp_version_minor(void) { return g_lamexp_version_minor; }
unsigned int lamexp_version_build(void) { return g_lamexp_version_build; }
unsigned int lamexp_version_confg(void) { return g_lamexp_version_confg; }
const char* lamexp_version_release(void) { return g_lamexp_version_rname; }
unsigned int lamexp_toolver_neroaac(void) { return g_lamexp_toolver_neroaac; }
unsigned int lamexp_toolver_fhgaacenc(void) { return g_lamexp_toolver_fhgaacenc; }
unsigned int lamexp_toolver_qaacenc(void) { return g_lamexp_toolver_qaacenc; }
@ -109,66 +100,77 @@ const char *lamexp_tracker_url(void) { return g_lamexp_tracker_url; }
*/
bool lamexp_version_demo(void)
{
return _strnicmp(g_lamexp_version.ver_release_name, "Final", 5) && _strnicmp(g_lamexp_version.ver_release_name, "Hotfix", 6);
QReadLocker readLock(&g_lamexp_version_lock);
if(g_lamexp_demo >= 0)
{
return (g_lamexp_demo > 0);
}
readLock.unlock();
QWriteLocker writeLock(&g_lamexp_version_lock);
if(g_lamexp_demo < 0)
{
g_lamexp_demo = (_strnicmp(g_lamexp_version_rname, "Final", 5) && _strnicmp(g_lamexp_version_rname, "Hotfix", 6)) ? (1) : (0);
}
return (g_lamexp_demo > 0);
}
/*
* Calculate expiration date
*/
QDate lamexp_version_expires(void)
QDate &lamexp_version_expires(void)
{
return MUtils::Version::app_build_date().addDays(MUTILS_DEBUG ? 7 : 30);
QReadLocker readLock(&g_lamexp_version_lock);
if(!g_lamexp_expiration_date.isNull())
{
return *g_lamexp_expiration_date;
}
readLock.unlock();
QWriteLocker writeLock(&g_lamexp_version_lock);
if(g_lamexp_expiration_date.isNull())
{
g_lamexp_expiration_date.reset(new QDate(MUtils::Version::app_build_date().addDays(MUTILS_DEBUG ? 7 : 30)));
}
return *g_lamexp_expiration_date;
}
/*
* Check for LameXP "portable" mode
*/
bool lamexp_portable_mode(void)
bool lamexp_version_portable(void)
{
QReadLocker readLock(&g_lamexp_portable.lock);
QReadLocker readLock(&g_lamexp_version_lock);
if(g_lamexp_portable.bInitialized)
if(g_lamexp_portable >= 0)
{
return g_lamexp_portable.bPortableModeEnabled;
return (g_lamexp_portable > 0);
}
readLock.unlock();
QWriteLocker writeLock(&g_lamexp_portable.lock);
QWriteLocker writeLock(&g_lamexp_version_lock);
if(!g_lamexp_portable.bInitialized)
if(g_lamexp_portable < 0)
{
if(VER_LAMEXP_PORTABLE_EDITION)
{
qWarning("LameXP portable edition!\n");
g_lamexp_portable.bPortableModeEnabled = true;
g_lamexp_portable = 1;
}
else
{
QString baseName = QFileInfo(QApplication::applicationFilePath()).completeBaseName();
int idx1 = baseName.indexOf("lamexp", 0, Qt::CaseInsensitive);
int idx2 = baseName.lastIndexOf("portable", -1, Qt::CaseInsensitive);
g_lamexp_portable.bPortableModeEnabled = ((idx1 >= 0) && (idx2 >= 0) && (idx1 < idx2));
const QString baseName = QFileInfo(QApplication::applicationFilePath()).completeBaseName();
const int idx1 = baseName.indexOf("lamexp", 0, Qt::CaseInsensitive);
const int idx2 = baseName.lastIndexOf("portable", -1, Qt::CaseInsensitive);
g_lamexp_portable = ((idx1 >= 0) && (idx2 >= 0) && (idx1 < idx2)) ? (1) : (0);
}
g_lamexp_portable.bInitialized = true;
}
return g_lamexp_portable.bPortableModeEnabled;
}
///////////////////////////////////////////////////////////////////////////////
// INITIALIZATION
///////////////////////////////////////////////////////////////////////////////
extern "C" void _lamexp_global_init_versn(void)
{
MUTILS_ZERO_MEMORY(g_lamexp_portable);
}
///////////////////////////////////////////////////////////////////////////////
// FINALIZATION
///////////////////////////////////////////////////////////////////////////////
extern "C" void _lamexp_global_free_versn(void)
{
/*nothing to do here*/
return (g_lamexp_portable > 0);
}

View File

@ -70,14 +70,8 @@ static size_t lamexp_entry_check(void)
extern "C"
{
int mainCRTStartup(void);
void _lamexp_global_init_versn(void);
void _lamexp_global_init_tools(void);
void _lamexp_global_init_utils(void);
void _lamexp_global_free_versn(void);
void _lamexp_global_free_tools(void);
void _lamexp_global_free_utils(void);
}
/*
@ -92,9 +86,7 @@ extern "C" int lamexp_entry_point(void)
}
//Call global initialization functions
_lamexp_global_init_versn();
_lamexp_global_init_tools();
_lamexp_global_init_utils();
//Make sure we will pass the check
g_lamexp_entry_check_flag = (~g_lamexp_entry_check_flag);
@ -111,7 +103,5 @@ void lamexp_finalization(void)
qDebug("lamexp_finalization()");
//Call global finalization functions, in proper order
_lamexp_global_free_versn();
_lamexp_global_free_tools();
_lamexp_global_free_utils();
}

View File

@ -355,7 +355,7 @@ int FileListModel::importFromCsv(QWidget *parent, const QString &inFile)
QStringList codecList;
codecList.append(systemDefault);
codecList.append(lamexp_available_codepages());
codecList.append(MUtils::available_codepages());
QInputDialog *input = new QInputDialog(parent);
input->setLabelText(EXPAND(tr("Select ANSI Codepage for CSV file:")));

View File

@ -287,7 +287,7 @@ SettingsModel::SettingsModel(void)
{
QString configPath = "LameXP.ini";
if(!lamexp_portable_mode())
if(!lamexp_version_portable())
{
QString dataPath = initDirectory(QDesktopServices::storageLocation(QDesktopServices::DataLocation));
if(!dataPath.isEmpty())
@ -567,7 +567,7 @@ LAMEXP_MAKE_OPTION_I(aftenExponentSearchSize, 8)
LAMEXP_MAKE_OPTION_B(aftenFastBitAllocation, false)
LAMEXP_MAKE_OPTION_B(antivirNotificationsEnabled, true)
LAMEXP_MAKE_OPTION_B(autoUpdateCheckBeta, false)
LAMEXP_MAKE_OPTION_B(autoUpdateEnabled, (!lamexp_portable_mode()));
LAMEXP_MAKE_OPTION_B(autoUpdateEnabled, (!lamexp_version_portable()));
LAMEXP_MAKE_OPTION_S(autoUpdateLastCheck, "Never")
LAMEXP_MAKE_OPTION_B(bitrateManagementEnabled, false)
LAMEXP_MAKE_OPTION_I(bitrateManagementMaxRate, 500)
@ -652,7 +652,7 @@ LAMEXP_MAKE_OPTION_B(prependRelativeSourcePath, false)
LAMEXP_MAKE_OPTION_B(renameOutputFilesEnabled, false)
LAMEXP_MAKE_OPTION_S(renameOutputFilesPattern, "[<TrackNo>] <Artist> - <Title>")
LAMEXP_MAKE_OPTION_I(samplingRate, 0)
LAMEXP_MAKE_OPTION_B(shellIntegrationEnabled, !lamexp_portable_mode())
LAMEXP_MAKE_OPTION_B(shellIntegrationEnabled, !lamexp_version_portable())
LAMEXP_MAKE_OPTION_B(slowStartup, false)
LAMEXP_MAKE_OPTION_B(soundsEnabled, true)
LAMEXP_MAKE_OPTION_I(toneAdjustBass, 0)

View File

@ -476,15 +476,15 @@ void EncoderRegistry::resetAllEncoders(SettingsModel *settings)
int EncoderRegistry::getAacEncoder(void)
{
if(lamexp_check_tool("qaac.exe") && lamexp_check_tool("libsoxr.dll") && lamexp_check_tool("libsoxconvolver.dll"))
if(lamexp_tool_check("qaac.exe") && lamexp_tool_check("libsoxr.dll") && lamexp_tool_check("libsoxconvolver.dll"))
{
return SettingsModel::AAC_ENCODER_QAAC;
}
else if(lamexp_check_tool("fhgaacenc.exe") && lamexp_check_tool("enc_fhgaac.dll") && lamexp_check_tool("nsutil.dll") && lamexp_check_tool("libmp4v2.dll"))
else if(lamexp_tool_check("fhgaacenc.exe") && lamexp_tool_check("enc_fhgaac.dll") && lamexp_tool_check("nsutil.dll") && lamexp_tool_check("libmp4v2.dll"))
{
return SettingsModel::AAC_ENCODER_FHG;
}
else if(lamexp_check_tool("neroAacEnc.exe") && lamexp_check_tool("neroAacDec.exe") && lamexp_check_tool("neroAacTag.exe"))
else if(lamexp_tool_check("neroAacEnc.exe") && lamexp_tool_check("neroAacDec.exe") && lamexp_tool_check("neroAacTag.exe"))
{
return SettingsModel::AAC_ENCODER_NERO;
}

View File

@ -56,7 +56,7 @@ CueSplitter::CueSplitter(const QString &outputDir, const QString &baseName, CueS
m_model(model),
m_outputDir(outputDir),
m_baseName(baseName),
m_soxBin(lamexp_lookup_tool("sox.exe"))
m_soxBin(lamexp_tool_lookup("sox.exe"))
{
if(m_soxBin.isEmpty())
{

View File

@ -63,8 +63,8 @@ AnalyzeTask::AnalyzeTask(const int taskId, const QString &inputFile, const QStri
m_taskId(taskId),
m_inputFile(inputFile),
m_templateFile(templateFile),
m_mediaInfoBin(lamexp_lookup_tool("mediainfo.exe")),
m_avs2wavBin(lamexp_lookup_tool("avs2wav.exe")),
m_mediaInfoBin(lamexp_tool_lookup("mediainfo.exe")),
m_avs2wavBin(lamexp_tool_lookup("avs2wav.exe")),
m_abortFlag(abortFlag)
{
if(m_mediaInfoBin.isEmpty() || m_avs2wavBin.isEmpty())

View File

@ -183,7 +183,7 @@ protected:
if(lockedFile)
{
lamexp_register_tool(toolShortName, lockedFile, version, &m_toolTag);
lamexp_tool_register(toolShortName, lockedFile, version, &m_toolTag);
}
}
@ -647,7 +647,7 @@ void InitializationThread::initNeroAac(void)
for(int i = 0; i < 3; i++)
{
lamexp_register_tool(neroFileInfo[i].fileName(), neroBin[i], neroVersion);
lamexp_tool_register(neroFileInfo[i].fileName(), neroBin[i], neroVersion);
}
}
@ -755,7 +755,7 @@ void InitializationThread::initFhgAac(void)
for(int i = 0; i < 5; i++)
{
lamexp_register_tool(fhgFileInfo[i].fileName(), fhgBin[i], fhgVersion);
lamexp_tool_register(fhgFileInfo[i].fileName(), fhgBin[i], fhgVersion);
}
}
@ -909,10 +909,10 @@ void InitializationThread::initQAac(void)
return;
}
lamexp_register_tool(qaacFileInfo[0].fileName(), qaacBin[0], qaacVersion);
lamexp_register_tool(qaacFileInfo[1].fileName(), qaacBin[1], qaacVersion);
lamexp_register_tool(qaacFileInfo[2].fileName(), qaacBin[2], qaacVersion);
lamexp_register_tool(qaacFileInfo[3].fileName(), qaacBin[3], qaacVersion);
lamexp_tool_register(qaacFileInfo[0].fileName(), qaacBin[0], qaacVersion);
lamexp_tool_register(qaacFileInfo[1].fileName(), qaacBin[1], qaacVersion);
lamexp_tool_register(qaacFileInfo[2].fileName(), qaacBin[2], qaacVersion);
lamexp_tool_register(qaacFileInfo[3].fileName(), qaacBin[3], qaacVersion);
}
void InitializationThread::selfTest(void)

View File

@ -35,7 +35,7 @@
WaveProperties::WaveProperties(void)
:
m_binary(lamexp_lookup_tool("sox.exe"))
m_binary(lamexp_tool_lookup("sox.exe"))
{
if(m_binary.isEmpty())
{