From cbe3cb21f5bca61a03bbd4ae811ee906e09b3f4f Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 13 Jun 2015 16:55:17 +0000 Subject: - miranda32.exe now does nothing bug extends PATH to %miranda_root%\libs and loads mir_app.dll; - everything that was in miranda32.exe (including resources) moved to mir_app.dll; - exports from mir_app.dll now available for using directly, without perversions; - src/stdplug.h deleted; git-svn-id: http://svn.miranda-ng.org/main/trunk@14143 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/langpack/langpack.cpp | 94 ---------------- src/modules/langpack/langpack.h | 58 ---------- src/modules/langpack/lpopts.cpp | 212 ------------------------------------ src/modules/langpack/lpservices.cpp | 113 ------------------- 4 files changed, 477 deletions(-) delete mode 100644 src/modules/langpack/langpack.cpp delete mode 100644 src/modules/langpack/langpack.h delete mode 100644 src/modules/langpack/lpopts.cpp delete mode 100644 src/modules/langpack/lpservices.cpp (limited to 'src/modules/langpack') diff --git a/src/modules/langpack/langpack.cpp b/src/modules/langpack/langpack.cpp deleted file mode 100644 index 4904e26fcc..0000000000 --- a/src/modules/langpack/langpack.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - -Miranda NG: the free IM client for Microsoft* Windows* - -Copyright (ñ) 2012-15 Miranda NG project (http://miranda-ng.org), -Copyright (c) 2000-12 Miranda IM project, -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "..\..\core\commonheaders.h" -#include "langpack.h" - -MIR_CORE_DLL(int) LoadLangPackDescr(const TCHAR *szLangPack, LANGPACK_INFO *lpInfo); - -BOOL EnumLangpacks(ENUM_PACKS_CALLBACK callback, WPARAM wParam, LPARAM lParam) -{ - if (callback == NULL) return FALSE; - - BOOL res = FALSE; - - /* language folder */ - ptrT langpack(db_get_tsa(NULL, "Langpack", "Current")); - - TCHAR tszFullPath[MAX_PATH]; - PathToAbsoluteT(_T("\\Languages\\langpack_*.txt"), tszFullPath); - - BOOL fPackFound = FALSE; - WIN32_FIND_DATA wfd; - HANDLE hFind = FindFirstFile(tszFullPath, &wfd); - if (hFind != INVALID_HANDLE_VALUE) { - do { - if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; - /* get data */ - PathToAbsoluteT(_T("\\Languages\\"), tszFullPath); - mir_tstrcat(tszFullPath, wfd.cFileName); - - LANGPACK_INFO pack; - if (!LoadLangPackDescr(tszFullPath, &pack)) { - pack.ftFileDate = wfd.ftLastWriteTime; - /* enabled? */ - if (langpack && !mir_tstrcmpi(langpack, wfd.cFileName)) { - if (!fPackFound) pack.flags |= LPF_ENABLED; - fPackFound = TRUE; - } - /* callback */ - res = callback(&pack, wParam, lParam); - if (!res) { FindClose(hFind); return FALSE; } - } - } while (FindNextFile(hFind, &wfd)); - FindClose(hFind); - } - - /* default langpack: English */ - if (callback != NULL) { - LANGPACK_INFO pack; - pack.Locale = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT); - mir_tstrcpy(pack.tszLanguage, _T("English")); - pack.szAuthors = "Miranda NG Development Team"; - pack.szAuthorEmail = "project-info@miranda-ng.org"; - DWORD v = CallService(MS_SYSTEM_GETVERSION, 0, 0); - pack.szLastModifiedUsing.Format("%d.%d.%d", ((v >> 24) & 0xFF), ((v >> 16) & 0xFF), ((v >> 8) & 0xFF)); - /* file date */ - if (GetModuleFileName(NULL, pack.tszFullPath, SIZEOF(pack.tszFullPath))) { - mir_tstrcpy(pack.tszFileName, _T("default")); - HANDLE hFile = CreateFile(pack.tszFileName, 0, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0); - if (hFile != INVALID_HANDLE_VALUE) { - GetFileTime(hFile, NULL, NULL, &pack.ftFileDate); - CloseHandle(hFile); - } - } - pack.flags = LPF_DEFAULT; - - if (!fPackFound) pack.flags |= LPF_ENABLED; - /* callback */ - if (!callback(&pack, wParam, lParam)) return FALSE; - } - - return fPackFound; -} diff --git a/src/modules/langpack/langpack.h b/src/modules/langpack/langpack.h deleted file mode 100644 index 900f853f69..0000000000 --- a/src/modules/langpack/langpack.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - -Miranda NG: the free IM client for Microsoft* Windows* - -Copyright (ñ) 2012-15 Miranda NG project (http://miranda-ng.org), -Copyright (c) 2000-12 Miranda IM project, -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -///////////////////////////////////////////////////////////////////////////////////////// - -static INT_PTR srvTranslateString(WPARAM wParam, LPARAM lParam); -static INT_PTR srvTranslateMenu(WPARAM wParam, LPARAM lParam); -static INT_PTR srvRegisterLP(WPARAM wParam, LPARAM lParam); -static INT_PTR srvGetDefaultCodePage(WPARAM, LPARAM); -static INT_PTR srvGetDefaultLocale(WPARAM, LPARAM); -static INT_PTR srvPcharToTchar(WPARAM wParam, LPARAM lParam); -static INT_PTR srvReloadLangpack(WPARAM wParam, LPARAM lParam); -static INT_PTR srvGetPluginLangpack(WPARAM wParam, LPARAM lParam); - -///////////////////////////////////////////////////////////////////////////////////////// - -#define LPF_ENABLED (1<<0) // pack is enabled -#define LPF_NOLOCALE (1<<1) // pack has no valid locale -#define LPF_DEFAULT (1<<2) // pack is the english default (no langpack) - -/* Langpack Info */ -struct LANGPACK_INFO -{ - TCHAR tszLanguage[64]; - LCID Locale; - WORD codepage; - CMStringA szAuthors, szAuthorEmail, szLastModifiedUsing; - FILETIME ftFileDate; - TCHAR tszFileName[MAX_PATH]; /* just the file name itself */ - TCHAR tszFullPath[MAX_PATH]; /* full path to the langpack */ - BYTE flags; /* see LPIF_* flags */ -}; - -typedef BOOL(*ENUM_PACKS_CALLBACK) (LANGPACK_INFO *pack, WPARAM wParam, LPARAM lParam); -BOOL EnumLangpacks(ENUM_PACKS_CALLBACK callback, WPARAM wParam, LPARAM lParam); - -int LangpackOptionsInit(WPARAM wParam, LPARAM); diff --git a/src/modules/langpack/lpopts.cpp b/src/modules/langpack/lpopts.cpp deleted file mode 100644 index 4adb56ec11..0000000000 --- a/src/modules/langpack/lpopts.cpp +++ /dev/null @@ -1,212 +0,0 @@ -/* - -Miranda NG: the free IM client for Microsoft* Windows* - -Copyright (ñ) 2012-15 Miranda NG project (http://miranda-ng.org), -Copyright (c) 2000-12 Miranda IM project, -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "..\..\core\commonheaders.h" -#include "langpack.h" - -static void SetDlgItemText_CP(HWND hwndDlg, int ctrlID, LPCSTR str) -{ - SetDlgItemText(hwndDlg, ctrlID, ptrT(mir_utf8decodeT(str))); -} - -static void DisplayPackInfo(HWND hwndDlg, const LANGPACK_INFO *pack) -{ - /* locale string */ - if (!(pack->flags & LPF_NOLOCALE)) { - TCHAR szLocaleName[256], szLanguageName[128], szContryName[128]; - - if (!GetLocaleInfo(pack->Locale, WINVER >= _WIN32_WINNT_WIN7 ? LOCALE_SENGLISHLANGUAGENAME : LOCALE_SENGLANGUAGE, szLanguageName, SIZEOF(szLanguageName))) - szLanguageName[0] = _T('\0'); - if (!GetLocaleInfo(pack->Locale, WINVER >= _WIN32_WINNT_WIN7 ? LOCALE_SENGLISHCOUNTRYNAME : LOCALE_SENGCOUNTRY, szContryName, SIZEOF(szContryName))) - szContryName[0] = _T('\0'); - - /* add some note if its incompatible */ - if (szLanguageName[0] && szContryName[0]) { - mir_sntprintf(szLocaleName, SIZEOF(szLocaleName), _T("%s (%s)"), TranslateTS(szLanguageName), TranslateTS(szContryName)); - if (!IsValidLocale(pack->Locale, LCID_INSTALLED)) { - TCHAR *pszIncompat; - pszIncompat = TranslateT("(incompatible)"); - szLocaleName[SIZEOF(szLocaleName) - mir_tstrlen(pszIncompat) - 1] = 0; - mir_tstrcat(mir_tstrcat(szLocaleName, _T(" ")), pszIncompat); - } - SetDlgItemText(hwndDlg, IDC_LANGLOCALE, szLocaleName); - } - else SetDlgItemText(hwndDlg, IDC_LANGLOCALE, TranslateT("Unknown")); - } - else SetDlgItemText(hwndDlg, IDC_LANGLOCALE, TranslateT("Unknown")); - - /* file date */ - SYSTEMTIME stFileDate; - TCHAR szDate[128]; szDate[0] = 0; - if (FileTimeToSystemTime(&pack->ftFileDate, &stFileDate)) - GetDateFormat((LCID)CallService(MS_LANGPACK_GETLOCALE, 0, 0), DATE_SHORTDATE, &stFileDate, NULL, szDate, SIZEOF(szDate)); - SetDlgItemText(hwndDlg, IDC_LANGDATE, szDate); - - /* general */ - SetDlgItemText_CP(hwndDlg, IDC_LANGMODUSING, pack->szLastModifiedUsing); - SetDlgItemText_CP(hwndDlg, IDC_LANGAUTHORS, pack->szAuthors); - SetDlgItemText_CP(hwndDlg, IDC_LANGEMAIL, pack->szAuthorEmail); - SetDlgItemText(hwndDlg, IDC_LANGINFOFRAME, TranslateTS(pack->tszLanguage)); -} - -static BOOL InsertPackItemEnumProc(LANGPACK_INFO *pack, WPARAM wParam, LPARAM lParam) -{ - LANGPACK_INFO *pack2 = new LANGPACK_INFO(); - *pack2 = *pack; - - /* insert */ - TCHAR tszName[512]; - mir_sntprintf(tszName, SIZEOF(tszName), _T("%s [%s]"), - TranslateTS(pack->tszLanguage), - pack->flags & LPF_DEFAULT ? TranslateT("built-in") : pack->tszFileName); - UINT message = pack->flags & LPF_DEFAULT ? CB_INSERTSTRING : CB_ADDSTRING; - int idx = SendMessage((HWND)wParam, message, 0, (LPARAM)tszName); - SendMessage((HWND)wParam, CB_SETITEMDATA, idx, (LPARAM)pack2); - if (pack->flags & LPF_ENABLED) { - SendMessage((HWND)wParam, CB_SETCURSEL, idx, 0); - DisplayPackInfo(GetParent((HWND)wParam), pack); - EnableWindow(GetDlgItem(GetParent((HWND)wParam), IDC_RELOAD), !(pack->flags & LPF_DEFAULT)); - } - - return TRUE; -} - -static void CALLBACK OpenOptions(void*) -{ - OPENOPTIONSDIALOG ood = { sizeof(ood) }; - ood.pszGroup = "Customize"; - ood.pszPage = "Languages"; - Options_Open(&ood); -} - -static void ReloadOptions(void *hWnd) -{ - while (IsWindow((HWND)hWnd)) - Sleep(50); - - CallFunctionAsync(OpenOptions, 0); -} - -INT_PTR CALLBACK DlgLangpackOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - HWND hwndList = GetDlgItem(hwndDlg, IDC_LANGUAGES); - - switch (msg) { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - ComboBox_ResetContent(hwndList); - EnumLangpacks(InsertPackItemEnumProc, (WPARAM)hwndList, (LPARAM)0); - return TRUE; - - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDC_LANGEMAIL: - { - char buf[512]; - mir_strcpy(buf, "mailto:"); - if (GetDlgItemTextA(hwndDlg, LOWORD(wParam), &buf[7], SIZEOF(buf) - 7)) - CallService(MS_UTILS_OPENURL, 0, (LPARAM)buf); - } - break; - - case IDC_MORELANG: - CallService(MS_UTILS_OPENURL, OUF_NEWWINDOW, (LPARAM)"http://wiki.miranda-ng.org/index.php?title=Langpacks/en#Download"); - break; - - case IDC_LANGUAGES: - if (HIWORD(wParam) == CBN_SELCHANGE) { - int idx = ComboBox_GetCurSel(hwndList); - LANGPACK_INFO *pack = (LANGPACK_INFO*)ComboBox_GetItemData(hwndList, idx); - DisplayPackInfo(hwndDlg, pack); - if (!(pack->flags & LPF_ENABLED)) - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_RELOAD), (pack->flags & LPF_ENABLED) && !(pack->flags & LPF_DEFAULT)); - } - break; - - case IDC_RELOAD: - { - EnableWindow(GetDlgItem(hwndDlg, IDC_RELOAD), FALSE); - int idx = ComboBox_GetCurSel(hwndList); - LANGPACK_INFO *pack = (LANGPACK_INFO*)ComboBox_GetItemData(hwndList, idx); - ReloadLangpack(pack->tszFullPath); - DisplayPackInfo(hwndDlg, pack); - EnableWindow(GetDlgItem(hwndDlg, IDC_RELOAD), TRUE); - } - break; - } - break; - - case WM_NOTIFY: - if (LPNMHDR(lParam)->code == PSN_APPLY) { - TCHAR tszPath[MAX_PATH]; tszPath[0] = 0; - int idx = ComboBox_GetCurSel(hwndList); - int count = ComboBox_GetCount(hwndList); - for (int i = 0; i < count; i++) { - LANGPACK_INFO *pack = (LANGPACK_INFO*)ComboBox_GetItemData(hwndList, i); - if (i == idx) { - db_set_ts(NULL, "Langpack", "Current", pack->tszFileName); - mir_tstrcpy(tszPath, pack->tszFullPath); - pack->flags |= LPF_ENABLED; - } - else pack->flags &= ~LPF_ENABLED; - } - - if (tszPath[0]) { - ReloadLangpack(tszPath); - - if (LPPSHNOTIFY(lParam)->lParam == IDC_APPLY) { - HWND hwndParent = GetParent(hwndDlg); - PostMessage(hwndParent, WM_CLOSE, 1, 0); - mir_forkthread(ReloadOptions, hwndParent); - } - } - } - break; - - case WM_DESTROY: - int count = ListBox_GetCount(hwndList); - for (int i = 0; i < count; i++) - delete (LANGPACK_INFO*)ListBox_GetItemData(hwndList, i); - ComboBox_ResetContent(hwndList); - return TRUE; - } - return FALSE; -} - -///////////////////////////////////////////////////////////////////////////////////////// - -int LangpackOptionsInit(WPARAM wParam, LPARAM) -{ - OPTIONSDIALOGPAGE odp = { 0 }; - odp.hInstance = hInst; - odp.pfnDlgProc = DlgLangpackOpt; - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_LANGUAGES); - odp.position = -1300000000; - odp.pszTitle = LPGEN("Languages"); - odp.pszGroup = LPGEN("Customize"); - odp.flags = ODPF_BOLDGROUPS; - Options_AddPage(wParam, &odp); - return 0; -} diff --git a/src/modules/langpack/lpservices.cpp b/src/modules/langpack/lpservices.cpp deleted file mode 100644 index 5bb898b709..0000000000 --- a/src/modules/langpack/lpservices.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/* - -Miranda NG: the free IM client for Microsoft* Windows* - -Copyright (ñ) 2012-15 Miranda NG project (http://miranda-ng.org), -Copyright (c) 2000-12 Miranda IM project, -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "..\..\core\commonheaders.h" - -///////////////////////////////////////////////////////////////////////////////////////// - -static INT_PTR srvTranslateString(WPARAM wParam, LPARAM lParam) -{ - if (wParam & LANG_UNICODE) - return (INT_PTR)TranslateW_LP((const WCHAR*)lParam, wParam); - return (INT_PTR)TranslateA_LP((const char *)lParam, wParam); -} - -///////////////////////////////////////////////////////////////////////////////////////// - -static INT_PTR srvTranslateMenu(WPARAM wParam, LPARAM lParam) -{ - TranslateMenu_LP((HMENU)wParam, lParam); - return 0; -} - -///////////////////////////////////////////////////////////////////////////////////////// - -static INT_PTR srvRegisterLP(WPARAM wParam, LPARAM lParam) -{ - PLUGININFOEX* ppi = (PLUGININFOEX*)lParam; - if (wParam && ppi) - *(int*)wParam = GetPluginFakeId(ppi->uuid, Langpack_MarkPluginLoaded(ppi)); - return 0; -} - -///////////////////////////////////////////////////////////////////////////////////////// - -static INT_PTR srvGetDefaultCodePage(WPARAM, LPARAM) -{ - return Langpack_GetDefaultCodePage(); -} - -///////////////////////////////////////////////////////////////////////////////////////// - -static INT_PTR srvGetDefaultLocale(WPARAM, LPARAM) -{ - return Langpack_GetDefaultLocale(); -} - -///////////////////////////////////////////////////////////////////////////////////////// - -static INT_PTR srvPcharToTchar(WPARAM wParam, LPARAM lParam) -{ - char *pszStr = (char*)lParam; - if (pszStr == NULL) - return NULL; - - int len = (int)mir_strlen(pszStr); - TCHAR *result = (TCHAR*)alloca((len+1)*sizeof(TCHAR)); - MultiByteToWideChar(Langpack_GetDefaultCodePage(), 0, pszStr, -1, result, len); - result[len] = 0; - return (INT_PTR)mir_wstrdup(TranslateW_LP(result, wParam)); -} - -///////////////////////////////////////////////////////////////////////////////////////// - -static INT_PTR srvReloadLangpack(WPARAM wParam, LPARAM lParam) -{ - ReloadLangpack((TCHAR*)lParam); - return 0; -} - -///////////////////////////////////////////////////////////////////////////////////////// - -static INT_PTR srvGetPluginLangpack(WPARAM wParam, LPARAM lParam) -{ - return GetPluginLangByInstance((HINSTANCE)lParam); -} - -///////////////////////////////////////////////////////////////////////////////////////// - -int LoadLangpackModule(void) -{ - LoadLangPackModule(); - - CreateServiceFunction(MS_LANGPACK_TRANSLATESTRING, srvTranslateString); - CreateServiceFunction(MS_LANGPACK_TRANSLATEMENU, srvTranslateMenu); - CreateServiceFunction(MS_LANGPACK_GETCODEPAGE, srvGetDefaultCodePage); - CreateServiceFunction(MS_LANGPACK_GETLOCALE, srvGetDefaultLocale); - CreateServiceFunction(MS_LANGPACK_PCHARTOTCHAR, srvPcharToTchar); - CreateServiceFunction(MS_LANGPACK_REGISTER, srvRegisterLP); - CreateServiceFunction(MS_LANGPACK_RELOAD, srvReloadLangpack); - CreateServiceFunction(MS_LANGPACK_LOOKUPHANDLE, srvGetPluginLangpack); - return 0; -} -- cgit v1.2.3