diff options
author | George Hazan <george.hazan@gmail.com> | 2012-07-04 14:14:58 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-07-04 14:14:58 +0000 |
commit | f5baf2606966349e067d423a596722b66c401651 (patch) | |
tree | d501fa4b011c2c074b12e48284f5f2b824d971b0 /src/modules | |
parent | fc477d493da24a91dd9d095fbcf74a9b09c15fa8 (diff) |
- internal langpack preparation for hLangpack-dependent resource cleaning
- langpack functions' names normalization (2Awk: safe for plugins written in Delphi)
git-svn-id: http://svn.miranda-ng.org/main/trunk@758 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/button/button.cpp | 2 | ||||
-rw-r--r-- | src/modules/clist/genmenuopt.cpp | 2 | ||||
-rw-r--r-- | src/modules/database/dbini.cpp | 2 | ||||
-rw-r--r-- | src/modules/database/profilemanager.cpp | 6 | ||||
-rw-r--r-- | src/modules/fonts/FontService.cpp | 2 | ||||
-rw-r--r-- | src/modules/langpack/lpservices.cpp | 10 | ||||
-rw-r--r-- | src/modules/options/filter.h | 2 | ||||
-rw-r--r-- | src/modules/options/options.cpp | 16 | ||||
-rw-r--r-- | src/modules/plugins/newplugins.cpp | 97 | ||||
-rw-r--r-- | src/modules/plugins/pluginopts.cpp | 2 | ||||
-rw-r--r-- | src/modules/userinfo/userinfo.cpp | 4 |
11 files changed, 70 insertions, 75 deletions
diff --git a/src/modules/button/button.cpp b/src/modules/button/button.cpp index 2f7fce43f4..75c4148980 100644 --- a/src/modules/button/button.cpp +++ b/src/modules/button/button.cpp @@ -509,7 +509,7 @@ static LRESULT CALLBACK MButtonWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, L if (lParam & BATF_UNICODE)
ti.lpszText = mir_wstrdup(TranslateW((WCHAR*)wParam));
else
- ti.lpszText = LangPackPcharToTchar((char*)wParam);
+ ti.lpszText = Langpack_PcharToTchar((char*)wParam);
if (bct->pAccPropServices) {
wchar_t *tmpstr = mir_t2u(ti.lpszText);
bct->pAccPropServices->SetHwndPropStr(bct->hwnd, OBJID_CLIENT,
diff --git a/src/modules/clist/genmenuopt.cpp b/src/modules/clist/genmenuopt.cpp index c2ecc3f18b..4ec48d0e20 100644 --- a/src/modules/clist/genmenuopt.cpp +++ b/src/modules/clist/genmenuopt.cpp @@ -145,7 +145,7 @@ static int BuildMenuObjectsTree(HWND hwndDlg) continue;
tvis.item.lParam = (LPARAM)g_menus[i]->id;
- tvis.item.pszText = LangPackPcharToTchar(g_menus[i]->Name);
+ tvis.item.pszText = Langpack_PcharToTchar(g_menus[i]->Name);
tvis.item.iImage = tvis.item.iSelectedImage = TRUE;
TreeView_InsertItem(hTree, &tvis);
mir_free(tvis.item.pszText);
diff --git a/src/modules/database/dbini.cpp b/src/modules/database/dbini.cpp index af15390857..70c1f965af 100644 --- a/src/modules/database/dbini.cpp +++ b/src/modules/database/dbini.cpp @@ -326,7 +326,7 @@ static void ProcessIniFile(TCHAR* szIniPath, char *szSafeSections, char *szUnsaf break;
case 'e':
case 'E':
- ConvertBackslashes(szValue+1, LangPackGetDefaultCodePage());
+ ConvertBackslashes(szValue+1, Langpack_GetDefaultCodePage());
case 's':
case 'S':
DBWriteContactSettingString(NULL, szSection, szName, szValue+1);
diff --git a/src/modules/database/profilemanager.cpp b/src/modules/database/profilemanager.cpp index 898fc323d6..32e515efbe 100644 --- a/src/modules/database/profilemanager.cpp +++ b/src/modules/database/profilemanager.cpp @@ -123,7 +123,7 @@ static int FindDbProviders(const char*, DATABASELINK * dblink, LPARAM lParam) if (dblink->getFriendlyName(szName, SIZEOF(szName), 1) == 0) {
// add to combo box
- TCHAR* p = LangPackPcharToTchar(szName);
+ TCHAR* p = Langpack_PcharToTchar(szName);
LRESULT index = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)p);
mir_free(p);
SendMessage(hwndCombo, CB_SETITEMDATA, index, (LPARAM)dblink);
@@ -607,7 +607,7 @@ static INT_PTR CALLBACK DlgProfileManager(HWND hwndDlg, UINT msg, WPARAM wParam, SendMessage(hwndCombo, CB_SETITEMDATA, index, (LPARAM)-1);
SendMessage(hwndCombo, CB_SETCURSEL, 0, 0);
while (list[i]) {
- TCHAR *str = LangPackPcharToTchar(list[i]);
+ TCHAR *str = Langpack_PcharToTchar(list[i]);
index = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)str);
mir_free(str);
SendMessage(hwndCombo, CB_SETITEMDATA, index, (LPARAM)i);
@@ -780,7 +780,7 @@ static int AddProfileManagerPage(struct DetailsPageInit * opi, OPTIONSDIALOGPAGE p->hInstance = odp->hInstance;
p->pfnDlgProc = odp->pfnDlgProc;
p->position = odp->position;
- p->ptszTitle = LangPackPcharToTchar(odp->pszTitle);
+ p->ptszTitle = Langpack_PcharToTchar(odp->pszTitle);
p->pszGroup = NULL;
p->groupPosition = odp->groupPosition;
p->hGroupIcon = odp->hGroupIcon;
diff --git a/src/modules/fonts/FontService.cpp b/src/modules/fonts/FontService.cpp index 2f1ff567b1..26bbcfcfe2 100644 --- a/src/modules/fonts/FontService.cpp +++ b/src/modules/fonts/FontService.cpp @@ -67,7 +67,7 @@ static int OnPreShutdown(WPARAM, LPARAM) int LoadFontserviceModule(void)
{
- code_page = LangPackGetDefaultCodePage();
+ code_page = Langpack_GetDefaultCodePage();
CreateServiceFunction("Font/Register", RegisterFont);
CreateServiceFunction("Font/RegisterW", RegisterFontW);
diff --git a/src/modules/langpack/lpservices.cpp b/src/modules/langpack/lpservices.cpp index e828a85c6a..b7ae5ef563 100644 --- a/src/modules/langpack/lpservices.cpp +++ b/src/modules/langpack/lpservices.cpp @@ -22,8 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "..\..\core\commonheaders.h"
-MIR_CORE_DLL(int) LangPackMarkPluginLoaded(PLUGININFOEX* pInfo);
-
/////////////////////////////////////////////////////////////////////////////////////////
static INT_PTR srvTranslateString(WPARAM wParam, LPARAM lParam)
@@ -45,7 +43,7 @@ static INT_PTR srvTranslateMenu(WPARAM wParam, LPARAM lParam) static INT_PTR srvRegisterLP(WPARAM wParam, LPARAM lParam)
{
- *(int*)wParam = LangPackMarkPluginLoaded((PLUGININFOEX*)lParam);
+ *(int*)wParam = Langpack_MarkPluginLoaded((PLUGININFOEX*)lParam);
return 0;
}
@@ -53,14 +51,14 @@ static INT_PTR srvRegisterLP(WPARAM wParam, LPARAM lParam) static INT_PTR srvGetDefaultCodePage(WPARAM, LPARAM)
{
- return LangPackGetDefaultCodePage();
+ return Langpack_GetDefaultCodePage();
}
/////////////////////////////////////////////////////////////////////////////////////////
static INT_PTR srvGetDefaultLocale(WPARAM, LPARAM)
{
- return LangPackGetDefaultLocale();
+ return Langpack_GetDefaultLocale();
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -73,7 +71,7 @@ static INT_PTR srvPcharToTchar(WPARAM wParam, LPARAM lParam) int len = (int)strlen(pszStr);
TCHAR* result = (TCHAR*)alloca((len+1)*sizeof(TCHAR));
- MultiByteToWideChar(LangPackGetDefaultCodePage(), 0, pszStr, -1, result, len);
+ MultiByteToWideChar(Langpack_GetDefaultCodePage(), 0, pszStr, -1, result, len);
result[len] = 0;
return (INT_PTR)mir_wstrdup( TranslateW_LP(result, wParam));
}
diff --git a/src/modules/options/filter.h b/src/modules/options/filter.h index ced8845b95..6bf38d17d5 100644 --- a/src/modules/options/filter.h +++ b/src/modules/options/filter.h @@ -38,7 +38,7 @@ void GetDialogStrings(int enableKeywordFiltering, const PageHash key, TCHAR *plu _inline TCHAR * _tcslwr_locale(TCHAR * buf)
{
- LCMapString(LangPackGetDefaultLocale() , LCMAP_LOWERCASE, buf, (int)_tcslen(buf), buf, (int)_tcslen(buf));
+ LCMapString(Langpack_GetDefaultLocale() , LCMAP_LOWERCASE, buf, (int)_tcslen(buf), buf, (int)_tcslen(buf));
return buf;
}
diff --git a/src/modules/options/options.cpp b/src/modules/options/options.cpp index 9310c6c5d9..e049105253 100644 --- a/src/modules/options/options.cpp +++ b/src/modules/options/options.cpp @@ -720,11 +720,11 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L DBFreeVariant(&dbv);
}
}
- else lastGroup = LangPackPcharToTchar(ood->pszGroup);
+ else lastGroup = Langpack_PcharToTchar(ood->pszGroup);
}
else {
- lastPage = LangPackPcharToTchar(ood->pszPage);
- lastGroup = (ood->pszGroup == NULL) ? NULL : LangPackPcharToTchar(ood->pszGroup);
+ lastPage = Langpack_PcharToTchar(ood->pszPage);
+ lastGroup = (ood->pszGroup == NULL) ? NULL : Langpack_PcharToTchar(ood->pszGroup);
}
if (ood->pszTab == NULL) {
@@ -733,7 +733,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L DBFreeVariant(&dbv);
}
}
- else lastTab = LangPackPcharToTchar(ood->pszTab);
+ else lastTab = Langpack_PcharToTchar(ood->pszTab);
OPTIONSDIALOGPAGE *odp = (OPTIONSDIALOGPAGE*)psh->ppsp;
for (size_t i = 0; i < psh->nPages; i++, odp++) {
@@ -1401,10 +1401,10 @@ static void OpenOptionsNow(const char *pszGroup, const char *pszPage, const char ShowWindow(hwndOptions, SW_RESTORE);
SetForegroundWindow(hwndOptions);
if (pszPage != NULL) {
- TCHAR *ptszPage = LangPackPcharToTchar(pszPage);
+ TCHAR *ptszPage = Langpack_PcharToTchar(pszPage);
HTREEITEM hItem = NULL;
if (pszGroup != NULL) {
- TCHAR *ptszGroup = LangPackPcharToTchar(pszGroup);
+ TCHAR *ptszGroup = Langpack_PcharToTchar(pszGroup);
hItem = FindNamedTreeItemAtRoot(GetDlgItem(hwndOptions, IDC_PAGETREE), ptszGroup);
if (hItem != NULL) {
hItem = FindNamedTreeItemAtChildren(GetDlgItem(hwndOptions, IDC_PAGETREE), hItem, ptszPage);
@@ -1511,7 +1511,7 @@ static INT_PTR AddOptionsPage(WPARAM wParam, LPARAM lParam) if (odp->flags & ODPF_UNICODE)
dst->ptszGroup = mir_wstrdup(odp->ptszGroup);
else {
- dst->ptszGroup = LangPackPcharToTchar(odp->pszGroup);
+ dst->ptszGroup = Langpack_PcharToTchar(odp->pszGroup);
dst->flags |= ODPF_UNICODE;
}
}
@@ -1520,7 +1520,7 @@ static INT_PTR AddOptionsPage(WPARAM wParam, LPARAM lParam) if (odp->flags & ODPF_UNICODE)
dst->ptszTab = mir_wstrdup(odp->ptszTab);
else {
- dst->ptszTab = LangPackPcharToTchar(odp->pszTab);
+ dst->ptszTab = Langpack_PcharToTchar(odp->pszTab);
dst->flags |= ODPF_UNICODE;
}
}
diff --git a/src/modules/plugins/newplugins.cpp b/src/modules/plugins/newplugins.cpp index 035b2e4c63..493c40bf10 100644 --- a/src/modules/plugins/newplugins.cpp +++ b/src/modules/plugins/newplugins.cpp @@ -266,6 +266,33 @@ LBL_Ok: goto LBL_Error;
}
+// perform any API related tasks to freeing
+void Plugin_Uninit(pluginEntry* p, bool bDynamic)
+{
+ if (bDynamic && p->bpi.hInst)
+ CallPluginEventHook(p->bpi.hInst, hOkToExitEvent, 0, 0);
+
+ // if it was an installed database plugin, call its unload
+ if (p->pclass & PCLASS_DB)
+ p->bpi.dblink->Unload(p->pclass & PCLASS_OK);
+
+ // if the basic API check had passed, call Unload if Load(void) was ever called
+ if (p->pclass & PCLASS_LOADED)
+ p->bpi.Unload();
+
+ // release the library
+ if (p->bpi.hInst != NULL) {
+ // we need to kill all resources which belong to that DLL before calling FreeLibrary
+ KillModuleEventHooks(p->bpi.hInst);
+ KillModuleServices(p->bpi.hInst);
+
+ FreeLibrary(p->bpi.hInst);
+ ZeroMemory(&p->bpi, sizeof(p->bpi));
+ }
+ UnregisterModule(p->bpi.hInst);
+ pluginList.remove(p);
+}
+
// returns true if the given file is <anything>.dll exactly
static int valid_library_name(TCHAR *name)
{
@@ -313,33 +340,6 @@ static int validguess_servicemode_name(TCHAR * name) return rc;
}
-// perform any API related tasks to freeing
-void Plugin_Uninit(pluginEntry* p, bool bDynamic)
-{
- if (bDynamic && p->bpi.hInst)
- CallPluginEventHook(p->bpi.hInst, hOkToExitEvent, 0, 0);
-
- // if it was an installed database plugin, call its unload
- if (p->pclass & PCLASS_DB)
- p->bpi.dblink->Unload(p->pclass & PCLASS_OK);
-
- // if the basic API check had passed, call Unload if Load(void) was ever called
- if (p->pclass & PCLASS_LOADED)
- p->bpi.Unload();
-
- // release the library
- if (p->bpi.hInst != NULL) {
- // we need to kill all resources which belong to that DLL before calling FreeLibrary
- KillModuleEventHooks(p->bpi.hInst);
- KillModuleServices(p->bpi.hInst);
-
- FreeLibrary(p->bpi.hInst);
- ZeroMemory(&p->bpi, sizeof(p->bpi));
- }
- UnregisterModule(p->bpi.hInst);
- pluginList.remove(p);
-}
-
void enumPlugins(SCAN_PLUGINS_CALLBACK cb, WPARAM wParam, LPARAM lParam)
{
// get miranda's exe path
@@ -393,12 +393,11 @@ static INT_PTR PluginsEnum(WPARAM, LPARAM lParam) pluginEntry* OpenPlugin(TCHAR* tszFileName, TCHAR* path)
{
- int isdb = validguess_db_name(tszFileName);
BASIC_PLUGIN_INFO bpi;
pluginEntry* p = (pluginEntry*)HeapAlloc(hPluginListHeap, HEAP_NO_SERIALIZE | HEAP_ZERO_MEMORY, sizeof(pluginEntry));
_tcsncpy(p->pluginname, tszFileName, SIZEOF(p->pluginname));
// plugin name suggests its a db module, load it right now
- if (isdb) {
+ if ( validguess_db_name(tszFileName)) {
TCHAR buf[MAX_PATH];
mir_sntprintf(buf, SIZEOF(buf), _T("%s\\Plugins\\%s"), path, tszFileName);
if (checkAPI(buf, &bpi, mirandaVersion, CHECKAPI_DB)) {
@@ -414,13 +413,13 @@ pluginEntry* OpenPlugin(TCHAR* tszFileName, TCHAR* path) // didn't have basic APIs or DB exports - failed.
p->pclass |= PCLASS_FAILED;
}
- else if (validguess_clist_name(tszFileName)) {
+ else if ( validguess_clist_name(tszFileName)) {
// keep a note of this plugin for later
if (pluginListUI != NULL) p->nextclass=pluginListUI;
pluginListUI=p;
p->pclass |= PCLASS_CLIST;
}
- else if (validguess_servicemode_name(tszFileName)) {
+ else if ( validguess_servicemode_name(tszFileName)) {
TCHAR buf[MAX_PATH];
mir_sntprintf(buf, SIZEOF(buf), _T("%s\\Plugins\\%s"), path, tszFileName);
if (checkAPI(buf, &bpi, mirandaVersion, CHECKAPI_NONE)) {
@@ -538,33 +537,31 @@ bool TryLoadPlugin(pluginEntry *p, bool bDynamic) static pluginEntry* getCListModule(TCHAR * exe, TCHAR * slice, int useWhiteList)
{
- pluginEntry * p = pluginListUI;
- BASIC_PLUGIN_INFO bpi;
- while (p != NULL) {
+ for (pluginEntry *p = pluginListUI; p != NULL; p = p->nextclass) {
mir_sntprintf(slice, &exe[MAX_PATH] - slice, _T("\\Plugins\\%s"), p->pluginname);
CharLower(p->pluginname);
- if (useWhiteList ? isPluginOnWhiteList(p->pluginname) : 1) {
- if (checkAPI(exe, &bpi, mirandaVersion, CHECKAPI_CLIST)) {
+ if (useWhiteList && !isPluginOnWhiteList(p->pluginname))
+ continue;
+
+ BASIC_PLUGIN_INFO bpi;
+ if (checkAPI(exe, &bpi, mirandaVersion, CHECKAPI_CLIST)) {
+ p->bpi = bpi;
+ p->pclass |= PCLASS_LAST | PCLASS_OK | PCLASS_BASICAPI;
+ RegisterModule(p->bpi.hInst);
+ if (bpi.clistlink() == 0) {
p->bpi = bpi;
- p->pclass |= PCLASS_LAST | PCLASS_OK | PCLASS_BASICAPI;
- RegisterModule(p->bpi.hInst);
- if (bpi.clistlink() == 0) {
- p->bpi = bpi;
- p->pclass |= PCLASS_LOADED;
- return p;
- }
- else Plugin_Uninit(p);
- } //if
- } //if
- p = p->nextclass;
+ p->pclass |= PCLASS_LOADED;
+ return p;
+ }
+ Plugin_Uninit(p);
+ }
}
return NULL;
}
int UnloadPlugin(TCHAR* buf, int bufLen)
{
- int i;
- for (i = pluginList.getCount()-1; i >= 0; i--) {
+ for (int i = pluginList.getCount()-1; i >= 0; i--) {
pluginEntry* p = pluginList[i];
if ( !_tcsicmp(p->pluginname, buf)) {
GetModuleFileName(p->bpi.hInst, buf, bufLen);
@@ -690,7 +687,7 @@ int LoadNewPluginsModule(void) // first load the clist cos alot of plugins need that to be present at Load(void)
for (useWhiteList = 1; useWhiteList >= 0 && clist == NULL; useWhiteList--)
- clist=getCListModule(exe, slice, useWhiteList);
+ clist = getCListModule(exe, slice, useWhiteList);
/* the loop above will try and get one clist DLL to work, if all fail then just bail now */
if (clist == NULL) {
// result = 0, no clist_* can be found
diff --git a/src/modules/plugins/pluginopts.cpp b/src/modules/plugins/pluginopts.cpp index 58d5b23128..69034567f3 100644 --- a/src/modules/plugins/pluginopts.cpp +++ b/src/modules/plugins/pluginopts.cpp @@ -358,7 +358,7 @@ INT_PTR CALLBACK DlgPluginOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar SetWindowTextA(GetDlgItem(hwndDlg, IDC_PLUGINAUTHOR), sel ? dat->author : "");
SetWindowTextA(GetDlgItem(hwndDlg, IDC_PLUGINEMAIL), sel ? dat->authorEmail : "");
{
- TCHAR* p = LangPackPcharToTchar(dat->description);
+ TCHAR* p = Langpack_PcharToTchar(dat->description);
SetWindowText(GetDlgItem(hwndDlg, IDC_PLUGINLONGINFO), sel ? p : _T(""));
mir_free(p);
}
diff --git a/src/modules/userinfo/userinfo.cpp b/src/modules/userinfo/userinfo.cpp index c636534b19..237c1bdee5 100644 --- a/src/modules/userinfo/userinfo.cpp +++ b/src/modules/userinfo/userinfo.cpp @@ -142,8 +142,8 @@ static INT_PTR AddDetailsPage(WPARAM wParam, LPARAM lParam) if (odp->flags & ODPF_DONTTRANSLATE)
dst->ptszTitle = (odp->pszTitle == 0) ? NULL : mir_a2t(odp->pszTitle);
else
- dst->ptszTitle = (odp->pszTitle == 0) ? NULL : LangPackPcharToTchar(odp->pszTitle);
- dst->ptszTab = ( !(odp->flags & ODPF_USERINFOTAB) || !odp->pszTab) ? NULL : LangPackPcharToTchar(odp->pszTab);
+ dst->ptszTitle = (odp->pszTitle == 0) ? NULL : Langpack_PcharToTchar(odp->pszTitle);
+ dst->ptszTab = ( !(odp->flags & ODPF_USERINFOTAB) || !odp->pszTab) ? NULL : Langpack_PcharToTchar(odp->pszTab);
}
dst->pszGroup = NULL;
|