diff options
-rw-r--r-- | include/delphi/m_api.pas | 19 | ||||
-rw-r--r-- | include/delphi/m_helpers.inc | 3 | ||||
-rw-r--r-- | include/delphi/m_langpack.inc | 4 | ||||
-rw-r--r-- | libs/win32/mir_app.lib | bin | 164330 -> 164768 bytes | |||
-rw-r--r-- | libs/win64/mir_app.lib | bin | 159446 -> 159848 bytes | |||
-rw-r--r-- | src/mir_app/src/CMPluginBase.cpp | 25 | ||||
-rw-r--r-- | src/mir_app/src/mir_app.def | 2 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 2 | ||||
-rw-r--r-- | src/mir_app/src/newplugins.cpp | 13 |
9 files changed, 51 insertions, 17 deletions
diff --git a/include/delphi/m_api.pas b/include/delphi/m_api.pas index 70d52c39af..21b2a365ac 100644 --- a/include/delphi/m_api.pas +++ b/include/delphi/m_api.pas @@ -140,6 +140,16 @@ type true : (uuid :MUUID); // plugin's unique identifier
end;
+type
+ PCMPlugin = ^CMPlugin;
+ CMPlugin = record
+ m_hInst : THANDLE;
+ m_szModule : PAnsiChar;
+ m_pInfo : PPLUGININFOEX;
+ m_hLogger : THANDLE;
+ m_hLang : int;
+ end;
+
//----- Fork enchancement -----
{
Miranda/System/LoadModule event
@@ -180,6 +190,7 @@ var { has to be returned via MirandaPluginInfo and has to be statically allocated,
this means only one module can return info, you shouldn't be merging them anyway! }
PluginInfo: TPLUGININFOEX;
+ g_plugin: CMPlugin;
{$include m_clist.inc}
{$include m_genmenu.inc}
@@ -243,4 +254,12 @@ implementation {$undef M_API_UNIT}
{$include m_helpers.inc}
+initialization
+ g_plugin.m_hInst := hInstance;
+ RegisterPlugin(g_plugin);
+ hLangpack := g_plugin.m_hLang;
+
+finalization
+ UnregisterPlugin(g_plugin);
+
end.
diff --git a/include/delphi/m_helpers.inc b/include/delphi/m_helpers.inc index 9810ff69a4..bea8231de3 100644 --- a/include/delphi/m_helpers.inc +++ b/include/delphi/m_helpers.inc @@ -254,9 +254,8 @@ end; function Langpack_Register:int_ptr;
begin
- mir_getLP(PluginInfo, hLangpack);
cli := Clist_GetInterface();
- result:=hLangpack;
+ result := hLangpack;
end;
diff --git a/include/delphi/m_langpack.inc b/include/delphi/m_langpack.inc index 3091b574b3..597c0cf1db 100644 --- a/include/delphi/m_langpack.inc +++ b/include/delphi/m_langpack.inc @@ -35,7 +35,7 @@ const ME_LANGPACK_CHANGE:PAnsiChar = 'LangPack/Changed';
-procedure mir_getLP(var pInfo:TPLUGININFOEX; var hLang:int); stdcall;
- external CoreDLL name 'mir_getLP';
+procedure RegisterPlugin(var pInfo:CMPlugin); stdcall; external AppDLL;
+procedure UnregisterPlugin(var pInfo:CMPlugin); stdcall; external AppDLL;
{$ENDIF}
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib Binary files differindex c86de765bc..65b4dd78f9 100644 --- a/libs/win32/mir_app.lib +++ b/libs/win32/mir_app.lib diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib Binary files differindex 05d0a32487..07a48a5396 100644 --- a/libs/win64/mir_app.lib +++ b/libs/win64/mir_app.lib diff --git a/src/mir_app/src/CMPluginBase.cpp b/src/mir_app/src/CMPluginBase.cpp index bcc1601967..4476db9c38 100644 --- a/src/mir_app/src/CMPluginBase.cpp +++ b/src/mir_app/src/CMPluginBase.cpp @@ -74,6 +74,15 @@ MIR_APP_DLL(int) GetPluginLangId(const MUUID &uuid, int _hLang) return 0; } +MIR_APP_DLL(int) IsPluginLoaded(const MUUID &uuid) +{ + for (auto &it : pluginListAddr) + if (it->getInfo().uuid == uuid) + return it->getInst() != nullptr; + + return false; +} + char* GetPluginNameByInstance(HINSTANCE hInst) { CMPluginBase *pPlugin = pluginListAddr.find((CMPluginBase*)&hInst); @@ -93,6 +102,22 @@ MIR_APP_DLL(int) GetPluginLangByInstance(HINSTANCE hInst) } ///////////////////////////////////////////////////////////////////////////////////////// +// stubs for pascal plugins + +EXTERN_C MIR_APP_DLL(void) RegisterPlugin(CMPluginBase *pPlugin) +{ + if (pPlugin->getInst() != nullptr) + pluginListAddr.insert(pPlugin); + + mir_getLP(&pPlugin->getInfo(), &pPlugin->m_hLang); +} + +EXTERN_C MIR_APP_DLL(void) UnregisterPlugin(CMPluginBase *pPlugin) +{ + pluginListAddr.remove(pPlugin); +} + +///////////////////////////////////////////////////////////////////////////////////////// CMPluginBase::CMPluginBase(const char *moduleName, const PLUGININFOEX &pInfo) : m_szModuleName(moduleName), diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index d586787cc3..4419a6009f 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -600,3 +600,5 @@ GetPluginByInstance @626 ?openOptions@CMPluginBase@@QAEXPB_W00@Z @629 NONAME
?openOptionsPage@CMPluginBase@@QAEXPB_W00@Z @630 NONAME
?getInfo@CMPluginBase@@QBEABUPLUGININFOEX@@XZ @631 NONAME
+RegisterPlugin @632
+UnregisterPlugin @633
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 9124e6c95f..219835d093 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -600,3 +600,5 @@ GetPluginByInstance @626 ?openOptions@CMPluginBase@@QEAAXPEB_W00@Z @629 NONAME
?openOptionsPage@CMPluginBase@@QEAAXPEB_W00@Z @630 NONAME
?getInfo@CMPluginBase@@QEBAAEBUPLUGININFOEX@@XZ @631 NONAME
+RegisterPlugin @632
+UnregisterPlugin @633
diff --git a/src/mir_app/src/newplugins.cpp b/src/mir_app/src/newplugins.cpp index 46ffe1a449..6ed202455e 100644 --- a/src/mir_app/src/newplugins.cpp +++ b/src/mir_app/src/newplugins.cpp @@ -174,19 +174,6 @@ int LoadStdPlugins() /////////////////////////////////////////////////////////////////////////////////////////
// global functions
-MIR_APP_DLL(int) IsPluginLoaded(const MUUID &uuid)
-{
- for (auto &p : pluginList) {
- if (!p->bpi.hInst)
- continue;
-
- if (p->bpi.pluginInfo->uuid == uuid)
- return true;
- }
-
- return false;
-}
-
static bool validInterfaceList(MUUID *piface)
{
if (piface == nullptr)
|