summaryrefslogtreecommitdiff
path: root/plugins/LangMan/src
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/LangMan/src')
-rw-r--r--plugins/LangMan/src/common.h1
-rw-r--r--plugins/LangMan/src/langpack.cpp177
-rw-r--r--plugins/LangMan/src/langpack.h15
-rw-r--r--plugins/LangMan/src/main.cpp121
-rw-r--r--plugins/LangMan/src/options.cpp96
-rw-r--r--plugins/LangMan/src/resource.h9
-rw-r--r--plugins/LangMan/src/utils.cpp67
-rw-r--r--plugins/LangMan/src/utils.h23
-rw-r--r--plugins/LangMan/src/version.h18
9 files changed, 159 insertions, 368 deletions
diff --git a/plugins/LangMan/src/common.h b/plugins/LangMan/src/common.h
index d3cd0a1397..2afafaff9d 100644
--- a/plugins/LangMan/src/common.h
+++ b/plugins/LangMan/src/common.h
@@ -38,7 +38,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "langpack.h"
#include "options.h"
-#include "utils.h"
#include "resource.h"
#include "version.h"
diff --git a/plugins/LangMan/src/langpack.cpp b/plugins/LangMan/src/langpack.cpp
index 1fb31928de..cab1a6d116 100644
--- a/plugins/LangMan/src/langpack.cpp
+++ b/plugins/LangMan/src/langpack.cpp
@@ -128,8 +128,8 @@ static void CleanupLastModifiedUsing(char *szLastModifiedUsing, int nSize)
if (p!=NULL) MoveMemory(p+1, p+2, lstrlenA(p+2)+1);
/* default if empty */
if (!szLastModifiedUsing[0]) {
- lstrcpynA(szLastModifiedUsing, MIRANDANAME" ", nSize);
- CallService(MS_SYSTEM_GETVERSIONTEXT, nSize-lstrlenA(szLastModifiedUsing), (LPARAM)szLastModifiedUsing+lstrlenA(szLastModifiedUsing));
+ DWORD v = CallService(MS_SYSTEM_GETVERSION, 0, 0);
+ mir_snprintf(szLastModifiedUsing, nSize, "%d.%d.%d.%d", ((v >> 24) & 0xFF), ((v >> 16) & 0xFF), ((v >> 8) & 0xFF), (v & 0xFF));
}
}
@@ -246,7 +246,7 @@ BOOL GetPackPath(TCHAR *pszPath, int nSize, BOOL fEnabledPacks, const TCHAR *psz
/* subdirectory */
if (!fEnabledPacks) {
if (nSize<(lstrlen(pszPath)+10)) return FALSE;
- lstrcat(pszPath, _T("Plugins\\Language\\"));
+ lstrcat(pszPath, _T("Languages\\"));
}
/* file name */
if (pszFile!=NULL) {
@@ -258,7 +258,7 @@ BOOL GetPackPath(TCHAR *pszPath, int nSize, BOOL fEnabledPacks, const TCHAR *psz
// callback is allowed to be NULL
// returns TRUE if any pack exists except default
-BOOL EnumPacks(ENUM_PACKS_CALLBACK callback, const TCHAR *pszFilePattern, const char *pszFileVersionHeader, BOOL fEnglishDefault, WPARAM wParam, LPARAM lParam)
+BOOL EnumPacks(ENUM_PACKS_CALLBACK callback, const TCHAR *pszFilePattern, const char *pszFileVersionHeader, WPARAM wParam, LPARAM lParam)
{
BOOL fPackFound = FALSE;
BOOL res = FALSE;
@@ -266,6 +266,8 @@ BOOL EnumPacks(ENUM_PACKS_CALLBACK callback, const TCHAR *pszFilePattern, const
WIN32_FIND_DATA wfd;
HANDLE hFind;
+ mir_ptr<TCHAR> langpack(db_get_tsa(NULL, "LangMan", "Langpack"));
+
/* enabled packs */
if (GetPackPath(pack.szFileName, SIZEOF(pack.szFileName), TRUE, pszFilePattern)) {
hFind = FindFirstFile(pack.szFileName, &wfd);
@@ -279,8 +281,10 @@ BOOL EnumPacks(ENUM_PACKS_CALLBACK callback, const TCHAR *pszFilePattern, const
if (LoadPackData(&pack, TRUE, pszFileVersionHeader)) {
pack.ftFileDate = wfd.ftLastWriteTime;
/* enabled? */
- if (!fPackFound) pack.flags |= LPF_ENABLED;
- fPackFound = TRUE;
+ if (!langpack) {
+ if (!fPackFound) pack.flags |= LPF_ENABLED;
+ fPackFound = TRUE;
+ }
/* callback */
if (callback!=NULL) res = callback(&pack, wParam, lParam);
if (!res) { FindClose(hFind); return FALSE; }
@@ -290,30 +294,6 @@ BOOL EnumPacks(ENUM_PACKS_CALLBACK callback, const TCHAR *pszFilePattern, const
}
}
- /* default: English (GB) */
- if (fEnglishDefault && callback!=NULL) {
- ZeroMemory(&pack, sizeof(pack));
- pack.Locale = LOCALE_USER_DEFAULT; /* miranda uses default locale in this case */
- lstrcpy(pack.szLanguage, _T("English (default)")); /* buffer safe */
- lstrcpyA(pack.szAuthors, "Miranda NG Development Team"); /* buffer safe */
- lstrcpyA(pack.szAuthorEmail, "project-info at miranda-ng.org"); /* buffer safe */
- CleanupEmail(pack.szAuthorEmail); /* correct " at " */
- CleanupLastModifiedUsing(pack.szLastModifiedUsing, sizeof(pack.szLastModifiedUsing));
- /* file date */
- if (GetModuleFileName(NULL, pack.szFileName, SIZEOF(pack.szFileName))) {
- HANDLE hFile;
- hFile = CreateFile(pack.szFileName, 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_NOLOCALE|LPF_DEFAULT;
- if (!fPackFound) pack.flags |= LPF_ENABLED;
- /* callback */
- if (!callback(&pack, wParam, lParam)) return FALSE;
- }
-
/* disabled packs */
if (GetPackPath(pack.szFileName, SIZEOF(pack.szFileName), FALSE, pszFilePattern)) {
hFind = FindFirstFile(pack.szFileName, &wfd);
@@ -326,7 +306,13 @@ BOOL EnumPacks(ENUM_PACKS_CALLBACK callback, const TCHAR *pszFilePattern, const
lstrcpy(pack.szFileName, CharLower(wfd.cFileName)); /* buffer safe */
if (LoadPackData(&pack, FALSE, pszFileVersionHeader)) {
pack.ftFileDate = wfd.ftLastWriteTime;
- fPackFound = TRUE;
+ /* enabled? */
+ if (langpack) {
+ if (!_tcscmp(pack.szFileName, langpack)) {
+ if (!fPackFound) pack.flags |= LPF_ENABLED;
+ fPackFound = TRUE;
+ }
+ }
/* callback */
if (callback!=NULL) res = callback(&pack, wParam, lParam);
if (!res) { FindClose(hFind); return FALSE; }
@@ -335,65 +321,36 @@ BOOL EnumPacks(ENUM_PACKS_CALLBACK callback, const TCHAR *pszFilePattern, const
FindClose(hFind);
}
}
- return fPackFound;
-}
-
-BOOL IsPluginIncluded(const LANGPACK_INFO *pack, char *pszFileBaseName)
-{
- char *p;
- if (!lstrcmpiA(pszFileBaseName, "png2dib") || !lstrcmpiA(pszFileBaseName, "loadavatars"))
- return TRUE; /* workaround: does not need no translation */
- for(p = (char*)pack->szPluginsIncluded;;) {
- p = strstr(p, CharLowerA(pszFileBaseName));
- if (p == NULL) return FALSE;
- if (p == pack->szPluginsIncluded || *(p-1) == ' ' || *(p-1) == ',') {
- p+=lstrlenA(pszFileBaseName)+1;
- if (*p == ',' || *p == ' ' || *p == 0) return TRUE;
- }
- else p+=lstrlenA(pszFileBaseName)+1;
- }
-}
-
-/************************* Switch *************************************/
-BOOL EnablePack(const LANGPACK_INFO *pack, const TCHAR *pszFilePattern)
-{
- TCHAR szFrom[MAX_PATH], szDest[MAX_PATH];
- HANDLE hFind;
- WIN32_FIND_DATA wfd;
-
- /* disable previous pack */
- if (GetPackPath(szFrom, SIZEOF(szFrom), TRUE, pszFilePattern)) {
- hFind = FindFirstFile(szFrom, &wfd);
- if (hFind!=INVALID_HANDLE_VALUE) {
- do {
- if (wfd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) continue;
- if (lstrlen(wfd.cFileName)<4 || wfd.cFileName[lstrlen(wfd.cFileName)-4]!=_T('.')) continue;
- /* ensure dir exists */
- if (GetPackPath(szFrom, SIZEOF(szFrom), FALSE, NULL))
- CreateDirectory(szFrom, NULL);
- /* move file */
- if (GetPackPath(szFrom, SIZEOF(szFrom), TRUE, wfd.cFileName))
- if (GetPackPath(szDest, SIZEOF(szDest), FALSE, wfd.cFileName))
- if (!MoveFile(szFrom, szDest) && GetLastError() == ERROR_ALREADY_EXISTS) {
- DeleteFile(szDest);
- MoveFile(szFrom, szDest);
- }
- break;
- } while(FindNextFile(hFind, &wfd));
- FindClose(hFind);
+ /* default: English (GB) */
+ if (callback!=NULL) {
+ ZeroMemory(&pack, sizeof(pack));
+ pack.Locale = LOCALE_USER_DEFAULT; /* miranda uses default locale in this case */
+ lstrcpy(pack.szLanguage, _T("English (default)")); /* buffer safe */
+ lstrcpyA(pack.szAuthors, "Miranda NG Development Team"); /* buffer safe */
+ lstrcpyA(pack.szAuthorEmail, "project-info at miranda-ng.org"); /* buffer safe */
+ CleanupEmail(pack.szAuthorEmail); /* correct " at " */
+ CleanupLastModifiedUsing(pack.szLastModifiedUsing, sizeof(pack.szLastModifiedUsing));
+ /* file date */
+ if (GetModuleFileName(NULL, pack.szFileName, SIZEOF(pack.szFileName))) {
+ HANDLE hFile;
+ hFile = CreateFile(pack.szFileName, 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_NOLOCALE|LPF_DEFAULT;
+ pack.Locale = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT);
+ if (!fPackFound) pack.flags |= LPF_ENABLED;
+ /* callback */
+ if (!callback(&pack, wParam, lParam)) return FALSE;
}
- /* enable current pack */
- if (pack->flags&LPF_DEFAULT) return TRUE;
- if (GetPackPath(szFrom, SIZEOF(szFrom), FALSE, pack->szFileName))
- if (GetPackPath(szDest, SIZEOF(szDest), TRUE, pack->szFileName))
- return MoveFile(szFrom, szDest);
- return FALSE;
+ return fPackFound;
}
-void CorrectPacks(const TCHAR *pszFilePattern, BOOL fDisableAll)
+void MovePacks(const TCHAR *pszFilePattern)
{
TCHAR szFrom[MAX_PATH], szDest[MAX_PATH], szDir[MAX_PATH], *pszFile;
BOOL fDirCreated = FALSE;
@@ -403,52 +360,34 @@ void CorrectPacks(const TCHAR *pszFilePattern, BOOL fDisableAll)
/* main path */
if (!GetModuleFileName(NULL, szDir, SIZEOF(szDir))) return;
pszFile = _tcsrchr(szDir, _T('\\'));
- if (pszFile!=NULL) *pszFile = _T('\0');
+ if (pszFile != NULL) *pszFile = _T('\0');
- /* move wrongly placed packs from 'Plugins' to 'Language' */
- mir_sntprintf(szFrom, SIZEOF(szFrom), _T("%s\\Plugins\\%s"), szDir, pszFilePattern);
+ if (!GetPackPath(szDest, SIZEOF(szDest), FALSE, _T(""))) return;
+
+ /* move wrongly placed packs from 'root' to 'Language' */
+ mir_sntprintf(szFrom, SIZEOF(szFrom), _T("%s\\%s"), szDir, pszFilePattern);
hFind = FindFirstFile(szFrom, &wfd);
- if (hFind!=INVALID_HANDLE_VALUE) {
+ if (hFind != INVALID_HANDLE_VALUE) {
do {
if (wfd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) continue;
- if (lstrlen(wfd.cFileName)<4 || wfd.cFileName[lstrlen(wfd.cFileName)-4]!=_T('.')) continue;
+ if (lstrlen(wfd.cFileName)<4 || wfd.cFileName[lstrlen(wfd.cFileName) - 4] != _T('.')) continue;
+ /* set first lp ad default */
+ mir_ptr<TCHAR> langpack(db_get_tsa(NULL, "LangMan", "Langpack"));
+ if (!langpack)
+ db_set_ws(NULL, "LangMan", "Langpack", wfd.cFileName);
/* ensure dir exists */
- if (!fDirCreated && GetPackPath(szFrom, SIZEOF(szFrom), FALSE, NULL))
- fDirCreated = CreateDirectory(szFrom, NULL);
+ if (!fDirCreated)
+ fDirCreated = CreateDirectory(szDest, NULL);
/* move file */
- if (GetPackPath(szDest, SIZEOF(szDest), FALSE, wfd.cFileName)) {
- mir_sntprintf(szFrom, SIZEOF(szFrom), _T("%s\\Plugins\\%s"), szDir, wfd.cFileName);
+ if (GetPackPath(szDest, SIZEOF(szDest), FALSE, wfd.cFileName))
+ {
+ mir_sntprintf(szFrom, SIZEOF(szFrom), _T("%s\\%s"), szDir, wfd.cFileName);
if (!MoveFile(szFrom, szDest) && GetLastError() == ERROR_ALREADY_EXISTS) {
DeleteFile(szDest);
MoveFile(szFrom, szDest);
}
}
- } while(FindNextFile(hFind, &wfd));
+ } while (FindNextFile(hFind, &wfd));
FindClose(hFind);
}
-
- /* disable all packs except one */
- if (GetPackPath(szFrom, SIZEOF(szFrom), TRUE, pszFilePattern)) {
- hFind = FindFirstFile(szFrom, &wfd);
- if (hFind!=INVALID_HANDLE_VALUE) {
- do {
- if (wfd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) continue;
- if (lstrlen(wfd.cFileName)<4 || wfd.cFileName[lstrlen(wfd.cFileName)-4]!=_T('.')) continue;
- /* skip first file */
- if (!fDisableAll) { fDisableAll = TRUE; continue; }
- /* ensure dir exists */
- if (!fDirCreated && GetPackPath(szFrom, SIZEOF(szFrom), FALSE, NULL))
- fDirCreated = CreateDirectory(szFrom, NULL);
- /* move file */
- if (GetPackPath(szFrom, SIZEOF(szFrom), TRUE, wfd.cFileName))
- if (GetPackPath(szDest, SIZEOF(szDest), FALSE, wfd.cFileName)) {
- if (!MoveFile(szFrom, szDest) && GetLastError() == ERROR_ALREADY_EXISTS) {
- DeleteFile(szDest);
- MoveFile(szFrom, szDest);
- }
- }
- } while(FindNextFile(hFind, &wfd));
- FindClose(hFind);
- }
- }
} \ No newline at end of file
diff --git a/plugins/LangMan/src/langpack.h b/plugins/LangMan/src/langpack.h
index 354286b405..0468340c55 100644
--- a/plugins/LangMan/src/langpack.h
+++ b/plugins/LangMan/src/langpack.h
@@ -19,6 +19,10 @@ along with this program (LangMan-License.txt); if not, write to the Free Softwar
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+#define LPF_ENABLED 0x01 // pack is enabled
+#define LPF_NOLOCALE 0x02 // pack has no valid locale
+#define LPF_DEFAULT 0x04 // pack is the english default (no langpack)
+
/* Langpack Info */
typedef struct {
TCHAR szLanguage[64];
@@ -34,16 +38,9 @@ typedef struct {
TCHAR szFileName[MAX_PATH]; /* just the file name itself */
BYTE flags; /* see LPIF_* flags */
} LANGPACK_INFO;
-#define LPF_ENABLED 0x01 // pack is enabled
-#define LPF_NOLOCALE 0x02 // pack has no valid locale
-#define LPF_DEFAULT 0x04 // pack is the english default (no langpack)
/* Enum */
BOOL GetPackPath(TCHAR *pszPath, int nSize, BOOL fEnabledPacks, const TCHAR *pszFile);
typedef BOOL (*ENUM_PACKS_CALLBACK)(LANGPACK_INFO *pack, WPARAM wParam, LPARAM lParam);
-BOOL EnumPacks(ENUM_PACKS_CALLBACK callback, const TCHAR *pszFilePattern, const char *pszFileVersionHeader, BOOL fEnglishDefault, WPARAM wParam, LPARAM lParam);
-BOOL IsPluginIncluded(const LANGPACK_INFO *pack, char *pszFileBaseName);
-
-/* Switch */
-BOOL EnablePack(const LANGPACK_INFO *pack, const TCHAR *pszFilePattern);
-void CorrectPacks(const TCHAR *pszFilePattern, BOOL fDisableAll);
+BOOL EnumPacks(ENUM_PACKS_CALLBACK callback, const TCHAR *pszFilePattern, const char *pszFileVersionHeader, WPARAM wParam, LPARAM lParam);
+void MovePacks(const TCHAR *pszFilePattern); \ No newline at end of file
diff --git a/plugins/LangMan/src/main.cpp b/plugins/LangMan/src/main.cpp
index e25e2cabc7..124a35427f 100644
--- a/plugins/LangMan/src/main.cpp
+++ b/plugins/LangMan/src/main.cpp
@@ -39,90 +39,95 @@ static PLUGININFOEX pluginInfo = {
{0xd4bdd1eb, 0x56f1, 0x4a87, {0xa1, 0x87, 0x67, 0x24, 0x6e, 0xe9, 0x19, 0xa2}},
};
-///////////////////////////////////////////////////////////////////////////////
-
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, void*)
{
hInst = hinstDLL;
return TRUE;
}
-///////////////////////////////////////////////////////////////////////////////
+extern "C" __declspec(dllexport) const PLUGININFOEX* MirandaPluginInfoEx(DWORD)
+{
+ return &pluginInfo;
+}
-static void InstallFile(const TCHAR *pszFileName, const TCHAR *pszDestSubDir)
+BOOL IsRunAsAdmin()
{
- TCHAR szFileFrom[MAX_PATH+1], szFileTo[MAX_PATH+1];
- if ( !GetModuleFileName(hInst, szFileFrom, SIZEOF(szFileFrom) - lstrlen(pszFileName)))
- return;
-
- TCHAR *p = _tcsrchr(szFileFrom, _T('\\'));
- if ( p != NULL ) *(++p) = 0;
- lstrcat(szFileFrom, pszFileName); /* buffer safe */
-
- HANDLE hFile = CreateFile(szFileFrom, 0, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
- if ( hFile == INVALID_HANDLE_VALUE ) return;
- CloseHandle(hFile);
-
- if ( !GetModuleFileName(NULL, szFileTo, SIZEOF(szFileTo) - lstrlen(pszDestSubDir) - lstrlen(pszFileName)))
- return;
-
- p = _tcsrchr(szFileTo, _T('\\'));
- if ( p != NULL ) *(++p) = 0;
- lstrcat(szFileTo, pszDestSubDir); /* buffer safe */
- CreateDirectory(szFileTo, NULL);
- lstrcat(szFileTo, pszFileName); /* buffer safe */
-
- if ( !MoveFile(szFileFrom, szFileTo) && GetLastError() == ERROR_ALREADY_EXISTS) {
- DeleteFile(szFileTo);
- MoveFile(szFileFrom, szFileTo);
+ BOOL fIsRunAsAdmin = FALSE;
+ DWORD dwError = ERROR_SUCCESS;
+ PSID pAdministratorsGroup = NULL;
+
+ // Allocate and initialize a SID of the administrators group.
+ SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
+ if (!AllocateAndInitializeSid(
+ &NtAuthority,
+ 2,
+ SECURITY_BUILTIN_DOMAIN_RID,
+ DOMAIN_ALIAS_RID_ADMINS,
+ 0, 0, 0, 0, 0, 0,
+ &pAdministratorsGroup))
+ {
+ dwError = GetLastError();
+ goto Cleanup;
}
-}
-///////////////////////////////////////////////////////////////////////////////
+ // Determine whether the SID of administrators group is enabled in
+ // the primary access token of the process.
+ if (!CheckTokenMembership(NULL, pAdministratorsGroup, &fIsRunAsAdmin))
+ {
+ dwError = GetLastError();
+ goto Cleanup;
+ }
-extern "C" __declspec(dllexport) const PLUGININFOEX* MirandaPluginInfoEx(DWORD)
-{
- return &pluginInfo;
-}
+Cleanup:
+ // Centralized cleanup for all allocated resources.
+ if (pAdministratorsGroup)
+ {
+ FreeSid(pAdministratorsGroup);
+ pAdministratorsGroup = NULL;
+ }
-///////////////////////////////////////////////////////////////////////////////
+ // Throw the error if something failed in the function.
+ if (ERROR_SUCCESS != dwError)
+ {
+ throw dwError;
+ }
+
+ return fIsRunAsAdmin;
+}
extern "C" __declspec(dllexport) int Load(void)
{
-
mir_getLP( &pluginInfo );
-
- /* existance of MS_SYSTEM_GETVERSION and MS_LANGPACK_TRANSLATESTRING
- * is checked in MirandaPluginInfo().
- * Not placed in MirandaPluginInfo() to avoid MessageBoxes on plugin options.
- * Using ANSI as LANG_UNICODE might not be supported. */
- INITCOMMONCONTROLSEX icc;
+ if (!IsRunAsAdmin())
+ MovePacks(_T("langpack_*.txt"));
+
+ /*INITCOMMONCONTROLSEX icc;
icc.dwSize = sizeof(icc);
icc.dwICC = ICC_TREEVIEW_CLASSES|ICC_USEREX_CLASSES;
- InitCommonControlsEx(&icc);
- InitOptions();
-
- /* menu item */
+ InitCommonControlsEx(&icc);*/
+
+ TCHAR *langpack = db_get_tsa(NULL, "LangMan", "Langpack");
+ if (langpack)
+ {
+ TCHAR szPath[MAX_PATH], szFile[MAX_PATH];
+ mir_sntprintf(szFile, MAX_PATH, _T("Languages\\%s"), langpack);
+ GetPackPath(szPath, SIZEOF(szPath), TRUE, CharLower(szFile));
+
+ DWORD dwAttrib = GetFileAttributes(szPath);
+ if (dwAttrib != INVALID_FILE_ATTRIBUTES && !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY))
+ CallService(MS_LANGPACK_RELOAD, 0, (LPARAM)szPath);
+ mir_free(langpack);
+ }
- CLISTMENUITEM mi = { sizeof(mi) };
- mi.position = 2000089999;
- mi.icolibItem = LoadIcon(hInst, MAKEINTRESOURCE(IDI_RELOAD));
- mi.pszName = LPGEN("Reload langpack");
- mi.pszService = MS_LANGPACK_RELOAD;
- Menu_AddMainMenuItem(&mi);
+ InitOptions();
- /* installation */
- InstallFile(_T("LangMan-Readme.txt"), _T("Docs\\"));
- InstallFile(_T("LangMan-License.txt"), _T("Docs\\"));
- InstallFile(_T("LangMan-SDK.zip"), _T("Docs\\"));
return 0;
}
-///////////////////////////////////////////////////////////////////////////////
-
extern "C" __declspec(dllexport) int Unload(void)
{
UninitOptions();
+
return 0;
} \ No newline at end of file
diff --git a/plugins/LangMan/src/options.cpp b/plugins/LangMan/src/options.cpp
index c191f55fa0..6abdf153c5 100644
--- a/plugins/LangMan/src/options.cpp
+++ b/plugins/LangMan/src/options.cpp
@@ -148,78 +148,8 @@ static void CleanupPluginName(char *szShortName)
szShortName[--len] = 0;
}
-static void DisplayNotIncludedPlugins(HWND hwndListBox, const LANGPACK_INFO *pack)
-{
- /* enum plugins */
- TCHAR szDir[MAX_PATH];
- if (!(pack->flags & LPF_DEFAULT) && GetModuleFileName(NULL, szDir, SIZEOF(szDir))) {
- TCHAR *p = _tcsrchr(szDir, _T('\\'));
- if (p != NULL)
- *p = _T('\0');
-
- TCHAR szSearch[MAX_PATH];
- mir_sntprintf(szSearch, SIZEOF(szSearch), _T("%s\\Plugins\\*.dll"), szDir);
- WIN32_FIND_DATA wfd;
- HANDLE hFind = FindFirstFile(szSearch, &wfd);
- if (hFind != INVALID_HANDLE_VALUE) {
- DWORD mirandaVersion = CallService(MS_SYSTEM_GETVERSION, 0, 0);
- SendMessage(hwndListBox, LB_SETLOCALE, CallService(MS_LANGPACK_GETLOCALE, 0, 0), 0); /* for sort order */
- SendMessage(hwndListBox, LB_INITSTORAGE, 128, lstrlenA(pack->szPluginsIncluded)); /* speed up */
- do {
- if (wfd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) continue;
- if ((lstrlen(wfd.cFileName) < 4) || (wfd.cFileName[lstrlen(wfd.cFileName) - 4] != _T('.'))) continue;
- /* file name */
- lstrcpy(szSearch, wfd.cFileName); /* buffer safe */
- p = _tcsrchr(szSearch, _T('.'));
- if (p != NULL)
- *p = _T('\0');
-
- char cFileNameA[MAX_PATH];
- cFileNameA[0] = '\0';
- WideCharToMultiByte(CP_ACP, 0, szSearch, -1, cFileNameA, sizeof(cFileNameA), NULL, NULL);
- if (IsPluginIncluded(pack, cFileNameA))
- continue;
-
- /* friendly name of the plugin */
- mir_sntprintf(szSearch, SIZEOF(szSearch), _T("%s\\Plugins\\%s"), szDir, wfd.cFileName);
- HMODULE hModule = GetModuleHandle(szSearch);
- bool fNeedsFree = (hModule == NULL);
- if (hModule == NULL) {
- hModule = LoadLibrary(szSearch);
- if (hModule == NULL) continue;
- }
-
- /* plugin info */
- pfnMirandaPluginInfo pFunc = (pfnMirandaPluginInfo)GetProcAddress(hModule, "MirandaPluginInfoEx");
- if (pFunc != NULL) { /* both structs have the same header */
- PLUGININFOEX *pluginInfo = pFunc(mirandaVersion);
- if (pluginInfo != NULL && pluginInfo->cbSize >= sizeof(PLUGININFOEX) && pluginInfo->shortName != NULL) {
- char buf[128];
- lstrcpynA(buf, pluginInfo->shortName, sizeof(buf)); /* buffer safe */
- CleanupPluginName(buf);
-
- TCHAR buf2[128];
- mir_sntprintf(buf2, SIZEOF(buf2), _T("%hs (%s)"), buf, CharLower(wfd.cFileName));
- SendMessage(hwndListBox, LB_ADDSTRING, 0, (LPARAM)buf2);
- }
- }
- if (fNeedsFree)
- FreeLibrary(hModule);
- }
- while (FindNextFile(hFind, &wfd));
- FindClose(hFind);
- }
- }
- /* all are included? */
- if (!SendMessage(hwndListBox, LB_GETCOUNT, 0, 0))
- SendMessage(hwndListBox, LB_ADDSTRING, 0, (LPARAM)TranslateT("All installed plugins are included."));
-}
-
static void DisplayPackInfo(HWND hwndDlg, const LANGPACK_INFO *pack)
{
- /* compute not-included from included list */
- SendDlgItemMessage(hwndDlg, IDC_LANGNOTINCLUDED, LB_RESETCONTENT, 0, 0);
- DisplayNotIncludedPlugins(GetDlgItem(hwndDlg, IDC_LANGNOTINCLUDED), pack);
/* locale string */
if (!(pack->flags & LPF_NOLOCALE)) {
TCHAR szLocaleName[128];
@@ -381,8 +311,11 @@ static INT_PTR CALLBACK LangOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
}
if ( ServiceExists(MS_FLAGS_LOADFLAGICON))
ListView_SetImageList(hwndList, ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR24, 8, 8), LVSIL_SMALL);
- CorrectPacks(_T("langpack_*.txt"), FALSE);
- CheckDlgButton(hwndDlg, IDC_ENABLEAUTOUPDATES, db_get_b(NULL, "LangMan", "EnableAutoUpdates", SETTING_ENABLEAUTOUPDATES_DEFAULT)!=0);
+
+ TCHAR szPath[MAX_PATH];
+ GetPackPath(szPath, SIZEOF(szPath), FALSE, _T(""));
+ SetDlgItemText(hwndDlg, IDC_SKINROOTFOLDER, szPath);
+
SendMessage(hwndDlg, M_RELOADLIST, 0, 0);
SendMessage(hwndDlg, M_SHOWFILECOL, 0, 1);
return TRUE;
@@ -395,10 +328,10 @@ static INT_PTR CALLBACK LangOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
HIMAGELIST himl = ListView_GetImageList(hwndList, LVSIL_SMALL);
ImageList_RemoveAll(himl);
/* enum all packs */
- EnumPacks(InsertPackItemEnumProc, _T("langpack_*.txt"), "Miranda Language Pack Version 1", TRUE, (WPARAM)hwndList, (LPARAM)himl);
+ EnumPacks(InsertPackItemEnumProc, _T("langpack_*.txt"), "Miranda Language Pack Version 1", (WPARAM)hwndList, (LPARAM)himl);
/* make it use current langpack locale for sort */
ListView_SortItems(hwndList, CompareListItem, CallService(MS_LANGPACK_GETLOCALE, 0, 0));
- CheckDlgButton(hwndDlg, IDC_ENABLEAUTOUPDATES, db_get_b(NULL, "LangMan", "EnableAutoUpdates", SETTING_ENABLEAUTOUPDATES_DEFAULT) != 0);
+ //CheckDlgButton(hwndDlg, IDC_ENABLEAUTOUPDATES, db_get_b(NULL, "LangMan", "EnableAutoUpdates", SETTING_ENABLEAUTOUPDATES_DEFAULT) != 0);
/* show selection */
int iItem = ListView_GetNextItem(hwndList, -1, LVNI_SELECTED);
if (iItem != -1)
@@ -596,13 +529,20 @@ static INT_PTR CALLBACK LangOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
lvi.iSubItem = 0;
for (lvi.iItem = 0; ListView_GetItem(hwndList, &lvi); ++lvi.iItem) {
LANGPACK_INFO *pack = (LANGPACK_INFO*)lvi.lParam;
- if (lvi.state&INDEXTOSTATEIMAGEMASK(2)) {
- EnablePack(pack, _T("langpack_*.txt"));
+ if (lvi.state&INDEXTOSTATEIMAGEMASK(2) && !(pack->flags & LPF_ENABLED)) {
+ if(!(pack->flags & LPF_DEFAULT))
+ db_set_ws(NULL, "LangMan", "Langpack", pack->szFileName);
+ else
+ db_unset(NULL, "LangMan", "Langpack");
+ TCHAR szPath[MAX_PATH];
+ GetPackPath(szPath, SIZEOF(szPath), FALSE, pack->szFileName);
+ CallService(MS_LANGPACK_RELOAD, 0, (LPARAM)szPath);
pack->flags |= LPF_ENABLED;
+ CloseWindow(GetParent(hwndDlg));
+ DestroyWindow(GetParent(hwndDlg));
}
else pack->flags &= ~LPF_ENABLED;
}
- db_set_b(NULL, "LangMan", "EnableAutoUpdates", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_ENABLEAUTOUPDATES) != 0));
return TRUE;
}
}
@@ -639,7 +579,7 @@ void InitOptions(void)
{
hwndLangOpt = NULL;
hHookOptInit = HookEvent(ME_OPT_INITIALISE, LangOptInit);
- CorrectPacks(_T("langpack_*.txt"), FALSE);
+ //CorrectPacks(_T("langpack_*.txt"), FALSE);
}
void UninitOptions(void)
diff --git a/plugins/LangMan/src/resource.h b/plugins/LangMan/src/resource.h
index 983f304ffb..bc7f8958ec 100644
--- a/plugins/LangMan/src/resource.h
+++ b/plugins/LangMan/src/resource.h
@@ -1,11 +1,10 @@
//{{NO_DEPENDENCIES}}
-// Microsoft Developer Studio generated include file.
-// Used by resource.rc
+// Microsoft Visual C++ generated include file.
+// Used by E:\Projects\C++\MirandaNG\plugins\LangMan\res\resource.rc
//
#define IDD_OPT_LANG 101
#define IDD_UPDATENOTIFY 102
#define IDD_DOWNLOADLANG 103
-#define IDI_RELOAD 104
#define IDC_LANGLIST 1001
#define IDC_LANGINFOFRAME 1002
#define IDC_LANGAUTHORSLABEL 1003
@@ -35,9 +34,11 @@
#define IDC_CURRENTVERSION 1026
#define IDC_NEWVERSION 1027
#define IDC_NEWVERSIONLABEL 1028
+#define IDC_SKINROOTFOLDER 1439
+#define IDC_LANGROOTFOLDER 1439
// Next default values for new objects
-//
+//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 1
diff --git a/plugins/LangMan/src/utils.cpp b/plugins/LangMan/src/utils.cpp
deleted file mode 100644
index c67b9813a8..0000000000
--- a/plugins/LangMan/src/utils.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
-
-'Language Pack Manager'-Plugin for Miranda IM
-
-Copyright (C) 2005-2007 H. Herkenrath
-
-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 (LangMan-License.txt); if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#include "common.h"
-
-/************************* Error Output ***************************/
-
-static void MessageBoxIndirectFree(MSGBOXPARAMSA *mbp)
-{
- MessageBoxIndirectA(mbp);
- mir_free((char*)mbp->lpszCaption); /* does NULL check */
- mir_free((char*)mbp->lpszText); /* does NULL check */
- mir_free(mbp);
-}
-
-void ShowInfoMessage(BYTE flags, const char *pszTitle, const char *pszTextFmt, ...)
-{
- va_list va;
- va_start(va, pszTextFmt);
- char szText[256]; /* max for systray */
- mir_vsnprintf(szText, SIZEOF(szText), pszTextFmt, va);
- va_end(va);
-
- if (ServiceExists(MS_CLIST_SYSTRAY_NOTIFY)) {
- MIRANDASYSTRAYNOTIFY msn;
- msn.cbSize = sizeof(msn);
- msn.szProto = NULL;
- msn.szInfoTitle = (char*)pszTitle;
- msn.szInfo = (char*)szText;
- msn.uTimeout = 30000; /* max timeout */
- msn.dwInfoFlags = flags;
- if (!CallServiceSync(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM)&msn))
- return; /* success */
- }
-
- MSGBOXPARAMSA *mbp = (MSGBOXPARAMSA*)mir_calloc(sizeof(*mbp));
- if (mbp == NULL) return;
- mbp->cbSize = sizeof(*mbp);
- mbp->lpszCaption = mir_strdup(pszTitle);
- mbp->lpszText = mir_strdup(szText);
- mbp->dwStyle = MB_OK|MB_SETFOREGROUND|MB_TASKMODAL;
- mbp->dwLanguageId = LANGIDFROMLCID((LCID)CallService(MS_LANGPACK_GETLOCALE, 0, 0));
- switch(flags&NIIF_ICON_MASK) {
- case NIIF_INFO: mbp->dwStyle |= MB_ICONINFORMATION; break;
- case NIIF_WARNING: mbp->dwStyle |= MB_ICONWARNING; break;
- case NIIF_ERROR: mbp->dwStyle |= MB_ICONERROR;
- }
- mir_forkthread(( pThreadFunc )MessageBoxIndirectFree, mbp);
-}
diff --git a/plugins/LangMan/src/utils.h b/plugins/LangMan/src/utils.h
deleted file mode 100644
index 8c4e299ebb..0000000000
--- a/plugins/LangMan/src/utils.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
-
-'Language Pack Manager'-Plugin for Miranda IM
-
-Copyright (C) 2005-2007 H. Herkenrath
-
-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 (LangMan-License.txt); if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-/* Error Output */
-void ShowInfoMessage(BYTE flags, const char *pszTitle, const char *pszTextFmt, ...);
diff --git a/plugins/LangMan/src/version.h b/plugins/LangMan/src/version.h
index a82809373c..c95c154578 100644
--- a/plugins/LangMan/src/version.h
+++ b/plugins/LangMan/src/version.h
@@ -1,14 +1,14 @@
-#define __MAJOR_VERSION 1
-#define __MINOR_VERSION 0
-#define __RELEASE_NUM 2
-#define __BUILD_NUM 3
+#define __MAJOR_VERSION 0
+#define __MINOR_VERSION 11
+#define __RELEASE_NUM 0
+#define __BUILD_NUM 1
#include <stdver.h>
#define __PLUGIN_NAME "Language pack manager"
#define __FILENAME "LangMan.dll"
-#define __DESCRIPTION "Helps you manage Language Packs of different languages."
-#define __AUTHOR "H. Herkenrath"
-#define __AUTHOREMAIL "hrathh@users.sourceforge.net"
-#define __AUTHORWEB "http://miranda-ng.org/p/LangMan/"
-#define __COPYRIGHT "© 2005-2007 H. Herkenrath"
+#define __DESCRIPTION "Helps you manage language packs of different languages."
+#define __AUTHOR "H. Herkenrath"
+#define __AUTHOREMAIL ""
+#define __AUTHORWEB "http://miranda-ng.org/p/LangMan/"
+#define __COPYRIGHT "© 2005-2007 H. Herkenrath, 2014 Miranda NG project"