From b065360292ad47075b4f7938fe6f3f2c26902640 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 22 Mar 2018 12:25:38 +0300 Subject: SetServiceModePlugin - core functionality exported from mir_app --- src/mir_app/src/mir_app.def | 1 + src/mir_app/src/mir_app64.def | 1 + src/mir_app/src/miranda.h | 2 ++ src/mir_app/src/modules.cpp | 3 +-- src/mir_app/src/newplugins.cpp | 20 +++++++------------- src/mir_app/src/profilemanager.cpp | 4 +--- 6 files changed, 13 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index ac28a88653..6623c82e7b 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -489,3 +489,4 @@ Image_Resize @506 Image_Save @507 GetDatabasePlugin @508 ?AccContacts@PROTO_INTERFACE@@QBE?AVContacts@@XZ @509 NONAME +SetServiceModePlugin @510 diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 6f4d79842a..642a4031ce 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -489,3 +489,4 @@ Image_Resize @506 Image_Save @507 GetDatabasePlugin @508 ?AccContacts@PROTO_INTERFACE@@QEBA?AVContacts@@XZ @509 NONAME +SetServiceModePlugin @510 diff --git a/src/mir_app/src/miranda.h b/src/mir_app/src/miranda.h index 5d54d49e57..639bb077ef 100644 --- a/src/mir_app/src/miranda.h +++ b/src/mir_app/src/miranda.h @@ -67,6 +67,8 @@ extern HINSTANCE g_hInst; extern DWORD hMainThreadId; extern HANDLE hOkToExitEvent, hModulesLoadedEvent, hevLoadModule, hevUnloadModule; extern wchar_t mirandabootini[MAX_PATH]; +extern struct pluginEntry *plugin_crshdmp, *plugin_service, *plugin_ssl; + /**** newplugins.cpp *******************************************************************/ diff --git a/src/mir_app/src/modules.cpp b/src/mir_app/src/modules.cpp index f63688d5cf..2c6ab808ec 100644 --- a/src/mir_app/src/modules.cpp +++ b/src/mir_app/src/modules.cpp @@ -59,7 +59,6 @@ int LoadButtonModule(void); // window class: button class int LoadFontserviceModule(void); // ui: font manager int LoadIcoLibModule(void); // ui: icons manager int LoadServiceModePlugin(void); -int LoadDefaultServiceModePlugin(void); void UnloadAccountsModule(void); void UnloadClcModule(void); @@ -104,7 +103,7 @@ int LoadDefaultModules(void) } } - switch (LoadDefaultServiceModePlugin()) { + switch (SetServiceModePlugin(CmdLine_GetOption(L"svc"))) { case SERVICE_CONTINUE: // continue loading Miranda normally case SERVICE_ONLYDB: // load database and go to the message cycle break; diff --git a/src/mir_app/src/newplugins.cpp b/src/mir_app/src/newplugins.cpp index 6c8a59924e..6431399e18 100644 --- a/src/mir_app/src/newplugins.cpp +++ b/src/mir_app/src/newplugins.cpp @@ -59,7 +59,7 @@ static int sttFakeID = -100; static HANDLE hPluginListHeap = nullptr; static int askAboutIgnoredPlugins; -static pluginEntry *plugin_crshdmp, *serviceModePlugin, *plugin_ssl; +pluginEntry *plugin_crshdmp, *plugin_service, *plugin_ssl; #define PLUGINDISABLELIST "PluginDisable" @@ -667,11 +667,6 @@ int UnloadPlugin(wchar_t* buf, int bufLen) ///////////////////////////////////////////////////////////////////////////////////////// // Service plugins functions -void SetServiceModePlugin(pluginEntry *p) -{ - serviceModePlugin = p; -} - static int LaunchServicePlugin(pluginEntry *p) { // plugin load failed - terminating Miranda @@ -692,18 +687,17 @@ static int LaunchServicePlugin(pluginEntry *p) return SERVICE_FAILED; } -int LoadDefaultServiceModePlugin() +MIR_APP_DLL(int) SetServiceModePlugin(const wchar_t *wszPluginName) { - LPCTSTR param = CmdLine_GetOption(L"svc"); - if (param == nullptr || *param == 0) + size_t cbLen = mir_wstrlen(wszPluginName); + if (cbLen == 0) return SERVICE_CONTINUE; - size_t cbLen = mir_wstrlen(param); for (auto &p : servicePlugins) { - if (!wcsnicmp(p->pluginname, param, cbLen)) { + if (!wcsnicmp(p->pluginname, wszPluginName, cbLen)) { int res = LaunchServicePlugin(p); if (res == SERVICE_ONLYDB) // load it later - serviceModePlugin = p; + plugin_service = p; return res; } } @@ -713,7 +707,7 @@ int LoadDefaultServiceModePlugin() int LoadServiceModePlugin() { - return (serviceModePlugin == nullptr) ? SERVICE_CONTINUE : LaunchServicePlugin(serviceModePlugin); + return (plugin_service == nullptr) ? SERVICE_CONTINUE : LaunchServicePlugin(plugin_service); } void EnsureCheckerLoaded(bool bEnable) diff --git a/src/mir_app/src/profilemanager.cpp b/src/mir_app/src/profilemanager.cpp index 48d7d71451..8393c0c591 100644 --- a/src/mir_app/src/profilemanager.cpp +++ b/src/mir_app/src/profilemanager.cpp @@ -35,8 +35,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. typedef BOOL (__cdecl *ENUMPROFILECALLBACK) (wchar_t *tszFullPath, wchar_t *profile, LPARAM lParam); -void SetServiceModePlugin(pluginEntry *p); - ///////////////////////////////////////////////////////////////////////////////////////// // Profile creator @@ -622,7 +620,7 @@ public: if (curSel != -1) { int idx = m_servicePlugs.GetItemData(curSel); if (idx != -1) - SetServiceModePlugin(servicePlugins[idx]); + plugin_service = servicePlugins[idx]; } DestroyIcon((HICON)SendMessage(m_hwnd, WM_SETICON, ICON_SMALL, 0)); -- cgit v1.2.3