1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2012 LoRd_MuldeR <MuldeR2@GMX.de>
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.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License along
16 // with this program; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 // http://www.gnu.org/licenses/gpl-2.0.txt
20 ///////////////////////////////////////////////////////////////////////////////
25 #include "Targetver.h"
27 //inlcude C standard library
33 #define WIN32_LEAN_AND_MEAN
68 lamexp_folder_localappdata
= 0,
69 lamexp_folder_programfiles
= 2,
70 lamexp_folder_systemfolder
= 3
72 lamexp_known_folder_t
;
74 //LameXP user-defined events
77 lamexp_event
= 1000, /*QEvent::User*/
78 lamexp_event_queryendsession
= lamexp_event
+ 666,
79 lamexp_event_endsession
= lamexp_event
+ 667
84 unsigned int lamexp_version_major(void);
85 unsigned int lamexp_version_minor(void);
86 unsigned int lamexp_version_build(void);
87 const QDate
&lamexp_version_date(void);
88 const char *lamexp_version_time(void);
89 const char *lamexp_version_release(void);
90 bool lamexp_version_demo(void);
91 const char *lamexp_version_compiler(void);
92 const char *lamexp_version_arch(void);
93 QDate
lamexp_version_expires(void);
94 unsigned int lamexp_toolver_neroaac(void);
95 unsigned int lamexp_toolver_fhgaacenc(void);
96 unsigned int lamexp_toolver_qaacenc(void);
97 unsigned int lamexp_toolver_coreaudio(void);
98 const char *lamexp_website_url(void);
99 const char *lamexp_support_url(void);
100 DWORD
lamexp_get_os_version(void);
101 bool lamexp_detect_wine(void);
104 void lamexp_init_console(int argc
, char* argv
[]);
105 bool lamexp_init_qt(int argc
, char* argv
[]);
106 int lamexp_init_ipc(void);
107 LONG WINAPI
lamexp_exception_handler(__in
struct _EXCEPTION_POINTERS
*ExceptionInfo
);
108 void lamexp_invalid_param_handler(const wchar_t*, const wchar_t*, const wchar_t*, unsigned int, uintptr_t);
109 void lamexp_message_handler(QtMsgType type
, const char *msg
);
110 void lamexp_register_tool(const QString
&toolName
, LockedFile
*file
, unsigned int version
= 0);
111 bool lamexp_check_tool(const QString
&toolName
);
112 const QString
lamexp_lookup_tool(const QString
&toolName
);
113 unsigned int lamexp_tool_version(const QString
&toolName
);
114 void lamexp_finalization(void);
115 QString
lamexp_rand_str(void);
116 const QString
&lamexp_temp_folder2(void);
117 void lamexp_ipc_read(unsigned int *command
, char* message
, size_t buffSize
);
118 void lamexp_ipc_send(unsigned int command
, const char* message
);
119 lamexp_cpu_t
lamexp_detect_cpu_features(int argc
= 0, char **argv
= NULL
);
120 bool lamexp_portable_mode(void);
121 bool lamexp_shutdown_computer(const QString
&message
, const unsigned long timeout
= 30, const bool forceShutdown
= true, const bool hibernate
= false);
122 bool lamexp_is_hibernation_supported(void);
123 QIcon
lamexp_app_icon(const QDate
*date
= NULL
, const QTime
*time
= NULL
);
125 //Translation support
126 QStringList
lamexp_query_translations(void);
127 bool lamexp_translation_register(const QString
&langId
, const QString
&qmFile
, const QString
&langName
, unsigned int &systemId
, unsigned int &country
);
128 QString
lamexp_translation_name(const QString
&language
);
129 unsigned int lamexp_translation_sysid(const QString
&langId
);
130 unsigned int lamexp_translation_country(const QString
&langId
);
131 bool lamexp_install_translator_from_file(const QString
&qmFile
);
132 bool lamexp_install_translator(const QString
&language
);
133 QStringList
lamexp_available_codepages(bool noAliases
= true);
134 static const char* LAMEXP_DEFAULT_LANGID
= "en";
136 //Auxiliary functions
137 bool lamexp_clean_folder(const QString
&folderPath
);
138 const QString
lamexp_version2string(const QString
&pattern
, unsigned int version
, const QString
&defaultText
);
139 QString
lamexp_known_folder(lamexp_known_folder_t folder_id
);
140 unsigned __int64
lamexp_free_diskspace(const QString
&path
, bool *ok
= NULL
);
141 bool lamexp_remove_file(const QString
&filename
);
142 bool lamexp_themes_enabled(void);
143 void lamexp_blink_window(QWidget
*poWindow
, unsigned int count
= 10, unsigned int delay
= 150);
144 const QString
lamexp_clean_filename(const QString
&str
);
145 const QString
lamexp_clean_filepath(const QString
&str
);
147 //Debug-only functions
148 SIZE_T
lamexp_dbg_private_bytes(void);
151 #define LAMEXP_DELETE(PTR) if(PTR) { delete PTR; PTR = NULL; }
152 #define LAMEXP_DELETE_ARRAY(PTR) if(PTR) { delete [] PTR; PTR = NULL; }
153 #define LAMEXP_SAFE_FREE(PTR) if(PTR) { free((void*) PTR); PTR = NULL; }
154 #define LAMEXP_CLOSE(HANDLE) if(HANDLE != NULL && HANDLE != INVALID_HANDLE_VALUE) { CloseHandle(HANDLE); HANDLE = NULL; }
155 #define LAMEXP_MIN_OS_VER(VER_INFO, VER_MAJ, VER_MIN) ((HIWORD(VER_INFO) > (VER_MAJ)) || ((HIWORD(VER_INFO) == (VER_MAJ)) && (LOWORD(VER_INFO) >= (VER_MIN))))
156 #define QWCHAR(STR) reinterpret_cast<const wchar_t*>(STR.utf16())
157 #define WCHAR2QSTR(STR) QString::fromUtf16(reinterpret_cast<const unsigned short*>(STR))
158 #define LAMEXP_DYNCAST(OUT,CLASS,SRC) try { OUT = dynamic_cast<CLASS>(SRC); } catch(std::bad_cast) { OUT = NULL; }
159 #define LAMEXP_BOOL(X) (X ? "1" : "0")
160 #define LAMEXP_MAKE_STRING_EX(X) #X
161 #define LAMEXP_MAKE_STRING(X) LAMEXP_MAKE_STRING_EX(X)
162 #define LAMEXP_COMPILER_WARNING(TXT) __pragma(message(__FILE__ "(" LAMEXP_MAKE_STRING(__LINE__) ") : warning: " TXT))
163 #define NOBR(STR) QString("<nobr>%1</nobr>").arg(STR).replace("-", "−")
165 //Output Qt debug message (Unicode-safe versions)
166 //#define qDebug64(FORMAT, ...) qDebug("@BASE64@%s", QString(FORMAT).arg(__VA_ARGS__).toUtf8().toBase64().constData());
167 //#define qWarning64(FORMAT, ...) qWarning("@BASE64@%s", QString(FORMAT).arg(__VA_ARGS__).toUtf8().toBase64().constData());
168 //#define qFatal64(FORMAT, ...) qFatal("@BASE64@%s", QString(FORMAT).arg(__VA_ARGS__).toUtf8().toBase64().constData());
170 //Check for debug build
171 #if defined(_DEBUG) && defined(QT_DEBUG) && !defined(NDEBUG) && !defined(QT_NO_DEBUG)
172 #define LAMEXP_DEBUG (1)
173 #elif defined(NDEBUG) && defined(QT_NO_DEBUG) && !defined(_DEBUG) && !defined(QT_DEBUG)
174 #define LAMEXP_DEBUG (0)
176 #error Inconsistent debug defines detected!
181 #define LAMEXP_MEMORY_CHECK(CMD) \
183 SIZE_T _privateBytesBefore = lamexp_dbg_private_bytes(); \
185 SIZE_T _privateBytesLeak = (lamexp_dbg_private_bytes() - _privateBytesBefore) / 1024; \
186 if(_privateBytesLeak > 10) { \
187 qWarning("Memory leak: Lost %u KiloBytes.", _privateBytesLeak); \
191 #define LAMEXP_MEMORY_CHECK(CMD) CMD
194 //Check for CPU-compatibility options
195 #if !defined(_M_X64) && defined(_M_IX86_FP)
196 #if (_M_IX86_FP != 0)
197 #error We should not enabled SSE or SSE2 in release builds!