diff options
author | George Hazan <george.hazan@gmail.com> | 2023-12-07 12:34:11 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2023-12-07 12:34:15 +0300 |
commit | 4e37f3cad6064396a701fe96bf4801d37d40b362 (patch) | |
tree | 120628241d4f69ad1db55b2d5b883d53670784e8 /plugins | |
parent | ceeb2257878b17ebda20f8f3eea72ae2de598fb4 (diff) |
fingerprint: more strict service definitions
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/ClientChangeNotify/src/ClientChangeNotify.cpp | 2 | ||||
-rw-r--r-- | plugins/ExternalAPI/m_fingerprint.h | 27 | ||||
-rw-r--r-- | plugins/FingerprintNG/src/fingerprint.cpp | 257 | ||||
-rw-r--r-- | plugins/MenuItemEx/src/main.cpp | 14 | ||||
-rw-r--r-- | plugins/QuickSearch/src/main.cpp | 3 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgdlgother.cpp | 2 | ||||
-rw-r--r-- | plugins/TipperYM/src/popwin.cpp | 2 |
7 files changed, 145 insertions, 162 deletions
diff --git a/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp b/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp index c8e7adbdca..f6f28b56c1 100644 --- a/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp +++ b/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp @@ -283,7 +283,7 @@ INT_PTR CALLBACK CCNErrorDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM) static int ModuleLoad(WPARAM, LPARAM)
{
- bFingerprintExists = ServiceExists(MS_FP_SAMECLIENTST) && ServiceExists(MS_FP_GETCLIENTICONT);
+ bFingerprintExists = Finger_IsPresent();
bVariablesExists = ServiceExists(MS_VARS_FORMATSTRING);
return 0;
}
diff --git a/plugins/ExternalAPI/m_fingerprint.h b/plugins/ExternalAPI/m_fingerprint.h index a7de242da0..6b411f41a5 100644 --- a/plugins/ExternalAPI/m_fingerprint.h +++ b/plugins/ExternalAPI/m_fingerprint.h @@ -18,28 +18,21 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-/************************************************************************/
-/* Author: Artem Shpynov aka FYR mailto:shpynov@nm.ru */
-/* icons by Angeli-Ka */
-/* January 12, 2006 */
-/************************************************************************/
-
-/*
- * FINGERPRINT PLUGIN SERVICES HEADER
- */
-
#pragma once
+__forceinline bool Finger_IsPresent()
+{ return ServiceExists("Fingerprint/SameClients");
+}
+
/*
* Service SameClientsW MS_FP_SAMECLIENTSW
* wParam - LPCWSTR first MirVer value
* lParam - LPCWSTR second MirVer value
* returns LPCWSTR: client desription (DO NOT DESTROY) if clients are same otherwise NULL
*/
-#define MS_FP_SAMECLIENTSW "Fingerprint/SameClientsW"
__forceinline LPCWSTR Finger_IsSameClents(LPCWSTR pwszName1, LPCWSTR pwszName2)
-{ return (LPCWSTR)CallService(MS_FP_SAMECLIENTSW, (WPARAM)pwszName1, (WPARAM)pwszName2);
+{ return (LPCWSTR)CallService("Fingerprint/SameClients", (WPARAM)pwszName1, (WPARAM)pwszName2);
}
/*
@@ -48,10 +41,9 @@ __forceinline LPCWSTR Finger_IsSameClents(LPCWSTR pwszName1, LPCWSTR pwszName2) * lParam - NULL (unused)
* returns LPCWSTR: client description (DO NOT DESTROY) otherwise NULL
*/
-#define MS_FP_GETCLIENTDESCRW "Fingerprint/GetClientDescrW"
__forceinline LPCWSTR Finger_GetClientDescr(LPCWSTR pwszName)
-{ return (LPCWSTR)CallService(MS_FP_GETCLIENTDESCRW, (WPARAM)pwszName, 0);
+{ return (LPCWSTR)CallService("Fingerprint/GetClientDescr", (WPARAM)pwszName, 0);
}
/*
@@ -60,12 +52,7 @@ __forceinline LPCWSTR Finger_GetClientDescr(LPCWSTR pwszName) * lParam - int noCopy - if wParam is equal to "1" will return icon handler without copiing icon.
* the returned in this case handler is static valid only till next service call.
*/
-#define MS_FP_GETCLIENTICONW "Fingerprint/GetClientIconW"
__forceinline HICON Finger_GetClientIcon(LPCWSTR pwszName, BOOL bNoCopy)
-{ return (HICON)CallService(MS_FP_GETCLIENTICONW, (WPARAM)pwszName, bNoCopy);
+{ return (HICON)CallService("Fingerprint/GetClientIcon", (WPARAM)pwszName, bNoCopy);
}
-
-#define MS_FP_SAMECLIENTST MS_FP_SAMECLIENTSW
-#define MS_FP_GETCLIENTDESCRT MS_FP_GETCLIENTDESCRW
-#define MS_FP_GETCLIENTICONT MS_FP_GETCLIENTICONW
diff --git a/plugins/FingerprintNG/src/fingerprint.cpp b/plugins/FingerprintNG/src/fingerprint.cpp index 31f41b9a8b..05ed0c8612 100644 --- a/plugins/FingerprintNG/src/fingerprint.cpp +++ b/plugins/FingerprintNG/src/fingerprint.cpp @@ -39,108 +39,11 @@ static OBJLIST<FOUNDINFO> arFI(50, CompareFI); static LIST<void> arMonitoredWindows(3, PtrKeySortT);
-static INT_PTR ServiceGetClientIconW(WPARAM wParam, LPARAM lParam);
-
-/* ApplyFingerprintImage
-* 1)Try to find appropriate mask
-* 2)Register icon in extraimage list if not yet registered (EMPTY_EXTRA_ICON)
-* 3)Set ExtraImage for contact
-*/
-
-static void SetSrmmIcon(MCONTACT hContact, LPTSTR ptszMirver)
-{
- if (mir_wstrlen(ptszMirver))
- Srmm_ModifyIcon(hContact, MODULENAME, 1, (HICON)ServiceGetClientIconW((WPARAM)ptszMirver, TRUE), ptszMirver);
- else
- Srmm_SetIconFlags(hContact, MODULENAME, 1, MBF_HIDDEN);
-}
-
-int __fastcall ApplyFingerprintImage(MCONTACT hContact, LPTSTR szMirVer)
-{
- if (hContact == NULL)
- return 0;
-
- HANDLE hImage = INVALID_HANDLE_VALUE;
- if (szMirVer)
- hImage = GetIconIndexFromFI(szMirVer);
-
- ExtraIcon_SetIcon(hExtraIcon, hContact, hImage);
-
- if (arMonitoredWindows.getIndex((HANDLE)hContact) != -1)
- SetSrmmIcon(hContact, szMirVer);
-
- return 0;
-}
-
-int OnExtraIconClick(WPARAM wParam, LPARAM, LPARAM)
-{
- CallService(MS_USERINFO_SHOWDIALOG, wParam, NULL);
- return 0;
-}
-
-/*
-* WildCompare
-* Compare 'name' string with 'mask' strings.
-* Masks can contain '*' or '?' wild symbols
-* Asterics '*' symbol covers 'empty' symbol too e.g WildCompare("Tst","T*st*"), returns TRUE
-* In order to handle situation 'at least one any sybol' use "?*" combination:
-* e.g WildCompare("Tst","T?*st*"), returns FALSE, but both WildCompare("Test","T?*st*") and
-* WildCompare("Teeest","T?*st*") return TRUE.
-*
-* Function is case sensitive! so convert input or modify func to use _qtoupper()
-*
-* Mask can contain several submasks. In this case each submask (including first)
-* should start from '|' e.g: "|first*submask|second*mask".
-*
-* Dec 25, 2006 by FYR:
-* Added Exception to masks: the mask "|^mask3|mask2|mask1" means:
-* if NOT according to mask 3 AND (mask1 OR mask2)
-* EXCEPTION should be BEFORE main mask:
-* IF Exception match - the comparing stops as FALSE
-* IF Exception does not match - comparing continue
-* IF Mask match - comparing stops as TRUE
-* IF Mask does not not match comparing continue
-*/
-BOOL __fastcall WildCompare(LPWSTR wszName, LPWSTR wszMask)
-{
- if (wszMask == nullptr)
- return NULL;
-
- if (*wszMask != L'|')
- return wildcmpw(wszName, wszMask);
-
- size_t s = 1, e = 1;
- LPWSTR wszTemp = (LPWSTR)_alloca(mir_wstrlen(wszMask) * sizeof(wchar_t) + sizeof(wchar_t));
- BOOL bExcept;
-
- while (wszMask[e] != L'\0')
- {
- s = e;
- while (wszMask[e] != L'\0' && wszMask[e] != L'|') e++;
-
- // exception mask
- bExcept = (*(wszMask + s) == L'^');
- if (bExcept) s++;
-
- memcpy(wszTemp, wszMask + s, (e - s) * sizeof(wchar_t));
- wszTemp[e - s] = L'\0';
-
- if (wildcmpw(wszName, wszTemp))
- return !bExcept;
-
- if (wszMask[e] != L'\0')
- e++;
- else
- return FALSE;
- }
- return FALSE;
-}
-
/* GetIconsIndexes
* Retrieves Icons indexes by Mirver
*/
-void __fastcall GetIconsIndexes(LPWSTR wszMirVer, KN_FP_MASK *&base, KN_FP_MASK *&overlay1, KN_FP_MASK *&overlay2, KN_FP_MASK *&overlay3, KN_FP_MASK *&overlay4)
+static void GetIconsIndexes(LPWSTR wszMirVer, KN_FP_MASK *&base, KN_FP_MASK *&overlay1, KN_FP_MASK *&overlay2, KN_FP_MASK *&overlay3, KN_FP_MASK *&overlay4)
{
base = overlay1 = overlay2 = overlay3 = overlay4 = nullptr;
@@ -267,6 +170,126 @@ HICON __fastcall CreateIconFromIndexes(KN_FP_MASK *base, KN_FP_MASK *overlay1, K return hIcon;
}
+/****************************************************************************************
+* ServiceGetClientIcon
+* MS_FP_GETCLIENTICONW service implementation.
+* wParam - LPWSTR MirVer value to get client for.
+* lParam - int noCopy - if wParam is equal to "1" will return icon handler without copiing icon.
+* ICON IS ALWAYS COPIED!!!
+*/
+
+static INT_PTR ServiceGetClientIcon(WPARAM wParam, LPARAM)
+{
+ LPWSTR wszMirVer = (LPWSTR)wParam; // MirVer value to get client for.
+ if (wszMirVer == nullptr)
+ return 0;
+
+ KN_FP_MASK *base, *overlay1, *overlay2, *overlay3, *overlay4;
+ GetIconsIndexes(wszMirVer, base, overlay1, overlay2, overlay3, overlay4);
+
+ HICON hIcon = nullptr; // returned HICON
+ if (base != nullptr)
+ hIcon = CreateIconFromIndexes(base, overlay1, overlay2, overlay3, overlay4);
+
+ return (INT_PTR)hIcon;
+}
+
+/****************************************************************************************
+* ApplyFingerprintImage
+* 1)Try to find appropriate mask
+* 2)Register icon in extraimage list if not yet registered (EMPTY_EXTRA_ICON)
+* 3)Set ExtraImage for contact
+*/
+
+static void SetSrmmIcon(MCONTACT hContact, LPTSTR ptszMirver)
+{
+ if (mir_wstrlen(ptszMirver))
+ Srmm_ModifyIcon(hContact, MODULENAME, 1, (HICON)ServiceGetClientIcon((WPARAM)ptszMirver, TRUE), ptszMirver);
+ else
+ Srmm_SetIconFlags(hContact, MODULENAME, 1, MBF_HIDDEN);
+}
+
+int __fastcall ApplyFingerprintImage(MCONTACT hContact, LPTSTR szMirVer)
+{
+ if (hContact == NULL)
+ return 0;
+
+ HANDLE hImage = INVALID_HANDLE_VALUE;
+ if (szMirVer)
+ hImage = GetIconIndexFromFI(szMirVer);
+
+ ExtraIcon_SetIcon(hExtraIcon, hContact, hImage);
+
+ if (arMonitoredWindows.getIndex((HANDLE)hContact) != -1)
+ SetSrmmIcon(hContact, szMirVer);
+
+ return 0;
+}
+
+int OnExtraIconClick(WPARAM wParam, LPARAM, LPARAM)
+{
+ CallService(MS_USERINFO_SHOWDIALOG, wParam, NULL);
+ return 0;
+}
+
+/*
+* WildCompare
+* Compare 'name' string with 'mask' strings.
+* Masks can contain '*' or '?' wild symbols
+* Asterics '*' symbol covers 'empty' symbol too e.g WildCompare("Tst","T*st*"), returns TRUE
+* In order to handle situation 'at least one any sybol' use "?*" combination:
+* e.g WildCompare("Tst","T?*st*"), returns FALSE, but both WildCompare("Test","T?*st*") and
+* WildCompare("Teeest","T?*st*") return TRUE.
+*
+* Function is case sensitive! so convert input or modify func to use _qtoupper()
+*
+* Mask can contain several submasks. In this case each submask (including first)
+* should start from '|' e.g: "|first*submask|second*mask".
+*
+* Dec 25, 2006 by FYR:
+* Added Exception to masks: the mask "|^mask3|mask2|mask1" means:
+* if NOT according to mask 3 AND (mask1 OR mask2)
+* EXCEPTION should be BEFORE main mask:
+* IF Exception match - the comparing stops as FALSE
+* IF Exception does not match - comparing continue
+* IF Mask match - comparing stops as TRUE
+* IF Mask does not not match comparing continue
+*/
+BOOL __fastcall WildCompare(LPWSTR wszName, LPWSTR wszMask)
+{
+ if (wszMask == nullptr)
+ return NULL;
+
+ if (*wszMask != L'|')
+ return wildcmpw(wszName, wszMask);
+
+ size_t s = 1, e = 1;
+ LPWSTR wszTemp = (LPWSTR)_alloca(mir_wstrlen(wszMask) * sizeof(wchar_t) + sizeof(wchar_t));
+ BOOL bExcept;
+
+ while (wszMask[e] != L'\0')
+ {
+ s = e;
+ while (wszMask[e] != L'\0' && wszMask[e] != L'|') e++;
+
+ // exception mask
+ bExcept = (*(wszMask + s) == L'^');
+ if (bExcept) s++;
+
+ memcpy(wszTemp, wszMask + s, (e - s) * sizeof(wchar_t));
+ wszTemp[e - s] = L'\0';
+
+ if (wildcmpw(wszName, wszTemp))
+ return !bExcept;
+
+ if (wszMask[e] != L'\0')
+ e++;
+ else
+ return FALSE;
+ }
+ return FALSE;
+}
+
/******************************************************************************
* Futher routines is for creating joined 'overlay' icons.
******************************************************************************/
@@ -586,30 +609,6 @@ VOID ClearFI() }
/****************************************************************************************
-* ServiceGetClientIconW
-* MS_FP_GETCLIENTICONW service implementation.
-* wParam - LPWSTR MirVer value to get client for.
-* lParam - int noCopy - if wParam is equal to "1" will return icon handler without copiing icon.
-* ICON IS ALWAYS COPIED!!!
-*/
-
-static INT_PTR ServiceGetClientIconW(WPARAM wParam, LPARAM)
-{
- LPWSTR wszMirVer = (LPWSTR)wParam; // MirVer value to get client for.
- if (wszMirVer == nullptr)
- return 0;
-
- KN_FP_MASK *base, *overlay1, *overlay2, *overlay3, *overlay4;
- GetIconsIndexes(wszMirVer, base, overlay1, overlay2, overlay3, overlay4);
-
- HICON hIcon = nullptr; // returned HICON
- if (base != nullptr)
- hIcon = CreateIconFromIndexes(base, overlay1, overlay2, overlay3, overlay4);
-
- return (INT_PTR)hIcon;
-}
-
-/****************************************************************************************
* ServiceGetClientDescrW
* MS_FP_GETCLIENTDESCRW service implementation.
* wParam - LPCWSTR MirVer value
@@ -617,7 +616,7 @@ static INT_PTR ServiceGetClientIconW(WPARAM wParam, LPARAM) * returns LPCWSTR: client description (do not destroy) or NULL
*/
-static INT_PTR ServiceGetClientDescrW(WPARAM wParam, LPARAM)
+static INT_PTR ServiceGetClientDescr(WPARAM wParam, LPARAM)
{
LPWSTR wszMirVer = (LPWSTR)wParam; // MirVer value to get client for.
if (wszMirVer == nullptr)
@@ -642,13 +641,13 @@ static INT_PTR ServiceGetClientDescrW(WPARAM wParam, LPARAM) * returns LPCWSTR: client description (do not destroy) if clients are same or NULL
*/
-static INT_PTR ServiceSameClientsW(WPARAM wParam, LPARAM lParam)
+static INT_PTR ServiceSameClients(WPARAM wParam, LPARAM lParam)
{
if (!wParam || !lParam)
return NULL; //one of its is not null
- INT_PTR res1 = ServiceGetClientDescrW(wParam, 0);
- INT_PTR res2 = ServiceGetClientDescrW(lParam, 0);
+ INT_PTR res1 = ServiceGetClientDescr(wParam, 0);
+ INT_PTR res2 = ServiceGetClientDescr(lParam, 0);
return (res1 == res2 && res1 != 0) ? res1 : NULL;
}
@@ -786,7 +785,7 @@ void InitFingerModule() HookEvent(ME_OPT_INITIALISE, OnOptInitialise);
HookEvent(ME_DB_CONTACT_SETTINGCHANGED, OnContactSettingChanged);
- CreateServiceFunction(MS_FP_SAMECLIENTSW, ServiceSameClientsW);
- CreateServiceFunction(MS_FP_GETCLIENTDESCRW, ServiceGetClientDescrW);
- CreateServiceFunction(MS_FP_GETCLIENTICONW, ServiceGetClientIconW);
+ CreateServiceFunction("Fingerprint/SameClients", ServiceSameClients);
+ CreateServiceFunction("Fingerprint/GetClientDescr", ServiceGetClientDescr);
+ CreateServiceFunction("Fingerprint/GetClientIcon", ServiceGetClientIcon);
}
diff --git a/plugins/MenuItemEx/src/main.cpp b/plugins/MenuItemEx/src/main.cpp index 2e0e54e8da..1ba2c38e31 100644 --- a/plugins/MenuItemEx/src/main.cpp +++ b/plugins/MenuItemEx/src/main.cpp @@ -269,14 +269,12 @@ BOOL MirVerExists(MCONTACT hContact) LPWSTR getMirVer(MCONTACT hContact)
{
LPSTR szProto = Proto_GetBaseAccountName(hContact);
- if (!szProto) return nullptr;
+ if (!szProto)
+ return nullptr;
- LPWSTR msg = db_get_wsa(hContact, szProto, "MirVer");
- if (msg) {
- if (msg[0] != 0)
- return msg;
- mir_free(msg);
- }
+ ptrW msg(db_get_wsa(hContact, szProto, "MirVer"));
+ if (msg && msg[0] != 0)
+ return msg.detach();
return nullptr;
}
@@ -422,7 +420,7 @@ static void ModifyCopyIP(MCONTACT hContact) static void ModifyCopyMirVer(MCONTACT hContact)
{
HICON hMenuIcon = nullptr;
- if (ServiceExists(MS_FP_GETCLIENTICONT)) {
+ if (Finger_IsPresent()) {
LPWSTR msg = getMirVer(hContact);
if (msg) {
hMenuIcon = Finger_GetClientIcon(msg, 1);
diff --git a/plugins/QuickSearch/src/main.cpp b/plugins/QuickSearch/src/main.cpp index 632bfb2aff..95feef345b 100644 --- a/plugins/QuickSearch/src/main.cpp +++ b/plugins/QuickSearch/src/main.cpp @@ -70,8 +70,7 @@ static int OnCheckPlugins(WPARAM, LPARAM) {
g_bVarsInstalled = ServiceExists(MS_VARS_FORMATSTRING);
g_bTipperInstalled = ServiceExists(MS_TIPPER_SHOWTIPW);
- g_bFingerInstalled = ServiceExists(MS_FP_GETCLIENTICONW);
-
+ g_bFingerInstalled = Finger_IsPresent();
return 0;
}
diff --git a/plugins/TabSRMM/src/msgdlgother.cpp b/plugins/TabSRMM/src/msgdlgother.cpp index d9b3633b58..0060ac5a0c 100644 --- a/plugins/TabSRMM/src/msgdlgother.cpp +++ b/plugins/TabSRMM/src/msgdlgother.cpp @@ -1157,7 +1157,7 @@ void CMsgDialog::GetClientIcon() DestroyIcon(m_hClientIcon);
m_hClientIcon = nullptr;
- if (ServiceExists(MS_FP_GETCLIENTICONT)) {
+ if (Finger_IsPresent()) {
ptrW tszMirver(db_get_wsa(m_cache->getActiveContact(), m_cache->getActiveProto(), "MirVer"));
if (tszMirver)
m_hClientIcon = Finger_GetClientIcon(tszMirver, 1);
diff --git a/plugins/TipperYM/src/popwin.cpp b/plugins/TipperYM/src/popwin.cpp index 3feb8c30ef..28eb6e4f4b 100644 --- a/plugins/TipperYM/src/popwin.cpp +++ b/plugins/TipperYM/src/popwin.cpp @@ -371,7 +371,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa // fingerprint icon if (pwd->bIsIconVisible[5]) { for (i = 0; opt.exIconsOrder[i] != 5; i++); - if (ServiceExists(MS_FP_GETCLIENTICONT)) { + if (Finger_IsPresent()) { ptrW tszVersion(db_get_wsa(pwd->hContact, szProto, "MirVer")); if (tszVersion != NULL) { pwd->extraIcons[i].hIcon = Finger_GetClientIcon(tszVersion, 0); |