diff options
author | George Hazan <george.hazan@gmail.com> | 2025-04-10 18:59:36 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2025-04-10 18:59:36 +0300 |
commit | 86cae9eed59527acdbd64f5a1964d5b82be07c22 (patch) | |
tree | 5e97ac7c4b7309a7a7f261f37bf59aa917e551e7 /protocols/Weather/src | |
parent | 7028b158bc798dffcb7b5ca0eaa4bc0ff77ed76a (diff) |
code cleaning
Diffstat (limited to 'protocols/Weather/src')
-rw-r--r-- | protocols/Weather/src/proto.h | 3 | ||||
-rw-r--r-- | protocols/Weather/src/weather_mwin.cpp | 4 | ||||
-rw-r--r-- | protocols/Weather/src/weather_proto.cpp | 4 | ||||
-rw-r--r-- | protocols/Weather/src/weather_svcs.cpp | 33 |
4 files changed, 27 insertions, 17 deletions
diff --git a/protocols/Weather/src/proto.h b/protocols/Weather/src/proto.h index ae92cf59b4..3e990931d1 100644 --- a/protocols/Weather/src/proto.h +++ b/protocols/Weather/src/proto.h @@ -170,8 +170,6 @@ class CWeatherProto : public PROTO<CWeatherProto> void InitMwin(void); void DestroyMwin(void); - int __cdecl BuildContactMenu(WPARAM, LPARAM); - INT_PTR __cdecl Mwin_MenuClicked(WPARAM, LPARAM); // options @@ -262,6 +260,7 @@ public: void OnShutdown() override; static void GlobalMenuInit(); + int __cdecl BuildContactMenu(MCONTACT); int __cdecl OnToolbarLoaded(WPARAM, LPARAM); }; diff --git a/protocols/Weather/src/weather_mwin.cpp b/protocols/Weather/src/weather_mwin.cpp index 058c6e56ad..cb1e33849b 100644 --- a/protocols/Weather/src/weather_mwin.cpp +++ b/protocols/Weather/src/weather_mwin.cpp @@ -276,9 +276,9 @@ INT_PTR CWeatherProto::Mwin_MenuClicked(WPARAM hContact, LPARAM) return 0; } -int CWeatherProto::BuildContactMenu(WPARAM wparam, LPARAM) +int CWeatherProto::BuildContactMenu(MCONTACT hContact) { - int flags = getDword(wparam, "mwin") ? CMIF_CHECKED : 0; + int flags = getDword(hContact, "mwin") ? CMIF_CHECKED : 0; Menu_ModifyItem(hMwinMenu, nullptr, INVALID_HANDLE_VALUE, flags); return 0; } diff --git a/protocols/Weather/src/weather_proto.cpp b/protocols/Weather/src/weather_proto.cpp index 3c5f8f1057..a5a3986bb7 100644 --- a/protocols/Weather/src/weather_proto.cpp +++ b/protocols/Weather/src/weather_proto.cpp @@ -30,7 +30,6 @@ CWeatherProto::CWeatherProto(const char *protoName, const wchar_t *userName) : HookProtoEvent(ME_OPT_INITIALISE, &CWeatherProto::OptInit); HookProtoEvent(ME_CLIST_DOUBLECLICKED, &CWeatherProto::BriefInfoEvt); - HookProtoEvent(ME_CLIST_PREBUILDCONTACTMENU, &CWeatherProto::BuildContactMenu); // load options and set defaults LoadOptions(); @@ -38,9 +37,6 @@ CWeatherProto::CWeatherProto(const char *protoName, const wchar_t *userName) : // reset the weather data at startup for individual contacts EraseAllInfo(); - // menu items - InitMenuItems(); - // popup initialization CMStringW wszTitle(FORMAT, L"%s %s", m_tszUserName, TranslateT("notifications")); g_plugin.addPopupOption(wszTitle, m_bPopups); diff --git a/protocols/Weather/src/weather_svcs.cpp b/protocols/Weather/src/weather_svcs.cpp index f61abe3b41..6f897e3d7a 100644 --- a/protocols/Weather/src/weather_svcs.cpp +++ b/protocols/Weather/src/weather_svcs.cpp @@ -185,6 +185,19 @@ INT_PTR CWeatherProto::EnableDisableCmd(WPARAM wParam, LPARAM lParam) ///////////////////////////////////////////////////////////////////////////////////////// // adding weather contact menus +static std::vector<HGENMENU> g_menuItems; + +static int OnPrebuildMenu(WPARAM hContact, LPARAM) +{ + auto *ppro = CMPlugin::getInstance(hContact); + for (auto &it : g_menuItems) + Menu_ShowItem(it, ppro != 0); + + if (ppro) + ppro->BuildContactMenu(hContact); + return 0; +} + void CWeatherProto::GlobalMenuInit() { CMenuItem mi(&g_plugin); @@ -195,7 +208,7 @@ void CWeatherProto::GlobalMenuInit() mi.hIcolibItem = g_plugin.getIconHandle(IDI_UPDATE); mi.name.a = LPGEN("Update Weather"); mi.pszService = MODULENAME "/Update"; - Menu_AddContactMenuItem(&mi); + g_menuItems.push_back(Menu_AddContactMenuItem(&mi)); CreateServiceFunction(mi.pszService, GlobalService<&CWeatherProto::UpdateSingleStation>); SET_UID(mi, 0x45361b4, 0x8de, 0x44b4, 0x8f, 0x11, 0x9b, 0xe9, 0x6e, 0xa8, 0x83, 0x54); @@ -203,7 +216,7 @@ void CWeatherProto::GlobalMenuInit() mi.hIcolibItem = g_plugin.getIconHandle(IDI_UPDATE2); mi.name.a = LPGEN("Remove Old Data then Update"); mi.pszService = MODULENAME "/Refresh"; - Menu_AddContactMenuItem(&mi); + g_menuItems.push_back(Menu_AddContactMenuItem(&mi)); CreateServiceFunction(mi.pszService, GlobalService<&CWeatherProto::UpdateSingleRemove>); SET_UID(mi, 0x4232975e, 0xb181, 0x46a5, 0xb7, 0x6e, 0xd2, 0x5f, 0xef, 0xb8, 0xc4, 0x4d); @@ -211,7 +224,7 @@ void CWeatherProto::GlobalMenuInit() mi.hIcolibItem = g_plugin.getIconHandle(IDI_S); mi.name.a = LPGEN("Brief Information"); mi.pszService = MODULENAME "/Brief"; - Menu_AddContactMenuItem(&mi); + g_menuItems.push_back(Menu_AddContactMenuItem(&mi)); CreateServiceFunction(mi.pszService, GlobalService<&CWeatherProto::BriefInfo>); SET_UID(mi, 0x3d6ed729, 0xd49a, 0x4ae9, 0x8e, 0x2, 0x9f, 0xe0, 0xf0, 0x2c, 0xcc, 0xb1); @@ -219,7 +232,7 @@ void CWeatherProto::GlobalMenuInit() mi.hIcolibItem = g_plugin.getIconHandle(IDI_READ); mi.name.a = LPGEN("Read Complete Forecast"); mi.pszService = MODULENAME "/CompleteForecast"; - Menu_AddContactMenuItem(&mi); + g_menuItems.push_back(Menu_AddContactMenuItem(&mi)); CreateServiceFunction(mi.pszService, GlobalService<&CWeatherProto::LoadForecast>); SET_UID(mi, 0xc4b6c5e0, 0x13c3, 0x4e02, 0x8a, 0xeb, 0xeb, 0x8a, 0xe2, 0x66, 0x40, 0xd4); @@ -227,7 +240,7 @@ void CWeatherProto::GlobalMenuInit() mi.hIcolibItem = g_plugin.getIconHandle(IDI_MAP); mi.name.a = LPGEN("Weather Map"); mi.pszService = MODULENAME "/Map"; - Menu_AddContactMenuItem(&mi); + g_menuItems.push_back(Menu_AddContactMenuItem(&mi)); CreateServiceFunction(mi.pszService, GlobalService<&CWeatherProto::WeatherMap>); SET_UID(mi, 0xee3ad7f4, 0x3377, 0x4e4c, 0x8f, 0x3c, 0x3b, 0xf5, 0xd4, 0x86, 0x28, 0x25); @@ -235,7 +248,7 @@ void CWeatherProto::GlobalMenuInit() mi.hIcolibItem = g_plugin.getIconHandle(IDI_LOG); mi.name.a = LPGEN("View Log"); mi.pszService = MODULENAME "/Log"; - Menu_AddContactMenuItem(&mi); + g_menuItems.push_back(Menu_AddContactMenuItem(&mi)); CreateServiceFunction(mi.pszService, GlobalService<&CWeatherProto::ViewLog>); SET_UID(mi, 0x1b01cd6a, 0xe5ee, 0x42b4, 0xa1, 0x6d, 0x43, 0xb9, 0x4, 0x58, 0x43, 0x2e); @@ -243,7 +256,7 @@ void CWeatherProto::GlobalMenuInit() mi.hIcolibItem = g_plugin.getIconHandle(IDI_EDIT); mi.name.a = LPGEN("Edit Settings"); mi.pszService = MODULENAME "/Edit"; - Menu_AddContactMenuItem(&mi); + g_menuItems.push_back(Menu_AddContactMenuItem(&mi)); CreateServiceFunction(mi.pszService, GlobalService<&CWeatherProto::EditSettings>); if (ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) { @@ -251,11 +264,13 @@ void CWeatherProto::GlobalMenuInit() mi.pszService = MODULENAME "/mwin_menu"; CreateServiceFunction(mi.pszService, GlobalService<&CWeatherProto::Mwin_MenuClicked>); mi.position = -0x7FFFFFF0; - mi.hIcolibItem = nullptr; + mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_FRAME); mi.root = nullptr; mi.name.a = LPGEN("Display in a frame"); - hMwinMenu = Menu_AddContactMenuItem(&mi); + g_menuItems.push_back(hMwinMenu = Menu_AddContactMenuItem(&mi)); } + + HookEvent(ME_CLIST_PREBUILDCONTACTMENU, &OnPrebuildMenu); } ///////////////////////////////////////////////////////////////////////////////////////// |