diff options
author | George Hazan <george.hazan@gmail.com> | 2013-08-10 14:04:29 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-08-10 14:04:29 +0000 |
commit | cd997e12f2ecf29c927f9c8c36ade9261140b2c5 (patch) | |
tree | fa382d3bad53952db440975922991e68c7383c72 | |
parent | 794fa3fb5cc63ac9b69908bd04f4be985a4a8cd1 (diff) |
- much more effective implementation of MS_FP_GETCLIENTICONT;
- new service, MS_FP_GETCLIENTDESCRT, to avoid perversions
git-svn-id: http://svn.miranda-ng.org/main/trunk@5633 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | plugins/ClientChangeNotify/src/ClientChangeNotify.cpp | 4 | ||||
-rw-r--r-- | plugins/ExternalAPI/m_fingerprint.h | 21 | ||||
-rw-r--r-- | plugins/FingerprintNG/src/fingerprint.cpp | 83 |
3 files changed, 51 insertions, 57 deletions
diff --git a/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp b/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp index 8a91324ae4..1a19e8ef1d 100644 --- a/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp +++ b/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp @@ -247,8 +247,8 @@ int ContactSettingChanged(WPARAM wParam, LPARAM lParam) sd.PopupOptPage = &PopupOptPage;
if (!PopupOptPage.GetValue(IDC_POPUPOPTDLG_VERCHGNOTIFY) || !PopupOptPage.GetValue(IDC_POPUPOPTDLG_SHOWVER)) {
if (bFingerprintExists) {
- LPCTSTR ptszOldClient = Finger_IsSameClents(sd.OldMirVer, sd.OldMirVer);
- LPCTSTR ptszClient = Finger_IsSameClents(sd.MirVer, sd.MirVer);
+ LPCTSTR ptszOldClient = Finger_GetClientDescr(sd.OldMirVer);
+ LPCTSTR ptszClient = Finger_GetClientDescr(sd.MirVer);
if (ptszOldClient && ptszClient) {
if (PerContactSetting != NOTIFY_ALMOST_ALWAYS && PerContactSetting != NOTIFY_ALWAYS && !PopupOptPage.GetValue(IDC_POPUPOPTDLG_VERCHGNOTIFY) && !_tcscmp(ptszClient, ptszOldClient))
return 0;
diff --git a/plugins/ExternalAPI/m_fingerprint.h b/plugins/ExternalAPI/m_fingerprint.h index 3dd6cbd694..35fc75c260 100644 --- a/plugins/ExternalAPI/m_fingerprint.h +++ b/plugins/ExternalAPI/m_fingerprint.h @@ -30,9 +30,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /*
* Service SameClientsW MS_FP_SAMECLIENTSW
- * wParam - LPWSTR first MirVer value
- * lParam - LPWSTR second MirVer value
- * return LPWSTR: client desription (DO NOT DESTROY) if clients are same otherwise NULL
+ * 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"
@@ -41,6 +41,18 @@ __forceinline LPCWSTR Finger_IsSameClents(LPCWSTR pwszName1, LPCWSTR pwszName2) }
/*
+ * Service GetClientDescrW MS_FP_GETCLIENTDESCRW
+ * wParam - LPCWSTR MirVer value to get client for.
+ * 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);
+}
+
+/*
* Service GetClientIconW MS_FP_GETCLIENTICONW
* wParam - LPWSTR MirVer value to get client for.
* lParam - int noCopy - if wParam is equal to "1" will return icon handler without copiing icon.
@@ -49,8 +61,9 @@ __forceinline LPCWSTR Finger_IsSameClents(LPCWSTR pwszName1, LPCWSTR pwszName2) #define MS_FP_GETCLIENTICONW "Fingerprint/GetClientIconW"
__forceinline HICON Finger_GetClientIcon(LPCWSTR pwszName, BOOL bNoCopy)
-{ return (HICON)CallService(MS_FP_SAMECLIENTSW, (WPARAM)pwszName, bNoCopy);
+{ return (HICON)CallService(MS_FP_GETCLIENTICONW, (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 40327b3c7e..0d103be59e 100644 --- a/plugins/FingerprintNG/src/fingerprint.cpp +++ b/plugins/FingerprintNG/src/fingerprint.cpp @@ -773,66 +773,46 @@ static INT_PTR ServiceGetClientIconW(WPARAM wParam, LPARAM lParam) }
/****************************************************************************************
- * ServiceSameClientW
- * MS_FP_SAMECLIENTSW service implementation.
- * wParam - LPWSTR first MirVer value
- * lParam - LPWSTR second MirVer value
- * return pointer to char string - client desription (do not destroy) if clients are same
+ * ServiceGetClientDescrW
+ * MS_FP_GETCLIENTDESCRW service implementation.
+ * wParam - LPCWSTR MirVer value
+ * lParam - (NULL) unused
+ * returns LPCWSTR: client desription (do not destroy) or NULL
*/
-static INT_PTR ServiceSameClientsW(WPARAM wParam, LPARAM lParam)
+static INT_PTR ServiceGetClientDescrW(WPARAM wParam, LPARAM lParam)
{
- LPWSTR wszMirVerFirst = (LPWSTR)wParam; // MirVer value to get client for.
- LPWSTR wszMirVerSecond = (LPWSTR)lParam; // MirVer value to get client for.
- int firstIndex, secondIndex;
- BOOL Result = FALSE;
-
- firstIndex = secondIndex = 0;
- if (!wszMirVerFirst || !wszMirVerSecond) return (INT_PTR)NULL; //one of its is not null
-
- {
- LPWSTR wszMirVerFirstUp, wszMirVerSecondUp;
- size_t iMirVerFirstUpLen, iMirVerSecondUpLen;
-
- iMirVerFirstUpLen = wcslen(wszMirVerFirst) + 1;
- iMirVerSecondUpLen = wcslen(wszMirVerSecond) + 1;
-
- wszMirVerFirstUp = (LPWSTR)mir_alloc(iMirVerFirstUpLen * sizeof(WCHAR));
- wszMirVerSecondUp = (LPWSTR)mir_alloc(iMirVerSecondUpLen * sizeof(WCHAR));
+ LPWSTR wszMirVer = (LPWSTR)wParam; // MirVer value to get client for.
+ if (wszMirVer == NULL)
+ return 0;
- wcscpy_s(wszMirVerFirstUp, iMirVerFirstUpLen, wszMirVerFirst);
- wcscpy_s(wszMirVerSecondUp, iMirVerSecondUpLen, wszMirVerSecond);
+ LPWSTR wszMirVerUp = NEWWSTR_ALLOCA(wszMirVer); _wcsupr(wszMirVerUp);
+ if (wcscmp(wszMirVerUp, L"?") == 0)
+ return (INT_PTR)def_kn_fp_mask[UNKNOWN_MASK_NUMBER].szClientDescription;
- _wcsupr_s(wszMirVerFirstUp, iMirVerFirstUpLen);
- _wcsupr_s(wszMirVerSecondUp, iMirVerSecondUpLen);
+ for (int index = 0; index < DEFAULT_KN_FP_MASK_COUNT; index++)
+ if (WildCompareW(wszMirVerUp, def_kn_fp_mask[index].szMaskUpper))
+ return (INT_PTR)def_kn_fp_mask[index].szClientDescription;
- if (wcscmp(wszMirVerFirstUp, L"?") == 0)
- firstIndex = UNKNOWN_MASK_NUMBER;
- else
- while(firstIndex < DEFAULT_KN_FP_MASK_COUNT) {
- if (WildCompareW(wszMirVerFirstUp, def_kn_fp_mask[firstIndex].szMaskUpper))
- break;
- firstIndex++;
- }
+ return NULL;
+}
- if (wcscmp(wszMirVerSecondUp, L"?") == 0)
- secondIndex = UNKNOWN_MASK_NUMBER;
- else
- while(secondIndex < DEFAULT_KN_FP_MASK_COUNT) {
- if (WildCompareW(wszMirVerSecondUp, def_kn_fp_mask[secondIndex].szMaskUpper))
- break;
- secondIndex++;
- }
+/****************************************************************************************
+ * ServiceSameClientW
+ * MS_FP_SAMECLIENTSW service implementation.
+ * wParam - LPWSTR first MirVer value
+ * lParam - LPWSTR second MirVer value
+ * returns LPCWSTR: client desñription (do not destroy) if clients are same or NULL
+ */
- mir_free(wszMirVerFirstUp);
- mir_free(wszMirVerSecondUp);
+static INT_PTR ServiceSameClientsW(WPARAM wParam, LPARAM lParam)
+{
+ if (!wParam || !lParam)
+ return NULL; //one of its is not null
- if (firstIndex == secondIndex && firstIndex < DEFAULT_KN_FP_MASK_COUNT)
- {
- return (INT_PTR)def_kn_fp_mask[firstIndex].szClientDescription;
- }
- }
- return (INT_PTR)NULL;
+ INT_PTR res1 = ServiceGetClientDescrW(wParam, 0);
+ INT_PTR res2 = ServiceGetClientDescrW(lParam, 0);
+ return (res1 == res2 && res1 != 0) ? res1 : NULL;
}
/****************************************************************************************
@@ -976,6 +956,7 @@ void InitFingerModule() HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
CreateServiceFunction(MS_FP_SAMECLIENTSW, ServiceSameClientsW);
+ CreateServiceFunction(MS_FP_GETCLIENTDESCRW, ServiceGetClientDescrW);
CreateServiceFunction(MS_FP_GETCLIENTICONW, ServiceGetClientIconW);
}
|