summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-05-29 14:47:59 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-05-29 14:47:59 +0300
commit51e1e489382e8f66d489b8bd68eb4e0711409cb7 (patch)
treeb0782fe4cedba67020eb7dd8ff9b3e13bbfc4e48
parent0a971c41b3fe5aff16d8c398ae5215968c14d36d (diff)
core:
- obsoleted flags bOk & bStopped removed from pluginEntry; - pluginEntry::bFailed is now set automatically;
-rw-r--r--src/mir_app/src/newplugins.cpp29
-rw-r--r--src/mir_app/src/plugins.h10
2 files changed, 13 insertions, 26 deletions
diff --git a/src/mir_app/src/newplugins.cpp b/src/mir_app/src/newplugins.cpp
index 454cde3569..4d6c27c146 100644
--- a/src/mir_app/src/newplugins.cpp
+++ b/src/mir_app/src/newplugins.cpp
@@ -184,20 +184,20 @@ bool pluginEntry::checkAPI(wchar_t *plugin, int checkTypeAPI)
if (h == nullptr)
return false;
- // loaded, check for exports
- CMPluginBase &ppb = GetPluginByInstance(h);
- pfnLoad = (Miranda_Plugin_Load)GetProcAddress(h, "Load");
- pfnUnload = (Miranda_Plugin_Unload)GetProcAddress(h, "Unload");
-
// dll must register itself during LoadLibrary
+ CMPluginBase &ppb = GetPluginByInstance(h);
if (ppb.getInst() != h) {
LBL_Error:
+ bFailed = true;
clear();
FreeLibrary(h);
return false;
}
m_pPlugin = &ppb;
+ pfnLoad = (Miranda_Plugin_Load)GetProcAddress(h, "Load");
+ pfnUnload = (Miranda_Plugin_Unload)GetProcAddress(h, "Unload");
+
m_pInterfaces = (MUUID*)GetProcAddress(h, "MirandaInterfaces");
if (m_pInterfaces == nullptr) {
// MirandaPluginInterfaces function is actual only for the only plugin, HistoryPlusPlus
@@ -381,7 +381,6 @@ pluginEntry* OpenPlugin(wchar_t *tszFileName, wchar_t *dir, wchar_t *path)
else
p->bLoaded = true;
}
- else p->bFailed = true;
}
// plugin declared that it's a contact list. mark it for the future load
else if (hasMuuid(pIds, MIID_CLIST)) {
@@ -398,15 +397,11 @@ pluginEntry* OpenPlugin(wchar_t *tszFileName, wchar_t *dir, wchar_t *path)
// load it for a profile manager's window
else if (hasMuuid(pIds, MIID_SERVICEMODE)) {
if (p->checkAPI(tszFullPath, CHECKAPI_NONE)) {
- p->bOk = true;
if (hasMuuid(pIds, MIID_SERVICEMODE)) {
p->bIsService = true;
servicePlugins.insert(p);
}
}
- else
- // didn't have basic APIs or DB exports - failed.
- p->bFailed = true;
}
else if (hasMuuid(pIds, MIID_PROTOCOL) || !mir_wstrcmpi(tszFileName, L"mradio.dll") || !mir_wstrcmpi(tszFileName, L"watrack.dll"))
p->bIsProtocol = true;
@@ -454,12 +449,8 @@ bool TryLoadPlugin(pluginEntry *p, bool bDynamic)
*slice = 0;
mir_snwprintf(tszFullPath, L"%s\\%s\\%s", exe, (p->bIsCore) ? L"Core" : L"Plugins", p->pluginname);
- if (!p->checkAPI(tszFullPath, CHECKAPI_NONE)) {
- p->bFailed = true;
+ if (!p->checkAPI(tszFullPath, CHECKAPI_NONE))
return false;
- }
-
- p->bOk = true;
}
if (p->m_pInterfaces) {
@@ -546,7 +537,7 @@ static bool loadClistModule(wchar_t *exe, pluginEntry *p)
g_bReadyToInitClist = true;
if (p->checkAPI(exe, CHECKAPI_CLIST)) {
- p->bIsLast = p->bOk = true;
+ p->bIsLast = true;
hCListImages = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 13, 0);
ImageList_AddIcon_NotShared(hCListImages, MAKEINTRESOURCE(IDI_BLANK));
@@ -676,7 +667,7 @@ void UnloadNewPlugins(void)
{
// unload everything but the special db/clist plugins
for (auto &it : pluginList.rev_iter())
- if (!it->bIsLast && it->bOk)
+ if (!it->bIsLast && !it->bFailed)
Plugin_Uninit(it);
}
@@ -696,9 +687,7 @@ int LoadProtocolPlugins(void)
wchar_t tszFullPath[MAX_PATH];
mir_snwprintf(tszFullPath, L"%s\\%s\\%s", exe, L"Plugins", p->pluginname);
-
- if (p->checkAPI(tszFullPath, CHECKAPI_NONE))
- p->bOk = true;
+ p->checkAPI(tszFullPath, CHECKAPI_NONE);
}
return 0;
diff --git a/src/mir_app/src/plugins.h b/src/mir_app/src/plugins.h
index 4802ee76e6..143ee44de5 100644
--- a/src/mir_app/src/plugins.h
+++ b/src/mir_app/src/plugins.h
@@ -21,9 +21,7 @@ struct pluginEntry
struct
{
bool bFailed : 1; // not a valid plugin, or API is invalid, pluginname is valid
- bool bOk : 1; // plugin should be loaded, if DB means nothing
bool bLoaded : 1; // Load(void) has been called, Unload() should be called.
- bool bStopped : 1; // wasn't loaded cos plugin name not on white list
bool bIsCore : 1; // a plugin from the /Core directory
bool bIsService : 1; // has Service Mode implementation
@@ -31,9 +29,9 @@ struct pluginEntry
bool bHasBasicApi : 1; // has Load, Unload, MirandaPluginInfo() -> PLUGININFO seems valid, this dll is in memory.
bool bIsProtocol : 1; // protocol module
- bool bIsDatabase : 1; // has MUUID_DATABASE in its interfaces, and PCLASS_BASICAPI has to be set too
- bool bIsClist : 1; // a CList implementation
- bool bIsCrypto : 1; // crypto provider
+ bool bIsClist : 1; // has MIID_CLIST in its interfaces
+ bool bIsCrypto : 1; // has MIID_CRYPTO in its interfaces
+ bool bIsDatabase : 1; // has MUUID_DATABASE in its interfaces
};
void clear()
@@ -45,7 +43,7 @@ struct pluginEntry
}
// old stubs for pascal plugins
- Miranda_Plugin_Load pfnLoad;
+ Miranda_Plugin_Load pfnLoad;
Miranda_Plugin_Unload pfnUnload;
MUUID* m_pInterfaces; // array of supported interfaces or NULL