diff options
author | George Hazan <george.hazan@gmail.com> | 2012-07-06 08:31:38 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-07-06 08:31:38 +0000 |
commit | 1ce002432b3a5c0bb0a4c9f9eb8d399d649fe283 (patch) | |
tree | 77852d7852ceaf1f0029e91e94ae7580bb4cef5d /src/modules/plugins | |
parent | 387a4b247a6c4363576b1f969e7ea19856f6eddd (diff) |
- mir_core.dll moved to the core :)
- plugins now obtain the fake langpack id if langpack is absent
git-svn-id: http://svn.miranda-ng.org/main/trunk@787 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules/plugins')
-rw-r--r-- | src/modules/plugins/newplugins.cpp | 102 | ||||
-rw-r--r-- | src/modules/plugins/pluginopts.cpp | 2 | ||||
-rw-r--r-- | src/modules/plugins/plugins.h | 3 |
3 files changed, 63 insertions, 44 deletions
diff --git a/src/modules/plugins/newplugins.cpp b/src/modules/plugins/newplugins.cpp index a07f371e42..7bbcc57411 100644 --- a/src/modules/plugins/newplugins.cpp +++ b/src/modules/plugins/newplugins.cpp @@ -68,7 +68,7 @@ static BOOL bModuleInitialized = FALSE; TCHAR mirandabootini[MAX_PATH];
static DWORD mirandaVersion;
-static int serviceModeIdx = -1;
+static int serviceModeIdx = -1, sttFakeID = -100;
static HANDLE hPluginListHeap = NULL;
static int askAboutIgnoredPlugins;
@@ -81,18 +81,8 @@ void UninitIni(void); int LoadDatabaseModule(void);
-char* GetPluginNameByInstance(HINSTANCE hInstance)
-{
- if (pluginList.getCount() == 0)
- return NULL;
-
- for (int i=0; i < pluginList.getCount(); i++) {
- pluginEntry* pe = pluginList[i];
- if (pe->bpi.pluginInfo && pe->bpi.hInst == hInstance)
- return pe->bpi.pluginInfo->shortName;
- }
- return NULL;
-}
+/////////////////////////////////////////////////////////////////////////////////////////
+// basic functions
int equalUUID(const MUUID& u1, const MUUID& u2)
{
@@ -119,6 +109,37 @@ int getDefaultPluginIdx(const MUUID& muuid) return -1;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+// global functions
+
+char* GetPluginNameByInstance(HINSTANCE hInstance)
+{
+ if (pluginList.getCount() == 0)
+ return NULL;
+
+ for (int i=0; i < pluginList.getCount(); i++) {
+ pluginEntry* p = pluginList[i];
+ if (p->bpi.pluginInfo && p->bpi.hInst == hInstance)
+ return p->bpi.pluginInfo->shortName;
+ }
+ return NULL;
+}
+
+int GetPluginFakeId(const MUUID &uuid, int hLangpack)
+{
+ for (int i=0; i < pluginList.getCount(); i++) {
+ pluginEntry* p = pluginList[i];
+ if ( !p->bpi.hInst)
+ continue;
+
+ if ( equalUUID(p->bpi.pluginInfo->uuid, uuid))
+ return p->hLangpack = (hLangpack) ? hLangpack : --sttFakeID;
+ }
+
+ return 0;
+}
+
+
MUUID miid_last = MIID_LAST;
MUUID miid_chat = MIID_CHAT;
MUUID miid_srmm = MIID_SRMM;
@@ -264,11 +285,8 @@ LBL_Ok: }
// perform any API related tasks to freeing
-void Plugin_Uninit(pluginEntry* p, bool bDynamic)
+void Plugin_Uninit(pluginEntry* p)
{
- 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);
@@ -283,24 +301,6 @@ void Plugin_Uninit(pluginEntry* p, bool bDynamic) KillModuleEventHooks(p->bpi.hInst);
KillModuleServices(p->bpi.hInst);
- if (bDynamic) {
- int hLangpack = Langpack_GetPluginHandle(p->bpi.pluginInfo);
- if (hLangpack != 0) {
- KillModuleMenus(hLangpack);
- KillModuleFonts(hLangpack);
- KillModuleColours(hLangpack);
- KillModuleEffects(hLangpack);
- KillModuleIcons(hLangpack);
- KillModuleHotkeys(hLangpack);
- KillModuleSounds(hLangpack);
- }
-
- // release default plugin
- for (int i=0; i < SIZEOF(pluginDefault); i++)
- if (pluginDefault[i].pImpl == p)
- pluginDefault[i].pImpl = NULL;
- }
-
FreeLibrary(p->bpi.hInst);
ZeroMemory(&p->bpi, sizeof(p->bpi));
}
@@ -310,15 +310,33 @@ void Plugin_Uninit(pluginEntry* p, bool bDynamic) int Plugin_UnloadDyn(pluginEntry* p)
{
- if (CallPluginEventHook(p->bpi.hInst, hOkToExitEvent, 0, 0) != 0)
- return FALSE;
+ if (p->bpi.hInst) {
+ if (CallPluginEventHook(p->bpi.hInst, hOkToExitEvent, 0, 0) != 0)
+ return FALSE;
- NotifyEventHooks(hevUnloadModule, (WPARAM)p->bpi.InfoEx, (LPARAM)p->bpi.hInst);
+ NotifyEventHooks(hevUnloadModule, (WPARAM)p->bpi.InfoEx, (LPARAM)p->bpi.hInst);
- CallPluginEventHook(p->bpi.hInst, hPreShutdownEvent, 0, 0);
- CallPluginEventHook(p->bpi.hInst, hShutdownEvent, 0, 0);
+ CallPluginEventHook(p->bpi.hInst, hPreShutdownEvent, 0, 0);
+ CallPluginEventHook(p->bpi.hInst, hShutdownEvent, 0, 0);
+ }
+
+ int hLangpack = p->hLangpack;
+ if (hLangpack != 0) {
+ KillModuleMenus(hLangpack);
+ KillModuleFonts(hLangpack);
+ KillModuleColours(hLangpack);
+ KillModuleEffects(hLangpack);
+ KillModuleIcons(hLangpack);
+ KillModuleHotkeys(hLangpack);
+ KillModuleSounds(hLangpack);
+ }
+
+ // release default plugin
+ for (int i=0; i < SIZEOF(pluginDefault); i++)
+ if (pluginDefault[i].pImpl == p)
+ pluginDefault[i].pImpl = NULL;
- Plugin_Uninit(p, true);
+ Plugin_Uninit(p);
return TRUE;
}
@@ -578,7 +596,7 @@ bool LoadCorePlugin(MuuidReplacement& mr) pluginEntry* pPlug = OpenPlugin(tszPlugName, _T("Core"), exe);
if (pPlug->pclass & PCLASS_FAILED) {
LBL_Error:
- Plugin_Uninit(pPlug, true);
+ Plugin_UnloadDyn(pPlug);
return FALSE;
}
diff --git a/src/modules/plugins/pluginopts.cpp b/src/modules/plugins/pluginopts.cpp index b8384ae593..15f9219192 100644 --- a/src/modules/plugins/pluginopts.cpp +++ b/src/modules/plugins/pluginopts.cpp @@ -167,7 +167,7 @@ static int LoadPluginDynamically(PluginListItemData* dat) pluginEntry* pPlug = OpenPlugin(dat->fileName, _T("Plugins"), exe);
if (pPlug->pclass & PCLASS_FAILED) {
LBL_Error:
- Plugin_Uninit(pPlug, true);
+ Plugin_UnloadDyn(pPlug);
return FALSE;
}
diff --git a/src/modules/plugins/plugins.h b/src/modules/plugins/plugins.h index 85922fcae8..4dcf76f439 100644 --- a/src/modules/plugins/plugins.h +++ b/src/modules/plugins/plugins.h @@ -48,6 +48,7 @@ struct pluginEntry {
TCHAR pluginname[64];
unsigned int pclass; // PCLASS_*
+ int hLangpack;
BASIC_PLUGIN_INFO bpi;
pluginEntry* nextclass;
};
@@ -70,7 +71,7 @@ int checkAPI(TCHAR* plugin, BASIC_PLUGIN_INFO* bpi, DWORD mirandaVersion, int ch pluginEntry* OpenPlugin(TCHAR *tszFileName, TCHAR *dir, TCHAR *path);
bool TryLoadPlugin(pluginEntry *p, TCHAR *dir, bool bDynamic);
-void Plugin_Uninit(pluginEntry* p, bool bDynamic = false);
+void Plugin_Uninit(pluginEntry* p);
int Plugin_UnloadDyn(pluginEntry* p);
typedef BOOL (*SCAN_PLUGINS_CALLBACK) (WIN32_FIND_DATA * fd, TCHAR *path, WPARAM wParam, LPARAM lParam);
|