Added version info class.
This commit is contained in:
parent
f71d33693d
commit
906ecb7ab2
@ -18,6 +18,7 @@
|
||||
<ClCompile Include="src\Global.cpp" />
|
||||
<ClCompile Include="src\OSSupport_Win32.cpp" />
|
||||
<ClCompile Include="src\UpdateChecker.cpp" />
|
||||
<ClCompile Include="src\Version.cpp" />
|
||||
<ClCompile Include="tmp\MUtilities_VS2013\MOC_UpdateChecker.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@ -35,6 +36,7 @@
|
||||
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MOC "$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp"</Message>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp;%(Outputs)</Outputs>
|
||||
</CustomBuild>
|
||||
<ClInclude Include="include\MUtils\Version.h" />
|
||||
<ClInclude Include="src\CriticalSection_Win32.h" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
|
@ -33,6 +33,9 @@
|
||||
<ClCompile Include="tmp\MUtilities_VS2013\MOC_UpdateChecker.cpp">
|
||||
<Filter>Source Files\Generated</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Version.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\CriticalSection_Win32.h">
|
||||
@ -47,6 +50,9 @@
|
||||
<ClInclude Include="include\MUtils\OSSupport.h">
|
||||
<Filter>Public Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\MUtils\Version.h">
|
||||
<Filter>Public Headers</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CustomBuild Include="include\Mutils\UpdateChecker.h">
|
||||
|
@ -41,6 +41,9 @@ namespace MUtils
|
||||
QString rand_str(const bool &bLong = false);
|
||||
quint32 next_rand32(void);
|
||||
quint64 next_rand64(void);
|
||||
|
||||
//Version
|
||||
const char* buildDate(void);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -73,7 +73,7 @@ namespace MUtils
|
||||
}
|
||||
update_status_t;
|
||||
|
||||
UpdateChecker(const QString &binWGet, const QString &binGnuPG, const QString &binKeys, const quint32 &installedBuildNo, const bool betaUpdates, const bool testMode = false);
|
||||
UpdateChecker(const QString &binWGet, const QString &binGnuPG, const QString &binKeys, const QString &applicationId, const quint32 &installedBuildNo, const bool betaUpdates, const bool testMode = false);
|
||||
~UpdateChecker(void);
|
||||
|
||||
const int getUpdateStatus(void) const { return m_status; }
|
||||
@ -99,6 +99,7 @@ namespace MUtils
|
||||
const bool m_betaUpdates;
|
||||
const bool m_testMode;
|
||||
|
||||
const QString m_applicationId;
|
||||
const quint32 m_installedBuildNo;
|
||||
|
||||
const QString m_binaryWGet;
|
||||
|
126
include/MUtils/Version.h
Normal file
126
include/MUtils/Version.h
Normal file
@ -0,0 +1,126 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// MuldeR's Utilities for Qt
|
||||
// Copyright (C) 2004-2014 LoRd_MuldeR <MuldeR2@GMX.de>
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library 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
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
//
|
||||
// http://www.gnu.org/licenses/lgpl-2.1.txt
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
#include <QDate>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define MUTILS_MAKE_STRING_HELPER(X) #X
|
||||
#define MUTILS_MAKE_STRING(X) MUTILS_MAKE_STRING_HELPER(X)
|
||||
#define MUTILS_COMPILER_WARNING(TXT) __pragma(message(__FILE__ "(" MUTILS_MAKE_STRING(__LINE__) ") : warning: " TXT))
|
||||
|
||||
namespace MUtils
|
||||
{
|
||||
namespace Version
|
||||
{
|
||||
//Raw Build date
|
||||
const char *const BUILD_DATE = __DATE__;
|
||||
|
||||
//Get Build Data
|
||||
const QDate build_date(const char *const raw_date = BUILD_DATE);
|
||||
|
||||
//Compiler detection
|
||||
#if defined(__INTEL_COMPILER)
|
||||
#if (__INTEL_COMPILER >= 1500)
|
||||
static const char *COMPILER_VERS = "ICL 15." MUTILS_MAKE_STRING(__INTEL_COMPILER_BUILD_DATE);
|
||||
#elif (__INTEL_COMPILER >= 1400)
|
||||
static const char *COMPILER_VERS = "ICL 14." MUTILS_MAKE_STRING(__INTEL_COMPILER_BUILD_DATE);
|
||||
#elif (__INTEL_COMPILER >= 1300)
|
||||
static const char *COMPILER_VERS = "ICL 13." MUTILS_MAKE_STRING(__INTEL_COMPILER_BUILD_DATE);
|
||||
#elif (__INTEL_COMPILER >= 1200)
|
||||
static const char *COMPILER_VERS = "ICL 12." MUTILS_MAKE_STRING(__INTEL_COMPILER_BUILD_DATE);
|
||||
#elif (__INTEL_COMPILER >= 1100)
|
||||
static const char *COMPILER_VERS = "ICL 11.x";
|
||||
#elif (__INTEL_COMPILER >= 1000)
|
||||
static const char *COMPILER_VERS = "ICL 10.x";
|
||||
#else
|
||||
#error Compiler is not supported!
|
||||
#endif
|
||||
#elif defined(_MSC_VER)
|
||||
#if (_MSC_VER == 1800)
|
||||
#if (_MSC_FULL_VER == 180021005)
|
||||
static const char *COMPILER_VERS = "MSVC 2013";
|
||||
#elif (_MSC_FULL_VER == 180030501)
|
||||
static const char *COMPILER_VERS = "MSVC 2013.2";
|
||||
#elif (_MSC_FULL_VER == 180030723)
|
||||
static const char *COMPILER_VERS = "MSVC 2013.3";
|
||||
#elif (_MSC_FULL_VER == 180031101)
|
||||
static const char *COMPILER_VERS = "MSVC 2013.4";
|
||||
#else
|
||||
#error Compiler version is not supported yet!
|
||||
#endif
|
||||
#elif (_MSC_VER == 1700)
|
||||
#if (_MSC_FULL_VER == 170050727)
|
||||
static const char *COMPILER_VERS = "MSVC 2012";
|
||||
#elif (_MSC_FULL_VER == 170051106)
|
||||
static const char *COMPILER_VERS = "MSVC 2012.1";
|
||||
#elif (_MSC_FULL_VER == 170060315)
|
||||
static const char *COMPILER_VERS = "MSVC 2012.2";
|
||||
#elif (_MSC_FULL_VER == 170060610)
|
||||
static const char *COMPILER_VERS = "MSVC 2012.3";
|
||||
#elif (_MSC_FULL_VER == 170061030)
|
||||
static const char *COMPILER_VERS = "MSVC 2012.4";
|
||||
#else
|
||||
#error Compiler version is not supported yet!
|
||||
#endif
|
||||
#elif (_MSC_VER == 1600)
|
||||
#if (_MSC_FULL_VER >= 160040219)
|
||||
static const char *COMPILER_VERS = "MSVC 2010-SP1";
|
||||
#else
|
||||
static const char *COMPILER_VERS = "MSVC 2010";
|
||||
#endif
|
||||
#elif (_MSC_VER == 1500)
|
||||
#if (_MSC_FULL_VER >= 150030729)
|
||||
static const char *COMPILER_VERS = "MSVC 2008-SP1";
|
||||
#else
|
||||
static const char *COMPILER_VERS = "MSVC 2008";
|
||||
#endif
|
||||
#else
|
||||
#error Compiler is not supported!
|
||||
#endif
|
||||
|
||||
// Note: /arch:SSE and /arch:SSE2 are only available for the x86 platform
|
||||
#if !defined(_M_X64) && defined(_M_IX86_FP)
|
||||
#if (_M_IX86_FP == 1)
|
||||
MUTILS_COMPILER_WARNING("SSE instruction set is enabled!")
|
||||
#elif (_M_IX86_FP == 2)
|
||||
MUTILS_COMPILER_WARNING("SSE2 (or higher) instruction set is enabled!")
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#error Compiler is not supported!
|
||||
#endif
|
||||
|
||||
//Architecture detection
|
||||
#if defined(_M_X64)
|
||||
static const char *COMPILER_ARCH = "x64";
|
||||
#elif defined(_M_IX86)
|
||||
static const char *COMPILER_ARCH = "x86";
|
||||
#else
|
||||
#error Architecture is not supported!
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
@ -244,7 +244,7 @@ static volatile bool g_fatal_exit_flag = true;
|
||||
|
||||
static DWORD WINAPI fatal_exit_helper(LPVOID lpParameter)
|
||||
{
|
||||
MessageBoxA(NULL, ((LPCSTR) lpParameter), "LameXP - Guru Meditation", MB_OK | MB_ICONERROR | MB_TASKMODAL | MB_TOPMOST | MB_SETFOREGROUND);
|
||||
MessageBoxA(NULL, ((LPCSTR) lpParameter), "Guru Meditation", MB_OK | MB_ICONERROR | MB_TASKMODAL | MB_TOPMOST | MB_SETFOREGROUND);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,6 @@ using namespace MUtils;
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static const char *header_id = "!Update";
|
||||
static const char *section_id = "LameXP";
|
||||
|
||||
static const char *mirror_url_postfix[] =
|
||||
{
|
||||
@ -199,12 +198,13 @@ void UpdateCheckerInfo::resetInfo(void)
|
||||
// Constructor & Destructor
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
UpdateChecker::UpdateChecker(const QString &binWGet, const QString &binGnuPG, const QString &binKeys, const quint32 &installedBuildNo, const bool betaUpdates, const bool testMode)
|
||||
UpdateChecker::UpdateChecker(const QString &binWGet, const QString &binGnuPG, const QString &binKeys, const QString &applicationId, const quint32 &installedBuildNo, const bool betaUpdates, const bool testMode)
|
||||
:
|
||||
m_updateInfo(new UpdateCheckerInfo()),
|
||||
m_binaryWGet(binWGet),
|
||||
m_binaryGnuPG(binGnuPG),
|
||||
m_binaryKeys(binKeys),
|
||||
m_applicationId(applicationId),
|
||||
m_installedBuildNo(installedBuildNo),
|
||||
m_betaUpdates(betaUpdates),
|
||||
m_testMode(testMode),
|
||||
@ -634,8 +634,8 @@ bool UpdateChecker::parseVersionInfo(const QString &file, UpdateCheckerInfo *upd
|
||||
return false;
|
||||
}
|
||||
|
||||
bool inHeader = false;
|
||||
bool inSection = false;
|
||||
bool inHdr = false;
|
||||
bool inSec = false;
|
||||
|
||||
while(!data.atEnd())
|
||||
{
|
||||
@ -643,11 +643,11 @@ bool UpdateChecker::parseVersionInfo(const QString &file, UpdateCheckerInfo *upd
|
||||
if(section.indexIn(line) >= 0)
|
||||
{
|
||||
log(QString("Sec: [%1]").arg(section.cap(1)));
|
||||
inSection = (section.cap(1).compare(section_id, Qt::CaseInsensitive) == 0);
|
||||
inHeader = (section.cap(1).compare(header_id, Qt::CaseInsensitive) == 0);
|
||||
inSec = (section.cap(1).compare(m_applicationId, Qt::CaseInsensitive) == 0);
|
||||
inHdr = (section.cap(1).compare(QString::fromLatin1(header_id), Qt::CaseInsensitive) == 0);
|
||||
continue;
|
||||
}
|
||||
if(inSection && (value.indexIn(line) >= 0))
|
||||
if(inSec && (value.indexIn(line) >= 0))
|
||||
{
|
||||
log(QString("Val: '%1' ==> '%2").arg(value.cap(1), value.cap(2)));
|
||||
if(value.cap(1).compare("BuildNo", Qt::CaseInsensitive) == 0)
|
||||
@ -678,7 +678,7 @@ bool UpdateChecker::parseVersionInfo(const QString &file, UpdateCheckerInfo *upd
|
||||
updateInfo->m_downloadFilecode = value.cap(2).trimmed();
|
||||
}
|
||||
}
|
||||
if(inHeader && (value.indexIn(line) >= 0))
|
||||
if(inHdr && (value.indexIn(line) >= 0))
|
||||
{
|
||||
log(QString("Val: '%1' ==> '%2").arg(value.cap(1), value.cap(2)));
|
||||
if(value.cap(1).compare("TimestampCreated", Qt::CaseInsensitive) == 0)
|
||||
|
81
src/Version.cpp
Normal file
81
src/Version.cpp
Normal file
@ -0,0 +1,81 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// MuldeR's Utilities for Qt
|
||||
// Copyright (C) 2004-2014 LoRd_MuldeR <MuldeR2@GMX.de>
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library 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
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
//
|
||||
// http://www.gnu.org/licenses/lgpl-2.1.txt
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <MUtils/Version.h>
|
||||
|
||||
#include <MUtils/Global.h>
|
||||
#include <MUtils/Exception.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static const char *g_months_lut[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
||||
|
||||
static int month2int(const char *str)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
for(int j = 0; j < 12; j++)
|
||||
{
|
||||
if(!_strcmpi(str, g_months_lut[j]))
|
||||
{
|
||||
ret = j+1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
const QDate MUtils::Version::build_date(const char *const raw_date)
|
||||
{
|
||||
int date[3] = {0, 0, 0};
|
||||
char temp_m[4], temp_d[3], temp_y[5];
|
||||
|
||||
temp_m[0] = raw_date[0x0];
|
||||
temp_m[1] = raw_date[0x1];
|
||||
temp_m[2] = raw_date[0x2];
|
||||
temp_m[3] = 0x00;
|
||||
|
||||
temp_d[0] = raw_date[0x4];
|
||||
temp_d[1] = raw_date[0x5];
|
||||
temp_d[2] = 0x00;
|
||||
|
||||
temp_y[0] = raw_date[0x7];
|
||||
temp_y[1] = raw_date[0x8];
|
||||
temp_y[2] = raw_date[0x9];
|
||||
temp_y[3] = raw_date[0xA];
|
||||
temp_y[4] = 0x00;
|
||||
|
||||
date[0] = atoi(temp_y);
|
||||
date[1] = month2int(temp_m);
|
||||
date[2] = atoi(temp_d);
|
||||
|
||||
if(!((date[0] > 0) && (date[1] > 0) && (date[2] > 0)))
|
||||
{
|
||||
MUTILS_THROW("Internal error: Date format could not be recognized!");
|
||||
}
|
||||
|
||||
return QDate(date[0], date[1], date[2]);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
Loading…
Reference in New Issue
Block a user