From 380ea39ed5a269e7caf32d9063b389650233fdbe Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 28 Mar 2018 20:17:40 +0300 Subject: Import now works without accounts' activation, without calling Load() of protocol plugins, just on CMPlugin information --- plugins/Import/src/import.cpp | 2 -- plugins/Import/src/version.h | 2 +- src/mir_app/src/modules.cpp | 4 ---- src/mir_app/src/newplugins.cpp | 37 ++++++++++++++++++++----------------- src/mir_app/src/plugins.h | 2 +- 5 files changed, 22 insertions(+), 25 deletions(-) diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp index 6ca7d031bb..8b3a8d4c03 100644 --- a/plugins/Import/src/import.cpp +++ b/plugins/Import/src/import.cpp @@ -521,8 +521,6 @@ bool ImportAccounts(OBJLIST &arSkippedModules) CopySettings(NULL, p->szSrcAcc, NULL, p->pa->szModuleName); if (bImportSysAll) arSkippedModules.insert(newStr(p->szSrcAcc)); - - Proto_ActivateAccount(p->pa); } CopySettings(NULL, META_PROTO, NULL, META_PROTO); diff --git a/plugins/Import/src/version.h b/plugins/Import/src/version.h index a1521e40d1..d5f247b3f0 100644 --- a/plugins/Import/src/version.h +++ b/plugins/Import/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 95 #define __RELEASE_NUM 8 -#define __BUILD_NUM 4 +#define __BUILD_NUM 5 #include diff --git a/src/mir_app/src/modules.cpp b/src/mir_app/src/modules.cpp index 9f77361280..a8abaac4c9 100644 --- a/src/mir_app/src/modules.cpp +++ b/src/mir_app/src/modules.cpp @@ -147,10 +147,6 @@ int LoadDefaultModules(void) return 1; } - for (auto &it : pluginList.rev_iter()) - if (!it->bIsLast && it->bOk) - Plugin_UnloadDyn(it, false); - plugin_service = nullptr; } diff --git a/src/mir_app/src/newplugins.cpp b/src/mir_app/src/newplugins.cpp index 1710e71a3d..192b916ab7 100644 --- a/src/mir_app/src/newplugins.cpp +++ b/src/mir_app/src/newplugins.cpp @@ -342,7 +342,7 @@ void Plugin_Uninit(pluginEntry *p) pluginList.remove(p); } -int Plugin_UnloadDyn(pluginEntry *p, bool bFreeDll) +int Plugin_UnloadDyn(pluginEntry *p) { if (p->bpi.hInst) { if (CallPluginEventHook(p->bpi.hInst, hOkToExitEvent, 0, 0) != 0) @@ -374,19 +374,13 @@ int Plugin_UnloadDyn(pluginEntry *p, bool bFreeDll) NotifyFastHook(hevUnloadModule, (WPARAM)p->bpi.pluginInfo, (LPARAM)p->bpi.hInst); - if (bFreeDll) { - Plugin_Uninit(p); + Plugin_Uninit(p); - // mark default plugins to be loaded - if (!p->bIsCore) - for (auto &it : pluginDefault) - if (it.pImpl == p) - it.pImpl = nullptr; - } - else if (p->bLoaded) { - p->bpi.Unload(); - p->bLoaded = false; - } + // mark default plugins to be loaded + if (!p->bIsCore) + for (auto &it : pluginDefault) + if (it.pImpl == p) + it.pImpl = nullptr; return TRUE; } @@ -772,15 +766,24 @@ void UnloadNewPlugins(void) int LoadProtocolPlugins(void) { + wchar_t exe[MAX_PATH]; + GetModuleFileName(nullptr, exe, _countof(exe)); + wchar_t* slice = wcsrchr(exe, '\\'); + if (slice) *slice = 0; + /* now loop thru and load all the other plugins, do this in one pass */ for (int i = 0; i < pluginList.getCount(); i++) { pluginEntry *p = pluginList[i]; - if (!p->bIsProtocol) + if (!p->bIsProtocol || p->bpi.hInst != nullptr) continue; - if (!TryLoadPlugin(p, false)) { - Plugin_Uninit(p); - i--; + wchar_t tszFullPath[MAX_PATH]; + mir_snwprintf(tszFullPath, L"%s\\%s\\%s", exe, L"Plugins", p->pluginname); + + BASIC_PLUGIN_INFO bpi; + if (checkAPI(tszFullPath, &bpi, 0, CHECKAPI_NONE)) { + p->bOk = p->bHasBasicApi = true; + p->bpi = bpi; } } diff --git a/src/mir_app/src/plugins.h b/src/mir_app/src/plugins.h index 9be88a225f..d860df1a67 100644 --- a/src/mir_app/src/plugins.h +++ b/src/mir_app/src/plugins.h @@ -74,7 +74,7 @@ pluginEntry* OpenPlugin(wchar_t *tszFileName, wchar_t *dir, wchar_t *path); bool TryLoadPlugin(pluginEntry *p, bool bDynamic); void Plugin_Uninit(pluginEntry *p); -int Plugin_UnloadDyn(pluginEntry *p, bool bFreeDll = true); +int Plugin_UnloadDyn(pluginEntry *p); typedef BOOL (*SCAN_PLUGINS_CALLBACK) (WIN32_FIND_DATA * fd, wchar_t *path, WPARAM wParam, LPARAM lParam); void enumPlugins(SCAN_PLUGINS_CALLBACK cb, WPARAM wParam, LPARAM lParam); -- cgit v1.2.3