OSDN Git Service

Moved set_window_icon() function into MUtilities function.
[lamexp/LameXP.git] / src / Global_Version.cpp
index 24eeadf..d0ce35c 100644 (file)
@@ -1,6 +1,6 @@
 ///////////////////////////////////////////////////////////////////////////////
 // LameXP - Audio Encoder Front-End
-// Copyright (C) 2004-2013 LoRd_MuldeR <MuldeR2@GMX.de>
+// Copyright (C) 2004-2014 LoRd_MuldeR <MuldeR2@GMX.de>
 //
 // 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
@@ -27,6 +27,9 @@
 #include "Resource.h"
 #include "Config.h"
 
+//MUtils
+#include <MUtils/Version.h>
+
 //Qt includes
 #include <QApplication>
 #include <QDate>
@@ -64,109 +67,19 @@ static struct
 }
 g_lamexp_portable;
 
-//Build date
-static QDate g_lamexp_version_date;
-static const char *g_lamexp_months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
-static const char *g_lamexp_version_raw_date = __DATE__;
-static const char *g_lamexp_version_raw_time = __TIME__;
-
 //Official web-site URL
 static const char *g_lamexp_website_url = "http://lamexp.sourceforge.net/";
-static const char *g_lamexp_support_url = "http://forum.doom9.org/showthread.php?t=157726";
 static const char *g_lamexp_mulders_url = "http://muldersoft.com/";
+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";
 
 //Tool versions (expected versions!)
-static const unsigned int g_lamexp_toolver_neroaac = VER_LAMEXP_TOOL_NEROAAC;
+static const unsigned int g_lamexp_toolver_neroaac   = VER_LAMEXP_TOOL_NEROAAC;
 static const unsigned int g_lamexp_toolver_fhgaacenc = VER_LAMEXP_TOOL_FHGAACENC;
-static const unsigned int g_lamexp_toolver_qaacenc = VER_LAMEXP_TOOL_QAAC;
+static const unsigned int g_lamexp_toolver_qaacenc   = VER_LAMEXP_TOOL_QAAC;
 static const unsigned int g_lamexp_toolver_coreaudio = VER_LAMEXP_TOOL_COREAUDIO;
 
 ///////////////////////////////////////////////////////////////////////////////
-// COMPILER INFO
-///////////////////////////////////////////////////////////////////////////////
-
-/*
- * Disclaimer: Parts of the following code were borrowed from MPC-HC project: http://mpc-hc.sf.net/
- */
-
-//Compiler detection
-#if defined(__INTEL_COMPILER)
-       #if (__INTEL_COMPILER >= 1300)
-               static const char *g_lamexp_version_compiler = "ICL 13." LAMEXP_MAKE_STR(__INTEL_COMPILER_BUILD_DATE);
-       #elif (__INTEL_COMPILER >= 1200)
-               static const char *g_lamexp_version_compiler = "ICL 12." LAMEXP_MAKE_STR(__INTEL_COMPILER_BUILD_DATE);
-       #elif (__INTEL_COMPILER >= 1100)
-               static const char *g_lamexp_version_compiler = "ICL 11.x";
-       #elif (__INTEL_COMPILER >= 1000)
-               static const char *g_lamexp_version_compiler = "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 *g_lamexp_version_compiler = "MSVC 2013-Beta";
-               #elif (_MSC_FULL_VER == 180021005)
-                       static const char *g_lamexp_version_compiler = "MSVC 2013";
-               #else
-                       #error Compiler version is not supported yet!
-               #endif
-       #elif (_MSC_VER == 1700)
-               #if (_MSC_FULL_VER < 170050727)
-                       static const char *g_lamexp_version_compiler = "MSVC 2012-Beta";
-               #elif (_MSC_FULL_VER < 170051020)
-                       static const char *g_lamexp_version_compiler = "MSVC 2012";
-               #elif (_MSC_FULL_VER < 170051106)
-                       static const char *g_lamexp_version_compiler = "MSVC 2012.1-CTP";
-               #elif (_MSC_FULL_VER < 170060315)
-                       static const char *g_lamexp_version_compiler = "MSVC 2012.1";
-               #elif (_MSC_FULL_VER < 170060610)
-                       static const char *g_lamexp_version_compiler = "MSVC 2012.2";
-               #elif (_MSC_FULL_VER == 170060610)
-                       static const char *g_lamexp_version_compiler = "MSVC 2012.3";
-               #else
-                       #error Compiler version is not supported yet!
-               #endif
-       #elif (_MSC_VER == 1600)
-               #if (_MSC_FULL_VER < 160040219)
-                       static const char *g_lamexp_version_compiler = "MSVC 2010";
-               #elif (_MSC_FULL_VER == 160040219)
-                       static const char *g_lamexp_version_compiler = "MSVC 2010-SP1";
-               #else
-                       #error Compiler version is not supported yet!
-               #endif
-       #elif (_MSC_VER == 1500)
-               #if (_MSC_FULL_VER >= 150030729)
-                       static const char *g_lamexp_version_compiler = "MSVC 2008-SP1";
-               #else
-                       static const char *g_lamexp_version_compiler = "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)
-                       LAMEXP_COMPILER_WARNING("SSE instruction set is enabled!")
-               #elif (_M_IX86_FP == 2)
-                       LAMEXP_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 *g_lamexp_version_arch = "x64";
-#elif defined(_M_IX86)
-       static const char *g_lamexp_version_arch = "x86";
-#else
-       #error Architecture is not supported!
-#endif
-
-///////////////////////////////////////////////////////////////////////////////
 // GLOBAL FUNCTIONS
 ///////////////////////////////////////////////////////////////////////////////
 
