diff options
author | George Hazan <george.hazan@gmail.com> | 2014-03-23 21:16:11 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-03-23 21:16:11 +0000 |
commit | d8a81a7a63b37b760d5c22641ed4f4b1cfbb232a (patch) | |
tree | a7494e040b919b674d4e26d572efd58ef45d0f49 /src | |
parent | 53be8fe2c490da232c7ec7e87c1a5d65a1215241 (diff) |
code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@8725 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r-- | src/core/miranda.h | 1 | ||||
-rw-r--r-- | src/modules/database/database.cpp | 1 | ||||
-rw-r--r-- | src/modules/database/dbini.cpp | 2 | ||||
-rw-r--r-- | src/modules/database/profilemanager.cpp | 3 | ||||
-rw-r--r-- | src/modules/langpack/langpack.cpp | 52 | ||||
-rw-r--r-- | src/modules/plugins/newplugins.cpp | 10 |
6 files changed, 38 insertions, 31 deletions
diff --git a/src/core/miranda.h b/src/core/miranda.h index 83af987c5a..29c3e48a5b 100644 --- a/src/core/miranda.h +++ b/src/core/miranda.h @@ -74,6 +74,7 @@ void KillModuleSounds(int hLangpack); extern HINSTANCE hInst;
extern DWORD hMainThreadId;
extern HANDLE hOkToExitEvent, hModulesLoadedEvent, hevLoadModule, hevUnloadModule;
+extern TCHAR mirandabootini[MAX_PATH];
/**** newplugins.cpp *******************************************************************/
diff --git a/src/modules/database/database.cpp b/src/modules/database/database.cpp index 05c9141a73..58112c2ac4 100644 --- a/src/modules/database/database.cpp +++ b/src/modules/database/database.cpp @@ -26,7 +26,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "profilemanager.h"
// contains the location of mirandaboot.ini
-extern TCHAR mirandabootini[MAX_PATH];
bool g_bDbCreated;
TCHAR g_profileDir[MAX_PATH], g_profileName[MAX_PATH], g_shortProfileName[MAX_PATH];
TCHAR* g_defaultProfile;
diff --git a/src/modules/database/dbini.cpp b/src/modules/database/dbini.cpp index 022f4c1188..ebcf7e3e89 100644 --- a/src/modules/database/dbini.cpp +++ b/src/modules/database/dbini.cpp @@ -28,8 +28,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static bool bModuleInitialized = false;
static HANDLE hIniChangeNotification;
-extern TCHAR mirandabootini[MAX_PATH];
-
static INT_PTR CALLBACK InstallIniDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) {
diff --git a/src/modules/database/profilemanager.cpp b/src/modules/database/profilemanager.cpp index 05c44aa603..30704d902d 100644 --- a/src/modules/database/profilemanager.cpp +++ b/src/modules/database/profilemanager.cpp @@ -24,6 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "..\..\core\commonheaders.h"
#include "..\plugins\plugins.h"
+#include "..\langpack\langpack.h"
#include "profilemanager.h"
#include <sys/stat.h>
@@ -799,6 +800,8 @@ static int AddProfileManagerPage(struct DetailsPageInit *opi, OPTIONSDIALOGPAGE int getProfileManager(PROFILEMANAGERDATA * pd)
{
+ Langpack_LoadLangpack();
+
DetailsPageInit opi = { 0 };
OPTIONSDIALOGPAGE odp = { sizeof(odp) };
diff --git a/src/modules/langpack/langpack.cpp b/src/modules/langpack/langpack.cpp index 80fa824b01..9d6f1fc914 100644 --- a/src/modules/langpack/langpack.cpp +++ b/src/modules/langpack/langpack.cpp @@ -101,33 +101,43 @@ void Langpack_LoadLangpack(void) TCHAR szSearch[MAX_PATH];
PathToAbsoluteT(_T("\\"), szSearch);
- /* try to load langpack */
+ // try to get the langpack's name from a profile first
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))
+ 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);
+ return;
}
}
+
+ // look into mirandaboot.ini
+ TCHAR tszDefaultLang[100];
+ if (GetPrivateProfileString(_T("Language"), _T("DefaultLanguage"), _T(""), tszDefaultLang, SIZEOF(tszDefaultLang), mirandabootini)) {
+ TCHAR tszLangPath[MAX_PATH];
+ PathToAbsoluteT(tszDefaultLang, tszLangPath);
+ LoadLangPack(tszLangPath);
+ return;
+ }
+
+ // finally try to load first file
+ 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/plugins/newplugins.cpp b/src/modules/plugins/newplugins.cpp index 8a33ddbea1..5a3ea6a735 100644 --- a/src/modules/plugins/newplugins.cpp +++ b/src/modules/plugins/newplugins.cpp @@ -26,6 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "plugins.h"
#include "..\database\profilemanager.h"
+#include "..\langpack\langpack.h"
void LoadExtraIconsModule();
@@ -652,6 +653,8 @@ static int LaunchServicePlugin(pluginEntry *p) p->pclass |= PCLASS_LOADED;
}
+ Langpack_LoadLangpack();
+
INT_PTR res = CallService(MS_SERVICEMODE_LAUNCH, 0, 0);
if (res != CALLSERVICE_NOTFOUND)
return res;
@@ -819,13 +822,6 @@ int LoadNewPluginsModuleInfos(void) // remember where the mirandaboot.ini goes
PathToAbsoluteT(_T("mirandaboot.ini"), mirandabootini);
- TCHAR tszDefaultLang[100];
- if (GetPrivateProfileString(_T("Language"), _T("DefaultLanguage"), _T(""), tszDefaultLang, SIZEOF(tszDefaultLang), mirandabootini)) {
- TCHAR tszLangPath[MAX_PATH];
- PathToAbsoluteT(tszDefaultLang, tszLangPath);
- LoadLangPack(tszLangPath);
- }
-
// look for all *.dll's
enumPlugins(scanPluginsDir, 0, 0);
|