Now each tool can also have a "tag" in addition to the version number.

This commit is contained in:
LoRd_MuldeR 2013-02-12 00:08:21 +01:00
parent 9ef67882a1
commit d7cb3001aa
4 changed files with 36 additions and 17 deletions

View File

@ -596,14 +596,14 @@ void AboutDialog::initSoftwareTab(void)
moreAboutText += makeToolText moreAboutText += makeToolText
( (
tr("LAME - OpenSource mp3 Encoder"), tr("LAME - OpenSource mp3 Encoder"),
"lame.exe", "v?.??, Final-?", "lame.exe", "v?.??, #-?",
tr("Released under the terms of the GNU Lesser General Public License."), tr("Released under the terms of the GNU Lesser General Public License."),
"http://lame.sourceforge.net/" "http://lame.sourceforge.net/"
); );
moreAboutText += makeToolText moreAboutText += makeToolText
( (
tr("OggEnc - Ogg Vorbis Encoder"), tr("OggEnc - Ogg Vorbis Encoder"),
"oggenc2.exe", "v?.??, aoTuV Beta-?.??", "oggenc2.exe", "v?.??, aoTuV #-?.??",
tr("Completely open and patent-free audio encoding technology."), tr("Completely open and patent-free audio encoding technology."),
"http://www.vorbis.com/" "http://www.vorbis.com/"
); );
@ -632,7 +632,7 @@ void AboutDialog::initSoftwareTab(void)
moreAboutText += makeToolText moreAboutText += makeToolText
( (
tr("Opus Audio Codec"), tr("Opus Audio Codec"),
"opusenc_std.exe", "????-??-??", "opusenc.exe", "????-??-??",
tr("Totally open, royalty-free, highly versatile audio codec."), tr("Totally open, royalty-free, highly versatile audio codec."),
"http://www.opus-codec.org/" "http://www.opus-codec.org/"
); );
@ -652,8 +652,8 @@ void AboutDialog::initSoftwareTab(void)
); );
moreAboutText += makeToolText moreAboutText += makeToolText
( (
tr("AC3Filter Tools - AC3/DTS Decoder"), tr("Valdec from AC3Filter Tools - AC3/DTS Decoder"),
"valdec.exe", "v?.??", "valdec.exe", "v?.?.?#",
tr("Released under the terms of the GNU Lesser General Public License."), tr("Released under the terms of the GNU Lesser General Public License."),
"http://www.ac3filter.net/projects/tools" "http://www.ac3filter.net/projects/tools"
); );
@ -837,11 +837,12 @@ void AboutDialog::initLicenseTab(void)
QString AboutDialog::makeToolText(const QString &toolName, const QString &toolBin, const QString &toolVerFmt, const QString &toolLicense, const QString &toolWebsite, const QString &extraInfo) QString AboutDialog::makeToolText(const QString &toolName, const QString &toolBin, const QString &toolVerFmt, const QString &toolLicense, const QString &toolWebsite, const QString &extraInfo)
{ {
QString toolText, verStr(toolVerFmt); QString toolText, toolTag, verStr(toolVerFmt);
if(!toolBin.isEmpty()) if(!toolBin.isEmpty())
{ {
verStr = lamexp_version2string(toolVerFmt, lamexp_tool_version(toolBin), tr("n/a")); const unsigned int version = lamexp_tool_version(toolBin, &toolTag);
verStr = lamexp_version2string(toolVerFmt, version, tr("n/a"), &toolTag);
} }
toolText += QString("<li>%1<br>").arg(NOBR(QString("<b>%1 (%2)</b>").arg(toolName, verStr))); toolText += QString("<li>%1<br>").arg(NOBR(QString("<b>%1 (%2)</b>").arg(toolName, verStr)));

View File

@ -233,6 +233,7 @@ static struct
{ {
QMap<QString, LockedFile*> *registry; QMap<QString, LockedFile*> *registry;
QMap<QString, unsigned int> *versions; QMap<QString, unsigned int> *versions;
QMap<QString, QString> *tags;
QReadWriteLock lock; QReadWriteLock lock;
} }
g_lamexp_tools; g_lamexp_tools;
@ -1567,12 +1568,13 @@ bool lamexp_clean_folder(const QString &folderPath)
/* /*
* Register tool * Register tool
*/ */
void lamexp_register_tool(const QString &toolName, LockedFile *file, unsigned int version) void lamexp_register_tool(const QString &toolName, LockedFile *file, unsigned int version, const QString *tag)
{ {
QWriteLocker writeLock(&g_lamexp_tools.lock); QWriteLocker writeLock(&g_lamexp_tools.lock);
if(!g_lamexp_tools.registry) g_lamexp_tools.registry = new QMap<QString, LockedFile*>(); if(!g_lamexp_tools.registry) g_lamexp_tools.registry = new QMap<QString, LockedFile*>();
if(!g_lamexp_tools.versions) g_lamexp_tools.versions = new QMap<QString, unsigned int>(); if(!g_lamexp_tools.versions) g_lamexp_tools.versions = new QMap<QString, unsigned int>();
if(!g_lamexp_tools.tags) g_lamexp_tools.tags = new QMap<QString, QString>();
if(g_lamexp_tools.registry->contains(toolName.toLower())) if(g_lamexp_tools.registry->contains(toolName.toLower()))
{ {
@ -1581,6 +1583,7 @@ void lamexp_register_tool(const QString &toolName, LockedFile *file, unsigned in
g_lamexp_tools.registry->insert(toolName.toLower(), file); g_lamexp_tools.registry->insert(toolName.toLower(), file);
g_lamexp_tools.versions->insert(toolName.toLower(), version); g_lamexp_tools.versions->insert(toolName.toLower(), version);
g_lamexp_tools.tags->insert(toolName.toLower(), (tag) ? (*tag) : QString());
} }
/* /*
@ -1619,14 +1622,19 @@ const QString lamexp_lookup_tool(const QString &toolName)
/* /*
* Lookup tool version * Lookup tool version
*/ */
unsigned int lamexp_tool_version(const QString &toolName) unsigned int lamexp_tool_version(const QString &toolName, QString *tag)
{ {
QReadLocker readLock(&g_lamexp_tools.lock); QReadLocker readLock(&g_lamexp_tools.lock);
if(tag) tag->clear();
if(g_lamexp_tools.versions) if(g_lamexp_tools.versions)
{ {
if(g_lamexp_tools.versions->contains(toolName.toLower())) if(g_lamexp_tools.versions->contains(toolName.toLower()))
{ {
if(tag)
{
if(g_lamexp_tools.tags->contains(toolName.toLower())) *tag = g_lamexp_tools.tags->value(toolName.toLower());
}
return g_lamexp_tools.versions->value(toolName.toLower()); return g_lamexp_tools.versions->value(toolName.toLower());
} }
else else
@ -1643,7 +1651,7 @@ unsigned int lamexp_tool_version(const QString &toolName)
/* /*
* Version number to human-readable string * Version number to human-readable string
*/ */
const QString lamexp_version2string(const QString &pattern, unsigned int version, const QString &defaultText) const QString lamexp_version2string(const QString &pattern, unsigned int version, const QString &defaultText, const QString *tag)
{ {
if(version == UINT_MAX) if(version == UINT_MAX)
{ {
@ -1668,6 +1676,11 @@ const QString lamexp_version2string(const QString &pattern, unsigned int version
index = result.indexOf("?", Qt::CaseInsensitive); index = result.indexOf("?", Qt::CaseInsensitive);
} }
if(tag)
{
result.replace(QChar('#'), *tag, Qt::CaseInsensitive);
}
return result; return result;
} }
@ -2417,6 +2430,7 @@ void lamexp_finalization(void)
} }
LAMEXP_DELETE(g_lamexp_tools.registry); LAMEXP_DELETE(g_lamexp_tools.registry);
LAMEXP_DELETE(g_lamexp_tools.versions); LAMEXP_DELETE(g_lamexp_tools.versions);
LAMEXP_DELETE(g_lamexp_tools.tags);
} }
//Delete temporary files //Delete temporary files

View File

@ -119,10 +119,10 @@ int lamexp_init_ipc(void);
LONG WINAPI lamexp_exception_handler(__in struct _EXCEPTION_POINTERS *ExceptionInfo); LONG WINAPI lamexp_exception_handler(__in struct _EXCEPTION_POINTERS *ExceptionInfo);
void lamexp_invalid_param_handler(const wchar_t*, const wchar_t*, const wchar_t*, unsigned int, uintptr_t); void lamexp_invalid_param_handler(const wchar_t*, const wchar_t*, const wchar_t*, unsigned int, uintptr_t);
void lamexp_message_handler(QtMsgType type, const char *msg); void lamexp_message_handler(QtMsgType type, const char *msg);
void lamexp_register_tool(const QString &toolName, LockedFile *file, unsigned int version = 0); void lamexp_register_tool(const QString &toolName, LockedFile *file, unsigned int version = 0, const QString *tag = NULL);
bool lamexp_check_tool(const QString &toolName); bool lamexp_check_tool(const QString &toolName);
const QString lamexp_lookup_tool(const QString &toolName); const QString lamexp_lookup_tool(const QString &toolName);
unsigned int lamexp_tool_version(const QString &toolName); unsigned int lamexp_tool_version(const QString &toolName, QString *tag = NULL);
void lamexp_finalization(void); void lamexp_finalization(void);
QString lamexp_rand_str(void); QString lamexp_rand_str(void);
const QString &lamexp_temp_folder2(void); const QString &lamexp_temp_folder2(void);
@ -149,7 +149,7 @@ extern const char* LAMEXP_DEFAULT_TRANSLATION;
//Auxiliary functions //Auxiliary functions
bool lamexp_clean_folder(const QString &folderPath); bool lamexp_clean_folder(const QString &folderPath);
const QString lamexp_version2string(const QString &pattern, unsigned int version, const QString &defaultText); const QString lamexp_version2string(const QString &pattern, unsigned int version, const QString &defaultText, const QString *tag = NULL);
const QString &lamexp_known_folder(lamexp_known_folder_t folder_id); const QString &lamexp_known_folder(lamexp_known_folder_t folder_id);
unsigned __int64 lamexp_free_diskspace(const QString &path, bool *ok = NULL); unsigned __int64 lamexp_free_diskspace(const QString &path, bool *ok = NULL);
bool lamexp_remove_file(const QString &filename); bool lamexp_remove_file(const QString &filename);

View File

@ -48,9 +48,9 @@ static const double g_allowedExtractDelay = 12.0;
class ExtractorTask : public QRunnable class ExtractorTask : public QRunnable
{ {
public: public:
ExtractorTask(const QDir &appDir, const QString &toolName, const QString &toolShortName, const QByteArray &toolHash, const unsigned int toolVersion) ExtractorTask(const QDir &appDir, const QString &toolName, const QString &toolShortName, const QByteArray &toolHash, const unsigned int toolVersion, const QString &toolTag)
: :
QRunnable(), m_appDir(appDir), m_toolName(toolName), m_toolShortName(toolShortName), m_toolHash(toolHash), m_toolVersion(toolVersion) QRunnable(), m_appDir(appDir), m_toolName(toolName), m_toolShortName(toolShortName), m_toolHash(toolHash), m_toolVersion(toolVersion), m_toolTag(toolTag)
{ {
/* Nothing to do */ /* Nothing to do */
} }
@ -90,7 +90,7 @@ protected:
if(lockedFile) if(lockedFile)
{ {
QMutexLocker lock(&s_mutex); QMutexLocker lock(&s_mutex);
lamexp_register_tool(m_toolShortName, lockedFile, version); lamexp_register_tool(m_toolShortName, lockedFile, version, &m_toolTag);
} }
} }
} }
@ -109,6 +109,7 @@ private:
const QDir m_appDir; const QDir m_appDir;
const QString m_toolName; const QString m_toolName;
const QString m_toolShortName; const QString m_toolShortName;
const QString m_toolTag;
const QByteArray m_toolHash; const QByteArray m_toolHash;
const unsigned int m_toolVersion; const unsigned int m_toolVersion;
@ -185,6 +186,7 @@ void InitializationThread::run()
QMap<QString, QString> mapChecksum; QMap<QString, QString> mapChecksum;
QMap<QString, unsigned int> mapVersion; QMap<QString, unsigned int> mapVersion;
QMap<QString, unsigned int> mapCpuType; QMap<QString, unsigned int> mapCpuType;
QMap<QString, QString> mapVersTag;
//Init properties //Init properties
for(int i = 0; i < INT_MAX; i++) for(int i = 0; i < INT_MAX; i++)
@ -199,6 +201,7 @@ void InitializationThread::run()
mapChecksum.insert(currentTool, QString::fromLatin1(g_lamexp_tools[i].pcHash)); mapChecksum.insert(currentTool, QString::fromLatin1(g_lamexp_tools[i].pcHash));
mapCpuType.insert(currentTool, g_lamexp_tools[i].uiCpuType); mapCpuType.insert(currentTool, g_lamexp_tools[i].uiCpuType);
mapVersion.insert(currentTool, g_lamexp_tools[i].uiVersion); mapVersion.insert(currentTool, g_lamexp_tools[i].uiVersion);
mapVersTag.insert(currentTool, g_lamexp_tools[i].pcVersTag);
} }
else else
{ {
@ -235,6 +238,7 @@ void InitializationThread::run()
QByteArray toolHash = mapChecksum.take(toolName).toLatin1(); QByteArray toolHash = mapChecksum.take(toolName).toLatin1();
unsigned int toolCpuType = mapCpuType.take(toolName); unsigned int toolCpuType = mapCpuType.take(toolName);
unsigned int toolVersion = mapVersion.take(toolName); unsigned int toolVersion = mapVersion.take(toolName);
QString toolVersTag = mapVersTag.take(toolName);
if(toolHash.size() != 96) if(toolHash.size() != 96)
{ {
@ -243,7 +247,7 @@ void InitializationThread::run()
if(toolCpuType & cpuSupport) if(toolCpuType & cpuSupport)
{ {
pool->start(new ExtractorTask(appDir, toolName, toolShortName, toolHash, toolVersion)); pool->start(new ExtractorTask(appDir, toolName, toolShortName, toolHash, toolVersion, toolVersTag));
QThread::yieldCurrentThread(); QThread::yieldCurrentThread();
} }
} }