@@ -177,10 +90,7 @@ 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; }
-const char *lamexp_version_time(void)       { return g_lamexp_version_raw_time; }
-const char *lamexp_version_compiler(void)   { return g_lamexp_version_compiler; }
-const char *lamexp_version_arch(void)       { return g_lamexp_version_arch; }
+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_toolver_fhgaacenc(void) { return g_lamexp_toolver_fhgaacenc; }
 unsigned int lamexp_toolver_qaacenc(void)   { return g_lamexp_toolver_qaacenc; }
@@ -192,23 +102,14 @@ unsigned int lamexp_toolver_coreaudio(void) { return g_lamexp_toolver_coreaudio;
 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; }
+const char *lamexp_tracker_url(void) { return g_lamexp_tracker_url; }
 
 /*
  * Check for Demo (pre-release) version
  */
 bool lamexp_version_demo(void)
 {
-       char buffer[128];
-       bool releaseVersion = false;
-       if(!strncpy_s(buffer, 128, g_lamexp_version.ver_release_name, _TRUNCATE))
-       {
-               char *context, *prefix = strtok_s(buffer, "-,; ", &context);
-               if(prefix)
-               {
-                       releaseVersion = (!_stricmp(prefix, "Final")) || (!_stricmp(prefix, "Hotfix"));
-               }
-       }
-       return (!releaseVersion);
+       return _strnicmp(g_lamexp_version.ver_release_name, "Final", 5) && _strnicmp(g_lamexp_version.ver_release_name, "Hotfix", 6);
 }
 
 /*
@@ -216,70 +117,7 @@ bool lamexp_version_demo(void)
  */
 QDate lamexp_version_expires(void)
 {
-       return lamexp_version_date().addDays(LAMEXP_DEBUG ? 7 : 30);
-}
-
-/*
- * Convert month string to integer value
- */
-static int lamexp_month2int(const char *str)
-{
-       int ret = 0;
-
-       for(int j = 0; j < 12; j++)
-       {
-               if(!_strcmpi(str, g_lamexp_months[j]))
-               {
-                       ret = j+1;
-                       break;
-               }
-       }
-
-       return ret;
-}
-
-/*
- * Get build date date
- */
-const QDate &lamexp_version_date(void)
-{
-       //Format of __DATE__ is defined as: "MMM DD YYYY"
-       if(!g_lamexp_version_date.isValid())
-       {
-               int date[3] = {0, 0, 0};
-               char temp_m[4], temp_d[3], temp_y[5];
-
-               temp_m[0] = g_lamexp_version_raw_date[0x0];
-               temp_m[1] = g_lamexp_version_raw_date[0x1];
-               temp_m[2] = g_lamexp_version_raw_date[0x2];
-               temp_m[3] = 0x00;
-
-               temp_d[0] = g_lamexp_version_raw_date[0x4];
-               temp_d[1] = g_lamexp_version_raw_date[0x5];
-               temp_d[2] = 0x00;
-
-               temp_y[0] = g_lamexp_version_raw_date[0x7];
-               temp_y[1] = g_lamexp_version_raw_date[0x8];
-               temp_y[2] = g_lamexp_version_raw_date[0x9];
-               temp_y[3] = g_lamexp_version_raw_date[0xA];
-               temp_y[4] = 0x00;
-               
-               date[0] = atoi(temp_y);
-               date[1] = lamexp_month2int(temp_m);
-               date[2] = atoi(temp_d);
-
-               if((date[0] > 0) && (date[1] > 0) && (date[2] > 0))
-               {
-
-                       g_lamexp_version_date = QDate(date[0], date[1], date[2]);
-               }
-               else
-               {
-                       THROW("Internal error: Date format could not be recognized!");
-               }
-       }
-
-       return g_lamexp_version_date;
+       return MUtils::Version::app_build_date().addDays(MUTILS_DEBUG ? 7 : 30);
 }
 
 /*
@@ -309,7 +147,7 @@ bool lamexp_portable_mode(void)
                        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);
+                       g_lamexp_portable.bPortableModeEnabled = ((idx1 >= 0) && (idx2 >= 0) && (idx1 < idx2));
                }
                g_lamexp_portable.bInitialized = true;
        }
@@ -323,7 +161,7 @@ bool lamexp_portable_mode(void)
 
 extern "C" void _lamexp_global_init_versn(void)
 {
-       LAMEXP_ZERO_MEMORY(g_lamexp_portable);
+       MUTILS_ZERO_MEMORY(g_lamexp_portable);
 }
 
 ///////////////////////////////////////////////////////////////////////////////