OSDN Git Service

More code refactoring and clean-up.
authorLoRd_MuldeR <mulder2@gmx.de>
Fri, 19 Dec 2014 22:49:11 +0000 (23:49 +0100)
committerLoRd_MuldeR <mulder2@gmx.de>
Fri, 19 Dec 2014 22:49:11 +0000 (23:49 +0100)
46 files changed:
src/Config.h
src/Decoder_AAC.cpp
src/Decoder_AC3.cpp
src/Decoder_ADPCM.cpp
src/Decoder_ALAC.cpp
src/Decoder_Avisynth.cpp
src/Decoder_FLAC.cpp
src/Decoder_MAC.cpp
src/Decoder_MP3.cpp
src/Decoder_Musepack.cpp
src/Decoder_Opus.cpp
src/Decoder_Shorten.cpp
src/Decoder_Speex.cpp
src/Decoder_TTA.cpp
src/Decoder_Vorbis.cpp
src/Decoder_WMA.cpp
src/Decoder_WavPack.cpp
src/Dialog_CueImport.cpp
src/Dialog_MainWindow.cpp
src/Dialog_Update.cpp
src/Encoder_AAC.cpp
src/Encoder_AAC_FHG.cpp
src/Encoder_AAC_QAAC.cpp
src/Encoder_AC3.cpp
src/Encoder_DCA.cpp
src/Encoder_FLAC.cpp
src/Encoder_MAC.cpp
src/Encoder_MP3.cpp
src/Encoder_Opus.cpp
src/Encoder_Vorbis.cpp
src/Filter_Downmix.cpp
src/Filter_Normalize.cpp
src/Filter_Resample.cpp
src/Filter_ToneAdjust.cpp
src/Global.h
src/Global_Tools.cpp
src/Global_Utils.cpp
src/Global_Version.cpp
src/Global_Zero.cpp
src/Model_FileList.cpp
src/Model_Settings.cpp
src/Registry_Encoder.cpp
src/Thread_CueSplitter.cpp
src/Thread_FileAnalyzer_Task.cpp
src/Thread_Initialization.cpp
src/Tool_WaveProperties.cpp

index e5e57fc..a4d147b 100644 (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
 
 ///////////////////////////////////////////////////////////////////////////////
index e9a4c5c..9af6c0b 100644 (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())
        {
index e8255a0..01adb7e 100644 (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())
        {
index 5c0762f..c3cba41 100644 (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())
        {
index 17b3f36..ecdc438 100644 (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())
        {
index e235f82..2c809a6 100644 (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())
        {
index 5e63441..f7a7eda 100644 (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())
        {
index 34b1b0f..36cd607 100644 (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())
        {
index da6d9ea..9c31aaa 100644 (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())
        {
index 8c1f895..32a7cdd 100644 (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())
        {
index 60e9584..8b76b69 100644 (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())
        {
index 4527187..cae1cd7 100644 (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())
        {
index e5bc085..c5b1d39 100644 (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())
        {
index e42551f..4b7e22c 100644 (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())
        {
index 87425cd..87e798b 100644 (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())
        {
index d9942a3..571b03e 100644 (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())
        {
index f96372b..3688161 100644 (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())
        {
index f9d25e6..5a7ae70 100644 (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:")));
index e354f93..f025ef8 100644 (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);
index f8ff9d5..436a447 100644 (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())
        {
index cb21579..1130ed9 100644 (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())
        {
index f8b0360..8e53a64 100644 (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())
        {
index 9143d11..5523cfb 100644 (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())
        {
index ee04dd9..7b9026c 100644 (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())
        {
index d517326..6b0d134 100644 (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())
        {
index e58ca61..29afd8a 100644 (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())
        {
index 16eb336..c1c3ffd 100644 (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())
        {
index 663c6cd..8929457 100644 (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())
        {
index 82dc096..c535df1 100644 (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())
        {
index c686cf1..fe62e22 100644 (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())
        {
index b8f6e52..212bef1 100644 (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())
        {
index 4708c59..be4c72a 100644 (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())
        {
index 3d1660f..397f6c4 100644 (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())
        {
index 2b49ed2..7a55d45 100644 (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())
        {
index 7dad133..d8d752b 100644 (file)
 
 #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);
-unsigned int lamexp_version_major(void);
-unsigned int lamexp_version_minor(void);
-const char *lamexp_version_release(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
index 42dea17..7f2c920 100644 (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;
        }
 }
 
index 54e22bb..b75ec82 100644 (file)
 // 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
  */
 static bool lamexp_computus(const QDate &date)
@@ -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;
 }
index d0ce35c..db1b095 100644 (file)
 // 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,14 +77,14 @@ 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_toolver_neroaac(void)   { return g_lamexp_toolver_neroaac; }
+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; }
+unsigned int lamexp_toolver_qaacenc(void)   { return g_lamexp_toolver_qaacenc;   }
 unsigned int lamexp_toolver_coreaudio(void) { return g_lamexp_toolver_coreaudio; }
 
 /*
@@ -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);
 }
index f3d0959..809c8bf 100644 (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();
 }
index 78d26aa..4ad59b3 100644 (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:")));
index db6f135..4f7dfc1 100644 (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)
index 668aa5e..f76e250 100644 (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;
        }
index e40fa6f..ce064d5 100644 (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())
        {
index 5c3193d..6438468 100644 (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())
index 16cde2c..99d63e5 100644 (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)
index e753caf..c122949 100644 (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())
        {