diff options
author | George Hazan <ghazan@miranda.im> | 2019-07-10 15:49:06 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-07-10 15:49:06 +0300 |
commit | 264bc39a3c07cca1dc2967fd0de88fc7110a8bf5 (patch) | |
tree | 70d2f26bd2a371f55ebdb815e623c71c20b2c06c /src/mir_app | |
parent | 4cd32228091528a8809c589ca2d18baf2ed27f1c (diff) |
dynamic unloaded plugins to be unchecked in Options - Plugins
Diffstat (limited to 'src/mir_app')
-rw-r--r-- | src/mir_app/src/miranda.h | 2 | ||||
-rw-r--r-- | src/mir_app/src/newplugins.cpp | 16 | ||||
-rw-r--r-- | src/mir_app/src/pluginopts.cpp | 41 | ||||
-rw-r--r-- | src/mir_app/src/plugins.h | 3 |
4 files changed, 32 insertions, 30 deletions
diff --git a/src/mir_app/src/miranda.h b/src/mir_app/src/miranda.h index cd25f39443..855a1bed4b 100644 --- a/src/mir_app/src/miranda.h +++ b/src/mir_app/src/miranda.h @@ -65,7 +65,7 @@ void UnloadIdleModule(void); /**** miranda.cpp **********************************************************************/
extern DWORD hMainThreadId;
-extern HANDLE hOkToExitEvent, hModulesLoadedEvent, hevLoadModule, hevUnloadModule;
+extern HANDLE hOkToExitEvent, hModulesLoadedEvent;
extern HANDLE hAccListChanged;
extern wchar_t mirandabootini[MAX_PATH];
extern struct pluginEntry *plugin_crshdmp, *plugin_service, *plugin_ssl, *plugin_clist;
diff --git a/src/mir_app/src/newplugins.cpp b/src/mir_app/src/newplugins.cpp index 72014fb9b7..757b323f91 100644 --- a/src/mir_app/src/newplugins.cpp +++ b/src/mir_app/src/newplugins.cpp @@ -33,6 +33,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. bool g_bReadyToInitClist = false;
void LoadExtraIconsModule();
+void freePluginInstance(HINSTANCE hInst);
static int sttComparePluginsByName(const pluginEntry *p1, const pluginEntry *p2)
{
@@ -52,9 +53,10 @@ MUUID miid_last = MIID_LAST; #define MAX_MIR_VER ULONG_MAX
-static BOOL bModuleInitialized = FALSE;
+static bool bModuleInitialized = FALSE;
+HANDLE hevLoadModule, hevUnloadModule;
-wchar_t mirandabootini[MAX_PATH];
+wchar_t mirandabootini[MAX_PATH];
static int askAboutIgnoredPlugins;
pluginEntry *plugin_crshdmp, *plugin_service, *plugin_ssl, *plugin_clist;
@@ -284,6 +286,8 @@ bool Plugin_UnloadDyn(pluginEntry *p) KillModuleServices(hInst);
}
+ freePluginInstance(ppb->getInst());
+
NotifyFastHook(hevUnloadModule, (WPARAM)&ppb->getInfo(), (LPARAM)ppb->getInst());
}
@@ -747,10 +751,11 @@ static BOOL scanPluginsDir(WIN32_FIND_DATA *fd, wchar_t *path, WPARAM, LPARAM) int LoadNewPluginsModuleInfos(void)
{
- bModuleInitialized = TRUE;
+ bModuleInitialized = true;
DeleteFile(L"mir_core.dll");
- LoadPluginOptions();
+ hevLoadModule = CreateHookableEvent(ME_SYSTEM_MODULELOAD);
+ hevUnloadModule = CreateHookableEvent(ME_SYSTEM_MODULEUNLOAD);
// remember where the mirandaboot.ini lays
PathToAbsoluteW(L"mirandaboot.ini", mirandabootini);
@@ -787,7 +792,8 @@ void UnloadNewPluginsModule(void) if (!bModuleInitialized)
return;
- UnloadPluginOptions();
+ DestroyHookableEvent(hevLoadModule);
+ DestroyHookableEvent(hevUnloadModule);
// unload everything but the DB
for (auto &it : pluginList.rev_iter())
diff --git a/src/mir_app/src/pluginopts.cpp b/src/mir_app/src/pluginopts.cpp index 20e766e75a..a8c0731c05 100644 --- a/src/mir_app/src/pluginopts.cpp +++ b/src/mir_app/src/pluginopts.cpp @@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "chat.h"
#include "plugins.h"
-HANDLE hevLoadModule, hevUnloadModule;
+extern HANDLE hevLoadModule;
/////////////////////////////////////////////////////////////////////////////////////////
// Plugins options page dialog
@@ -54,7 +54,25 @@ struct PluginListItemData }
};
-static wchar_t* sttUtf8auto(const char *src)
+static int sttSortPlugins(const PluginListItemData *p1, const PluginListItemData *p2)
+{
+ return mir_wstrcmp(p1->fileName, p2->fileName);
+}
+
+static LIST<PluginListItemData> arPluginList(10, sttSortPlugins);
+
+void freePluginInstance(HINSTANCE hInst)
+{
+ for (auto &it : arPluginList)
+ if (it->hInst == hInst) {
+ it->hInst = nullptr;
+ break;
+ }
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static wchar_t *sttUtf8auto(const char *src)
{
if (src == nullptr)
return mir_wstrdup(L"");
@@ -64,13 +82,6 @@ static wchar_t* sttUtf8auto(const char *src) return (mir_utf8decode(p, &pwszRes) != nullptr) ? pwszRes : mir_a2u_cp(src, 1250);
}
-static int sttSortPlugins(const PluginListItemData *p1, const PluginListItemData *p2)
-{
- return mir_wstrcmp(p1->fileName, p2->fileName);
-}
-
-static LIST<PluginListItemData> arPluginList(10, sttSortPlugins);
-
static BOOL dialogListPlugins(WIN32_FIND_DATA *fd, wchar_t *path, WPARAM, LPARAM lParam)
{
wchar_t buf[MAX_PATH];
@@ -541,15 +552,3 @@ int PluginOptionsInit(WPARAM wParam, LPARAM) g_plugin.addOptions(wParam, &odp);
return 0;
}
-
-void LoadPluginOptions()
-{
- hevLoadModule = CreateHookableEvent(ME_SYSTEM_MODULELOAD);
- hevUnloadModule = CreateHookableEvent(ME_SYSTEM_MODULEUNLOAD);
-}
-
-void UnloadPluginOptions()
-{
- DestroyHookableEvent(hevLoadModule);
- DestroyHookableEvent(hevUnloadModule);
-}
diff --git a/src/mir_app/src/plugins.h b/src/mir_app/src/plugins.h index f46b3fa056..9525c27417 100644 --- a/src/mir_app/src/plugins.h +++ b/src/mir_app/src/plugins.h @@ -58,9 +58,6 @@ extern MUUID miid_last; int PluginOptionsInit(WPARAM, LPARAM);
-void LoadPluginOptions();
-void UnloadPluginOptions();
-
int isPluginOnWhiteList(const wchar_t *pluginname);
void SetPluginOnWhiteList(const wchar_t *pluginname, int allow);
|