From f2935b7bf093965926cee07254f7a015ecd492cd Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 10 Aug 2013 12:32:03 +0000 Subject: fix for ClientChangeNotify: - popup never gets displayed; - "common" files extracted to the separate filter in project git-svn-id: http://svn.miranda-ng.org/main/trunk@5631 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- .../ClientChangeNotify_10.vcxproj | 12 +- .../ClientChangeNotify_10.vcxproj.filters | 17 +- .../ClientChangeNotify_11.vcxproj | 12 +- .../ClientChangeNotify_11.vcxproj.filters | 19 ++- .../ClientChangeNotify/src/ClientChangeNotify.cpp | 180 ++++++++++----------- .../ClientChangeNotify/src/CommonLibs/CString.cpp | 2 +- .../ClientChangeNotify/src/CommonLibs/Options.cpp | 2 +- plugins/ClientChangeNotify/src/CommonLibs/pcre.cpp | 2 +- 8 files changed, 130 insertions(+), 116 deletions(-) (limited to 'plugins/ClientChangeNotify') diff --git a/plugins/ClientChangeNotify/ClientChangeNotify_10.vcxproj b/plugins/ClientChangeNotify/ClientChangeNotify_10.vcxproj index f30360ca36..006efe07cf 100644 --- a/plugins/ClientChangeNotify/ClientChangeNotify_10.vcxproj +++ b/plugins/ClientChangeNotify/ClientChangeNotify_10.vcxproj @@ -184,10 +184,16 @@ Create - + + ../Common.h + - - + + ../Common.h + + + ../Common.h + diff --git a/plugins/ClientChangeNotify/ClientChangeNotify_10.vcxproj.filters b/plugins/ClientChangeNotify/ClientChangeNotify_10.vcxproj.filters index aaf82085aa..872af3d866 100644 --- a/plugins/ClientChangeNotify/ClientChangeNotify_10.vcxproj.filters +++ b/plugins/ClientChangeNotify/ClientChangeNotify_10.vcxproj.filters @@ -13,25 +13,28 @@ {3887cace-f8eb-45a3-854b-f32b02819763} ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + {41f0858e-1f97-48b6-bb24-b40945d188ad} + Source Files - + Source Files - + Source Files + + Source Files\CommonLibs + - Source Files + Source Files\CommonLibs - Source Files - - - Source Files + Source Files\CommonLibs diff --git a/plugins/ClientChangeNotify/ClientChangeNotify_11.vcxproj b/plugins/ClientChangeNotify/ClientChangeNotify_11.vcxproj index ab35b5df9f..76dec68b52 100644 --- a/plugins/ClientChangeNotify/ClientChangeNotify_11.vcxproj +++ b/plugins/ClientChangeNotify/ClientChangeNotify_11.vcxproj @@ -187,10 +187,16 @@ Create - + + ../Common.h + - - + + ../Common.h + + + ../Common.h + diff --git a/plugins/ClientChangeNotify/ClientChangeNotify_11.vcxproj.filters b/plugins/ClientChangeNotify/ClientChangeNotify_11.vcxproj.filters index aaf82085aa..c26e442322 100644 --- a/plugins/ClientChangeNotify/ClientChangeNotify_11.vcxproj.filters +++ b/plugins/ClientChangeNotify/ClientChangeNotify_11.vcxproj.filters @@ -13,26 +13,29 @@ {3887cace-f8eb-45a3-854b-f32b02819763} ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + {e1c3e36c-54d1-4e6e-83db-68358191bda8} + Source Files - - Source Files - - + Source Files - - Source Files + + Source Files\CommonLibs - Source Files + Source Files\CommonLibs - + Source Files + + Source Files\CommonLibs + diff --git a/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp b/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp index 387eef44de..00113d2b31 100644 --- a/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp +++ b/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp @@ -54,16 +54,12 @@ extern "C" __declspec(dllexport) PLUGININFOEX *MirandaPluginInfoEx(DWORD miranda static int CALLBACK MenuWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - switch (uMsg) - { - case WM_MEASUREITEM: - { - return CallService(MS_CLIST_MENUMEASUREITEM, wParam, lParam); - } - case WM_DRAWITEM: - { - return CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam); - } + switch (uMsg) { + case WM_MEASUREITEM: + return CallService(MS_CLIST_MENUMEASUREITEM, wParam, lParam); + + case WM_DRAWITEM: + return CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam); } return DefWindowProc(hWnd, uMsg, wParam, lParam); } @@ -202,99 +198,99 @@ void ShowPopup(SHOWPOPUP_DATA *sd) int ContactSettingChanged(WPARAM wParam, LPARAM lParam) { DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam; - if (!lstrcmpA(cws->szSetting, DB_MIRVER)) { - HANDLE hContact = (HANDLE)wParam; - SHOWPOPUP_DATA sd = {0}; - char *szProto = GetContactProto(hContact); - if (g_PreviewOptPage) - sd.MirVer = _T("Miranda NG ICQ 0.93.5.3007"); - else { - if (!hContact) // exit if hContact == NULL and it's not a popup preview - return 0; - - _ASSERT(szProto); - if (bMetaContactsExists && !strcmp(szProto, (char*)CallService(MS_MC_GETPROTOCOLNAME, 0, 0))) // workaround for metacontacts - return 0; - - sd.MirVer = db_get_s(hContact, szProto, DB_MIRVER, _T("")); - if (sd.MirVer.IsEmpty()) - return 0; - } - sd.OldMirVer = db_get_s(hContact, MOD_NAME, DB_OLDMIRVER, _T("")); - db_set_ts(hContact, MOD_NAME, DB_OLDMIRVER, sd.MirVer); // we have to write it here, because we modify sd.OldMirVer and sd.MirVer to conform our settings later - if (sd.OldMirVer.IsEmpty()) // looks like it's the right way to do + if (lstrcmpA(cws->szSetting, DB_MIRVER)) + return 0; + + HANDLE hContact = (HANDLE)wParam; + SHOWPOPUP_DATA sd = {0}; + char *szProto = GetContactProto(hContact); + if (g_PreviewOptPage) + sd.MirVer = _T("Miranda NG ICQ 0.93.5.3007"); + else { + if (!hContact) // exit if hContact == NULL and it's not a popup preview return 0; - COptPage PopupOptPage; - if (g_PreviewOptPage) - PopupOptPage = *g_PreviewOptPage; - else { - PopupOptPage = g_PopupOptPage; - PopupOptPage.DBToMem(); - } - - HANDLE hContactOrMeta = (hContact && bMetaContactsExists) ? (HANDLE)CallService(MS_MC_GETMETACONTACT, (WPARAM)hContact, 0) : hContact; - if (!hContactOrMeta) - hContactOrMeta = hContact; + _ASSERT(szProto); + if (bMetaContactsExists && !strcmp(szProto, (char*)CallService(MS_MC_GETPROTOCOLNAME, 0, 0))) // workaround for metacontacts + return 0; - if (hContact && db_get_b(hContactOrMeta, "CList", "Hidden", 0)) + sd.MirVer = db_get_s(hContact, szProto, DB_MIRVER, _T("")); + if (sd.MirVer.IsEmpty()) return 0; + } + sd.OldMirVer = db_get_s(hContact, MOD_NAME, DB_OLDMIRVER, _T("")); + db_set_ts(hContact, MOD_NAME, DB_OLDMIRVER, sd.MirVer); // we have to write it here, because we modify sd.OldMirVer and sd.MirVer to conform our settings later + if (sd.OldMirVer.IsEmpty()) // looks like it's the right way to do + return 0; + + COptPage PopupOptPage; + if (g_PreviewOptPage) + PopupOptPage = *g_PreviewOptPage; + else { + PopupOptPage = g_PopupOptPage; + PopupOptPage.DBToMem(); + } - int PerContactSetting = hContact ? db_get_b(hContact, MOD_NAME, DB_CCN_NOTIFY, NOTIFY_USEGLOBAL) : NOTIFY_ALWAYS; // NOTIFY_ALWAYS for preview - if (PerContactSetting == NOTIFY_USEGLOBAL && hContactOrMeta != hContact) // subcontact setting has a priority over a metacontact setting - PerContactSetting = db_get_b(hContactOrMeta, MOD_NAME, DB_CCN_NOTIFY, NOTIFY_USEGLOBAL); - - if (PerContactSetting && (PerContactSetting == NOTIFY_ALMOST_ALWAYS || PerContactSetting == NOTIFY_ALWAYS || !PopupOptPage.GetValue(IDC_POPUPOPTDLG_USESTATUSNOTIFYFLAG) || !(db_get_dw(hContactOrMeta, "Ignore", "Mask1", 0) & 0x8))) { // check if we need to notify at all - sd.hContact = hContact; - sd.PopupOptPage = &PopupOptPage; - if (!PopupOptPage.GetValue(IDC_POPUPOPTDLG_VERCHGNOTIFY) || !PopupOptPage.GetValue(IDC_POPUPOPTDLG_SHOWVER)) { - CString OldMirVerA = TCHAR2ANSI(sd.OldMirVer); - CString MirVerA = TCHAR2ANSI(sd.MirVer); - if (bFingerprintExists) { - char *szOldClient = (char*)CallService(MS_FP_SAMECLIENTS, (WPARAM)(const char*)OldMirVerA, (LPARAM)(const char*)OldMirVerA); // remove version from MirVer strings. I know, the way in which MS_FP_SAMECLIENTS is used here is pretty ugly, but at least it gives necessary results - char *szClient = (char*)CallService(MS_FP_SAMECLIENTS, (WPARAM)(const char*)MirVerA, (LPARAM)(const char*)MirVerA); - if (szOldClient && szClient) { - if (PerContactSetting != NOTIFY_ALMOST_ALWAYS && PerContactSetting != NOTIFY_ALWAYS && !PopupOptPage.GetValue(IDC_POPUPOPTDLG_VERCHGNOTIFY) && !strcmp(szClient, szOldClient)) - return 0; - - if (!PopupOptPage.GetValue(IDC_POPUPOPTDLG_SHOWVER)) { - sd.MirVer = ANSI2TCHAR(szClient); - sd.OldMirVer = ANSI2TCHAR(szOldClient); - } + HANDLE hContactOrMeta = (hContact && bMetaContactsExists) ? (HANDLE)CallService(MS_MC_GETMETACONTACT, (WPARAM)hContact, 0) : hContact; + if (!hContactOrMeta) + hContactOrMeta = hContact; + + if (hContact && db_get_b(hContactOrMeta, "CList", "Hidden", 0)) + return 0; + + int PerContactSetting = hContact ? db_get_b(hContact, MOD_NAME, DB_CCN_NOTIFY, NOTIFY_USEGLOBAL) : NOTIFY_ALWAYS; // NOTIFY_ALWAYS for preview + if (PerContactSetting == NOTIFY_USEGLOBAL && hContactOrMeta != hContact) // subcontact setting has a priority over a metacontact setting + PerContactSetting = db_get_b(hContactOrMeta, MOD_NAME, DB_CCN_NOTIFY, NOTIFY_USEGLOBAL); + + if (PerContactSetting && (PerContactSetting == NOTIFY_ALMOST_ALWAYS || PerContactSetting == NOTIFY_ALWAYS || !PopupOptPage.GetValue(IDC_POPUPOPTDLG_USESTATUSNOTIFYFLAG) || !(db_get_dw(hContactOrMeta, "Ignore", "Mask1", 0) & 0x8))) { // check if we need to notify at all + sd.hContact = hContact; + sd.PopupOptPage = &PopupOptPage; + if (!PopupOptPage.GetValue(IDC_POPUPOPTDLG_VERCHGNOTIFY) || !PopupOptPage.GetValue(IDC_POPUPOPTDLG_SHOWVER)) { + if (bFingerprintExists) { + LPCTSTR ptszOldClient = (LPCTSTR)CallService(MS_FP_SAMECLIENTST, (WPARAM)(TCHAR*)sd.OldMirVer, (LPARAM)(TCHAR*)sd.OldMirVer); // remove version from MirVer strings. I know, the way in which MS_FP_SAMECLIENTS is used here is pretty ugly, but at least it gives necessary results + LPCTSTR ptszClient = (LPCTSTR)CallService(MS_FP_SAMECLIENTST, (WPARAM)(TCHAR*)sd.MirVer, (LPARAM)(TCHAR*)sd.MirVer); + if (ptszOldClient && ptszClient) { + if (PerContactSetting != NOTIFY_ALMOST_ALWAYS && PerContactSetting != NOTIFY_ALWAYS && !PopupOptPage.GetValue(IDC_POPUPOPTDLG_VERCHGNOTIFY) && !_tcscmp(ptszClient, ptszOldClient)) + return 0; + + if (!PopupOptPage.GetValue(IDC_POPUPOPTDLG_SHOWVER)) { + sd.MirVer = ptszClient; + sd.OldMirVer = ptszOldClient; } } } - if (sd.MirVer == (const TCHAR*)sd.OldMirVer) { - _ASSERT(hContact); - return 0; - } - if (PerContactSetting == NOTIFY_ALWAYS || (PopupOptPage.GetValue(IDC_POPUPOPTDLG_POPUPNOTIFY) && (g_PreviewOptPage || PerContactSetting == NOTIFY_ALMOST_ALWAYS || !PcreCheck(sd.MirVer)))) { - ShowPopup(&sd); - SkinPlaySound(CLIENTCHANGED_SOUND); - } } - if (hContact) { - TCString ClientName; - if (PopupOptPage.GetValue(IDC_POPUPOPTDLG_SHOWPREVCLIENT) && sd.OldMirVer.GetLen()) { - mir_sntprintf(ClientName.GetBuffer(MAX_MSG_LEN), MAX_MSG_LEN, TranslateT("%s (was %s)"), (const TCHAR*)sd.MirVer, (const TCHAR*)sd.OldMirVer); - ClientName.ReleaseBuffer(); - } - else ClientName = sd.MirVer; - - if (bVariablesExists) - logservice_log(LOG_ID, hContact, ClientName); - else { - _ASSERT(szProto); - TCString szUID(_T("")); - char *uid = (char*)CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); - if (uid && (INT_PTR)uid != CALLSERVICE_NOTFOUND) - szUID = DBGetContactSettingAsString(hContact, szProto, uid, _T("")); - - logservice_log(LOG_ID, hContact, TCString((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)) + _T(" (") + szUID + TranslateT(") changed client to ") + ClientName); - } + if (sd.MirVer == (const TCHAR*)sd.OldMirVer) { + _ASSERT(hContact); + return 0; + } + if (PerContactSetting == NOTIFY_ALWAYS || (PopupOptPage.GetValue(IDC_POPUPOPTDLG_POPUPNOTIFY) && (g_PreviewOptPage || PerContactSetting == NOTIFY_ALMOST_ALWAYS || -1 == PcreCheck(sd.MirVer)))) { + ShowPopup(&sd); + SkinPlaySound(CLIENTCHANGED_SOUND); + } + } + + if (hContact) { + TCString ClientName; + if (PopupOptPage.GetValue(IDC_POPUPOPTDLG_SHOWPREVCLIENT) && sd.OldMirVer.GetLen()) { + mir_sntprintf(ClientName.GetBuffer(MAX_MSG_LEN), MAX_MSG_LEN, TranslateT("%s (was %s)"), (const TCHAR*)sd.MirVer, (const TCHAR*)sd.OldMirVer); + ClientName.ReleaseBuffer(); + } + else ClientName = sd.MirVer; + + if (bVariablesExists) + logservice_log(LOG_ID, hContact, ClientName); + else { + _ASSERT(szProto); + TCString szUID(_T("")); + char *uid = (char*)CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); + if (uid && (INT_PTR)uid != CALLSERVICE_NOTFOUND) + szUID = DBGetContactSettingAsString(hContact, szProto, uid, _T("")); + + logservice_log(LOG_ID, hContact, TCString((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)) + _T(" (") + szUID + TranslateT(") changed client to ") + ClientName); } - _ASSERT(sd.MirVer.GetLen()); // save the last known MirVer value even if the new one is empty } + _ASSERT(sd.MirVer.GetLen()); // save the last known MirVer value even if the new one is empty return 0; } diff --git a/plugins/ClientChangeNotify/src/CommonLibs/CString.cpp b/plugins/ClientChangeNotify/src/CommonLibs/CString.cpp index a874b75721..de3e26d238 100644 --- a/plugins/ClientChangeNotify/src/CommonLibs/CString.cpp +++ b/plugins/ClientChangeNotify/src/CommonLibs/CString.cpp @@ -17,7 +17,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "Common.h" +#include "../Common.h" #include "CString.h" #define STR_GROWBY 64 diff --git a/plugins/ClientChangeNotify/src/CommonLibs/Options.cpp b/plugins/ClientChangeNotify/src/CommonLibs/Options.cpp index e0d585d991..59bc65adfe 100644 --- a/plugins/ClientChangeNotify/src/CommonLibs/Options.cpp +++ b/plugins/ClientChangeNotify/src/CommonLibs/Options.cpp @@ -17,7 +17,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "Common.h" +#include "../Common.h" #include "Options.h" static CString sEmptyString(""); diff --git a/plugins/ClientChangeNotify/src/CommonLibs/pcre.cpp b/plugins/ClientChangeNotify/src/CommonLibs/pcre.cpp index ae82e43435..492c2f2a92 100644 --- a/plugins/ClientChangeNotify/src/CommonLibs/pcre.cpp +++ b/plugins/ClientChangeNotify/src/CommonLibs/pcre.cpp @@ -17,7 +17,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "common.h" +#include "../Common.h" #include #include #include -- cgit v1.2.3