From c066a9b843e7bfc8f2ab9a991e8fe4d8a2cb54e0 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 17 May 2022 18:45:09 +0300 Subject: MWindow - further window unification code for Linux --- src/mir_app/mir_app.mk | 14 ++--- src/mir_app/src/miranda.cpp | 139 ++++++++++++++++++++++++++------------------ src/mir_app/src/stdafx.h | 2 + 3 files changed, 92 insertions(+), 63 deletions(-) (limited to 'src/mir_app') diff --git a/src/mir_app/mir_app.mk b/src/mir_app/mir_app.mk index 5163e32169..67afc86242 100644 --- a/src/mir_app/mir_app.mk +++ b/src/mir_app/mir_app.mk @@ -14,7 +14,7 @@ CurrentFileName := CurrentFilePath := CurrentFileFullPath := User :=George Hazan -Date :=10/05/22 +Date :=17/05/22 CodeLitePath :=/home/ghazan/.codelite MakeDirCommand :=mkdir -p LinkerName :=g++ @@ -62,7 +62,7 @@ AS := as ## User defined environment variables ## CodeLiteDir:=/usr/share/codelite -Objects0=$(IntermediateDirectory)/src_miranda.cpp$(ObjectSuffix) $(IntermediateDirectory)/src_database.cpp$(ObjectSuffix) $(IntermediateDirectory)/src_db_intf.cpp$(ObjectSuffix) $(IntermediateDirectory)/src_db_events.cpp$(ObjectSuffix) $(IntermediateDirectory)/src_contact.cpp$(ObjectSuffix) $(IntermediateDirectory)/src_CMPluginBase.cpp$(ObjectSuffix) $(IntermediateDirectory)/src_addcontact.cpp$(ObjectSuffix) $(IntermediateDirectory)/src_stdafx.cxx$(ObjectSuffix) +Objects0=$(IntermediateDirectory)/src_miranda.cpp$(ObjectSuffix) $(IntermediateDirectory)/src_db_intf.cpp$(ObjectSuffix) $(IntermediateDirectory)/src_db_events.cpp$(ObjectSuffix) $(IntermediateDirectory)/src_database.cpp$(ObjectSuffix) $(IntermediateDirectory)/src_contact.cpp$(ObjectSuffix) $(IntermediateDirectory)/src_CMPluginBase.cpp$(ObjectSuffix) $(IntermediateDirectory)/src_addcontact.cpp$(ObjectSuffix) $(IntermediateDirectory)/src_stdafx.cxx$(ObjectSuffix) @@ -99,11 +99,6 @@ $(IntermediateDirectory)/src_miranda.cpp$(ObjectSuffix): src/miranda.cpp $(IntermediateDirectory)/src_miranda.cpp$(PreprocessSuffix): src/miranda.cpp $(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/src_miranda.cpp$(PreprocessSuffix) src/miranda.cpp -$(IntermediateDirectory)/src_database.cpp$(ObjectSuffix): src/database.cpp - $(CXX) $(IncludePCH) $(SourceSwitch) "/home/ghazan/miranda-ng/src/mir_app/src/database.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/src_database.cpp$(ObjectSuffix) $(IncludePath) -$(IntermediateDirectory)/src_database.cpp$(PreprocessSuffix): src/database.cpp - $(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/src_database.cpp$(PreprocessSuffix) src/database.cpp - $(IntermediateDirectory)/src_db_intf.cpp$(ObjectSuffix): src/db_intf.cpp $(CXX) $(IncludePCH) $(SourceSwitch) "/home/ghazan/miranda-ng/src/mir_app/src/db_intf.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/src_db_intf.cpp$(ObjectSuffix) $(IncludePath) $(IntermediateDirectory)/src_db_intf.cpp$(PreprocessSuffix): src/db_intf.cpp @@ -114,6 +109,11 @@ $(IntermediateDirectory)/src_db_events.cpp$(ObjectSuffix): src/db_events.cpp $(IntermediateDirectory)/src_db_events.cpp$(PreprocessSuffix): src/db_events.cpp $(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/src_db_events.cpp$(PreprocessSuffix) src/db_events.cpp +$(IntermediateDirectory)/src_database.cpp$(ObjectSuffix): src/database.cpp + $(CXX) $(IncludePCH) $(SourceSwitch) "/home/ghazan/miranda-ng/src/mir_app/src/database.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/src_database.cpp$(ObjectSuffix) $(IncludePath) +$(IntermediateDirectory)/src_database.cpp$(PreprocessSuffix): src/database.cpp + $(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/src_database.cpp$(PreprocessSuffix) src/database.cpp + $(IntermediateDirectory)/src_contact.cpp$(ObjectSuffix): src/contact.cpp $(CXX) $(IncludePCH) $(SourceSwitch) "/home/ghazan/miranda-ng/src/mir_app/src/contact.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/src_contact.cpp$(ObjectSuffix) $(IncludePath) $(IntermediateDirectory)/src_contact.cpp$(PreprocessSuffix): src/contact.cpp diff --git a/src/mir_app/src/miranda.cpp b/src/mir_app/src/miranda.cpp index 12c4d64c69..4f6e7b1beb 100644 --- a/src/mir_app/src/miranda.cpp +++ b/src/mir_app/src/miranda.cpp @@ -61,6 +61,8 @@ CMPlugin::CMPlugin() : PLUGIN(nullptr, pluginInfoEx) {} +#ifdef _WINDOWS + ///////////////////////////////////////////////////////////////////////////////////////// // dll entry point @@ -83,6 +85,8 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, uint32_t dwReason, LPVOID) return TRUE; } +#endif + ///////////////////////////////////////////////////////////////////////////////////////// static int SystemShutdownProc(WPARAM, LPARAM) @@ -117,10 +121,13 @@ protected: { if (m_progress.Move() == MIRANDA_PROCESS_WAIT_STEPS) EndModal(0); - if (WaitForSingleObject(m_hProcess, 1) != WAIT_TIMEOUT) { - m_progress.SetPosition(MIRANDA_PROCESS_WAIT_STEPS); - EndModal(0); - } + + #ifdef _WINDOWS + if (WaitForSingleObject(m_hProcess, 1) != WAIT_TIMEOUT) { + m_progress.SetPosition(MIRANDA_PROCESS_WAIT_STEPS); + EndModal(0); + } + #endif } void Cancel_OnClick(CCtrlBase*) @@ -145,12 +152,14 @@ INT_PTR CheckRestart() { LPCTSTR tszPID = CmdLine_GetOption(L"restart"); if (tszPID) { - HANDLE hProcess = OpenProcess(SYNCHRONIZE, FALSE, _wtol(tszPID)); - if (hProcess) { - INT_PTR result = CWaitRestartDlg(hProcess).DoModal(); - CloseHandle(hProcess); - return result; - } + #ifdef _WINDOWS + HANDLE hProcess = OpenProcess(SYNCHRONIZE, FALSE, _wtol(tszPID)); + if (hProcess) { + INT_PTR result = CWaitRestartDlg(hProcess).DoModal(); + CloseHandle(hProcess); + return result; + } + #endif } return 0; } @@ -171,7 +180,7 @@ static MSystemWindow *g_pSystemWindow; ///////////////////////////////////////////////////////////////////////////////////////// -int WINAPI mir_main(LPTSTR cmdLine) +int CALLBACK mir_main(LPTSTR cmdLine) { hMainThreadId = GetCurrentThreadId(); @@ -227,15 +236,19 @@ MIR_APP_DLL(bool) Miranda_OkToExit() MIR_APP_DLL(void) Miranda_Close() { while (!Miranda_OkToExit()) { - MSG msg; - while (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - Sleep(0); + #ifdef _WINDOWS + MSG msg; + while (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + Sleep(0); + #endif } - DestroyWindow(g_clistApi.hwndContactList); + #ifdef _WINDOWS + DestroyWindow(g_clistApi.hwndContactList); + #endif } ///////////////////////////////////////////////////////////////////////////////////////// @@ -243,53 +256,67 @@ MIR_APP_DLL(void) Miranda_Close() MIR_APP_DLL(uint32_t) Miranda_GetVersion() { - wchar_t filename[MAX_PATH]; - GetModuleFileName(g_plugin.getInst(), filename, _countof(filename)); - - DWORD unused, verInfoSize = GetFileVersionInfoSize(filename, &unused); - PVOID pVerInfo = _alloca(verInfoSize); - GetFileVersionInfo(filename, 0, verInfoSize, pVerInfo); - - UINT blockSize; - VS_FIXEDFILEINFO *vsffi; - VerQueryValue(pVerInfo, L"\\", (PVOID*)&vsffi, &blockSize); - return (((vsffi->dwProductVersionMS >> 16) & 0xFF) << 24) | - ((vsffi->dwProductVersionMS & 0xFF) << 16) | - (((vsffi->dwProductVersionLS >> 16) & 0xFF) << 8) | - (vsffi->dwProductVersionLS & 0xFF); + #ifdef _WINDOWS + wchar_t filename[MAX_PATH]; + GetModuleFileName(g_plugin.getInst(), filename, _countof(filename)); + + DWORD unused, verInfoSize = GetFileVersionInfoSize(filename, &unused); + PVOID pVerInfo = _alloca(verInfoSize); + GetFileVersionInfo(filename, 0, verInfoSize, pVerInfo); + + UINT blockSize; + VS_FIXEDFILEINFO *vsffi; + VerQueryValue(pVerInfo, L"\\", (PVOID*)&vsffi, &blockSize); + return (((vsffi->dwProductVersionMS >> 16) & 0xFF) << 24) | + ((vsffi->dwProductVersionMS & 0xFF) << 16) | + (((vsffi->dwProductVersionLS >> 16) & 0xFF) << 8) | + (vsffi->dwProductVersionLS & 0xFF); + #else + return MIRANDA_VERSION_DWORD; + #endif } MIR_APP_DLL(void) Miranda_GetFileVersion(MFileVersion *pVer) { - wchar_t filename[MAX_PATH]; - GetModuleFileName(g_plugin.getInst(), filename, _countof(filename)); - - DWORD unused, verInfoSize = GetFileVersionInfoSize(filename, &unused); - PVOID pVerInfo = _alloca(verInfoSize); - GetFileVersionInfo(filename, 0, verInfoSize, pVerInfo); - - UINT blockSize; - VS_FIXEDFILEINFO *vsffi; - VerQueryValue(pVerInfo, L"\\", (PVOID*)&vsffi, &blockSize); - - (*pVer)[0] = HIWORD(vsffi->dwProductVersionMS); - (*pVer)[1] = LOWORD(vsffi->dwProductVersionMS); - (*pVer)[2] = HIWORD(vsffi->dwProductVersionLS); - (*pVer)[3] = LOWORD(vsffi->dwProductVersionLS); + #ifdef _WINDOWS + wchar_t filename[MAX_PATH]; + GetModuleFileName(g_plugin.getInst(), filename, _countof(filename)); + + DWORD unused, verInfoSize = GetFileVersionInfoSize(filename, &unused); + PVOID pVerInfo = _alloca(verInfoSize); + GetFileVersionInfo(filename, 0, verInfoSize, pVerInfo); + + UINT blockSize; + VS_FIXEDFILEINFO *vsffi; + VerQueryValue(pVerInfo, L"\\", (PVOID*)&vsffi, &blockSize); + + (*pVer)[0] = HIWORD(vsffi->dwProductVersionMS); + (*pVer)[1] = LOWORD(vsffi->dwProductVersionMS); + (*pVer)[2] = HIWORD(vsffi->dwProductVersionLS); + (*pVer)[3] = LOWORD(vsffi->dwProductVersionLS); + #else + uint16_t tmp[4] = { MIRANDA_VERSION_FILEVERSION }; + memcpy(pVer, tmp, sizeof(tmp)); + #endif } MIR_APP_DLL(void) Miranda_GetVersionText(char *pDest, size_t cbSize) { - wchar_t filename[MAX_PATH], *productVersion; - GetModuleFileName(g_plugin.getInst(), filename, _countof(filename)); - - DWORD unused, verInfoSize = GetFileVersionInfoSize(filename, &unused); - PVOID pVerInfo = _alloca(verInfoSize); - GetFileVersionInfo(filename, 0, verInfoSize, pVerInfo); + #ifdef _WINDOWS + wchar_t filename[MAX_PATH], *productVersion; + GetModuleFileName(g_plugin.getInst(), filename, _countof(filename)); + + DWORD unused, verInfoSize = GetFileVersionInfoSize(filename, &unused); + PVOID pVerInfo = _alloca(verInfoSize); + GetFileVersionInfo(filename, 0, verInfoSize, pVerInfo); + + UINT blockSize; + VerQueryValue(pVerInfo, L"\\StringFileInfo\\000004b0\\ProductVersion", (LPVOID*)&productVersion, &blockSize); + strncpy_s(pDest, cbSize, _T2A(productVersion), _TRUNCATE); + #else + strncpy_s(pDest, cbSize, "Miranda NG " MIRANDA_VERSION_DISPLAY, _TRUNCATE); + #endif - UINT blockSize; - VerQueryValue(pVerInfo, L"\\StringFileInfo\\000004b0\\ProductVersion", (LPVOID*)&productVersion, &blockSize); - strncpy_s(pDest, cbSize, _T2A(productVersion), _TRUNCATE); #if defined(_WIN64) strcat_s(pDest, cbSize, " x64"); #endif diff --git a/src/mir_app/src/stdafx.h b/src/mir_app/src/stdafx.h index d6770083fa..9e8bb456c8 100644 --- a/src/mir_app/src/stdafx.h +++ b/src/mir_app/src/stdafx.h @@ -41,6 +41,8 @@ typedef struct SslHandle *HSSL; #include #include #include +#else + #include #endif #include -- cgit v1.2.3