Bump version.
[LameXP.git] / src / Global_Version.cpp
blobceb56a6bdeb26c9903009edd37be8719ccbcb58e
1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2021 LoRd_MuldeR <MuldeR2@GMX.de>
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU GENERAL PUBLIC LICENSE as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version; always including the non-optional
9 // LAMEXP GNU GENERAL PUBLIC LICENSE ADDENDUM. See "License.txt" file!
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this program; if not, write to the Free Software Foundation, Inc.,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 // http://www.gnu.org/licenses/gpl-2.0.txt
21 ///////////////////////////////////////////////////////////////////////////////
23 #include "Global.h"
25 //LameXP includes
26 #define LAMEXP_INC_CONFIG 1
27 #include "Resource.h"
28 #include "Config.h"
30 //MUtils
31 #include <MUtils/Version.h>
33 //Qt includes
34 #include <QApplication>
35 #include <QDate>
36 #include <QFileInfo>
37 #include <QReadWriteLock>
38 #include <QRegExp>
40 ///////////////////////////////////////////////////////////////////////////////
41 // GLOBAL VARS
42 ///////////////////////////////////////////////////////////////////////////////
44 static QReadWriteLock g_lamexp_version_lock;
46 //Build version
47 static const unsigned int g_lamexp_version_major = VER_LAMEXP_MAJOR;
48 static const unsigned int g_lamexp_version_minor = (10 * VER_LAMEXP_MINOR_HI) + VER_LAMEXP_MINOR_LO;
49 static const unsigned int g_lamexp_version_build = VER_LAMEXP_BUILD;
50 static const unsigned int g_lamexp_version_confg = VER_LAMEXP_CONFG;
51 static const char* g_lamexp_version_rname = VER_LAMEXP_RNAME;
53 //Demo Version
54 static int g_lamexp_demo = -1;
56 //Portable Mode
57 static int g_lamexp_portable = -1;
59 //Expiration date
60 static QScopedPointer<QDate> g_lamexp_expiration_date;
62 //Official web-site URL
63 static const char *g_lamexp_website_url = "http://lamexp.sourceforge.net/";
64 static const char *g_lamexp_mulders_url = "http://muldersoft.com/";
65 static const char *g_lamexp_support_url = "http://forum.doom9.org/showthread.php?t=157726";
66 static const char *g_lamexp_tracker_url = "https://github.com/lordmulder/LameXP/issues";
68 //Tool versions (expected versions!)
69 static const unsigned int g_lamexp_toolver_neroaac = VER_LAMEXP_TOOL_NEROAAC;
70 static const unsigned int g_lamexp_toolver_fhgaacenc = VER_LAMEXP_TOOL_FHGAACENC;
71 static const unsigned int g_lamexp_toolver_fdkaacenc = VER_LAMEXP_TOOL_FDKAACENC;
72 static const unsigned int g_lamexp_toolver_qaacenc = VER_LAMEXP_TOOL_QAAC;
74 ///////////////////////////////////////////////////////////////////////////////
75 // GLOBAL FUNCTIONS
76 ///////////////////////////////////////////////////////////////////////////////
79 * Version getters
81 unsigned int lamexp_version_major(void) { return g_lamexp_version_major; }
82 unsigned int lamexp_version_minor(void) { return g_lamexp_version_minor; }
83 unsigned int lamexp_version_build(void) { return g_lamexp_version_build; }
84 unsigned int lamexp_version_confg(void) { return g_lamexp_version_confg; }
85 const char* lamexp_version_release(void) { return g_lamexp_version_rname; }
86 unsigned int lamexp_toolver_neroaac(void) { return g_lamexp_toolver_neroaac; }
87 unsigned int lamexp_toolver_fhgaacenc(void) { return g_lamexp_toolver_fhgaacenc; }
88 unsigned int lamexp_toolver_fdkaacenc(void) { return g_lamexp_toolver_fdkaacenc; }
89 unsigned int lamexp_toolver_qaacenc(void) { return g_lamexp_toolver_qaacenc; }
92 * URL getters
94 const char *lamexp_website_url(void) { return g_lamexp_website_url; }
95 const char *lamexp_mulders_url(void) { return g_lamexp_mulders_url; }
96 const char *lamexp_support_url(void) { return g_lamexp_support_url; }
97 const char *lamexp_tracker_url(void) { return g_lamexp_tracker_url; }
100 * Check for test (pre-release) version
102 bool lamexp_version_test(void)
104 QReadLocker readLock(&g_lamexp_version_lock);
106 if(g_lamexp_demo >= 0)
108 return (g_lamexp_demo > 0);
111 readLock.unlock();
112 QWriteLocker writeLock(&g_lamexp_version_lock);
114 if(g_lamexp_demo < 0)
116 g_lamexp_demo = (_strnicmp(g_lamexp_version_rname, "Final", 5) && _strnicmp(g_lamexp_version_rname, "Hotfix", 6)) ? (1) : (0);
119 return (g_lamexp_demo > 0);
123 * Calculate expiration date
125 const QDate &lamexp_version_expires(void)
127 QReadLocker readLock(&g_lamexp_version_lock);
129 if(!g_lamexp_expiration_date.isNull())
131 return *g_lamexp_expiration_date;
134 readLock.unlock();
135 QWriteLocker writeLock(&g_lamexp_version_lock);
137 if(g_lamexp_expiration_date.isNull())
139 g_lamexp_expiration_date.reset(new QDate(MUtils::Version::app_build_date().addDays(MUTILS_DEBUG ? 7 : 30)));
142 return *g_lamexp_expiration_date;
146 * Check for LameXP "portable" mode
148 bool lamexp_version_portable(void)
150 QReadLocker readLock(&g_lamexp_version_lock);
152 if(g_lamexp_portable >= 0)
154 return (g_lamexp_portable > 0);
157 readLock.unlock();
158 QWriteLocker writeLock(&g_lamexp_version_lock);
160 if(g_lamexp_portable < 0)
162 if(VER_LAMEXP_PORTABLE_EDITION)
164 qWarning("LameXP portable edition!\n");
165 g_lamexp_portable = 1;
167 else
169 const QRegExp regex_portable("[_\\-]p", Qt::CaseInsensitive);
170 const QString baseName = QFileInfo(QApplication::applicationFilePath()).baseName();
171 g_lamexp_portable = qBound(0, baseName.indexOf(regex_portable), 1);
175 return (g_lamexp_portable > 0);