From 50c2fbbb1f7f6f233c980d7e4a52151fb72820f7 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 9 May 2021 18:45:30 +0300 Subject: suddenly: tipper services were used as string constants (cherry picked from commit 15fcbbc128178ea5a4cdb1a58927a43ea740be88) --- plugins/Clist_modern/src/modern_clisttray.cpp | 2 +- plugins/Clist_modern/src/stdafx.h | 1 + plugins/Clist_nicer/src/statusbar.cpp | 6 +++--- plugins/Clist_nicer/src/stdafx.h | 1 + plugins/ExternalAPI/m_tipper.h | 29 ++++++++++++++++++++++----- plugins/TabSRMM/src/container.cpp | 2 +- plugins/TabSRMM/src/controls.cpp | 10 ++++----- plugins/TabSRMM/src/stdafx.h | 1 + plugins/TabSRMM/src/tabctrl.cpp | 12 +++++------ plugins/TipperYM/src/options.h | 2 -- plugins/TipperYM/src/tipper.cpp | 6 +++--- plugins/TrafficCounter/src/TrafficCounter.cpp | 7 ++----- 12 files changed, 48 insertions(+), 31 deletions(-) (limited to 'plugins') diff --git a/plugins/Clist_modern/src/modern_clisttray.cpp b/plugins/Clist_modern/src/modern_clisttray.cpp index bef48fc9ef..b300c8a012 100644 --- a/plugins/Clist_modern/src/modern_clisttray.cpp +++ b/plugins/Clist_modern/src/modern_clisttray.cpp @@ -409,7 +409,7 @@ int cliTrayCalcChanged(const char *szChangedProto, int, int) nid.uFlags = NIF_ICON | NIF_TIP; // if Tipper is missing or turned off for tray, use system tooltips - if (!ServiceExists("mToolTip/ShowTip") || !db_get_b(0, "Tipper", "TrayTip", 1)) + if (!ServiceExists(MS_TIPPER_SHOWTIPW) || !db_get_b(0, "Tipper", "TrayTip", 1)) wcsncpy_s(nid.szTip, g_clistApi.szTip, _TRUNCATE); Shell_NotifyIcon(NIM_MODIFY, &nid); diff --git a/plugins/Clist_modern/src/stdafx.h b/plugins/Clist_modern/src/stdafx.h index 4fca6633eb..a9b2e1fb57 100644 --- a/plugins/Clist_modern/src/stdafx.h +++ b/plugins/Clist_modern/src/stdafx.h @@ -95,6 +95,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include #include +#include #include #include #include diff --git a/plugins/Clist_nicer/src/statusbar.cpp b/plugins/Clist_nicer/src/statusbar.cpp index 348924f623..a61bd60c1e 100644 --- a/plugins/Clist_nicer/src/statusbar.cpp +++ b/plugins/Clist_nicer/src/statusbar.cpp @@ -49,7 +49,7 @@ LRESULT CALLBACK NewStatusBarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM if (tooltip_active) { KillTimer(hwnd, TIMERID_HOVER); if (!NotifyEventHooks(hStatusBarHideToolTipEvent, 0, 0)) - CallService("mToolTip/HideTip", 0, 0); + Tipper_Hide(); tooltip_active = FALSE; } KillTimer(hwnd, TIMERID_HOVER); @@ -74,7 +74,7 @@ LRESULT CALLBACK NewStatusBarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM case WM_RBUTTONDOWN: KillTimer(hwnd, TIMERID_HOVER); if (!NotifyEventHooks(hStatusBarHideToolTipEvent, 0, 0)) - CallService("mToolTip/HideTip", 0, 0); + Tipper_Hide(); tooltip_active = FALSE; break; @@ -164,7 +164,7 @@ LRESULT CALLBACK NewStatusBarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM CLCINFOTIP ti = { sizeof(ti) }; ti.isTreeFocused = (GetFocus() == g_clistApi.hwndContactList); - CallService("mToolTip/ShowTipW", (WPARAM)szTipText, (LPARAM)&ti); + Tipper_ShowTip(szTipText, &ti); } break; } diff --git a/plugins/Clist_nicer/src/stdafx.h b/plugins/Clist_nicer/src/stdafx.h index 80427aa16a..39216d9f92 100644 --- a/plugins/Clist_nicer/src/stdafx.h +++ b/plugins/Clist_nicer/src/stdafx.h @@ -55,6 +55,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include #include +#include #include #include #include diff --git a/plugins/ExternalAPI/m_tipper.h b/plugins/ExternalAPI/m_tipper.h index abaac6c206..f97e105959 100644 --- a/plugins/ExternalAPI/m_tipper.h +++ b/plugins/ExternalAPI/m_tipper.h @@ -18,27 +18,46 @@ not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - // Tipper API # pragma once +#include + // translation function type // use hContact, module and setting to read your db value(s) and put the resulting string into buff // return buff if the translation was successful, or return 0 for failure -typedef TCHAR *(TranslateFunc)(MCONTACT hContact, const char *module, const char *setting_or_prefix, TCHAR *buff, int bufflen); +typedef wchar_t* (TranslateFunc)(MCONTACT hContact, const char *module, const char *setting_or_prefix, wchar_t *buff, int bufflen); typedef struct { TranslateFunc *transFunc; // address of your translation function (see typedef above) - const TCHAR *swzName; // make sure this is unique, and DO NOT translate it + const wchar_t *swzName; // make sure this is unique, and DO NOT translate it DWORD id; // will be overwritten by Tipper - do not use } DBVTranslation; // add a translation to tipper // wParam not used // lParam = (DBVTranslation *)translation -#define MS_TIPPER_ADDTRANSLATION "Tipper/AddTranslation" +#define MS_TIPPER_ADDTRANSLATION "Tipper/AddTranslation" + +// ansi version of tipper +// wParam - optional (wchar_t *)text for text-only tips +// lParam - (CLCINFOTIP *)infoTip +#define MS_TIPPER_SHOWTIP "mToolTip/ShowTip" // unicode extension to the basic functionality // wParam - optional (wchar_t *)text for text-only tips // lParam - (CLCINFOTIP *)infoTip -#define MS_TIPPER_SHOWTIPW "mToolTip/ShowTipW" \ No newline at end of file +#define MS_TIPPER_SHOWTIPW "mToolTip/ShowTipW" + +__forceinline void Tipper_ShowTip(const wchar_t *pwsztext, CLCINFOTIP *ti) +{ CallService(MS_TIPPER_SHOWTIPW, WPARAM(pwsztext), LPARAM(ti)); +} + +// hides a tooltip +// wParam - 0 +// lParam - 0 +#define MS_TIPPER_HIDETIP "mToolTip/HideTip" + +__forceinline void Tipper_Hide() +{ CallService(MS_TIPPER_HIDETIP, 0, 0); +} diff --git a/plugins/TabSRMM/src/container.cpp b/plugins/TabSRMM/src/container.cpp index 9ab8c299a2..32d3aba8da 100644 --- a/plugins/TabSRMM/src/container.cpp +++ b/plugins/TabSRMM/src/container.cpp @@ -408,7 +408,7 @@ void TContainerData::InitDialog(HWND hwndDlg) Configure(); // tab tooltips... - if (!::ServiceExists("mToolTip/ShowTip") || M.GetByte("d_tooltips", 0) == 0) { + if (!::ServiceExists(MS_TIPPER_SHOWTIPW) || M.GetByte("d_tooltips", 0) == 0) { m_hwndTip = ::CreateWindowEx(0, TOOLTIPS_CLASS, nullptr, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwndDlg, nullptr, g_plugin.getInst(), (LPVOID)nullptr); diff --git a/plugins/TabSRMM/src/controls.cpp b/plugins/TabSRMM/src/controls.cpp index 94d1b72dd3..4c426a9e1d 100644 --- a/plugins/TabSRMM/src/controls.cpp +++ b/plugins/TabSRMM/src/controls.cpp @@ -903,7 +903,7 @@ LONG_PTR CALLBACK CMsgDialog::StatusBarSubclassProc(HWND hWnd, UINT msg, WPARAM ptMouse = pt; if (tooltip_active) { KillTimer(hWnd, TIMERID_HOVER); - CallService("mToolTip/HideTip", 0, 0); + Tipper_Hide(); tooltip_active = FALSE; } KillTimer(hWnd, TIMERID_HOVER); @@ -913,7 +913,7 @@ LONG_PTR CALLBACK CMsgDialog::StatusBarSubclassProc(HWND hWnd, UINT msg, WPARAM case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: KillTimer(hWnd, TIMERID_HOVER); - CallService("mToolTip/HideTip", 0, 0); + Tipper_Hide(); tooltip_active = FALSE; GetCursorPos(&pt); rcLastStatusBarClick.left = pt.x - 2; @@ -970,7 +970,7 @@ LONG_PTR CALLBACK CMsgDialog::StatusBarSubclassProc(HWND hWnd, UINT msg, WPARAM wcsncpy_s(wBuf, sid->szTooltip.w, _TRUNCATE); if (wBuf[0]) { - CallService("mToolTip/ShowTipW", (WPARAM)wBuf, (LPARAM)&ti); + Tipper_ShowTip(wBuf, &ti); tooltip_active = TRUE; } } @@ -982,7 +982,7 @@ LONG_PTR CALLBACK CMsgDialog::StatusBarSubclassProc(HWND hWnd, UINT msg, WPARAM mir_snwprintf(wBuf, TranslateT("There are %d pending send jobs. Message length: %d bytes, message length limit: %d bytes\n\n%d messages are queued for later delivery"), dat->m_iOpenJobs, dat->m_message.GetRichTextLength(CP_UTF8), dat->m_cache->getMaxMessageLength(), iQueued); - CallService("mToolTip/ShowTipW", (WPARAM)wBuf, (LPARAM)&ti); + Tipper_ShowTip(wBuf, &ti); } if (SendMessage(dat->m_pContainer->m_hwndStatus, SB_GETTEXT, 0, (LPARAM)wBuf)) { @@ -997,7 +997,7 @@ LONG_PTR CALLBACK CMsgDialog::StatusBarSubclassProc(HWND hWnd, UINT msg, WPARAM ptrW tszTopic(db_get_wsa(dat->m_hContact, dat->m_szProto, "Topic")); if (tszTopic != nullptr) { tooltip_active = TRUE; - CallService("mToolTip/ShowTipW", tszTopic, (LPARAM)&ti); + Tipper_ShowTip(tszTopic, &ti); } } } diff --git a/plugins/TabSRMM/src/stdafx.h b/plugins/TabSRMM/src/stdafx.h index 35440301fa..4299063adc 100644 --- a/plugins/TabSRMM/src/stdafx.h +++ b/plugins/TabSRMM/src/stdafx.h @@ -78,6 +78,7 @@ #include #include #include +#include #include #include diff --git a/plugins/TabSRMM/src/tabctrl.cpp b/plugins/TabSRMM/src/tabctrl.cpp index 62aaf2a189..5c9de4d029 100644 --- a/plugins/TabSRMM/src/tabctrl.cpp +++ b/plugins/TabSRMM/src/tabctrl.cpp @@ -1098,7 +1098,7 @@ static LRESULT CALLBACK TabControlSubclassProc(HWND hwnd, UINT msg, WPARAM wPara ptMouseT = pt; if (tabdat->bTipActive) { KillTimer(hwnd, TIMERID_HOVER_T); - CallService("mToolTip/HideTip", 0, 0); + Tipper_Hide(); tabdat->bTipActive = false; } KillTimer(hwnd, TIMERID_HOVER_T); @@ -1147,13 +1147,13 @@ static LRESULT CALLBACK TabControlSubclassProc(HWND hwnd, UINT msg, WPARAM wPara case WM_RBUTTONDOWN: KillTimer(hwnd, TIMERID_HOVER_T); - CallService("mToolTip/HideTip", 0, 0); + Tipper_Hide(); tabdat->bTipActive = false; break; case WM_LBUTTONDOWN: KillTimer(hwnd, TIMERID_HOVER_T); - CallService("mToolTip/HideTip", 0, 0); + Tipper_Hide(); tabdat->bTipActive = false; if (GetKeyState(VK_CONTROL) & 0x8000) @@ -1258,7 +1258,7 @@ static LRESULT CALLBACK TabControlSubclassProc(HWND hwnd, UINT msg, WPARAM wPara GetCursorPos(&pt); if (abs(pt.x - ptMouseT.x) < 5 && abs(pt.y - ptMouseT.y) < 5) { - CLCINFOTIP ti = { 0 }; + CLCINFOTIP ti = {}; ti.cbSize = sizeof(ti); ti.ptCursor = pt; @@ -1274,7 +1274,7 @@ static LRESULT CALLBACK TabControlSubclassProc(HWND hwnd, UINT msg, WPARAM wPara ti.isGroup = 0; ti.hItem = (HANDLE)dat->m_hContact; ti.isTreeFocused = 0; - CallService("mToolTip/ShowTip", 0, (LPARAM)&ti); + Tipper_ShowTip(0, &ti); } } } @@ -1295,7 +1295,7 @@ static LRESULT CALLBACK TabControlSubclassProc(HWND hwnd, UINT msg, WPARAM wPara case WM_USER + 100: if (tabdat->bTipActive) { tabdat->bTipActive = false; - CallService("mToolTip/HideTip", 0, 0); + Tipper_Hide(); } break; } diff --git a/plugins/TipperYM/src/options.h b/plugins/TipperYM/src/options.h index b95cf7c533..deccb7dd50 100644 --- a/plugins/TipperYM/src/options.h +++ b/plugins/TipperYM/src/options.h @@ -31,8 +31,6 @@ Boston, MA 02111-1307, USA. #define IDPRESETITEM 1000 -#define MS_TOOLTIP_SHOWTIP "mToolTip/ShowTip" - struct OPTBUTTON { UINT id, uintCoreIconId, uintResIconId; diff --git a/plugins/TipperYM/src/tipper.cpp b/plugins/TipperYM/src/tipper.cpp index eb81f2f938..4c67fbe5c3 100644 --- a/plugins/TipperYM/src/tipper.cpp +++ b/plugins/TipperYM/src/tipper.cpp @@ -303,9 +303,9 @@ int CMPlugin::Load() InitMessagePump(); // for compatibility with mToolTip status tooltips - CreateServiceFunction("mToolTip/ShowTip", ShowTip); - CreateServiceFunction("mToolTip/ShowTipW", ShowTipW); - CreateServiceFunction("mToolTip/HideTip", HideTip); + CreateServiceFunction(MS_TIPPER_SHOWTIP, ShowTip); + CreateServiceFunction(MS_TIPPER_SHOWTIPW, ShowTipW); + CreateServiceFunction(MS_TIPPER_HIDETIP, HideTip); CreateServiceFunction("mToolTip/ReloadSkin", ReloadSkin); HookEvent(ME_DB_CONTACT_SETTINGCHANGED, SettingChanged); diff --git a/plugins/TrafficCounter/src/TrafficCounter.cpp b/plugins/TrafficCounter/src/TrafficCounter.cpp index d30b307942..b686c7e66a 100644 --- a/plugins/TrafficCounter/src/TrafficCounter.cpp +++ b/plugins/TrafficCounter/src/TrafficCounter.cpp @@ -780,16 +780,13 @@ LRESULT CALLBACK TrafficCounterWndProc_MW(HWND hwnd, UINT msg, WPARAM wParam, LP if (PtInRect(&rt, TooltipPosition)) { GetCursorPos(&ptMouse); - CLCINFOTIP ti = { 0 }; + CLCINFOTIP ti = {}; ti.rcItem.left = TooltipPosition.x - 10; ti.rcItem.right = TooltipPosition.x + 10; ti.rcItem.top = TooltipPosition.y - 10; ti.rcItem.bottom = TooltipPosition.y + 10; ti.cbSize = sizeof(ti); - - wchar_t *TooltipText = variables_parsedup(Traffic_TooltipFormat, nullptr, NULL); - CallService(MS_TIPPER_SHOWTIPW, (WPARAM)TooltipText, (LPARAM)&ti); - mir_free(TooltipText); + Tipper_ShowTip(ptrW(variables_parsedup(Traffic_TooltipFormat, nullptr, NULL)), &ti); TooltipShowing = TRUE; } -- cgit v1.2.3