2013-11-03 23:43:21 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// LameXP - Audio Encoder Front-End
|
2018-01-17 21:18:10 +01:00
|
|
|
// Copyright (C) 2004-2018 LoRd_MuldeR <MuldeR2@GMX.de>
|
2013-11-03 23:43:21 +01:00
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
|
|
// (at your option) any later version, but always including the *additional*
|
|
|
|
// restrictions defined in the "License.txt" file.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License along
|
|
|
|
// with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
//
|
|
|
|
// http://www.gnu.org/licenses/gpl-2.0.txt
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "Global.h"
|
|
|
|
|
|
|
|
//LameXP includes
|
2014-12-20 23:44:43 +01:00
|
|
|
#define LAMEXP_INC_CONFIG 1
|
2013-11-03 23:43:21 +01:00
|
|
|
#include "Resource.h"
|
|
|
|
#include "Config.h"
|
|
|
|
|
2014-11-25 02:14:42 +01:00
|
|
|
//MUtils
|
|
|
|
#include <MUtils/Version.h>
|
|
|
|
|
2013-11-03 23:43:21 +01:00
|
|
|
//Qt includes
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QDate>
|
|
|
|
#include <QFileInfo>
|
|
|
|
#include <QReadWriteLock>
|
2017-06-11 13:36:40 +02:00
|
|
|
#include <QRegExp>
|
2013-11-03 23:43:21 +01:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// GLOBAL VARS
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2014-12-19 23:49:11 +01:00
|
|
|
static QReadWriteLock g_lamexp_version_lock;
|
|
|
|
|
2013-11-03 23:43:21 +01:00
|
|
|
//Build version
|
2014-12-19 23:49:11 +01:00
|
|
|
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;
|
2013-11-03 23:43:21 +01:00
|
|
|
|
|
|
|
//Portable Mode
|
2014-12-19 23:49:11 +01:00
|
|
|
static int g_lamexp_portable = -1;
|
|
|
|
|
|
|
|
//Expiration date
|
|
|
|
static QScopedPointer<QDate> g_lamexp_expiration_date;
|
2013-11-03 23:43:21 +01:00
|
|
|
|
|
|
|
//Official web-site URL
|
|
|
|
static const char *g_lamexp_website_url = "http://lamexp.sourceforge.net/";
|
|
|
|
static const char *g_lamexp_mulders_url = "http://muldersoft.com/";
|
2014-06-27 21:06:33 +02:00
|
|
|
static const char *g_lamexp_support_url = "http://forum.doom9.org/showthread.php?t=157726";
|
|
|
|
static const char *g_lamexp_tracker_url = "https://github.com/lordmulder/LameXP/issues";
|
2013-11-03 23:43:21 +01:00
|
|
|
|
|
|
|
//Tool versions (expected versions!)
|
2014-11-25 02:14:42 +01:00
|
|
|
static const unsigned int g_lamexp_toolver_neroaac = VER_LAMEXP_TOOL_NEROAAC;
|
2013-11-03 23:43:21 +01:00
|
|
|
static const unsigned int g_lamexp_toolver_fhgaacenc = VER_LAMEXP_TOOL_FHGAACENC;
|
2015-04-24 20:36:05 +02:00
|
|
|
static const unsigned int g_lamexp_toolver_fdkaacenc = VER_LAMEXP_TOOL_FDKAACENC;
|
2014-11-25 02:14:42 +01:00
|
|
|
static const unsigned int g_lamexp_toolver_qaacenc = VER_LAMEXP_TOOL_QAAC;
|
2013-11-03 23:43:21 +01:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// GLOBAL FUNCTIONS
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Version getters
|
|
|
|
*/
|
2014-12-19 23:49:11 +01:00
|
|
|
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; }
|
2013-11-03 23:43:21 +01:00
|
|
|
unsigned int lamexp_toolver_fhgaacenc(void) { return g_lamexp_toolver_fhgaacenc; }
|
2015-04-24 20:36:05 +02:00
|
|
|
unsigned int lamexp_toolver_fdkaacenc(void) { return g_lamexp_toolver_fdkaacenc; }
|
2014-12-19 23:49:11 +01:00
|
|
|
unsigned int lamexp_toolver_qaacenc(void) { return g_lamexp_toolver_qaacenc; }
|
2013-11-03 23:43:21 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* URL getters
|
|
|
|
*/
|
|
|
|
const char *lamexp_website_url(void) { return g_lamexp_website_url; }
|
|
|
|
const char *lamexp_mulders_url(void) { return g_lamexp_mulders_url; }
|
|
|
|
const char *lamexp_support_url(void) { return g_lamexp_support_url; }
|
2014-06-27 21:06:33 +02:00
|
|
|
const char *lamexp_tracker_url(void) { return g_lamexp_tracker_url; }
|
2013-11-03 23:43:21 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Check for Demo (pre-release) version
|
|
|
|
*/
|
|
|
|
bool lamexp_version_demo(void)
|
|
|
|
{
|
2014-12-19 23:49:11 +01:00
|
|
|
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);
|
2013-11-03 23:43:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Calculate expiration date
|
|
|
|
*/
|
2014-12-20 23:44:43 +01:00
|
|
|
const QDate &lamexp_version_expires(void)
|
2013-11-03 23:43:21 +01:00
|
|
|
{
|
2014-12-19 23:49:11 +01:00
|
|
|
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;
|
2013-11-03 23:43:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check for LameXP "portable" mode
|
|
|
|
*/
|
2014-12-19 23:49:11 +01:00
|
|
|
bool lamexp_version_portable(void)
|
2013-11-03 23:43:21 +01:00
|
|
|
{
|
2014-12-19 23:49:11 +01:00
|
|
|
QReadLocker readLock(&g_lamexp_version_lock);
|
2013-11-03 23:43:21 +01:00
|
|
|
|
2014-12-19 23:49:11 +01:00
|
|
|
if(g_lamexp_portable >= 0)
|
2013-11-03 23:43:21 +01:00
|
|
|
{
|
2014-12-19 23:49:11 +01:00
|
|
|
return (g_lamexp_portable > 0);
|
2013-11-03 23:43:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
readLock.unlock();
|
2014-12-19 23:49:11 +01:00
|
|
|
QWriteLocker writeLock(&g_lamexp_version_lock);
|
2013-11-03 23:43:21 +01:00
|
|
|
|
2014-12-19 23:49:11 +01:00
|
|
|
if(g_lamexp_portable < 0)
|
2013-11-03 23:43:21 +01:00
|
|
|
{
|
|
|
|
if(VER_LAMEXP_PORTABLE_EDITION)
|
|
|
|
{
|
|
|
|
qWarning("LameXP portable edition!\n");
|
2014-12-19 23:49:11 +01:00
|
|
|
g_lamexp_portable = 1;
|
2013-11-03 23:43:21 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-06-11 13:36:40 +02:00
|
|
|
const QRegExp regex_portable("[_\\-]p", Qt::CaseInsensitive);
|
|
|
|
const QString baseName = QFileInfo(QApplication::applicationFilePath()).baseName();
|
|
|
|
g_lamexp_portable = qBound(0, baseName.indexOf(regex_portable), 1);
|
2013-11-03 23:43:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-19 23:49:11 +01:00
|
|
|
return (g_lamexp_portable > 0);
|
2013-11-26 23:00:33 +01:00
|
|
|
}
|