2010-11-06 23:04:47 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// LameXP - Audio Encoder Front-End
|
2012-01-02 00:52:27 +01:00
|
|
|
// Copyright (C) 2004-2012 LoRd_MuldeR <MuldeR2@GMX.de>
|
2010-11-06 23:04:47 +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.
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2011-04-11 21:55:34 +02:00
|
|
|
//Target version
|
2010-11-06 23:04:47 +01:00
|
|
|
#include "Targetver.h"
|
|
|
|
|
2011-04-11 21:55:34 +02:00
|
|
|
//inlcude C standard library
|
2010-11-06 23:04:47 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <tchar.h>
|
|
|
|
|
2011-04-11 21:55:34 +02:00
|
|
|
//Windows includes
|
2011-11-26 17:25:33 +01:00
|
|
|
#define NOMINMAX
|
2011-04-11 21:55:34 +02:00
|
|
|
#define WIN32_LEAN_AND_MEAN
|
2010-11-06 23:04:47 +01:00
|
|
|
#include <Windows.h>
|
|
|
|
|
2012-04-06 22:24:05 +02:00
|
|
|
//Visual Leaks Detector
|
|
|
|
#include <vld.h>
|
|
|
|
|
2010-11-19 13:31:45 +01:00
|
|
|
//Declarations
|
2010-11-06 23:04:47 +01:00
|
|
|
class QString;
|
2010-12-28 21:26:16 +01:00
|
|
|
class QStringList;
|
2010-11-06 23:04:47 +01:00
|
|
|
class QDate;
|
2011-12-26 21:02:55 +01:00
|
|
|
class QTime;
|
|
|
|
class QIcon;
|
2011-05-03 20:17:33 +02:00
|
|
|
class QWidget;
|
2010-12-28 21:26:16 +01:00
|
|
|
class LockedFile;
|
2010-11-19 13:31:45 +01:00
|
|
|
enum QtMsgType;
|
2010-11-06 23:04:47 +01:00
|
|
|
|
2010-11-15 04:42:06 +01:00
|
|
|
//Types definitions
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int family;
|
|
|
|
int model;
|
|
|
|
int stepping;
|
2010-11-15 14:02:58 +01:00
|
|
|
int count;
|
|
|
|
bool x64;
|
2010-11-15 04:42:06 +01:00
|
|
|
bool mmx;
|
|
|
|
bool sse;
|
|
|
|
bool sse2;
|
|
|
|
bool sse3;
|
|
|
|
bool ssse3;
|
2010-11-26 00:29:53 +01:00
|
|
|
char vendor[0x40];
|
2010-11-15 04:42:06 +01:00
|
|
|
char brand[0x40];
|
2010-11-26 00:29:53 +01:00
|
|
|
bool intel;
|
|
|
|
}
|
|
|
|
lamexp_cpu_t;
|
2010-11-15 04:42:06 +01:00
|
|
|
|
2010-12-15 18:43:21 +01:00
|
|
|
//Known folders
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
lamexp_folder_localappdata = 0,
|
2010-12-19 21:23:43 +01:00
|
|
|
lamexp_folder_programfiles = 2,
|
|
|
|
lamexp_folder_systemfolder = 3
|
2010-12-15 18:43:21 +01:00
|
|
|
}
|
|
|
|
lamexp_known_folder_t;
|
|
|
|
|
2011-12-29 14:42:20 +01:00
|
|
|
//LameXP user-defined events
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
lamexp_event = 1000, /*QEvent::User*/
|
|
|
|
lamexp_event_queryendsession = lamexp_event + 666,
|
|
|
|
lamexp_event_endsession = lamexp_event + 667
|
|
|
|
}
|
|
|
|
lamexp_event_t;
|
|
|
|
|
2012-09-09 23:05:00 +02:00
|
|
|
//OS version number
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
unsigned int versionMajor;
|
|
|
|
unsigned int versionMinor;
|
|
|
|
}
|
|
|
|
lamexp_os_version_t;
|
|
|
|
|
2010-11-06 23:04:47 +01:00
|
|
|
//LameXP version info
|
|
|
|
unsigned int lamexp_version_major(void);
|
|
|
|
unsigned int lamexp_version_minor(void);
|
|
|
|
unsigned int lamexp_version_build(void);
|
|
|
|
const QDate &lamexp_version_date(void);
|
2011-07-26 22:17:14 +02:00
|
|
|
const char *lamexp_version_time(void);
|
2010-11-06 23:04:47 +01:00
|
|
|
const char *lamexp_version_release(void);
|
|
|
|
bool lamexp_version_demo(void);
|
2010-11-20 22:14:29 +01:00
|
|
|
const char *lamexp_version_compiler(void);
|
2011-07-26 22:17:14 +02:00
|
|
|
const char *lamexp_version_arch(void);
|
2011-01-20 22:06:59 +01:00
|
|
|
QDate lamexp_version_expires(void);
|
2010-11-12 15:58:53 +01:00
|
|
|
unsigned int lamexp_toolver_neroaac(void);
|
2011-08-21 14:43:18 +02:00
|
|
|
unsigned int lamexp_toolver_fhgaacenc(void);
|
2011-11-21 01:22:41 +01:00
|
|
|
unsigned int lamexp_toolver_qaacenc(void);
|
2011-11-21 14:40:32 +01:00
|
|
|
unsigned int lamexp_toolver_coreaudio(void);
|
2011-02-28 01:28:27 +01:00
|
|
|
const char *lamexp_website_url(void);
|
2011-03-20 14:28:27 +01:00
|
|
|
const char *lamexp_support_url(void);
|
2012-09-09 23:05:00 +02:00
|
|
|
const lamexp_os_version_t *lamexp_get_os_version(void);
|
2012-04-05 13:40:52 +02:00
|
|
|
bool lamexp_detect_wine(void);
|
2010-11-06 23:04:47 +01:00
|
|
|
|
|
|
|
//Public functions
|
2012-06-22 15:49:56 +02:00
|
|
|
void lamexp_init_console(const QStringList &argv);
|
2010-11-06 23:04:47 +01:00
|
|
|
bool lamexp_init_qt(int argc, char* argv[]);
|
2010-11-08 21:47:35 +01:00
|
|
|
int lamexp_init_ipc(void);
|
2011-04-17 15:53:28 +02:00
|
|
|
LONG WINAPI lamexp_exception_handler(__in struct _EXCEPTION_POINTERS *ExceptionInfo);
|
2011-07-26 22:17:14 +02:00
|
|
|
void lamexp_invalid_param_handler(const wchar_t*, const wchar_t*, const wchar_t*, unsigned int, uintptr_t);
|
2010-11-19 13:31:45 +01:00
|
|
|
void lamexp_message_handler(QtMsgType type, const char *msg);
|
2010-11-12 15:58:53 +01:00
|
|
|
void lamexp_register_tool(const QString &toolName, LockedFile *file, unsigned int version = 0);
|
2010-11-11 22:58:02 +01:00
|
|
|
bool lamexp_check_tool(const QString &toolName);
|
2010-11-06 23:04:47 +01:00
|
|
|
const QString lamexp_lookup_tool(const QString &toolName);
|
2010-11-12 15:58:53 +01:00
|
|
|
unsigned int lamexp_tool_version(const QString &toolName);
|
2010-11-06 23:04:47 +01:00
|
|
|
void lamexp_finalization(void);
|
2010-12-07 22:58:28 +01:00
|
|
|
QString lamexp_rand_str(void);
|
2011-02-25 22:03:39 +01:00
|
|
|
const QString &lamexp_temp_folder2(void);
|
2010-11-08 19:29:36 +01:00
|
|
|
void lamexp_ipc_read(unsigned int *command, char* message, size_t buffSize);
|
|
|
|
void lamexp_ipc_send(unsigned int command, const char* message);
|
2012-06-23 18:18:57 +02:00
|
|
|
lamexp_cpu_t lamexp_detect_cpu_features(const QStringList &argv);
|
2011-01-24 00:04:07 +01:00
|
|
|
bool lamexp_portable_mode(void);
|
2011-10-22 01:13:28 +02:00
|
|
|
bool lamexp_shutdown_computer(const QString &message, const unsigned long timeout = 30, const bool forceShutdown = true, const bool hibernate = false);
|
2011-10-22 01:34:24 +02:00
|
|
|
bool lamexp_is_hibernation_supported(void);
|
2011-12-26 21:02:55 +01:00
|
|
|
QIcon lamexp_app_icon(const QDate *date = NULL, const QTime *time = NULL);
|
2012-06-22 15:49:56 +02:00
|
|
|
const QStringList &lamexp_arguments(void);
|
2010-12-30 16:12:21 +01:00
|
|
|
|
|
|
|
//Translation support
|
2010-12-28 21:26:16 +01:00
|
|
|
QStringList lamexp_query_translations(void);
|
2011-12-19 17:26:20 +01:00
|
|
|
bool lamexp_translation_register(const QString &langId, const QString &qmFile, const QString &langName, unsigned int &systemId, unsigned int &country);
|
2010-12-30 16:12:21 +01:00
|
|
|
QString lamexp_translation_name(const QString &language);
|
2011-01-04 19:58:18 +01:00
|
|
|
unsigned int lamexp_translation_sysid(const QString &langId);
|
2011-12-19 17:26:20 +01:00
|
|
|
unsigned int lamexp_translation_country(const QString &langId);
|
2011-01-06 00:53:52 +01:00
|
|
|
bool lamexp_install_translator_from_file(const QString &qmFile);
|
2010-12-28 21:26:16 +01:00
|
|
|
bool lamexp_install_translator(const QString &language);
|
2011-12-10 23:12:47 +01:00
|
|
|
QStringList lamexp_available_codepages(bool noAliases = true);
|
2011-01-02 01:09:05 +01:00
|
|
|
static const char* LAMEXP_DEFAULT_LANGID = "en";
|
2010-11-06 23:04:47 +01:00
|
|
|
|
|
|
|
//Auxiliary functions
|
2011-03-21 17:36:43 +01:00
|
|
|
bool lamexp_clean_folder(const QString &folderPath);
|
2011-01-14 23:34:31 +01:00
|
|
|
const QString lamexp_version2string(const QString &pattern, unsigned int version, const QString &defaultText);
|
2012-08-18 22:37:10 +02:00
|
|
|
const QString &lamexp_known_folder(lamexp_known_folder_t folder_id);
|
2011-10-29 16:26:09 +02:00
|
|
|
unsigned __int64 lamexp_free_diskspace(const QString &path, bool *ok = NULL);
|
2010-12-21 01:09:25 +01:00
|
|
|
bool lamexp_remove_file(const QString &filename);
|
2011-01-02 20:47:26 +01:00
|
|
|
bool lamexp_themes_enabled(void);
|
2011-05-03 20:17:33 +02:00
|
|
|
void lamexp_blink_window(QWidget *poWindow, unsigned int count = 10, unsigned int delay = 150);
|
2011-08-04 20:35:40 +02:00
|
|
|
const QString lamexp_clean_filename(const QString &str);
|
|
|
|
const QString lamexp_clean_filepath(const QString &str);
|
2012-10-09 17:43:17 +02:00
|
|
|
unsigned int lamexp_mix(const unsigned int x, const unsigned int y, const unsigned int z);
|
2010-11-06 23:04:47 +01:00
|
|
|
|
2010-11-07 16:32:54 +01:00
|
|
|
//Debug-only functions
|
|
|
|
SIZE_T lamexp_dbg_private_bytes(void);
|
|
|
|
|
2010-11-06 23:04:47 +01:00
|
|
|
//Helper macros
|
2012-07-29 19:09:15 +02:00
|
|
|
#define LAMEXP_DELETE(PTR) do { if(PTR) { delete PTR; PTR = NULL; } } while(0)
|
|
|
|
#define LAMEXP_DELETE_ARRAY(PTR) do { if(PTR) { delete [] PTR; PTR = NULL; } } while(0)
|
|
|
|
#define LAMEXP_SAFE_FREE(PTR) do { if(PTR) { free((void*) PTR); PTR = NULL; } } while(0)
|
|
|
|
#define LAMEXP_CLOSE(HANDLE) do { if(HANDLE != NULL && HANDLE != INVALID_HANDLE_VALUE) { CloseHandle(HANDLE); HANDLE = NULL; } } while(0)
|
2012-09-09 23:05:00 +02:00
|
|
|
#define LAMEXP_MIN_OS_VER(VER_INFO, VER_MAJ, VER_MIN) (((VER_INFO)->versionMajor > (VER_MAJ)) || (((VER_INFO)->versionMajor == (VER_MAJ)) && ((VER_INFO)->versionMinor >= (VER_MIN))))
|
|
|
|
#define LAMEXP_MAX_OS_VER(VER_INFO, VER_MAJ, VER_MIN) (((VER_INFO)->versionMajor < (VER_MAJ)) || (((VER_INFO)->versionMajor == (VER_MAJ)) && ((VER_INFO)->versionMinor <= (VER_MIN))))
|
|
|
|
#define LAMEXP_EQL_OS_VER(VER_INFO, VER_MAJ, VER_MIN) (((VER_INFO)->versionMajor == (VER_MAJ)) && ((VER_INFO)->versionMinor == (VER_MIN)))
|
2010-11-06 23:04:47 +01:00
|
|
|
#define QWCHAR(STR) reinterpret_cast<const wchar_t*>(STR.utf16())
|
2011-02-18 20:14:45 +01:00
|
|
|
#define WCHAR2QSTR(STR) QString::fromUtf16(reinterpret_cast<const unsigned short*>(STR))
|
2012-07-29 19:09:15 +02:00
|
|
|
#define LAMEXP_BOOL2STR(X) (X ? "1" : "0")
|
2011-03-25 16:17:19 +01:00
|
|
|
#define LAMEXP_MAKE_STRING_EX(X) #X
|
|
|
|
#define LAMEXP_MAKE_STRING(X) LAMEXP_MAKE_STRING_EX(X)
|
|
|
|
#define LAMEXP_COMPILER_WARNING(TXT) __pragma(message(__FILE__ "(" LAMEXP_MAKE_STRING(__LINE__) ") : warning: " TXT))
|
2012-04-18 22:53:07 +02:00
|
|
|
#define NOBR(STR) (QString("<nobr>%1</nobr>").arg((STR)).replace("-", "−"))
|
2010-11-06 23:04:47 +01:00
|
|
|
|
2011-03-12 21:58:46 +01:00
|
|
|
//Output Qt debug message (Unicode-safe versions)
|
2012-07-29 19:09:15 +02:00
|
|
|
/*
|
|
|
|
#define qDebug64(FORMAT, ...) qDebug("@BASE64@%s", QString(FORMAT).arg(__VA_ARGS__).toUtf8().toBase64().constData());
|
|
|
|
#define qWarning64(FORMAT, ...) qWarning("@BASE64@%s", QString(FORMAT).arg(__VA_ARGS__).toUtf8().toBase64().constData());
|
|
|
|
#define qFatal64(FORMAT, ...) qFatal("@BASE64@%s", QString(FORMAT).arg(__VA_ARGS__).toUtf8().toBase64().constData());
|
|
|
|
*/
|
2011-03-12 21:58:46 +01:00
|
|
|
|
2010-11-06 23:04:47 +01:00
|
|
|
//Check for debug build
|
2011-04-14 01:40:11 +02:00
|
|
|
#if defined(_DEBUG) && defined(QT_DEBUG) && !defined(NDEBUG) && !defined(QT_NO_DEBUG)
|
|
|
|
#define LAMEXP_DEBUG (1)
|
|
|
|
#elif defined(NDEBUG) && defined(QT_NO_DEBUG) && !defined(_DEBUG) && !defined(QT_DEBUG)
|
|
|
|
#define LAMEXP_DEBUG (0)
|
2010-11-06 23:04:47 +01:00
|
|
|
#else
|
2011-04-14 01:40:11 +02:00
|
|
|
#error Inconsistent debug defines detected!
|
2010-11-06 23:04:47 +01:00
|
|
|
#endif
|
2010-11-07 16:32:54 +01:00
|
|
|
|
|
|
|
//Memory check
|
2012-04-10 01:25:34 +02:00
|
|
|
#if LAMEXP_DEBUG
|
2012-08-18 20:55:59 +02:00
|
|
|
#define LAMEXP_MEMORY_CHECK(FUNC, RETV, ...) do \
|
2010-11-07 16:32:54 +01:00
|
|
|
{ \
|
|
|
|
SIZE_T _privateBytesBefore = lamexp_dbg_private_bytes(); \
|
2012-04-06 22:24:05 +02:00
|
|
|
RETV = FUNC(__VA_ARGS__); \
|
2010-11-07 16:32:54 +01:00
|
|
|
SIZE_T _privateBytesLeak = (lamexp_dbg_private_bytes() - _privateBytesBefore) / 1024; \
|
2012-04-06 22:24:05 +02:00
|
|
|
if(_privateBytesLeak > 0) { \
|
|
|
|
char _buffer[128]; \
|
2012-04-10 01:25:34 +02:00
|
|
|
_snprintf_s(_buffer, 128, _TRUNCATE, "Memory leak: Lost %u KiloBytes of PrivateUsage memory.\n", _privateBytesLeak); \
|
2012-04-06 22:24:05 +02:00
|
|
|
OutputDebugStringA("----------\n"); \
|
|
|
|
OutputDebugStringA(_buffer); \
|
|
|
|
OutputDebugStringA("----------\n"); \
|
2010-11-07 16:32:54 +01:00
|
|
|
} \
|
2012-08-18 20:55:59 +02:00
|
|
|
} \
|
|
|
|
while(0)
|
2010-11-07 16:32:54 +01:00
|
|
|
#else
|
2012-08-18 20:55:59 +02:00
|
|
|
#define LAMEXP_MEMORY_CHECK(FUNC, RETV, ...) do \
|
2012-04-06 22:24:05 +02:00
|
|
|
{ \
|
2012-04-10 01:25:34 +02:00
|
|
|
RETV = __noop(__VA_ARGS__); \
|
2012-08-18 20:55:59 +02:00
|
|
|
} \
|
|
|
|
while(0)
|
2010-11-07 16:32:54 +01:00
|
|
|
#endif
|
2010-11-13 02:11:15 +01:00
|
|
|
|
|
|
|
//Check for CPU-compatibility options
|
2011-04-07 22:40:47 +02:00
|
|
|
#if !defined(_M_X64) && defined(_M_IX86_FP)
|
|
|
|
#if (_M_IX86_FP != 0)
|
|
|
|
#error We should not enabled SSE or SSE2 in release builds!
|
|
|
|
#endif
|
2010-11-13 02:11:15 +01:00
|
|
|
#endif
|