diff options
| author | George Hazan <george.hazan@gmail.com> | 2014-03-23 14:26:29 +0000 | 
|---|---|---|
| committer | George Hazan <george.hazan@gmail.com> | 2014-03-23 14:26:29 +0000 | 
| commit | 58002bcdddc61a9290bcfd0459c38ea044f88de7 (patch) | |
| tree | e97f6a25d08956254a1e8177e78688d16ecc49ae /src | |
| parent | fb86ce59e1c9970560cb3b4482c798d7572edee7 (diff) | |
ability to select & store the langpack chosen
git-svn-id: http://svn.miranda-ng.org/main/trunk@8702 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/modules.cpp | 78 | ||||
| -rw-r--r-- | src/mir_core/langpack.cpp | 202 | ||||
| -rw-r--r-- | src/mir_core/mir_core.def | 1 | ||||
| -rw-r--r-- | src/miranda32_10.vcxproj | 8 | ||||
| -rw-r--r-- | src/miranda32_10.vcxproj.filters | 13 | ||||
| -rw-r--r-- | src/miranda32_12.vcxproj | 8 | ||||
| -rw-r--r-- | src/miranda32_12.vcxproj.filters | 19 | ||||
| -rw-r--r-- | src/modules/langpack/langpack.cpp | 135 | ||||
| -rw-r--r-- | src/modules/langpack/langpack.h | 63 | ||||
| -rw-r--r-- | src/modules/langpack/lpopts.cpp | 189 | ||||
| -rw-r--r-- | src/resource.h | 23 | ||||
| -rw-r--r-- | src/resource.rc | 41 | 
12 files changed, 644 insertions, 136 deletions
diff --git a/src/core/modules.cpp b/src/core/modules.cpp index 3243e81058..909e1811f2 100644 --- a/src/core/modules.cpp +++ b/src/core/modules.cpp @@ -24,46 +24,47 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.  #include "commonheaders.h"
  #include "../modules/plugins/plugins.h"
 +#include "../modules/langpack/langpack.h"
  #include "../modules/chat/chat.h"
  int CheckRestart();		// core: IDD_WAITRESTART
 -int LoadSystemModule(void);		// core: m_system.h services
 -int LoadNewPluginsModuleInfos(void); // core: preloading plugins
 -int LoadNewPluginsModule(void);	// core: N.O. plugins
 -int LoadSslModule(void);
 -int LoadNetlibModule(void);		// core: network
 +int  LoadSystemModule(void);		// core: m_system.h services
 +int  LoadNewPluginsModuleInfos(void); // core: preloading plugins
 +int  LoadNewPluginsModule(void);	// core: N.O. plugins
 +int  LoadSslModule(void);
 +int  LoadNetlibModule(void);		// core: network
  void NetlibInitSsl(void);
 -int LoadLangpackModule(void);	// core: translation
 -int LoadProtocolsModule(void);	// core: protocol manager
 -int LoadAccountsModule(void);    // core: account manager
 -int LoadIgnoreModule(void);		// protocol filter: ignore
 -int LoadDbintfModule(void);
 -int LoadEventsModule(void);
 -int LoadSrmmModule(void);
 -
 -int LoadContactsModule(void);
 -int LoadContactListModule(void);// ui: clist
 -int LoadDatabaseModule(void);
 -int LoadMetacontacts(void);
 -int LoadOptionsModule(void);	// ui: options dialog
 -int LoadFindAddModule(void);	// ui: search/add users
 -int LoadSkinIcons(void);
 -int LoadSkinSounds(void);
 -int LoadSkinHotkeys(void);
 -int LoadUserInfoModule(void);	// ui: user info
 -int LoadVisibilityModule(void);	// ui: visibility control
 -
 -int LoadPluginOptionsModule(void);	// ui: plugin viewer
 -int LoadAddContactModule(void);	// ui: authcontrol contacts
 -int LoadUtilsModule(void);		// ui: utils (has a few window classes, like HyperLink)
 -int LoadCLCModule(void);		// window class: CLC control
 -int LoadButtonModule(void);		// window class: button class
 -int LoadFontserviceModule(void); // ui: font manager
 -int LoadIcoLibModule(void);   // ui: icons manager
 -int LoadServiceModePlugin(void);
 -int LoadDefaultServiceModePlugin(void);
 -int LoadErrorsModule(void);
 +int  LoadLangpackModule(void);	// core: translation
 +int  LoadProtocolsModule(void);	// core: protocol manager
 +int  LoadAccountsModule(void);    // core: account manager
 +int  LoadIgnoreModule(void);		// protocol filter: ignore
 +int  LoadDbintfModule(void);
 +int  LoadEventsModule(void);
 +int  LoadSrmmModule(void);
 +
 +int  LoadContactsModule(void);
 +int  LoadContactListModule(void);// ui: clist
 +int  LoadDatabaseModule(void);
 +int  LoadMetacontacts(void);
 +int  LoadOptionsModule(void);	// ui: options dialog
 +int  LoadFindAddModule(void);	// ui: search/add users
 +int  LoadSkinIcons(void);
 +int  LoadSkinSounds(void);
 +int  LoadSkinHotkeys(void);
 +int  LoadUserInfoModule(void);	// ui: user info
 +int  LoadVisibilityModule(void);	// ui: visibility control
 +
 +int  LoadPluginOptionsModule(void);	// ui: plugin viewer
 +int  LoadAddContactModule(void);	// ui: authcontrol contacts
 +int  LoadUtilsModule(void);		// ui: utils (has a few window classes, like HyperLink)
 +int  LoadCLCModule(void);		// window class: CLC control
 +int  LoadButtonModule(void);		// window class: button class
 +int  LoadFontserviceModule(void); // ui: font manager
 +int  LoadIcoLibModule(void);   // ui: icons manager
 +int  LoadServiceModePlugin(void);
 +int  LoadDefaultServiceModePlugin(void);
 +int  LoadErrorsModule(void);
  void UnloadAccountsModule(void);
  void UnloadButtonModule(void);
 @@ -84,9 +85,9 @@ void UnloadSrmmModule(void);  void UnloadSslModule(void);
  void UnloadUtilsModule(void);
 -int LoadIcoTabsModule();
 -int LoadHeaderbarModule();
 -int LoadDescButtonModule();
 +int  LoadIcoTabsModule();
 +int  LoadHeaderbarModule();
 +int  LoadDescButtonModule();
  int LoadDefaultModules(void)
  {
 @@ -154,6 +155,7 @@ int LoadDefaultModules(void)  	if (LoadNewPluginsModule()) return 1;    // will call Load(void) on everything, clist will load first
 +	Langpack_LoadLangpack();
  	Langpack_SortDuplicates();
  	if (LoadAccountsModule()) return 1;
 diff --git a/src/mir_core/langpack.cpp b/src/mir_core/langpack.cpp index dab2a777ad..64a94bc57c 100644 --- a/src/mir_core/langpack.cpp +++ b/src/mir_core/langpack.cpp @@ -21,7 +21,9 @@ 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 "commonheaders.h"
 +#include "../modules/langpack/langpack.h"
  #define LANGPACK_BUF_SIZE 4000
 @@ -45,20 +47,10 @@ struct LangPackEntry  	LangPackEntry* pNext;  // for langpack items with the same hash value
  };
 -struct
 -{
 -	TCHAR filename[MAX_PATH];
 -	TCHAR filePath[MAX_PATH];
 -	char  language[64];
 -	char  lastModifiedUsing[64];
 -	char  authors[256];
 -	char  authorEmail[128];
 -	LangPackEntry *entry;
 -	int entryCount, entriesAlloced;
 -	LCID localeID;
 -	UINT defaultANSICp;
 -}
 -static langPack;
 +static LANGPACK_INFO langPack;
 +
 +static LangPackEntry *g_pEntries;
 +static int g_entryCount, g_entriesAlloced;
  static int IsEmpty(const char *str)
  {
 @@ -223,13 +215,13 @@ static void LoadLangPackFile(FILE *fp, char *line, UINT fileCp)  			if (!memcmp(line + 1, "include", 7)) {
  				TCHAR tszFileName[MAX_PATH];
  				TCHAR* fileName = mir_a2t(ltrim(line + 9));
 -				mir_sntprintf(tszFileName, SIZEOF(tszFileName), _T("%s%s"), langPack.filePath, fileName);
 +				mir_sntprintf(tszFileName, SIZEOF(tszFileName), _T("%s%s"), langPack.tszFullPath, fileName);
  				mir_free(fileName);
  				FILE *p = _tfopen(tszFileName, _T("r"));
  				if (p) {
  					line[0] = 0;
 -					fgets(line, SIZEOF(line), p);
 +					fgets(line, LANGPACK_BUF_SIZE, p);
  					UINT fileCp = CP_ACP;
  					if (strlen(line) >= 3 && line[0] == '\xef' && line[1] == '\xbb' && line[2] == '\xbf') {
 @@ -237,7 +229,7 @@ static void LoadLangPackFile(FILE *fp, char *line, UINT fileCp)  						fseek(p, 3, SEEK_SET);
  					}
  					else {
 -						fileCp = langPack.defaultANSICp;
 +						fileCp = langPack.codepage;
  						fseek(p, 0, SEEK_SET);
  					}
 @@ -265,17 +257,17 @@ static void LoadLangPackFile(FILE *fp, char *line, UINT fileCp)  		size_t cbLen = strlen(line) - 1;
  		if (cFirst == '[' && line[cbLen] == ']') {
 -			if (langPack.entryCount && langPack.entry[langPack.entryCount - 1].wszLocal == NULL)
 -				langPack.entryCount--;
 +			if (g_entryCount && g_pEntries[g_entryCount-1].wszLocal == NULL)
 +				g_entryCount--;
  			char *pszLine = line + 1;
  			line[cbLen] = '\0';
 -			if (++langPack.entryCount > langPack.entriesAlloced) {
 -				langPack.entriesAlloced += 128;
 -				langPack.entry = (LangPackEntry*)mir_realloc(langPack.entry, sizeof(LangPackEntry)*langPack.entriesAlloced);
 +			if (++g_entryCount > g_entriesAlloced) {
 +				g_entriesAlloced += 128;
 +				g_pEntries = (LangPackEntry*)mir_realloc(g_pEntries, sizeof(LangPackEntry)*g_entriesAlloced);
  			}
 -			LangPackEntry *E = &langPack.entry[langPack.entryCount - 1];
 +			LangPackEntry *E = &g_pEntries[g_entryCount - 1];
  			E->englishHash = mir_hashstr(pszLine);
  			E->szLocal = NULL;
  			E->wszLocal = NULL;
 @@ -284,10 +276,10 @@ static void LoadLangPackFile(FILE *fp, char *line, UINT fileCp)  			continue;
  		}
 -		if (!langPack.entryCount)
 +		if (!g_entryCount)
  			continue;
 -		LangPackEntry *E = &langPack.entry[langPack.entryCount - 1];
 +		LangPackEntry *E = &g_pEntries[g_entryCount - 1];
  		int iNeeded = MultiByteToWideChar(fileCp, 0, line, -1, 0, 0), iOldLen;
  		if (E->wszLocal == NULL) {
  			iOldLen = 0;
 @@ -303,25 +295,11 @@ static void LoadLangPackFile(FILE *fp, char *line, UINT fileCp)  	}
  }
 -MIR_CORE_DLL(int) LoadLangPack(const TCHAR *szLangPack)
 +static int LoadLangDescr(LANGPACK_INFO &lpinfo, FILE *fp, char *line, int &startOfLine, UINT &fileCp)
  {
 -	int startOfLine = 0;
 -	USHORT langID;
 -
 -	lstrcpy(langPack.filename, szLangPack);
 -	lstrcpy(langPack.filePath, szLangPack);
 -	TCHAR *p = _tcsrchr(langPack.filePath, '\\');
 -	if (p)
 -		p[1] = 0;
 -
 -	FILE *fp = _tfopen(szLangPack, _T("rt"));
 -	if (fp == NULL)
 -		return 1;
 -
 -	char line[LANGPACK_BUF_SIZE] = "";
 -	fgets(line, SIZEOF(line), fp);
 +	char szLanguage[64]; szLanguage[0] = 0;
 -	UINT fileCp = CP_ACP;
 +	fgets(line, LANGPACK_BUF_SIZE, fp);
  	size_t lineLen = strlen(line);
  	if (lineLen >= 3 && line[0] == '\xef' && line[1] == '\xbb' && line[2] == '\xbf') {
  		fileCp = CP_UTF8;
 @@ -329,15 +307,13 @@ MIR_CORE_DLL(int) LoadLangPack(const TCHAR *szLangPack)  	}
  	lrtrim(line);
 -	if (lstrcmpA(line, "Miranda Language Pack Version 1")) {
 -		fclose(fp);
 +	if (lstrcmpA(line, "Miranda Language Pack Version 1"))
  		return 2;
 -	}
 -	//headers
 +	// headers
  	while (!feof(fp)) {
  		startOfLine = ftell(fp);
 -		if (fgets(line, SIZEOF(line), fp) == NULL)
 +		if (fgets(line, LANGPACK_BUF_SIZE, fp) == NULL)
  			break;
  		lrtrim(line);
 @@ -348,39 +324,94 @@ MIR_CORE_DLL(int) LoadLangPack(const TCHAR *szLangPack)  			break;
  		char *pszColon = strchr(line, ':');
 -		if (pszColon == NULL) {
 -			fclose(fp);
 +		if (pszColon == NULL)
  			return 3;
 -		}
  		*pszColon++ = 0;
 -		if (!lstrcmpA(line, "Language")) { mir_snprintf(langPack.language, sizeof(langPack.language), "%s", pszColon); lrtrim(langPack.language); }
 -		else if (!lstrcmpA(line, "Last-Modified-Using")) { mir_snprintf(langPack.lastModifiedUsing, sizeof(langPack.lastModifiedUsing), "%s", pszColon); lrtrim(langPack.lastModifiedUsing); }
 -		else if (!lstrcmpA(line, "Authors")) { mir_snprintf(langPack.authors, sizeof(langPack.authors), "%s", pszColon); lrtrim(langPack.authors); }
 -		else if (!lstrcmpA(line, "Author-email")) { mir_snprintf(langPack.authorEmail, sizeof(langPack.authorEmail), "%s", pszColon); lrtrim(langPack.authorEmail); }
 +		if (!lstrcmpA(line, "Language")) { mir_snprintf(szLanguage, sizeof(szLanguage), "%s", pszColon); lrtrim(szLanguage); }
 +		else if (!lstrcmpA(line, "Last-Modified-Using")) { mir_snprintf(lpinfo.szLastModifiedUsing, sizeof(lpinfo.szLastModifiedUsing), "%s", pszColon); lrtrim(lpinfo.szLastModifiedUsing); }
 +		else if (!lstrcmpA(line, "Authors")) { mir_snprintf(lpinfo.szAuthors, sizeof(lpinfo.szAuthors), "%s", pszColon); lrtrim(lpinfo.szAuthors); }
 +		else if (!lstrcmpA(line, "Author-email")) { mir_snprintf(lpinfo.szAuthorEmail, sizeof(lpinfo.szAuthorEmail), "%s", pszColon); lrtrim(lpinfo.szAuthorEmail); }
  		else if (!lstrcmpA(line, "Locale")) {
  			char szBuf[20], *stopped;
  			lrtrim(pszColon + 1);
 -			langID = (USHORT)strtol(pszColon, &stopped, 16);
 -			langPack.localeID = MAKELCID(langID, 0);
 -			GetLocaleInfoA(langPack.localeID, LOCALE_IDEFAULTANSICODEPAGE, szBuf, 10);
 +			USHORT langID = (USHORT)strtol(pszColon, &stopped, 16);
 +			lpinfo.Locale = MAKELCID(langID, 0);
 +			GetLocaleInfoA(lpinfo.Locale, LOCALE_IDEFAULTANSICODEPAGE, szBuf, 10);
  			szBuf[5] = 0;                       // codepages have max. 5 digits
 -			langPack.defaultANSICp = atoi(szBuf);
 +			lpinfo.codepage = atoi(szBuf);
  			if (fileCp == CP_ACP)
 -				fileCp = langPack.defaultANSICp;
 +				fileCp = lpinfo.codepage;
  		}
  	}
 -	//body
 +	MultiByteToWideChar(lpinfo.codepage, 0, szLanguage, -1, lpinfo.tszLanguage, SIZEOF(lpinfo.tszLanguage));
 +
 +	if (!lpinfo.tszLanguage[0] && (lpinfo.Locale == 0) || !GetLocaleInfo(lpinfo.Locale, LOCALE_SENGLANGUAGE, lpinfo.tszLanguage, sizeof(lpinfo.tszLanguage))) {
 +		TCHAR *p = _tcschr(lpinfo.tszFileName, '_');
 +		lstrcpyn(lpinfo.tszLanguage, p != NULL ? p + 1 : lpinfo.tszFileName, sizeof(lpinfo.tszLanguage));
 +		p = _tcsrchr(lpinfo.tszLanguage, _T('.'));
 +		if (p != NULL) *p = '\0';
 +	}
 +	return 0;
 +}
 +
 +MIR_CORE_DLL(int) LoadLangPack(const TCHAR *szLangPack)
 +{
 +	lstrcpy(langPack.tszFileName, szLangPack);
 +	lstrcpy(langPack.tszFullPath, szLangPack);
 +	TCHAR *p = _tcsrchr(langPack.tszFullPath, '\\');
 +	if (p)
 +		p[1] = 0;
 +
 +	FILE *fp = _tfopen(szLangPack, _T("rt"));
 +	if (fp == NULL)
 +		return 1;
 +
 +	char line[LANGPACK_BUF_SIZE] = "";
 +	UINT fileCp = CP_ACP;
 +	int startOfLine = 0;
 +	if (LoadLangDescr(langPack, fp, line, startOfLine, fileCp)) {
 +		fclose(fp);
 +		return 1;
 +	}
 +
 +	// body
  	fseek(fp, startOfLine, SEEK_SET);
 -	langPack.entriesAlloced = 0;
 +	g_entriesAlloced = 0;
  	LoadLangPackFile(fp, line, fileCp);
  	fclose(fp);
  	pCurrentMuuid = NULL;
 -	qsort(langPack.entry, langPack.entryCount, sizeof(LangPackEntry), (int(*)(const void*, const void*))SortLangPackHashesProc);
 +	qsort(g_pEntries, g_entryCount, sizeof(LangPackEntry), (int(*)(const void*, const void*))SortLangPackHashesProc);
 +	return 0;
 +}
 +
 +MIR_CORE_DLL(int) LoadLangPackDescr(const TCHAR *szLangPack, LANGPACK_INFO *lpInfo)
 +{
 +	if (lpInfo == NULL)
 +		return 1;
 +
 +	lstrcpy(lpInfo->tszFileName, szLangPack);
 +	lstrcpy(lpInfo->tszFullPath, szLangPack);
 +	TCHAR *p = _tcsrchr(lpInfo->tszFullPath, '\\');
 +	if (p)
 +		p[1] = 0;
 +
 +	FILE *fp = _tfopen(szLangPack, _T("rt"));
 +	if (fp == NULL)
 +		return 1;
 +
 +	char line[LANGPACK_BUF_SIZE] = "";
 +	UINT fileCp = CP_ACP;
 +	int startOfLine = 0;
 +	if (LoadLangDescr(*lpInfo, fp, line, startOfLine, fileCp)) {
 +		fclose(fp);
 +		return 1;
 +	}
 +
  	return 0;
  }
 @@ -395,12 +426,12 @@ static int SortLangPackHashesProc2(LangPackEntry *arg1, LangPackEntry *arg2)  static char *LangPackTranslateString(MUUID *pUuid, const char *szEnglish, const int W)
  {
 -	if (langPack.entryCount == 0 || szEnglish == NULL)
 +	if (g_entryCount == 0 || szEnglish == NULL)
  		return (char*)szEnglish;
  	LangPackEntry key, *entry;
  	key.englishHash = W ? hashstrW(szEnglish) : mir_hashstr(szEnglish);
 -	entry = (LangPackEntry*)bsearch(&key, langPack.entry, langPack.entryCount, sizeof(LangPackEntry), (int(*)(const void*, const void*))SortLangPackHashesProc2);
 +	entry = (LangPackEntry*)bsearch(&key, g_pEntries, g_entryCount, sizeof(LangPackEntry), (int(*)(const void*, const void*))SortLangPackHashesProc2);
  	if (entry == NULL)
  		return (char*)szEnglish;
 @@ -418,18 +449,18 @@ static char *LangPackTranslateString(MUUID *pUuid, const char *szEnglish, const  		return (char*)entry->wszLocal;
  	if (entry->szLocal == NULL && entry->wszLocal != NULL)
 -		entry->szLocal = mir_u2a_cp(entry->wszLocal, langPack.defaultANSICp);
 +		entry->szLocal = mir_u2a_cp(entry->wszLocal, langPack.codepage);
  	return entry->szLocal;
  }
  MIR_CORE_DLL(int) Langpack_GetDefaultCodePage()
  {
 -	return langPack.defaultANSICp;
 +	return langPack.codepage;
  }
  MIR_CORE_DLL(int) Langpack_GetDefaultLocale()
  {
 -	return (langPack.localeID == 0) ? LOCALE_USER_DEFAULT : langPack.localeID;
 +	return (langPack.Locale == 0) ? LOCALE_USER_DEFAULT : langPack.Locale;
  }
  MIR_CORE_DLL(TCHAR*) Langpack_PcharToTchar(const char *pszStr)
 @@ -541,14 +572,14 @@ MIR_CORE_DLL(int) Langpack_MarkPluginLoaded(PLUGININFOEX *pInfo)  MIR_CORE_DLL(void) Langpack_SortDuplicates(void)
  {
 -	if (langPack.entryCount == 0)
 +	if (g_entryCount == 0)
  		return;
 -	LangPackEntry *s = langPack.entry + 1, *d = s, *pLast = langPack.entry;
 -	DWORD dwSavedHash = langPack.entry->englishHash;
 +	LangPackEntry *s = g_pEntries + 1, *d = s, *pLast = g_pEntries;
 +	DWORD dwSavedHash = g_pEntries->englishHash;
  	bool bSortNeeded = false;
 -	for (int i = 1; i < langPack.entryCount; i++, s++) {
 +	for (int i = 1; i < g_entryCount; i++, s++) {
  		if (s->englishHash != dwSavedHash) {
  			pLast = d;
  			if (s != d)
 @@ -566,8 +597,8 @@ MIR_CORE_DLL(void) Langpack_SortDuplicates(void)  	}
  	if (bSortNeeded) {
 -		langPack.entryCount = (int)(d - langPack.entry);
 -		qsort(langPack.entry, langPack.entryCount, sizeof(LangPackEntry), (int(*)(const void*, const void*))SortLangPackHashesProc);
 +		g_entryCount = (int)(d - g_pEntries);
 +		qsort(g_pEntries, g_entryCount, sizeof(LangPackEntry), (int(*)(const void*, const void*))SortLangPackHashesProc);
  	}
  }
 @@ -580,17 +611,6 @@ MIR_CORE_DLL(int) LoadLangPackModule(void)  	ZeroMemory(&langPack, sizeof(langPack));
  	hevChanged = CreateHookableEvent(ME_LANGPACK_CHANGED);
 -
 -	TCHAR szSearch[MAX_PATH];
 -	PathToAbsoluteT(_T("langpack_*.txt"), szSearch);
 -
 -	WIN32_FIND_DATA fd;
 -	HANDLE hFind = FindFirstFile(szSearch, &fd);
 -	if (hFind != INVALID_HANDLE_VALUE) {
 -		PathToAbsoluteT(fd.cFileName, szSearch);
 -		FindClose(hFind);
 -		LoadLangPack(szSearch);
 -	}
  	return 0;
  }
 @@ -603,8 +623,8 @@ void UnloadLangPackModule()  		mir_free(lMuuids[i]);
  	lMuuids.destroy();
 -	LangPackEntry *p = langPack.entry;
 -	for (i = 0; i < langPack.entryCount; i++, p++) {
 +	LangPackEntry *p = g_pEntries;
 +	for (i = 0; i < g_entryCount; i++, p++) {
  		if (p->pNext != NULL) {
  			for (LangPackEntry *p1 = p->pNext; p1 != NULL;) {
  				LangPackEntry *p2 = p1; p1 = p1->pNext;
 @@ -618,10 +638,10 @@ void UnloadLangPackModule()  		mir_free(p->wszLocal);
  	}
 -	if (langPack.entryCount) {
 -		mir_free(langPack.entry);
 -		langPack.entry = 0;
 -		langPack.entryCount = 0;
 +	if (g_entryCount) {
 +		mir_free(g_pEntries);
 +		g_pEntries = 0;
 +		g_entryCount = 0;
  	}
  }
 @@ -630,7 +650,7 @@ void UnloadLangPackModule()  MIR_CORE_DLL(void) ReloadLangpack(TCHAR *pszStr)
  {
  	if (pszStr == NULL)
 -		pszStr = langPack.filename;
 +		pszStr = langPack.tszFileName;
  	UnloadLangPackModule();
  	LoadLangPack(pszStr);
 diff --git a/src/mir_core/mir_core.def b/src/mir_core/mir_core.def index 1bcaa310cc..3a30eaea4a 100644 --- a/src/mir_core/mir_core.def +++ b/src/mir_core/mir_core.def @@ -261,3 +261,4 @@ db_mc_setDefaultNum           @258  mir_closeLog                  @259
  db_mc_enable                  @260
  db_mc_isEnabled               @261
 +LoadLangPackDescr             @262
 diff --git a/src/miranda32_10.vcxproj b/src/miranda32_10.vcxproj index ea739cbd45..910f4525df 100644 --- a/src/miranda32_10.vcxproj +++ b/src/miranda32_10.vcxproj @@ -264,6 +264,7 @@      <ClInclude Include="modules\extraicons\extraicons.h" />
      <ClInclude Include="modules\extraicons\usedIcons.h" />
      <ClInclude Include="modules\findadd\findadd.h" />
 +    <ClInclude Include="modules\langpack\langpack.h" />
      <ClInclude Include="modules\metacontacts\metacontacts.h" />
      <ClInclude Include="modules\netlib\netlib.h" />
      <ClInclude Include="modules\options\filter.h" />
 @@ -276,6 +277,7 @@      <ClInclude Include="modules\icolib\IcoLib.h" />
      <ClInclude Include="..\include\m_xml.h" />
      <ClInclude Include="modules\xml\xmlParser.h" />
 +    <ClInclude Include="resource.h" />
    </ItemGroup>
    <ItemGroup>
      <ClCompile Include="core\stdafx.cpp">
 @@ -371,6 +373,12 @@      <ClCompile Include="modules\ignore\ignore.cpp">
        <PrecompiledHeaderFile>..\..\core\commonheaders.h</PrecompiledHeaderFile>
      </ClCompile>
 +    <ClCompile Include="modules\langpack\langpack.cpp">
 +      <PrecompiledHeaderFile>..\..\core\commonheaders.h</PrecompiledHeaderFile>
 +    </ClCompile>
 +    <ClCompile Include="modules\langpack\lpopts.cpp">
 +      <PrecompiledHeaderFile>..\..\core\commonheaders.h</PrecompiledHeaderFile>
 +    </ClCompile>
      <ClCompile Include="modules\langpack\lpservices.cpp">
        <PrecompiledHeaderFile>..\..\core\commonheaders.h</PrecompiledHeaderFile>
      </ClCompile>
 diff --git a/src/miranda32_10.vcxproj.filters b/src/miranda32_10.vcxproj.filters index 69b91ede81..6d57666c92 100644 --- a/src/miranda32_10.vcxproj.filters +++ b/src/miranda32_10.vcxproj.filters @@ -79,6 +79,9 @@      <Filter Include="Modules\metacontacts">
        <UniqueIdentifier>{79f0ee25-4708-4fd6-aeef-fb5f2628008b}</UniqueIdentifier>
      </Filter>
 +    <Filter Include="Resources\Icons">
 +      <UniqueIdentifier>{7fbe104f-6dd8-45f8-8c9e-29b2e254d2ee}</UniqueIdentifier>
 +    </Filter>
    </ItemGroup>
    <ItemGroup>
      <ClInclude Include="..\include\m_addcontact.h">
 @@ -267,6 +270,10 @@      <ClInclude Include="..\include\m_metacontacts.h">
        <Filter>Modules\metacontacts</Filter>
      </ClInclude>
 +    <ClInclude Include="modules\langpack\langpack.h">
 +      <Filter>Modules\langpack</Filter>
 +    </ClInclude>
 +    <ClInclude Include="resource.h" />
    </ItemGroup>
    <ItemGroup>
      <ClCompile Include="core\commonheaders.cpp">
 @@ -614,6 +621,12 @@      <ClCompile Include="modules\metacontacts\meta_edit.cpp">
        <Filter>Modules\metacontacts</Filter>
      </ClCompile>
 +    <ClCompile Include="modules\langpack\langpack.cpp">
 +      <Filter>Modules\langpack</Filter>
 +    </ClCompile>
 +    <ClCompile Include="modules\langpack\lpopts.cpp">
 +      <Filter>Modules\langpack</Filter>
 +    </ClCompile>
    </ItemGroup>
    <ItemGroup>
      <ResourceCompile Include="resource.rc">
 diff --git a/src/miranda32_12.vcxproj b/src/miranda32_12.vcxproj index 84ae122c6c..a37070b3b8 100644 --- a/src/miranda32_12.vcxproj +++ b/src/miranda32_12.vcxproj @@ -271,6 +271,7 @@      <ClInclude Include="modules\extraicons\extraicons.h" />
      <ClInclude Include="modules\extraicons\usedIcons.h" />
      <ClInclude Include="modules\findadd\findadd.h" />
 +    <ClInclude Include="modules\langpack\langpack.h" />
      <ClInclude Include="modules\metacontacts\metacontacts.h" />
      <ClInclude Include="modules\netlib\netlib.h" />
      <ClInclude Include="modules\options\filter.h" />
 @@ -283,6 +284,7 @@      <ClInclude Include="modules\icolib\IcoLib.h" />
      <ClInclude Include="..\include\m_xml.h" />
      <ClInclude Include="modules\xml\xmlParser.h" />
 +    <ClInclude Include="resource.h" />
    </ItemGroup>
    <ItemGroup>
      <ClCompile Include="core\stdafx.cpp">
 @@ -378,6 +380,12 @@      <ClCompile Include="modules\ignore\ignore.cpp">
        <PrecompiledHeaderFile>..\..\core\commonheaders.h</PrecompiledHeaderFile>
      </ClCompile>
 +    <ClCompile Include="modules\langpack\langpack.cpp">
 +      <PrecompiledHeaderFile>..\..\core\commonheaders.h</PrecompiledHeaderFile>
 +    </ClCompile>
 +    <ClCompile Include="modules\langpack\lpopts.cpp">
 +      <PrecompiledHeaderFile>..\..\core\commonheaders.h</PrecompiledHeaderFile>
 +    </ClCompile>
      <ClCompile Include="modules\langpack\lpservices.cpp">
        <PrecompiledHeaderFile>..\..\core\commonheaders.h</PrecompiledHeaderFile>
      </ClCompile>
 diff --git a/src/miranda32_12.vcxproj.filters b/src/miranda32_12.vcxproj.filters index b712d24a4a..21b7bb2984 100644 --- a/src/miranda32_12.vcxproj.filters +++ b/src/miranda32_12.vcxproj.filters @@ -79,6 +79,9 @@      <Filter Include="Modules\metacontacts">
        <UniqueIdentifier>{79f0ee25-4708-4fd6-aeef-fb5f2628008b}</UniqueIdentifier>
      </Filter>
 +    <Filter Include="Resources\Icons">
 +      <UniqueIdentifier>{453959e1-554a-4053-b2c4-fdc3c903154f}</UniqueIdentifier>
 +    </Filter>
    </ItemGroup>
    <ItemGroup>
      <ClInclude Include="..\include\m_addcontact.h">
 @@ -276,6 +279,10 @@      <ClInclude Include="..\include\m_metacontacts.h">
        <Filter>Modules\metacontacts</Filter>
      </ClInclude>
 +    <ClInclude Include="resource.h" />
 +    <ClInclude Include="modules\langpack\langpack.h">
 +      <Filter>Modules\langpack</Filter>
 +    </ClInclude>
    </ItemGroup>
    <ItemGroup>
      <ClCompile Include="core\commonheaders.cpp">
 @@ -314,9 +321,6 @@      <ClCompile Include="modules\ignore\ignore.cpp">
        <Filter>Modules\ignore</Filter>
      </ClCompile>
 -    <ClCompile Include="modules\langpack\lpservices.cpp">
 -      <Filter>Modules\langpack</Filter>
 -    </ClCompile>
      <ClCompile Include="modules\netlib\netlib.cpp">
        <Filter>Modules\netlib</Filter>
      </ClCompile>
 @@ -623,6 +627,15 @@      <ClCompile Include="modules\metacontacts\meta_edit.cpp">
        <Filter>Modules\metacontacts</Filter>
      </ClCompile>
 +    <ClCompile Include="modules\langpack\lpservices.cpp">
 +      <Filter>Modules\langpack</Filter>
 +    </ClCompile>
 +    <ClCompile Include="modules\langpack\lpopts.cpp">
 +      <Filter>Modules\langpack</Filter>
 +    </ClCompile>
 +    <ClCompile Include="modules\langpack\langpack.cpp">
 +      <Filter>Modules\langpack</Filter>
 +    </ClCompile>
    </ItemGroup>
    <ItemGroup>
      <ResourceCompile Include="resource.rc">
 diff --git a/src/modules/langpack/langpack.cpp b/src/modules/langpack/langpack.cpp new file mode 100644 index 0000000000..56fd08f64f --- /dev/null +++ b/src/modules/langpack/langpack.cpp @@ -0,0 +1,135 @@ +/*
 +
 +Miranda NG: the free IM client for Microsoft* Windows*
 +
 +Copyright (c) 2012-14 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"));
 +
 +	LANGPACK_INFO pack;
 +	PathToAbsoluteT(_T("\\langpack_*.txt"), pack.tszFullPath);
 +
 +	BOOL fPackFound = FALSE;
 +	WIN32_FIND_DATA wfd;
 +	HANDLE hFind = FindFirstFile(pack.tszFullPath, &wfd);
 +	if (hFind != INVALID_HANDLE_VALUE) {
 +		do {
 +			if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue;
 +			/* get data */
 +			TCHAR tszFullPath[MAX_PATH];
 +			PathToAbsoluteT(_T("\\"), tszFullPath);
 +			lstrcat(tszFullPath, wfd.cFileName);
 +
 +			ZeroMemory(&pack, sizeof(pack));
 +			if (!LoadLangPackDescr(tszFullPath, &pack)) {
 +				pack.ftFileDate = wfd.ftLastWriteTime;
 +				/* enabled? */
 +				if (langpack && !lstrcmpi(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) {
 +		ZeroMemory(&pack, sizeof(pack));
 +		pack.Locale = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT);
 +		lstrcpy(pack.tszLanguage, _T("English"));
 +		lstrcpyA(pack.szAuthors, "Miranda NG Development Team");
 +		lstrcpyA(pack.szAuthorEmail, "project-info@miranda-ng.org");
 +		DWORD v = CallService(MS_SYSTEM_GETVERSION, 0, 0);
 +		mir_snprintf(pack.szLastModifiedUsing, sizeof(pack.szLastModifiedUsing), "%d.%d.%d.%d", ((v >> 24) & 0xFF), ((v >> 16) & 0xFF), ((v >> 8) & 0xFF), (v & 0xFF));
 +		/* file date */
 +		if (GetModuleFileName(NULL, pack.tszFullPath, SIZEOF(pack.tszFullPath))) {
 +			lstrcpy(pack.tszFileName, _tcsrchr(pack.tszFullPath, '\\') + 1);
 +			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;
 +}
 +
 +/////////////////////////////////////////////////////////////////////////////////////////
 +
 +void Langpack_LoadLangpack(void)
 +{
 +	HookEvent(ME_OPT_INITIALISE, LangpackOptionsInit);
 +
 +	TCHAR szSearch[MAX_PATH];
 +	PathToAbsoluteT(_T("\\"), szSearch);
 +
 +	/* try to load langpack */
 +	ptrT langpack(db_get_tsa(NULL, "Langpack", "Current"));
 +	if (langpack && langpack[0] != '\0') {
 +		lstrcat(szSearch, langpack);
 +
 +		DWORD dwAttrib = GetFileAttributes(szSearch);
 +		if (dwAttrib != INVALID_FILE_ATTRIBUTES && !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY))
 +			LoadLangPack(szSearch);
 +	}
 +	/* else try to load first file */
 +	else if (!langpack) {
 +		lstrcat(szSearch, _T("langpack_*.txt"));
 +
 +		WIN32_FIND_DATA fd;
 +		HANDLE hFind = FindFirstFile(szSearch, &fd);
 +		if (hFind != INVALID_HANDLE_VALUE) {
 +			do {
 +				/* search first langpack that could be loaded */
 +				if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue;
 +				/* load langpack */
 +				PathToAbsoluteT(_T("\\"), szSearch);
 +				lstrcat(szSearch, fd.cFileName);
 +				if (!LoadLangPack(szSearch))
 +					db_set_ws(NULL, "Langpack", "Current", fd.cFileName);
 +				break;
 +			} while (FindNextFile(hFind, &fd));
 +			FindClose(hFind);
 +		}
 +	}
 +}
 diff --git a/src/modules/langpack/langpack.h b/src/modules/langpack/langpack.h new file mode 100644 index 0000000000..47f44de94d --- /dev/null +++ b/src/modules/langpack/langpack.h @@ -0,0 +1,63 @@ +/*
 +
 +Miranda NG: the free IM client for Microsoft* Windows*
 +
 +Copyright (c) 2012-14 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;
 +	char szAuthors[2048];
 +	char szAuthorEmail[128];
 +	char szLastModifiedUsing[64];
 +	char szPluginsIncluded[4080];
 +	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);
 +
 +void Langpack_LoadLangpack(void);
 diff --git a/src/modules/langpack/lpopts.cpp b/src/modules/langpack/lpopts.cpp new file mode 100644 index 0000000000..f52254afff --- /dev/null +++ b/src/modules/langpack/lpopts.cpp @@ -0,0 +1,189 @@ +/*
 +
 +Miranda NG: the free IM client for Microsoft* Windows*
 +
 +Copyright (c) 2012-14 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 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) - lstrlen(pszIncompat) - 1] = 0;
 +				lstrcat(lstrcat(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);
 +	
 +	/* plugins included */
 +	SetDlgItemTextA(hwndDlg, IDC_PLUGINSINCLUDED, pack->szPluginsIncluded);
 +	if (pack->szPluginsIncluded[0]) {
 +		if (!IsWindowVisible(GetDlgItem(hwndDlg, IDC_PLUGINSINCLUDEDLABEL))) {
 +			ShowWindow(GetDlgItem(hwndDlg,IDC_PLUGINSINCLUDEDLABEL), SW_SHOW);
 +			ShowWindow(GetDlgItem(hwndDlg, IDC_PLUGINSINCLUDED), SW_SHOW);
 +		}
 +	}
 +	else {
 +		ShowWindow(GetDlgItem(hwndDlg, IDC_PLUGINSINCLUDEDLABEL), SW_HIDE);
 +		ShowWindow(GetDlgItem(hwndDlg, IDC_PLUGINSINCLUDED), SW_HIDE);
 +	}
 +	
 +	/* general */
 +	SetDlgItemTextA(hwndDlg, IDC_LANGMODUSING, pack->szLastModifiedUsing);
 +	SetDlgItemTextA(hwndDlg, IDC_LANGAUTHORS, pack->szAuthors);
 +	SetDlgItemTextA(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 = (LANGPACK_INFO*)mir_alloc(sizeof(LANGPACK_INFO));
 +	if (pack2 == NULL) return FALSE;
 +	CopyMemory(pack2, pack, sizeof(LANGPACK_INFO));
 +
 +	/* 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);
 +	}
 +
 +	return TRUE;
 +}
 +
 +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_DESTROY:
 +		{
 +			int count = ListBox_GetCount(hwndList);
 +			for (int i = 0; i < count; i++)
 +				mir_free((LANGPACK_INFO*)ListBox_GetItemData(hwndList, i));
 +			ComboBox_ResetContent(hwndList);
 +		}
 +		return TRUE;
 +
 +	case WM_COMMAND:
 +		switch (LOWORD(wParam)) {
 +		case IDC_LANGEMAIL:
 +			{
 +				char buf[512];
 +				lstrcpyA(buf, "mailto:");
 +				if (GetWindowTextA(GetDlgItem(hwndDlg, LOWORD(wParam)), &buf[7], sizeof(buf)-7))
 +					CallService(MS_UTILS_OPENURL, FALSE, (LPARAM)buf);
 +			}
 +			break;
 +
 +		case IDC_MORELANG:
 +			CallService(MS_UTILS_OPENURL, TRUE, (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);
 +			}
 +		}
 +		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, idx);
 +				if (i == idx) {
 +					db_set_ws(NULL, "Langpack", "Current", pack->tszFileName);
 +					lstrcpy(tszPath, pack->tszFullPath);
 +					pack->flags |= LPF_ENABLED;
 +				}
 +				else pack->flags &= ~LPF_ENABLED;
 +			}
 +
 +			if (tszPath[0]) {
 +				CallService(MS_LANGPACK_RELOAD, 0, (LPARAM)tszPath);
 +				CloseWindow(GetParent(hwndDlg));
 +				DestroyWindow(GetParent(hwndDlg));
 +			}
 +		}
 +		break;
 +	}
 +	return FALSE;
 +}
 +
 +/////////////////////////////////////////////////////////////////////////////////////////
 +
 +int LangpackOptionsInit(WPARAM wParam, LPARAM)
 +{
 +	OPTIONSDIALOGPAGE odp = { sizeof(odp) };
 +	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/resource.h b/src/resource.h index 2b9f2f107e..5d353b048f 100644 --- a/src/resource.h +++ b/src/resource.h @@ -6,6 +6,7 @@  #define IDC_NOTOALL                     3
  #define IDC_APPLY                       3
  #define IDC_DECIDELATER                 3
 +#define IDD_OPT_LANGUAGES               101
  #define IDI_MIRANDA                     102
  #define IDD_ABOUT                       103
  #define IDI_SMS                         103
 @@ -164,28 +165,42 @@  #define IDI_AUTH_REVOKE                 327
  #define IDI_ONTHEPHONE                  1002
  #define IDC_MESSAGE                     1002
 +#define IDC_LANGINFOFRAME               1002
  #define IDI_OUTTOLUNCH                  1003
 +#define IDC_LANGAUTHORSLABEL            1003
  #define IDC_AUTOCLOSE                   1004
 +#define IDC_LANGAUTHORS                 1004
  #define IDC_FROM                        1005
  #define IDC_AUTOMIN                     1005
 +#define IDC_LANGEMAILLABEL              1005
  #define IDC_DATE                        1006
  #define IDC_DUMPRECV                    1006
 +#define IDC_LANGEMAIL                   1006
  #define IDC_AUTOCLEAR                   1007
 +#define IDC_LANGMODUSINGLABEL           1007
  #define IDC_MSG                         1008
  #define IDC_PROXYDNS                    1008
 +#define IDC_LANGMODUSING                1008
  #define IDC_NAME                        1009
  #define IDC_PROXYTYPE                   1009
 +#define IDC_LANGDATELABEL               1009
  #define IDC_STATIC23                    1010
  #define IDC_NAMEVAL                     1010
  #define IDC_LNK_NETWORK                 1010
 +#define IDC_LANGDATE                    1010
  #define IDC_LNK_ADDONS                  1011
  #define IDC_SPECIFYPORTS                1013
  #define IDC_ST_ENTERMSG                 1013
 +#define IDC_LANGLOCALELABEL             1013
  #define IDC_ST_ENTERURL                 1014
  #define IDC_SPECIFYPORTSO               1014
 +#define IDC_LANGLOCALE                  1014
  #define IDC_ENABLEUPNP                  1015
 +#define IDC_PLUGINSINCLUDEDLABEL        1015
  #define IDC_VALIDATESSL                 1016
 +#define IDC_PLUGINSINCLUDED             1016
  #define IDC_ONLYAVAIL                   1017
 +#define IDC_MORELANG                    1017
  #define IDC_METALIST                    1018
  #define IDC_CHK_SRT                     1019
  #define IDC_LST_CONTACTS                1020
 @@ -549,6 +564,8 @@  #define IDC_ADDCHECK                    1742
  #define IDC_GETMOREPLUGINS              1744
  #define IDC_DISABLEMENUICONS            1745
 +#define IDC_COMBO1                      1746
 +#define IDC_LANGUAGES                   1746
  #define IDC_EFFECT_COLOUR_TEXT1         1853
  #define IDC_EFFECT_COLOUR_SPIN1         1854
  #define IDC_EXTRAORDER                  1889
 @@ -582,12 +599,12 @@  #define ID_UNGROUP                      40067
  // Next default values for new objects
 -//
 +// 
  #ifdef APSTUDIO_INVOKED
  #ifndef APSTUDIO_READONLY_SYMBOLS
 -#define _APS_NEXT_RESOURCE_VALUE        328
 +#define _APS_NEXT_RESOURCE_VALUE        329
  #define _APS_NEXT_COMMAND_VALUE         40018
 -#define _APS_NEXT_CONTROL_VALUE         1746
 +#define _APS_NEXT_CONTROL_VALUE         1747
  #define _APS_NEXT_SYMED_VALUE           101
  #endif
  #endif
 diff --git a/src/resource.rc b/src/resource.rc index b1b875aa12..40b134a18b 100644 --- a/src/resource.rc +++ b/src/resource.rc @@ -744,7 +744,7 @@ BEGIN      CTEXT           "Please select a MetaContact:",IDC_STATIC,5,4,207,8
      DEFPUSHBUTTON   "&OK",IDOK,115,241,48,14
      PUSHBUTTON      "&Cancel",IDCANCEL,167,241,48,14
 -    LISTBOX         IDC_METALIST,4,16,211,222,LBS_NOINTEGRALHEIGHT | LBS_NOTIFY | WS_VSCROLL
 +    LISTBOX         IDC_METALIST,4,16,211,222,LBS_NOINTEGRALHEIGHT | WS_VSCROLL
      CONTROL         "Sort Alphabetically",IDC_CHK_SRT,"Button",BS_AUTOCHECKBOX | BS_VCENTER | WS_TABSTOP,6,244,104,8
  END
 @@ -824,6 +824,30 @@ BEGIN      CTEXT           "(Lower ranks are preferred)",IDC_STATIC,51,99,162,8
  END
 +IDD_OPT_LANGUAGES DIALOGEX 0, 0, 301, 232
 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
 +EXSTYLE WS_EX_CONTROLPARENT
 +FONT 8, "MS Shell Dlg", 0, 0, 0x1
 +BEGIN
 +    GROUPBOX        "",IDC_LANGINFOFRAME,5,22,291,118,WS_GROUP
 +    RTEXT           "Author(s):",IDC_LANGAUTHORSLABEL,9,32,72,9,SS_NOPREFIX
 +    EDITTEXT        IDC_LANGAUTHORS,86,32,206,25,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | NOT WS_BORDER | WS_VSCROLL
 +    RTEXT           "E-mail:",IDC_LANGEMAILLABEL,9,61,72,8,SS_NOPREFIX
 +    CONTROL         "",IDC_LANGEMAIL,"Hyperlink",WS_TABSTOP,86,61,206,10
 +    RTEXT           "Last modified using:",IDC_LANGMODUSINGLABEL,9,74,72,9,SS_NOPREFIX
 +    EDITTEXT        IDC_LANGMODUSING,86,74,206,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER
 +    RTEXT           "Date:",IDC_LANGDATELABEL,9,87,72,9,SS_NOPREFIX
 +    EDITTEXT        IDC_LANGDATE,86,87,206,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER
 +    RTEXT           "Locale:",IDC_LANGLOCALELABEL,9,99,72,9,SS_NOPREFIX
 +    EDITTEXT        IDC_LANGLOCALE,86,99,206,12,ES_READONLY | NOT WS_BORDER
 +    CONTROL         "Download more Language Packs",IDC_MORELANG,"Hyperlink",WS_GROUP | WS_TABSTOP | 0x1,9,144,283,10
 +    COMBOBOX        IDC_LANGUAGES,86,4,210,30,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
 +    RTEXT           "Current language:",IDC_STATIC,5,7,76,8
 +    RTEXT           "Plugins included:",IDC_PLUGINSINCLUDEDLABEL,9,112,72,9,SS_NOPREFIX
 +    EDITTEXT        IDC_PLUGINSINCLUDED,86,112,205,24,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | NOT WS_BORDER | WS_VSCROLL
 +END
 +
 +
  /////////////////////////////////////////////////////////////////////////////
  //
  // DESIGNINFO
 @@ -994,6 +1018,10 @@ BEGIN          BOTTOMMARGIN, 241
      END
 +    IDD_OPT_KEYBINDINGS, DIALOG
 +    BEGIN
 +    END
 +
      IDD_ACCMGR, DIALOG
      BEGIN
          VERTGUIDE, 7
 @@ -1086,6 +1114,17 @@ BEGIN      IDD_METAEDIT, DIALOG
      BEGIN
      END
 +
 +    IDD_OPT_LANGUAGES, DIALOG
 +    BEGIN
 +        VERTGUIDE, 5
 +        VERTGUIDE, 9
 +        VERTGUIDE, 81
 +        VERTGUIDE, 86
 +        VERTGUIDE, 292
 +        VERTGUIDE, 296
 +        BOTTOMMARGIN, 227
 +    END
  END
  #endif    // APSTUDIO_INVOKED
  | 
