summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-04-11 10:57:33 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-04-11 10:57:33 +0300
commit13c7eccb6472c3c47c9c3dff582df9552938fe0e (patch)
treedc9ac47d1409b1ded3550524ba06ee5c463b9d07 /src
parent77cb253361e491335b2db7b64a1b6f40ff5bd6e4 (diff)
unneeded ME_SYSTEM_MODULESLOADED hooks inside mir_app.dll joined together
Diffstat (limited to 'src')
-rw-r--r--src/mir_app/src/clc.cpp9
-rw-r--r--src/mir_app/src/clistmod.cpp31
-rw-r--r--src/mir_app/src/clui.cpp17
-rw-r--r--src/mir_app/src/menu_utils.cpp23
-rw-r--r--src/mir_app/src/meta_main.cpp9
-rw-r--r--src/mir_app/src/meta_services.cpp3
-rw-r--r--src/mir_app/src/miranda.h2
-rw-r--r--src/mir_app/src/movetogroup.cpp2
-rw-r--r--src/mir_app/src/options.cpp17
-rw-r--r--src/mir_app/src/proto_opts.cpp13
10 files changed, 41 insertions, 85 deletions
diff --git a/src/mir_app/src/clc.cpp b/src/mir_app/src/clc.cpp
index 6d6b248cf8..9358aa5247 100644
--- a/src/mir_app/src/clc.cpp
+++ b/src/mir_app/src/clc.cpp
@@ -29,8 +29,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
void InitCustomMenus(void);
void UninitCustomMenus(void);
-void MTG_OnmodulesLoad(void);
-
static bool bModuleInitialized = false;
static HANDLE hShowInfoTipEvent;
HANDLE hHideInfoTipEvent;
@@ -124,12 +122,6 @@ static int ClcSettingChanged(WPARAM hContact, LPARAM lParam)
return 0;
}
-static int ClcModulesLoaded(WPARAM, LPARAM)
-{
- MTG_OnmodulesLoad();
- return 0;
-}
-
static int ClcProtoAck(WPARAM, LPARAM lParam)
{
ACKDATA *ack = (ACKDATA *)lParam;
@@ -205,7 +197,6 @@ int LoadCLCModule(void)
CreateServiceFunction(MS_CLC_SETINFOTIPHOVERTIME, SetInfoTipHoverTime);
CreateServiceFunction(MS_CLC_GETINFOTIPHOVERTIME, GetInfoTipHoverTime);
- HookEvent(ME_SYSTEM_MODULESLOADED, ClcModulesLoaded);
HookEvent(ME_DB_CONTACT_SETTINGCHANGED, ClcSettingChanged);
HookEvent(ME_DB_CONTACT_ADDED, ClcContactAdded);
HookEvent(ME_SKIN_ICONSCHANGED, ClcIconsChanged);
diff --git a/src/mir_app/src/clistmod.cpp b/src/mir_app/src/clistmod.cpp
index a07e2ba351..a5afd418f3 100644
--- a/src/mir_app/src/clistmod.cpp
+++ b/src/mir_app/src/clistmod.cpp
@@ -29,6 +29,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
int ContactSettingChanged(WPARAM wParam, LPARAM lParam);
int InitClistHotKeys(void);
+void InitMoveToGroup(void);
void ScheduleMenuUpdate(void);
HANDLE hContactDoubleClicked, hContactIconChangedEvent;
@@ -171,6 +172,33 @@ static int ContactListModulesLoaded(WPARAM, LPARAM)
InitClistHotKeys();
InitStaticAccounts();
+ InitMoveToGroup();
+
+ CMenuItem mi(&g_plugin);
+ SET_UID(mi, 0xb1f74008, 0x1fa6, 0x4e98, 0x95, 0x28, 0x5a, 0x7e, 0xab, 0xfe, 0x10, 0x61);
+ mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_ACCMGR);
+ mi.position = 1900000000;
+ mi.name.a = LPGEN("&Accounts...");
+ mi.pszService = MS_PROTO_SHOWACCMGR;
+ Menu_AddMainMenuItem(&mi);
+
+ SET_UID(mi, 0xc1284523, 0x548d, 0x4744, 0xb0, 0x9, 0xfb, 0xa0, 0x4, 0x8e, 0xa8, 0x67);
+ mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_OPTIONS);
+ mi.name.a = LPGEN("&Options...");
+ mi.pszService = MS_OPTIONS_OPEN;
+ Menu_AddMainMenuItem(&mi);
+
+ if (g_clistApi.hMenuMain) {
+ MENUITEMINFO mii = { 0 };
+ mii.cbSize = sizeof(mii);
+ mii.fMask = MIIM_SUBMENU;
+
+ mii.hSubMenu = Menu_GetMainMenu();
+ SetMenuItemInfo(g_clistApi.hMenuMain, 0, TRUE, &mii);
+
+ mii.hSubMenu = Menu_GetStatusMenu();
+ SetMenuItemInfo(g_clistApi.hMenuMain, 1, TRUE, &mii);
+ }
return 0;
}
@@ -380,6 +408,7 @@ int LoadContactListModule2(void)
HookEvent(ME_DB_CONTACT_ADDED, ContactAdded);
HookEvent(ME_DB_CONTACT_DELETED, ContactDeleted);
HookEvent(ME_OPT_INITIALISE, ClcOptInit);
+ HookEvent(ME_SKIN_ICONSCHANGED, CListIconsChanged);
hContactDoubleClicked = CreateHookableEvent(ME_CLIST_DOUBLECLICKED);
hContactIconChangedEvent = CreateHookableEvent(ME_CLIST_CONTACTICONCHANGED);
@@ -387,8 +416,6 @@ int LoadContactListModule2(void)
InitCListEvents();
InitGroupServices();
InitTray();
-
- HookEvent(ME_SKIN_ICONSCHANGED, CListIconsChanged);
return 0;
}
diff --git a/src/mir_app/src/clui.cpp b/src/mir_app/src/clui.cpp
index 4c7bcd492a..0aabd2f7f1 100644
--- a/src/mir_app/src/clui.cpp
+++ b/src/mir_app/src/clui.cpp
@@ -57,22 +57,6 @@ void fnLoadCluiGlobalOpts()
cluiopt.alpha = db_get_b(0, "CList", "Alpha", SETTING_ALPHA_DEFAULT);
}
-static int CluiModulesLoaded(WPARAM, LPARAM)
-{
- if (g_clistApi.hMenuMain) {
- MENUITEMINFO mii = { 0 };
- mii.cbSize = sizeof(mii);
- mii.fMask = MIIM_SUBMENU;
-
- mii.hSubMenu = Menu_GetMainMenu();
- SetMenuItemInfo(g_clistApi.hMenuMain, 0, TRUE, &mii);
-
- mii.hSubMenu = Menu_GetStatusMenu();
- SetMenuItemInfo(g_clistApi.hMenuMain, 1, TRUE, &mii);
- }
- return 0;
-}
-
// Disconnect all protocols.
// Happens on shutdown and standby.
static void DisconnectAll()
@@ -268,7 +252,6 @@ int LoadCLUIModule(void)
uMsgProcessProfile = RegisterWindowMessage(L"Miranda::ProcessProfile");
g_clistApi.pfnLoadCluiGlobalOpts();
- HookEvent(ME_SYSTEM_MODULESLOADED, CluiModulesLoaded);
HookEvent(ME_SKIN_ICONSCHANGED, CluiIconsChanged);
hContactDraggingEvent = CreateHookableEvent(ME_CLUI_CONTACTDRAGGING);
diff --git a/src/mir_app/src/menu_utils.cpp b/src/mir_app/src/menu_utils.cpp
index 1380de2271..0811a7439d 100644
--- a/src/mir_app/src/menu_utils.cpp
+++ b/src/mir_app/src/menu_utils.cpp
@@ -1208,6 +1208,7 @@ int OnIconLibChanges(WPARAM, LPARAM)
}
/////////////////////////////////////////////////////////////////////////////////////////
+// register all icons from all menus in IcoLib
static int MO_RegisterIcon(TMO_IntMenuItem *pmi, void*)
{
@@ -1255,44 +1256,28 @@ static int MO_RegisterIcon(TMO_IntMenuItem *pmi, void*)
return FALSE;
}
-int RegisterAllIconsInIconLib()
+static void CALLBACK RegisterAllIconsInIconLib()
{
- // register all icons
for (auto &p : g_menus) {
if (hStatusMenuObject == p->id) //skip status menu
continue;
MO_RecursiveWalkMenu(p->m_items.first, MO_RegisterIcon, nullptr);
}
-
- return 0;
}
/////////////////////////////////////////////////////////////////////////////////////////
// Static services
-int posttimerid;
-
-static VOID CALLBACK PostRegisterIcons(HWND, UINT, UINT_PTR, DWORD)
-{
- KillTimer(nullptr, posttimerid);
- RegisterAllIconsInIconLib();
-}
-
-static int OnModulesLoaded(WPARAM, LPARAM)
-{
- posttimerid = SetTimer(nullptr, 0, 5, (TIMERPROC)PostRegisterIcons);
- return 0;
-}
-
int InitGenMenu()
{
bIconsDisabled = db_get_b(0, "CList", "DisableMenuIcons", 0) != 0;
bIsGenMenuInited = true;
- HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
HookEvent(ME_OPT_INITIALISE, GenMenuOptInit);
HookEvent(ME_SKIN_ICONSCHANGED, OnIconLibChanges);
+
+ Miranda_WaitOnHandle(RegisterAllIconsInIconLib);
return 0;
}
diff --git a/src/mir_app/src/meta_main.cpp b/src/mir_app/src/meta_main.cpp
index 67edc51798..457da24655 100644
--- a/src/mir_app/src/meta_main.cpp
+++ b/src/mir_app/src/meta_main.cpp
@@ -57,13 +57,6 @@ void UnloadMetacontacts(void)
// Initializes the services provided and the link to those needed
// Called when the plugin is loaded into Miranda
-static int RegisterMeta(WPARAM, LPARAM)
-{
- Proto_RegisterModule(PROTOTYPE_FILTER, META_FILTER);
- Proto_RegisterModule(PROTOTYPE_VIRTUAL, META_PROTO);
- return 0;
-}
-
int LoadMetacontacts(void)
{
g_plugin.registerIcon(LPGEN("MetaContacts"), iconList, "mc");
@@ -80,8 +73,6 @@ int LoadMetacontacts(void)
Meta_ReadOptions();
- HookEvent(ME_SYSTEM_MODULESLOADED, RegisterMeta);
-
// further db setup done in modules loaded (nick [protocol string required] & clist display name)
Meta_InitServices();
return 0;
diff --git a/src/mir_app/src/meta_services.cpp b/src/mir_app/src/meta_services.cpp
index 890e719234..5c1f4f56e9 100644
--- a/src/mir_app/src/meta_services.cpp
+++ b/src/mir_app/src/meta_services.cpp
@@ -586,6 +586,9 @@ static int Meta_SrmmIconClicked(WPARAM hMeta, LPARAM lParam)
int Meta_ModulesLoaded(WPARAM, LPARAM)
{
+ Proto_RegisterModule(PROTOTYPE_FILTER, META_FILTER);
+ Proto_RegisterModule(PROTOTYPE_VIRTUAL, META_PROTO);
+
HookEvent(ME_CLIST_PREBUILDCONTACTMENU, Meta_ModifyMenu);
// hook srmm window close/open events
diff --git a/src/mir_app/src/miranda.h b/src/mir_app/src/miranda.h
index 737535f48c..7878f792f7 100644
--- a/src/mir_app/src/miranda.h
+++ b/src/mir_app/src/miranda.h
@@ -24,6 +24,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#pragma once
+#define MS_OPTIONS_OPEN "Options/OptionsCommand"
+
typedef HRESULT (STDAPICALLTYPE *pfnDrawThemeTextEx)(HTHEME, HDC, int, int, LPCWSTR, int, DWORD, LPRECT, const struct _DTTOPTS *);
typedef HRESULT (STDAPICALLTYPE *pfnSetWindowThemeAttribute)(HWND, enum WINDOWTHEMEATTRIBUTETYPE, PVOID, DWORD);
typedef HRESULT (STDAPICALLTYPE *pfnBufferedPaintInit)(void);
diff --git a/src/mir_app/src/movetogroup.cpp b/src/mir_app/src/movetogroup.cpp
index 248a6b140a..78bbdb53be 100644
--- a/src/mir_app/src/movetogroup.cpp
+++ b/src/mir_app/src/movetogroup.cpp
@@ -128,7 +128,7 @@ static INT_PTR MTG_DOMOVE(WPARAM wParam, LPARAM lParam)
return 0;
}
-void MTG_OnmodulesLoad()
+void InitMoveToGroup()
{
HookEvent(ME_CLIST_PREBUILDCONTACTMENU, OnContactMenuBuild);
CreateServiceFunction(MTG_MOVE, MTG_DOMOVE);
diff --git a/src/mir_app/src/options.cpp b/src/mir_app/src/options.cpp
index a8f1ae437b..3e34f00092 100644
--- a/src/mir_app/src/options.cpp
+++ b/src/mir_app/src/options.cpp
@@ -1275,19 +1275,6 @@ static int OptDynamicLoadOptions(WPARAM, LPARAM hInstance)
return 0;
}
-static int OptModulesLoaded(WPARAM, LPARAM)
-{
- CMenuItem mi(&g_plugin);
- SET_UID(mi, 0xc1284523, 0x548d, 0x4744, 0xb0, 0x9, 0xfb, 0xa0, 0x4, 0x8e, 0xa8, 0x67);
- mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_OPTIONS);
- mi.position = 1900000000;
- mi.name.a = LPGEN("&Options...");
- mi.pszService = "Options/OptionsCommand";
- Menu_AddMainMenuItem(&mi);
- CreateServiceFunction(mi.pszService, OpenOptionsDialog);
- return 0;
-}
-
int ShutdownOptionsModule(WPARAM, LPARAM)
{
delete pOptionsDlg; pOptionsDlg = nullptr;
@@ -1296,10 +1283,10 @@ int ShutdownOptionsModule(WPARAM, LPARAM)
int LoadOptionsModule(void)
{
- HookEvent(ME_OPT_INITIALISE, LangpackOptionsInit);
+ CreateServiceFunction(MS_OPTIONS_OPEN, OpenOptionsDialog);
+ HookEvent(ME_OPT_INITIALISE, LangpackOptionsInit);
HookEvent(ME_SYSTEM_MODULELOAD, OptDynamicLoadOptions);
- HookEvent(ME_SYSTEM_MODULESLOADED, OptModulesLoaded);
HookEvent(ME_SYSTEM_PRESHUTDOWN, ShutdownOptionsModule);
return 0;
}
diff --git a/src/mir_app/src/proto_opts.cpp b/src/mir_app/src/proto_opts.cpp
index 6c3784d9e7..3742a04f4a 100644
--- a/src/mir_app/src/proto_opts.cpp
+++ b/src/mir_app/src/proto_opts.cpp
@@ -979,18 +979,6 @@ static INT_PTR OptProtosShow(WPARAM, LPARAM)
return 0;
}
-int OptProtosLoaded(WPARAM, LPARAM)
-{
- CMenuItem mi(&g_plugin);
- SET_UID(mi, 0xb1f74008, 0x1fa6, 0x4e98, 0x95, 0x28, 0x5a, 0x7e, 0xab, 0xfe, 0x10, 0x61);
- mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_ACCMGR);
- mi.position = 1900000000;
- mi.name.a = LPGEN("&Accounts...");
- mi.pszService = MS_PROTO_SHOWACCMGR;
- Menu_AddMainMenuItem(&mi);
- return 0;
-}
-
static int OnAccListChanged(WPARAM eventCode, LPARAM lParam)
{
PROTOACCOUNT *pa = (PROTOACCOUNT*)lParam;
@@ -1018,7 +1006,6 @@ int LoadProtoOptions(void)
{
CreateServiceFunction(MS_PROTO_SHOWACCMGR, OptProtosShow);
- HookEvent(ME_SYSTEM_MODULESLOADED, OptProtosLoaded);
HookEvent(ME_PROTO_ACCLISTCHANGED, OnAccListChanged);
HookEvent(ME_SYSTEM_PRESHUTDOWN, ShutdownAccMgr);
return 0;