<ClCompile Include="src\Filter_Resample.cpp" />
<ClCompile Include="src\Filter_ToneAdjust.cpp" />
<ClCompile Include="src\Genres.cpp" />
- <ClCompile Include="src\Global_EntryPoint.cpp" />
+ <ClCompile Include="src\Global_Zero.cpp" />
<ClCompile Include="src\Global_IPC.cpp" />
<ClCompile Include="src\Global_Utils.cpp" />
<ClCompile Include="src\Global_Version.cpp" />
<ClCompile Include="src\Global_IPC.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="src\Global_EntryPoint.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="src\Global_Version.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="tmp\MOC_Thread_CheckUpdate.cpp">
<Filter>Generated Files\MOC</Filter>
</ClCompile>
+ <ClCompile Include="src\Global_Zero.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\Config.h">
}
lamexp_syscolor_t;
+//Icon type
+class lamexp_icon_t;
+
///////////////////////////////////////////////////////////////////////////////
// GLOBAL FUNCTIONS
///////////////////////////////////////////////////////////////////////////////
bool lamexp_check_tool(const QString &toolName);
const QString lamexp_clean_filename(const QString &str);
const QString lamexp_clean_filepath(const QString &str);
-void lamexp_clean_all_tools(void);
-void lamexp_clean_all_translations(void);
bool lamexp_clean_folder(const QString &folderPath);
QDate lamexp_current_date_safe(void);
unsigned __int64 lamexp_current_file_time(void);
void lamexp_fatal_exit(const wchar_t* exitMessage, const wchar_t* errorBoxMessage = NULL);
void lamexp_finalization(void);
unsigned __int64 lamexp_free_diskspace(const QString &path, bool *ok = NULL);
+void lamexp_free_window_icon(lamexp_icon_t *icon);
const lamexp_os_version_t &lamexp_get_os_version(void);
void lamexp_init_console(const QStringList &argv);
void lamexp_init_error_handlers(void);
bool lamexp_install_translator(const QString &language);
bool lamexp_install_translator_from_file(const QString &qmFile);
void lamexp_invalid_param_handler(const wchar_t*, const wchar_t*, const wchar_t*, unsigned int, uintptr_t);
-void lamexp_ipc_exit(void);
void lamexp_ipc_read(unsigned int *command, char* message, size_t buffSize);
void lamexp_ipc_send(unsigned int command, const char* message);
bool lamexp_is_hibernation_supported(void);
void lamexp_register_tool(const QString &toolName, LockedFile *file, unsigned int version = 0, const QString *tag = NULL);
bool lamexp_remove_file(const QString &filename);
void lamexp_seed_rand(void);
-bool lamexp_set_window_icon(QWidget *window, const QIcon &icon, const bool bIsBigIcon);
+lamexp_icon_t *lamexp_set_window_icon(QWidget *window, const QIcon &icon, const bool bIsBigIcon);
bool lamexp_sheet_of_glass(QWidget *window);
bool lamexp_sheet_of_glass_update(QWidget *window);
bool lamexp_shutdown_computer(const QString &message, const unsigned long timeout = 30, const bool forceShutdown = true, const bool hibernate = false);
void lamexp_sleep(const unsigned int delay);
QColor lamexp_system_color(const int color_id);
+int lamexp_system_message(const wchar_t *text, int beepType);
const char *lamexp_support_url(void);
const QString &lamexp_temp_folder2(void);
-void lamexp_temp_folder_clear(void);
bool lamexp_themes_enabled(void);
unsigned int lamexp_tool_version(const QString &toolName, QString *tag = NULL);
unsigned int lamexp_toolver_coreaudio(void);
}
}
-/*
- * Exit and clean-up IPC
- */
-void lamexp_ipc_exit(void)
-{
- if(g_lamexp_ipc_ptr.sharedmem) g_lamexp_ipc_ptr.sharedmem->detach();
- LAMEXP_DELETE(g_lamexp_ipc_ptr.sharedmem);
- LAMEXP_DELETE(g_lamexp_ipc_ptr.semaphore_read);
- LAMEXP_DELETE(g_lamexp_ipc_ptr.semaphore_write);
- LAMEXP_DELETE(g_lamexp_ipc_ptr.semaphore_read_mutex);
- LAMEXP_DELETE(g_lamexp_ipc_ptr.semaphore_write_mutex);
-}
-
///////////////////////////////////////////////////////////////////////////////
// INITIALIZATION
///////////////////////////////////////////////////////////////////////////////
{
LAMEXP_ZERO_MEMORY(g_lamexp_ipc_ptr);
}
+
+///////////////////////////////////////////////////////////////////////////////
+// FINALIZATION
+///////////////////////////////////////////////////////////////////////////////
+
+extern "C" void _lamexp_global_free_ipcom(void)
+{
+ if(g_lamexp_ipc_ptr.sharedmem)
+ {
+ g_lamexp_ipc_ptr.sharedmem->detach();
+ }
+
+ LAMEXP_DELETE(g_lamexp_ipc_ptr.sharedmem);
+ LAMEXP_DELETE(g_lamexp_ipc_ptr.semaphore_read);
+ LAMEXP_DELETE(g_lamexp_ipc_ptr.semaphore_write);
+ LAMEXP_DELETE(g_lamexp_ipc_ptr.semaphore_read_mutex);
+ LAMEXP_DELETE(g_lamexp_ipc_ptr.semaphore_write_mutex);
+}
}
/*
- * Free all registered tools (final clean-up)
- */
-void lamexp_clean_all_tools(void)
-{
- if(g_lamexp_tools.registry)
- {
- QStringList keys = g_lamexp_tools.registry->keys();
- for(int i = 0; i < keys.count(); i++)
- {
- LockedFile *lf = g_lamexp_tools.registry->take(keys.at(i));
- LAMEXP_DELETE(lf);
- }
- g_lamexp_tools.registry->clear();
- g_lamexp_tools.versions->clear();
- g_lamexp_tools.tags->clear();
- }
-
- LAMEXP_DELETE(g_lamexp_tools.registry);
- LAMEXP_DELETE(g_lamexp_tools.versions);
- LAMEXP_DELETE(g_lamexp_tools.tags);
-}
-
-/*
* Initialize translations and add default language
*/
bool lamexp_translation_init(void)
return success;
}
-/*
- * Free all registered translations (final clean-up)
- */
-void lamexp_clean_all_translations(void)
+///////////////////////////////////////////////////////////////////////////////
+// INITIALIZATION
+///////////////////////////////////////////////////////////////////////////////
+
+extern "C" void _lamexp_global_init_tools(void)
{
- QWriteLocker writeLockTranslator(&g_lamexp_currentTranslator.lock);
+ LAMEXP_ZERO_MEMORY(g_lamexp_tools);
+ LAMEXP_ZERO_MEMORY(g_lamexp_currentTranslator);
+ LAMEXP_ZERO_MEMORY(g_lamexp_translation);
+}
+///////////////////////////////////////////////////////////////////////////////
+// FINALIZATION
+///////////////////////////////////////////////////////////////////////////////
+
+extern "C" void _lamexp_global_free_tools(void)
+{
+ //Free *all* registered translations
if(g_lamexp_currentTranslator.instance)
{
QApplication::removeTranslator(g_lamexp_currentTranslator.instance);
LAMEXP_DELETE(g_lamexp_currentTranslator.instance);
}
-
- writeLockTranslator.unlock();
- QWriteLocker writeLockTranslations(&g_lamexp_translation.lock);
-
LAMEXP_DELETE(g_lamexp_translation.files);
LAMEXP_DELETE(g_lamexp_translation.names);
LAMEXP_DELETE(g_lamexp_translation.cntry);
LAMEXP_DELETE(g_lamexp_translation.sysid);
-}
-///////////////////////////////////////////////////////////////////////////////
-// INITIALIZATION
-///////////////////////////////////////////////////////////////////////////////
+ //Free *all* registered tools
+ if(g_lamexp_tools.registry)
+ {
+ QStringList keys = g_lamexp_tools.registry->keys();
+ for(int i = 0; i < keys.count(); i++)
+ {
+ LockedFile *lf = g_lamexp_tools.registry->take(keys.at(i));
+ LAMEXP_DELETE(lf);
+ }
+ g_lamexp_tools.registry->clear();
+ g_lamexp_tools.versions->clear();
+ g_lamexp_tools.tags->clear();
+ }
+ LAMEXP_DELETE(g_lamexp_tools.registry);
+ LAMEXP_DELETE(g_lamexp_tools.versions);
+ LAMEXP_DELETE(g_lamexp_tools.tags);
-extern "C" void _lamexp_global_init_tools(void)
-{
- LAMEXP_ZERO_MEMORY(g_lamexp_tools);
- LAMEXP_ZERO_MEMORY(g_lamexp_currentTranslator);
- LAMEXP_ZERO_MEMORY(g_lamexp_translation);
}
}
/*
- * Clear LameXP temp folder cache
- */
-void lamexp_temp_folder_clear(void)
-{
- QWriteLocker writeLock(&g_lamexp_temp_folder.lock);
- LAMEXP_DELETE(g_lamexp_temp_folder.path);
-}
-
-/*
* Setup QPorcess object
*/
void lamexp_init_process(QProcess &process, const QString &wokringDir, const bool bReplaceTempDir)
LAMEXP_ZERO_MEMORY(g_lamexp_temp_folder);
LAMEXP_ZERO_MEMORY(g_lamexp_app_icon);
}
+
+///////////////////////////////////////////////////////////////////////////////
+// FINALIZATION
+///////////////////////////////////////////////////////////////////////////////
+
+extern "C" void _lamexp_global_free_utils(void)
+{
+ //Delete temporary files
+ const QString &tempFolder = lamexp_temp_folder2();
+ if(!tempFolder.isEmpty())
+ {
+ bool success = false;
+ for(int i = 0; i < 100; i++)
+ {
+ if(lamexp_clean_folder(tempFolder))
+ {
+ success = true;
+ break;
+ }
+ lamexp_sleep(100);
+ }
+ if(!success)
+ {
+ lamexp_system_message(L"Sorry, LameXP was unable to clean up all temporary files. Some residual files in your TEMP directory may require manual deletion!", lamexp_beep_warning);
+ lamexp_exec_shell(NULL, tempFolder, QString(), QString(), true);
+ }
+ }
+
+ //Free memory
+ LAMEXP_DELETE(g_lamexp_temp_folder.path);
+ LAMEXP_DELETE(g_lamexp_app_icon.appIcon);
+}
{
LAMEXP_ZERO_MEMORY(g_lamexp_portable);
}
+
+///////////////////////////////////////////////////////////////////////////////
+// FINALIZATION
+///////////////////////////////////////////////////////////////////////////////
+
+extern "C" void _lamexp_global_free_versn(void)
+{
+ /*nothing to do here*/
+}
}
/*
+ * Show system message box
+ */
+int lamexp_system_message(const wchar_t *text, int beepType)
+{
+ UINT flags = MB_OK | MB_TOPMOST;
+
+ switch(beepType)
+ {
+ case lamexp_beep_info: flags = flags | MB_ICONASTERISK;
+ case lamexp_beep_warning: flags = flags | MB_ICONEXCLAMATION;
+ case lamexp_beep_error: flags = flags | MB_ICONHAND;
+ }
+
+ return MessageBoxW(NULL, text, L"LameXP", flags);
+}
+
+/*
* Suspend calling thread for N milliseconds
*/
inline void lamexp_sleep(const unsigned int delay)
/*
* Bring the specifed window to the front
*/
-bool lamexp_bring_to_front(const QWidget *win)
+bool lamexp_bring_to_front(const QWidget *window)
{
- const bool ret = (SetForegroundWindow(win->winId()) == TRUE);
- SwitchToThisWindow(win->winId(), TRUE);
+ bool ret = false;
+
+ if(window)
+ {
+ ret = (SetForegroundWindow(window->winId()) == TRUE);
+ SwitchToThisWindow(window->winId(), TRUE);
+ }
+
return ret;
}
/*
* Update the window icon
*/
-bool lamexp_set_window_icon(QWidget *window, const QIcon &icon, const bool bIsBigIcon)
+lamexp_icon_t *lamexp_set_window_icon(QWidget *window, const QIcon &icon, const bool bIsBigIcon)
{
if(!icon.isNull())
{
if(HICON hIcon = lamexp_qicon2hicon(icon, extend, extend))
{
SendMessage(window->winId(), WM_SETICON, (bIsBigIcon ? ICON_BIG : ICON_SMALL), LPARAM(hIcon));
- //DestroyIcon(hIcon); /*FIXME: Destroying the icon here will remove it from the window*/
+ return reinterpret_cast<lamexp_icon_t*>(hIcon);
}
- return true;
}
- return false;
+ return NULL;
+}
+
+/*
+ * Free window icon
+ */
+void lamexp_free_window_icon(lamexp_icon_t *icon)
+{
+ if(HICON hIcon = reinterpret_cast<HICON>(icon))
+ {
+ DestroyIcon(hIcon);
+ }
}
/*
}
/*
- * Finalization function (final clean-up)
- */
-void lamexp_finalization(void)
-{
- qDebug("lamexp_finalization()");
-
- //Free all tools
- lamexp_clean_all_tools();
-
- //Delete temporary files
- const QString &tempFolder = lamexp_temp_folder2();
- if(!tempFolder.isEmpty())
- {
- bool success = false;
- for(int i = 0; i < 100; i++)
- {
- if(lamexp_clean_folder(tempFolder))
- {
- success = true;
- break;
- }
- lamexp_sleep(100);
- }
- if(!success)
- {
- MessageBoxW(NULL, L"Sorry, LameXP was unable to clean up all temporary files. Some residual files in your TEMP directory may require manual deletion!", L"LameXP", MB_ICONEXCLAMATION|MB_TOPMOST);
- lamexp_exec_shell(NULL, tempFolder, QString(), QString(), true);
- }
- }
-
- //Clear folder cache
- LAMEXP_DELETE(g_lamexp_known_folder.knownFolders);
-
- //Clear languages
- lamexp_clean_all_translations();
-
- //Destroy Qt application object
- QApplication *application = dynamic_cast<QApplication*>(QApplication::instance());
- LAMEXP_DELETE(application);
-
- //Release DWM API
- g_lamexp_dwmapi.dwmIsCompositionEnabled = NULL;
- g_lamexp_dwmapi.dwmExtendFrameIntoClientArea = NULL;
- g_lamexp_dwmapi.dwmEnableBlurBehindWindow = NULL;
- LAMEXP_DELETE(g_lamexp_dwmapi.dwmapi_dll);
-
- //Detach from shared memory
- lamexp_ipc_exit();
-
- //Free STDOUT and STDERR buffers
- if(g_lamexp_console_attached)
- {
- if(std::filebuf *tmp = dynamic_cast<std::filebuf*>(std::cout.rdbuf()))
- {
- std::cout.rdbuf(NULL);
- LAMEXP_DELETE(tmp);
- }
- if(std::filebuf *tmp = dynamic_cast<std::filebuf*>(std::cerr.rdbuf()))
- {
- std::cerr.rdbuf(NULL);
- LAMEXP_DELETE(tmp);
- }
- }
-
- //Close log file
- if(g_lamexp_log_file)
- {
- fclose(g_lamexp_log_file);
- g_lamexp_log_file = NULL;
- }
-
- //Free CLI Arguments
- LAMEXP_DELETE(g_lamexp_argv.list);
-
- //Free TEMP folder
- lamexp_temp_folder_clear();
-}
-
-/*
* Initialize debug thread
*/
static const HANDLE g_debug_thread1 = LAMEXP_DEBUG ? NULL : lamexp_debug_thread_init();
LAMEXP_ZERO_MEMORY(g_lamexp_themes_enabled);
LAMEXP_ZERO_MEMORY(g_lamexp_dwmapi);
}
+
+///////////////////////////////////////////////////////////////////////////////
+// FINALIZATION
+///////////////////////////////////////////////////////////////////////////////
+
+extern "C" void _lamexp_global_free_win32(void)
+{
+ //Clear folder cache
+ LAMEXP_DELETE(g_lamexp_known_folder.knownFolders);
+
+ //Destroy Qt application object
+ QApplication *application = dynamic_cast<QApplication*>(QApplication::instance());
+ LAMEXP_DELETE(application);
+
+ //Release DWM API
+ g_lamexp_dwmapi.dwmIsCompositionEnabled = NULL;
+ g_lamexp_dwmapi.dwmExtendFrameIntoClientArea = NULL;
+ g_lamexp_dwmapi.dwmEnableBlurBehindWindow = NULL;
+ LAMEXP_DELETE(g_lamexp_dwmapi.dwmapi_dll);
+
+ //Free STDOUT and STDERR buffers
+ if(g_lamexp_console_attached)
+ {
+ if(std::filebuf *tmp = dynamic_cast<std::filebuf*>(std::cout.rdbuf()))
+ {
+ std::cout.rdbuf(NULL);
+ LAMEXP_DELETE(tmp);
+ }
+ if(std::filebuf *tmp = dynamic_cast<std::filebuf*>(std::cerr.rdbuf()))
+ {
+ std::cerr.rdbuf(NULL);
+ LAMEXP_DELETE(tmp);
+ }
+ }
+
+ //Close log file
+ if(g_lamexp_log_file)
+ {
+ fclose(g_lamexp_log_file);
+ g_lamexp_log_file = NULL;
+ }
+
+ //Free CLI Arguments
+ LAMEXP_DELETE(g_lamexp_argv.list);
+}
#include "Global.h"
+#include <QtGlobal>
+
///////////////////////////////////////////////////////////////////////////////
// GLOBAL FUNCTIONS
///////////////////////////////////////////////////////////////////////////////
}
/*
- * Application entry point (runs before static initializers)
+ * Function declarations
*/
extern "C"
{
void _lamexp_global_init_ipcom(void);
void _lamexp_global_init_utils(void);
- int lamexp_entry_point(void)
+ void _lamexp_global_free_win32(void);
+ void _lamexp_global_free_versn(void);
+ void _lamexp_global_free_tools(void);
+ void _lamexp_global_free_ipcom(void);
+ void _lamexp_global_free_utils(void);
+}
+
+/*
+ * Application entry point (runs before static initializers)
+ */
+
+extern "C" int lamexp_entry_point(void)
+{
+ if(g_lamexp_entry_check_flag != 0x789E09B2)
{
- if(g_lamexp_entry_check_flag != 0x789E09B2)
- {
- lamexp_fatal_exit(L"Application initialization has failed, take care!");
- }
+ lamexp_fatal_exit(L"Application initialization has failed, take care!");
+ }
- //Call global initialization functions
- _lamexp_global_init_win32();
- _lamexp_global_init_versn();
- _lamexp_global_init_tools();
- _lamexp_global_init_ipcom();
- _lamexp_global_init_utils();
+ //Call global initialization functions
+ _lamexp_global_init_win32();
+ _lamexp_global_init_versn();
+ _lamexp_global_init_tools();
+ _lamexp_global_init_ipcom();
+ _lamexp_global_init_utils();
- //Make sure we will pass the check
- g_lamexp_entry_check_flag = (~g_lamexp_entry_check_flag);
+ //Make sure we will pass the check
+ g_lamexp_entry_check_flag = (~g_lamexp_entry_check_flag);
- //Now initialize the C Runtime library!
- return WinMainCRTStartup();
- }
+ //Now initialize the C Runtime library!
+ return WinMainCRTStartup();
+}
+
+/*
+ * Application finalization function
+ */
+void lamexp_finalization(void)
+{
+ qDebug("lamexp_finalization()");
+
+ //Call global finalization functions, in proper order
+ _lamexp_global_free_versn();
+ _lamexp_global_free_tools();
+ _lamexp_global_free_ipcom();
+ _lamexp_global_free_utils();
+ _lamexp_global_free_win32();
}