From 229ea44a84d524e90fcc03529ba2df02507fb39c Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 9 Jul 2018 18:43:06 +0300 Subject: ClientChangeNotify: - fixes #1461 (Client change notify: crash) - minor code cleaning; - version bump; --- plugins/ClientChangeNotify/src/CString.cpp | 104 +++++++-------- plugins/ClientChangeNotify/src/CString.h | 124 +++++++++--------- .../ClientChangeNotify/src/ClientChangeNotify.cpp | 12 +- plugins/ClientChangeNotify/src/Misc.h | 38 +++--- plugins/ClientChangeNotify/src/OptDlg.cpp | 36 +++--- plugins/ClientChangeNotify/src/Options.cpp | 30 ++--- plugins/ClientChangeNotify/src/Options.h | 124 +++++++++--------- plugins/ClientChangeNotify/src/TMyArray.h | 140 ++++++++------------- plugins/ClientChangeNotify/src/pcre.cpp | 88 ++++++------- plugins/ClientChangeNotify/src/pcre.h | 22 ++-- plugins/ClientChangeNotify/src/stdafx.h | 28 ++--- plugins/ClientChangeNotify/src/version.h | 14 +-- 12 files changed, 346 insertions(+), 414 deletions(-) diff --git a/plugins/ClientChangeNotify/src/CString.cpp b/plugins/ClientChangeNotify/src/CString.cpp index d664213498..66d5477201 100644 --- a/plugins/ClientChangeNotify/src/CString.cpp +++ b/plugins/ClientChangeNotify/src/CString.cpp @@ -2,19 +2,19 @@ TCString.cpp - TCString class Copyright (c) 2005-2008 Chervov Dmitry - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "stdafx.h" @@ -24,7 +24,6 @@ #define min(a,b) (((a) < (b)) ? (a) : (b)) - template void TString::Empty() { @@ -37,7 +36,7 @@ void TString::Empty() template void TString::Free() { -// HeapFree(GetProcessHeap(), 0, pBuf); + // HeapFree(GetProcessHeap(), 0, pBuf); free(pBuf); pBuf = nullptr; nBufSize = 0; @@ -48,8 +47,7 @@ void TString::Free() template T *TString::GetBuffer(int nNewLen) { - if (nNewLen != -1) - { + if (nNewLen != -1) { SetBufSize(nNewLen + 1); } _ASSERT(pBuf); @@ -60,11 +58,10 @@ T *TString::GetBuffer(int nNewLen) template void TString::ReleaseBuffer(int nNewLen) { - if (nNewLen == -1) - { + if (nNewLen == -1) { nBufSize = My_lstrlen(pBuf) + 1; - } else - { + } + else { nBufSize = nNewLen + 1; pBuf[nNewLen] = 0; _ASSERT(My_lstrlen(pBuf) == nNewLen); @@ -78,9 +75,8 @@ void TString::SetAllocSize(int nNewAllocSize) { _ASSERT(nNewAllocSize > 0); T *pNewBuf = /*(char *)HeapAlloc(GetProcessHeap(), 0, sizeof(char) * nNewAllocSize);*/ -(T *)malloc(sizeof(T) * nNewAllocSize); - if (pBuf) - { + (T *)malloc(sizeof(T) * nNewAllocSize); + if (pBuf) { memcpy(pNewBuf, pBuf, sizeof(T) * min(nBufSize, nNewAllocSize)); //HeapFree(GetProcessHeap(), 0, pBuf); free(pBuf); @@ -94,13 +90,11 @@ template void TString::SetBufSize(int nNewBufSize) { _ASSERT(nNewBufSize >= 0); - if (nNewBufSize < nBufSize) - { + if (nNewBufSize < nBufSize) { _ASSERT(pBuf); pBuf[nNewBufSize - 1] = 0; } - if ((unsigned)(nAllocSize - nNewBufSize) / STR_GROWBY) - { + if ((unsigned)(nAllocSize - nNewBufSize) / STR_GROWBY) { SetAllocSize((nNewBufSize + STR_GROWBY - 1) - (nNewBufSize + STR_GROWBY - 1) % STR_GROWBY); } nBufSize = nNewBufSize; @@ -148,8 +142,7 @@ TString& TString::DiffCat(const T *pStart, const T *pEnd) template TString& TString::Replace(const T *szFind, const T *szReplaceBy) { - if (!pBuf) - { + if (!pBuf) { return *this; } T *pCurPos = pBuf; @@ -158,8 +151,7 @@ TString& TString::Replace(const T *szFind, const T *szReplaceBy) TString Result; Result.GetBuffer(1)[0] = '\0'; Result.ReleaseBuffer(0); // set the string to ""; we can't do it in a usual way (using a constructor or an assignment) because we don't know whether "" needs to be unicode or ansi - while (p = ( T* )My_strstr(pCurPos, szFind)) - { + while (p = (T*)My_strstr(pCurPos, szFind)) { Result.DiffCat(pCurPos, p); Result += szReplaceBy; pCurPos = p + FindLen; @@ -173,20 +165,17 @@ TString& TString::Replace(const T *szFind, const T *szReplaceBy) template TString& TString::Replace(int nIndex, int nCount, const T *szReplaceBy) { - if (!pBuf || !szReplaceBy || nIndex < 0 || nCount < 0) - { + if (!pBuf || !szReplaceBy || nIndex < 0 || nCount < 0) { return *this; } TString Result; Result.GetBuffer(1)[0] = '\0'; Result.ReleaseBuffer(0); // set the string to ""; we can't do it in a usual way (using a constructor or an assignment) because we don't know whether "" needs to be unicode or ansi - if (nIndex > GetLen()) - { + if (nIndex > GetLen()) { nIndex = GetLen(); } - if (nIndex + nCount > GetLen()) - { + if (nIndex + nCount > GetLen()) { nCount = GetLen() - nIndex; } Result.DiffCat(pBuf, pBuf + nIndex); @@ -211,11 +200,10 @@ template TString TString::Right(int nCount) const { _ASSERT(nCount >= 0); - if (nCount < GetLen()) - { + if (nCount < GetLen()) { return &pBuf[GetLen() - nCount]; - } else - { + } + else { return *this; } } @@ -226,12 +214,11 @@ TString TString::SubStr(int nIndex, int nCount) const { _ASSERT(nIndex >= 0 && nCount >= 0); TString Result; - if (nIndex < GetLen()) - { + if (nIndex < GetLen()) { My_strncpy(Result.GetBuffer(nCount), &pBuf[nIndex], nCount); Result.ReleaseBuffer(); - } else - { + } + else { Result.GetBuffer(1)[0] = '\0'; Result.ReleaseBuffer(0); } @@ -243,8 +230,7 @@ template TString TString::ToLower() const { TString Result(*this); - if (!pBuf) - { + if (!pBuf) { return Result; // return NULL string } My_strlwr((T*)Result); @@ -255,14 +241,13 @@ TString TString::ToLower() const template TString& TString::operator=(const T *pStr) { - if (pStr) - { + if (pStr) { int StrLen = My_lstrlen(pStr); SetBufSize(StrLen + 1); My_lstrcpy(GetBuffer(), pStr); ReleaseBuffer(StrLen); - } else - { + } + else { Free(); } return *this; @@ -274,28 +259,27 @@ template class TString; CString db_get_s(MCONTACT hContact, const char *szModule, const char *szSetting, const char *szDefaultValue) { - ptrA p( db_get_sa(hContact, szModule, szSetting)); + ptrA p(db_get_sa(hContact, szModule, szSetting)); return CString(p == NULL ? szDefaultValue : p); } TCString db_get_s(MCONTACT hContact, const char *szModule, const char *szSetting, const wchar_t *szDefaultValue) { - ptrW p( db_get_wsa(hContact, szModule, szSetting)); + ptrW p(db_get_wsa(hContact, szModule, szSetting)); return TCString(p == NULL ? szDefaultValue : p); } TCString DBGetContactSettingAsString(MCONTACT hContact, const char *szModule, const char *szSetting, const wchar_t *szDefaultValue) -{ // also converts numeric values to a string - DBVARIANT dbv = {0}; +{ + // also converts numeric values to a string + DBVARIANT dbv = { 0 }; int iRes = db_get_ws(hContact, szModule, szSetting, &dbv); TCString Result; - if (!iRes && (dbv.type == DBVT_ASCIIZ || dbv.type == DBVT_WCHAR)) - { + if (!iRes && (dbv.type == DBVT_ASCIIZ || dbv.type == DBVT_WCHAR)) { Result = dbv.ptszVal; } - else if (dbv.type == DBVT_BYTE || dbv.type == DBVT_WORD || dbv.type == DBVT_DWORD) - { + else if (dbv.type == DBVT_BYTE || dbv.type == DBVT_WORD || dbv.type == DBVT_DWORD) { long value = (dbv.type == DBVT_DWORD) ? dbv.dVal : (dbv.type == DBVT_WORD ? dbv.wVal : dbv.bVal); _ultow(value, Result.GetBuffer(64), 10); Result.ReleaseBuffer(); diff --git a/plugins/ClientChangeNotify/src/CString.h b/plugins/ClientChangeNotify/src/CString.h index 38d6080fba..cf18c6f881 100644 --- a/plugins/ClientChangeNotify/src/CString.h +++ b/plugins/ClientChangeNotify/src/CString.h @@ -2,19 +2,19 @@ TCString.h - TCString class Copyright (c) 2005-2008 Chervov Dmitry - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #pragma once @@ -28,30 +28,30 @@ #include "m_system.h" #include "m_database.h" -__inline int My_lstrlen(LPCSTR lpString) {return (int)mir_strlen(lpString);} -__inline int My_lstrlen(LPCWSTR lpString) {return (int)mir_wstrlen(lpString);} -__inline int My_lstrcmp(LPCSTR lpString1, LPCSTR lpString2) {return mir_strcmp(lpString1, lpString2);} -__inline int My_lstrcmp(LPCWSTR lpString1, LPCWSTR lpString2) {return mir_wstrcmp(lpString1, lpString2);} -__inline LPCSTR My_strstr(LPCSTR lpString1, LPCSTR lpString2) {return strstr(lpString1, lpString2);} -__inline LPWSTR My_strstr(LPCWSTR lpString1, LPCWSTR lpString2) {return (LPWSTR)wcsstr(lpString1, lpString2);} -__inline LPSTR My_lstrcpy(LPSTR lpString1, LPCSTR lpString2) {return mir_strcpy(lpString1, lpString2);} -__inline LPWSTR My_lstrcpy(LPWSTR lpString1, LPCWSTR lpString2) {return mir_wstrcpy(lpString1, lpString2);} -__inline LPSTR My_strncpy(LPSTR lpString1, LPCSTR lpString2, int Len) {return strncpy(lpString1, lpString2, Len);} -__inline LPWSTR My_strncpy(LPWSTR lpString1, LPCWSTR lpString2, int Len) {return wcsncpy(lpString1, lpString2, Len);} -__inline LPSTR My_strlwr(LPSTR lpString) {return _strlwr(lpString);} -__inline LPWSTR My_strlwr(LPWSTR lpString) {return _wcslwr(lpString);} +__inline int My_lstrlen(LPCSTR lpString) { return (int)mir_strlen(lpString); } +__inline int My_lstrlen(LPCWSTR lpString) { return (int)mir_wstrlen(lpString); } +__inline int My_lstrcmp(LPCSTR lpString1, LPCSTR lpString2) { return mir_strcmp(lpString1, lpString2); } +__inline int My_lstrcmp(LPCWSTR lpString1, LPCWSTR lpString2) { return mir_wstrcmp(lpString1, lpString2); } +__inline LPCSTR My_strstr(LPCSTR lpString1, LPCSTR lpString2) { return strstr(lpString1, lpString2); } +__inline LPWSTR My_strstr(LPCWSTR lpString1, LPCWSTR lpString2) { return (LPWSTR)wcsstr(lpString1, lpString2); } +__inline LPSTR My_lstrcpy(LPSTR lpString1, LPCSTR lpString2) { return mir_strcpy(lpString1, lpString2); } +__inline LPWSTR My_lstrcpy(LPWSTR lpString1, LPCWSTR lpString2) { return mir_wstrcpy(lpString1, lpString2); } +__inline LPSTR My_strncpy(LPSTR lpString1, LPCSTR lpString2, int Len) { return strncpy(lpString1, lpString2, Len); } +__inline LPWSTR My_strncpy(LPWSTR lpString1, LPCWSTR lpString2, int Len) { return wcsncpy(lpString1, lpString2, Len); } +__inline LPSTR My_strlwr(LPSTR lpString) { return _strlwr(lpString); } +__inline LPWSTR My_strlwr(LPWSTR lpString) { return _wcslwr(lpString); } template class TString { public: - TString(): pBuf(NULL), nBufSize(0), nAllocSize(0) {} - TString(const T *pStr): pBuf(NULL), nBufSize(0), nAllocSize(0) {*this = pStr;} - TString(const TString &Str): pBuf(NULL), nBufSize(0), nAllocSize(0) {*this = Str.pBuf;} - ~TString() {Free();} + TString() : pBuf(NULL), nBufSize(0), nAllocSize(0) {} + TString(const T *pStr) : pBuf(NULL), nBufSize(0), nAllocSize(0) { *this = pStr; } + TString(const TString &Str) : pBuf(NULL), nBufSize(0), nAllocSize(0) { *this = Str.pBuf; } + ~TString() { Free(); } - int GetLen() const {return (nBufSize) ? (nBufSize - 1) : 0;}; - int IsEmpty() const {return (!GetLen());}; + int GetLen() const { return (nBufSize) ? (nBufSize - 1) : 0; }; + int IsEmpty() const { return (!GetLen()); }; T *GetBuffer(int nNewLen = -1); void ReleaseBuffer(int nNewLen = -1); TString& Cat(const T *pStr); @@ -65,26 +65,28 @@ public: TString ToLower() const; void Empty(); void Free(); - T& operator [] (int nIndex) {_ASSERT(nIndex >= 0 && nIndex <= GetLen()); return pBuf[nIndex];} - operator const T*() const {return pBuf;} - operator T*() {return pBuf;} + T& operator [] (int nIndex) { _ASSERT(nIndex >= 0 && nIndex <= GetLen()); return pBuf[nIndex]; } + operator const T*() const { return pBuf; } + operator T*() { return pBuf; } TString& operator=(const T *pStr); - TString& operator=(const TString &Str) {return *this = Str.pBuf;} -// TCString& operator + (const char *pStr) -// {_ASSERT(pBuf && pStr); TCString Result(*this); return Result.Cat(pStr);} + TString& operator=(const TString &Str) { return *this = Str.pBuf; } + // TCString& operator + (const char *pStr) + // {_ASSERT(pBuf && pStr); TCString Result(*this); return Result.Cat(pStr);} friend TString operator + (const TString &Str1, const T *Str2) - {_ASSERT(Str1.pBuf && Str2); TString Result(Str1); return Result.Cat(Str2);} -/* friend TCString operator + (const char *Str1, const TCString &Str2) - {_ASSERT(Str1 && Str2.pBuf); TCString Result(Str1); return Result.Cat(Str2);}*/ - TString& operator+=(const T *pStr) {_ASSERT(pBuf && pStr); return this->Cat(pStr);} - TString& operator+=(const T c) {_ASSERT(pBuf); return this->Cat(c);} - int operator == (const T *pStr) const {return (!pBuf || !pStr) ? (pBuf == pStr) : !My_lstrcmp(pBuf, pStr);} - int operator != (const T *pStr) const {return (!pBuf || !pStr) ? (pBuf != pStr) : My_lstrcmp(pBuf, pStr);} - int operator < (const T *pStr) const {_ASSERT(pBuf && pStr); return My_lstrcmp(pBuf, pStr) > 0;} - int operator > (const T *pStr) const {_ASSERT(pBuf && pStr); return My_lstrcmp(pBuf, pStr) < 0;} - int operator <= (const T *pStr) const {_ASSERT(pBuf && pStr); return My_lstrcmp(pBuf, pStr) >= 0;} - int operator >= (const T *pStr) const {_ASSERT(pBuf && pStr); return My_lstrcmp(pBuf, pStr) <= 0;} -// TCString& Format(char *pszFormat, ...); + { + _ASSERT(Str1.pBuf && Str2); TString Result(Str1); return Result.Cat(Str2); + } + /* friend TCString operator + (const char *Str1, const TCString &Str2) + {_ASSERT(Str1 && Str2.pBuf); TCString Result(Str1); return Result.Cat(Str2);}*/ + TString& operator+=(const T *pStr) { _ASSERT(pBuf && pStr); return this->Cat(pStr); } + TString& operator+=(const T c) { _ASSERT(pBuf); return this->Cat(c); } + int operator == (const T *pStr) const { return (!pBuf || !pStr) ? (pBuf == pStr) : !My_lstrcmp(pBuf, pStr); } + int operator != (const T *pStr) const { return (!pBuf || !pStr) ? (pBuf != pStr) : My_lstrcmp(pBuf, pStr); } + int operator < (const T *pStr) const { _ASSERT(pBuf && pStr); return My_lstrcmp(pBuf, pStr) > 0; } + int operator > (const T *pStr) const { _ASSERT(pBuf && pStr); return My_lstrcmp(pBuf, pStr) < 0; } + int operator <= (const T *pStr) const { _ASSERT(pBuf && pStr); return My_lstrcmp(pBuf, pStr) >= 0; } + int operator >= (const T *pStr) const { _ASSERT(pBuf && pStr); return My_lstrcmp(pBuf, pStr) <= 0; } + // TCString& Format(char *pszFormat, ...); private: void SetBufSize(int nNewBufSize); @@ -106,15 +108,12 @@ __inline CHARARRAY WCHAR2ANSI_ARRAY(CHARARRAY &c) { CHARARRAY Result; int Len = WideCharToMultiByte(CP_ACP, 0, (WCHAR*)c.GetData(), c.GetSize() / sizeof(WCHAR), NULL, 0, NULL, NULL); - if (Len) - { + if (Len) { Result.SetAtGrow(Len - 1); - if (!WideCharToMultiByte(CP_ACP, 0, (WCHAR*)c.GetData(), c.GetSize() / sizeof(WCHAR), Result.GetData(), Len, NULL, NULL)) - { + if (!WideCharToMultiByte(CP_ACP, 0, (WCHAR*)c.GetData(), c.GetSize() / sizeof(WCHAR), Result.GetData(), Len, NULL, NULL)) { Result.RemoveAll(); } - if (Result.GetSize()) - { + if (Result.GetSize()) { Result.RemoveElem(Result.GetSize() - 1); // remove the null terminator } } @@ -125,15 +124,12 @@ __inline CHARARRAY ANSI2WCHAR_ARRAY(CHARARRAY &c) { CHARARRAY Result; int Len = MultiByteToWideChar(CP_ACP, 0, c.GetData(), c.GetSize(), NULL, 0); - if (Len) - { + if (Len) { Result.SetAtGrow(Len * sizeof(WCHAR) - 1); - if (!MultiByteToWideChar(CP_ACP, 0, c.GetData(), c.GetSize(), (WCHAR*)Result.GetData(), Len)) - { + if (!MultiByteToWideChar(CP_ACP, 0, c.GetData(), c.GetSize(), (WCHAR*)Result.GetData(), Len)) { Result.RemoveAll(); } - if (Result.GetSize()) - { + if (Result.GetSize()) { Result.RemoveElem(Result.GetSize() - 1); Result.RemoveElem(Result.GetSize() - 1); // remove the null terminator } @@ -146,11 +142,9 @@ __inline CHARARRAY WCHAR2UTF8(WCString Str) { CHARARRAY Result; int Len = WideCharToMultiByte(CP_UTF8, 0, Str, -1, NULL, 0, NULL, NULL); - if (Len) - { + if (Len) { Result.SetAtGrow(Len - 1); - if (!WideCharToMultiByte(CP_UTF8, 0, Str, -1, Result.GetData(), Len, NULL, NULL)) - { + if (!WideCharToMultiByte(CP_UTF8, 0, Str, -1, Result.GetData(), Len, NULL, NULL)) { Result.RemoveAll(); } } diff --git a/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp b/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp index eb4c8d6abe..1e80c5b4d1 100644 --- a/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp +++ b/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp @@ -178,15 +178,17 @@ int ContactSettingChanged(WPARAM hContact, LPARAM lParam) return 0; SHOWPOPUP_DATA sd = { 0 }; - char *szProto = GetContactProto(hContact); - if (g_PreviewOptPage) - sd.MirVer = L"Miranda NG ICQ 0.93.5.3007"; + if (g_PreviewOptPage) { + char szVersion[200]; + Miranda_GetVersionText(szVersion, _countof(szVersion)); + sd.MirVer = _A2T(szVersion); + } else { if (!hContact) // exit if hContact == NULL and it's not a popup preview return 0; - _ASSERT(szProto); - if (!strcmp(szProto, META_PROTO)) // workaround for metacontacts + char *szProto = GetContactProto(hContact); + if (!mir_strcmp(szProto, META_PROTO)) // workaround for metacontacts return 0; sd.MirVer = db_get_s(hContact, szProto, DB_MIRVER, L""); diff --git a/plugins/ClientChangeNotify/src/Misc.h b/plugins/ClientChangeNotify/src/Misc.h index 9ea8beba5d..feb0ef296e 100644 --- a/plugins/ClientChangeNotify/src/Misc.h +++ b/plugins/ClientChangeNotify/src/Misc.h @@ -2,19 +2,19 @@ ClientChangeNotify - Plugin for Miranda IM Copyright (c) 2006-2008 Chervov Dmitry - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #pragma once @@ -24,9 +24,8 @@ extern BOOL bPopupExists; __inline void ShowMsg(wchar_t *FirstLine, wchar_t *SecondLine = L"", bool IsErrorMsg = false, int Timeout = 0) { - if (bPopupExists) - { - POPUPDATAT ppd = {0}; + if (bPopupExists) { + POPUPDATAT ppd = { 0 }; ppd.lchIcon = LoadIcon(NULL, IsErrorMsg ? IDI_EXCLAMATION : IDI_INFORMATION); mir_wstrcpy(ppd.lptzContactName, FirstLine); mir_wstrcpy(ppd.lptzText, SecondLine); @@ -34,8 +33,8 @@ __inline void ShowMsg(wchar_t *FirstLine, wchar_t *SecondLine = L"", bool IsErro ppd.colorText = IsErrorMsg ? 0xE8F1FD : 0x000000; ppd.iSeconds = Timeout; PUAddPopupT(&ppd); - } else - { + } + else { MessageBox(NULL, SecondLine, FirstLine, MB_OK | (IsErrorMsg ? MB_ICONEXCLAMATION : MB_ICONINFORMATION)); } } @@ -55,8 +54,7 @@ __inline void RecompileRegexps(TCString IgnoreSubstrings) { FreePcreCompileData(); wchar_t *p = wcstok(IgnoreSubstrings, L";"); - while (p) - { + while (p) { CompileRegexp(p, p[0] != '/'); p = wcstok(NULL, L";"); } diff --git a/plugins/ClientChangeNotify/src/OptDlg.cpp b/plugins/ClientChangeNotify/src/OptDlg.cpp index 0095a2a4cc..0ec1557d1c 100644 --- a/plugins/ClientChangeNotify/src/OptDlg.cpp +++ b/plugins/ClientChangeNotify/src/OptDlg.cpp @@ -76,25 +76,25 @@ INT_PTR CALLBACK PopupOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara static int ChangeLock = 0; switch (msg) { case WM_INITDIALOG: - { - TranslateDialogDefault(hwndDlg); - ChangeLock++; - g_PopupOptPage.SetWnd(hwndDlg); - SendDlgItemMessage(hwndDlg, IDC_POPUPOPTDLG_POPUPDELAY, EM_LIMITTEXT, 4, 0); - SendDlgItemMessage(hwndDlg, IDC_POPUPOPTDLG_IGNORESTRINGS, EM_LIMITTEXT, IGNORESTRINGS_MAX_LEN, 0); - SendDlgItemMessage(hwndDlg, IDC_POPUPOPTDLG_POPUPDELAY_SPIN, UDM_SETRANGE32, -1, 9999); - - HWND hLCombo = GetDlgItem(hwndDlg, IDC_POPUPOPTDLG_LCLICK_ACTION); - HWND hRCombo = GetDlgItem(hwndDlg, IDC_POPUPOPTDLG_RCLICK_ACTION); - for (int i = 0; i < _countof(PopupActions); i++) { - SendMessage(hLCombo, CB_SETITEMDATA, SendMessage(hLCombo, CB_ADDSTRING, 0, (LPARAM)TranslateW(PopupActions[i].Text)), PopupActions[i].Action); - SendMessage(hRCombo, CB_SETITEMDATA, SendMessage(hRCombo, CB_ADDSTRING, 0, (LPARAM)TranslateW(PopupActions[i].Text)), PopupActions[i].Action); + { + TranslateDialogDefault(hwndDlg); + ChangeLock++; + g_PopupOptPage.SetWnd(hwndDlg); + SendDlgItemMessage(hwndDlg, IDC_POPUPOPTDLG_POPUPDELAY, EM_LIMITTEXT, 4, 0); + SendDlgItemMessage(hwndDlg, IDC_POPUPOPTDLG_IGNORESTRINGS, EM_LIMITTEXT, IGNORESTRINGS_MAX_LEN, 0); + SendDlgItemMessage(hwndDlg, IDC_POPUPOPTDLG_POPUPDELAY_SPIN, UDM_SETRANGE32, -1, 9999); + + HWND hLCombo = GetDlgItem(hwndDlg, IDC_POPUPOPTDLG_LCLICK_ACTION); + HWND hRCombo = GetDlgItem(hwndDlg, IDC_POPUPOPTDLG_RCLICK_ACTION); + for (int i = 0; i < _countof(PopupActions); i++) { + SendMessage(hLCombo, CB_SETITEMDATA, SendMessage(hLCombo, CB_ADDSTRING, 0, (LPARAM)TranslateW(PopupActions[i].Text)), PopupActions[i].Action); + SendMessage(hRCombo, CB_SETITEMDATA, SendMessage(hRCombo, CB_ADDSTRING, 0, (LPARAM)TranslateW(PopupActions[i].Text)), PopupActions[i].Action); + } + g_PopupOptPage.DBToMemToPage(); + EnablePopupOptDlgControls(); + ChangeLock--; } - g_PopupOptPage.DBToMemToPage(); - EnablePopupOptDlgControls(); - ChangeLock--; - } - return true; + return true; case WM_NOTIFY: switch (((NMHDR*)lParam)->code) { diff --git a/plugins/ClientChangeNotify/src/Options.cpp b/plugins/ClientChangeNotify/src/Options.cpp index fbca20ce87..cc30202f41 100644 --- a/plugins/ClientChangeNotify/src/Options.cpp +++ b/plugins/ClientChangeNotify/src/Options.cpp @@ -2,19 +2,19 @@ Options.cpp Copyright (c) 2005-2008 Chervov Dmitry - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "stdafx.h" @@ -259,7 +259,7 @@ struct sTreeReadEnumData TreeCtrl(_p1), sModule(_p2), sDBSettingPrefix(_p3) - {} + {} COptItem_TreeCtrl *TreeCtrl; const CString &sModule, &sDBSettingPrefix; @@ -609,7 +609,7 @@ void COptItem_TreeCtrl::MoveItem(HWND hWnd, HTREEITEM hItem, HTREEITEM hMoveTo) if (ItemOrder <= TREECTRL_ROOTORDEROFFS) return; // can't move root items - + if (m_value[ItemOrder].Flags & TIF_GROUP) { // need to check for a case when trying to move a group to its own subgroup. int Order = MoveToOrder; while (Order >= 0) { diff --git a/plugins/ClientChangeNotify/src/Options.h b/plugins/ClientChangeNotify/src/Options.h index 35f62f817c..9f464d6407 100644 --- a/plugins/ClientChangeNotify/src/Options.h +++ b/plugins/ClientChangeNotify/src/Options.h @@ -2,19 +2,19 @@ Options.h Copyright (c) 2005-2008 Chervov Dmitry - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #pragma once @@ -28,8 +28,7 @@ public: COptItem() {} COptItem(int m_dlgItemID, char *szDBSetting, int nValueSize, int lParam = 0, bool m_bReadOnly = false) : m_dlgItemID(m_dlgItemID), nValueSize(nValueSize), sDBSetting(szDBSetting), lParam(lParam), m_bEnabled(true), m_bReadOnly(m_bReadOnly), m_bModified(false) - { - } + {} virtual ~COptItem() {} @@ -45,14 +44,14 @@ public: virtual void SetDefValue(INT_PTR) {} virtual INT_PTR GetValue() { return 0; } virtual INT_PTR GetDefValue() { return 0; } - + INT_PTR GetDBValue(const CString &sModule, CString *sDBSettingPrefix = NULL) { DBToMem(sModule, sDBSettingPrefix); return GetValue(); } void SetDBValue(const CString &sModule, INT_PTR m_value, CString *sDBSettingPrefix = NULL) { SetValue(m_value); MemToDB(sModule, sDBSettingPrefix); } INT_PTR GetDBValueCopy(const CString &sModule, CString *sDBSettingPrefix = NULL) { COptItem* Item = Copy(); Item->DBToMem(sModule, sDBSettingPrefix); INT_PTR m_value = Item->GetValue(); delete Item; return m_value; } // retrieves DB value, but doesn't affect current page/item state; beware! it doesn't work with string values / other dynamic pointers void SetDBValueCopy(const CString &sModule, INT_PTR m_value, CString *sDBSettingPrefix = NULL) { COptItem* Item = Copy(); Item->SetValue(m_value); Item->MemToDB(sModule, sDBSettingPrefix); delete Item; } INT_PTR GetWndValue(HWND hWnd) { WndToMem(hWnd); return GetValue(); } void SetWndValue(HWND hWnd, INT_PTR m_value) { SetValue(m_value); MemToWnd(hWnd); } - + void SetDlgItemID(int _DlgItemID) { m_dlgItemID = _DlgItemID; } bool GetModified() { return m_bModified; } void SetModified(bool _Modified) { m_bModified = _Modified; } @@ -93,16 +92,16 @@ public: COptItem_Edit() {} COptItem_Edit(int m_dlgItemID, char *szDBSetting, int nMaxLen, wchar_t *szDefValue, int lParam = 0, bool m_bReadOnly = false) : COptItem(m_dlgItemID, szDBSetting, nMaxLen, lParam, m_bReadOnly), sDefValue(szDefValue) - {} + {} void DBToMem(const CString &sModule, CString *sDBSettingPrefix = NULL) { sValue = GetStrDBVal(sModule, sDBSettingPrefix); COptItem::DBToMem(sModule, sDBSettingPrefix); } void MemToDB(const CString &sModule, CString *sDBSettingPrefix = NULL) { SetStrDBVal(sModule, sValue, sDBSettingPrefix); COptItem::MemToDB(sModule, sDBSettingPrefix); } void WndToMem(HWND hWnd) { GetDlgItemText(hWnd, m_dlgItemID, sValue.GetBuffer(nValueSize), nValueSize); sValue.ReleaseBuffer(); COptItem::MemToWnd(hWnd); } void MemToWnd(HWND hWnd) { SetDlgItemText(hWnd, m_dlgItemID, sValue); COptItem::MemToWnd(hWnd); } - + virtual void SetValue(INT_PTR m_value) { sValue = *(TCString*)m_value; COptItem::SetValue(m_value); } virtual void SetDefValue(INT_PTR m_defValue) { sDefValue = *(TCString*)m_defValue; COptItem::SetDefValue(m_defValue); } - + virtual INT_PTR GetValue() { return (INT_PTR)&sValue; } virtual INT_PTR GetDefValue() { return (INT_PTR)&sDefValue; } @@ -119,16 +118,16 @@ public: COptItem_IntEdit() {} COptItem_IntEdit(int m_dlgItemID, char *szDBSetting, int nValueSize = DBVT_BYTE, int bSigned = true, int m_defValue = 0, int lParam = 0, bool m_bReadOnly = false) : COptItem(m_dlgItemID, szDBSetting, nValueSize, lParam, m_bReadOnly), m_defValue(m_defValue), m_value(0), bSigned(bSigned) - {} - + {} + void DBToMem(const CString &sModule, CString *sDBSettingPrefix = NULL) { m_value = GetIntDBVal(sModule, bSigned, sDBSettingPrefix); COptItem::DBToMem(sModule, sDBSettingPrefix); } void MemToDB(const CString &sModule, CString *sDBSettingPrefix = NULL) { SetIntDBVal(sModule, m_value, sDBSettingPrefix); COptItem::MemToDB(sModule, sDBSettingPrefix); } void WndToMem(HWND hWnd) { m_value = GetDlgItemInt(hWnd, m_dlgItemID, NULL, bSigned); COptItem::WndToMem(hWnd); } void MemToWnd(HWND hWnd) { SetDlgItemInt(hWnd, m_dlgItemID, m_value, bSigned); COptItem::MemToWnd(hWnd); } - + virtual void SetValue(INT_PTR _Value) { this->m_value = _Value; COptItem::SetValue(_Value); } virtual void SetDefValue(INT_PTR _DefValue) { this->m_defValue = _DefValue; COptItem::SetDefValue(_DefValue); } - + virtual INT_PTR GetValue() { return m_value; } virtual INT_PTR GetDefValue() { return m_defValue; } virtual COptItem* Copy() { return new COptItem_IntEdit(*this); } @@ -145,7 +144,7 @@ public: COptItem_Checkbox() {} COptItem_Checkbox(int m_dlgItemID, char *szDBSetting, int nValueSize = DBVT_BYTE, int m_defValue = 0, int m_valueMask = 0, int lParam = 0, bool m_bReadOnly = false) : COptItem(m_dlgItemID, szDBSetting, nValueSize, lParam, m_bReadOnly), m_defValue(m_defValue), m_value(0), m_valueMask(m_valueMask) - {} + {} void DBToMem(const CString &sModule, CString *sDBSettingPrefix = NULL); void MemToDB(const CString &sModule, CString *sDBSettingPrefix = NULL); @@ -154,10 +153,10 @@ public: virtual void SetValue(INT_PTR _Value) { this->m_value = _Value; COptItem::SetValue(_Value); } virtual void SetDefValue(INT_PTR _DefValue) { this->m_defValue = _DefValue; COptItem::SetDefValue(_DefValue); } - + virtual INT_PTR GetValue() { return m_value; } virtual INT_PTR GetDefValue() { return m_defValue; } - + virtual COptItem* Copy() { return new COptItem_Checkbox(*this); } int m_value; @@ -171,7 +170,7 @@ public: COptItem_Radiobutton() {} COptItem_Radiobutton(int m_dlgItemID, char *szDBSetting, int nValueSize, int m_defValue, int m_valueMask, int lParam = 0, bool m_bReadOnly = false) : COptItem(m_dlgItemID, szDBSetting, nValueSize, lParam, m_bReadOnly), m_defValue(m_defValue), m_value(0), m_valueMask(m_valueMask) - {} + {} void DBToMem(const CString &sModule, CString *sDBSettingPrefix = NULL) { m_value = (GetIntDBVal(sModule, false, sDBSettingPrefix) == m_valueMask) ? BST_CHECKED : BST_UNCHECKED; COptItem::DBToMem(sModule, sDBSettingPrefix); } void MemToDB(const CString &sModule, CString *sDBSettingPrefix = NULL) { if ((m_value == BST_CHECKED)) SetIntDBVal(sModule, m_valueMask, sDBSettingPrefix); COptItem::MemToDB(sModule, sDBSettingPrefix); } @@ -180,10 +179,10 @@ public: virtual void SetValue(INT_PTR _Value) { this->m_value = _Value; COptItem::SetValue(_Value); } virtual void SetDefValue(INT_PTR _DefValue) { this->m_defValue = _DefValue; COptItem::SetDefValue(_DefValue); } - + virtual INT_PTR GetValue() { return m_value; } virtual INT_PTR GetDefValue() { return m_defValue; } - + virtual COptItem* Copy() { return new COptItem_Radiobutton(*this); } int m_value; @@ -197,19 +196,19 @@ public: COptItem_Combobox() {} COptItem_Combobox(int m_dlgItemID, char *szDBSetting, int nValueSize = DBVT_BYTE, int m_defValue = 0, int lParam = 0, bool m_bReadOnly = false) : COptItem(m_dlgItemID, szDBSetting, nValueSize, lParam, m_bReadOnly), m_defValue(m_defValue), m_value(0) - {} - + {} + void DBToMem(const CString &sModule, CString *sDBSettingPrefix = NULL) { m_value = GetIntDBVal(sModule, false, sDBSettingPrefix); COptItem::DBToMem(sModule, sDBSettingPrefix); } void MemToDB(const CString &sModule, CString *sDBSettingPrefix = NULL) { SetIntDBVal(sModule, m_value, sDBSettingPrefix); COptItem::MemToDB(sModule, sDBSettingPrefix); } void WndToMem(HWND hWnd) { m_value = SendDlgItemMessage(hWnd, m_dlgItemID, CB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hWnd, m_dlgItemID, CB_GETCURSEL, 0, 0), 0); COptItem::WndToMem(hWnd); } void MemToWnd(HWND hWnd) { SendDlgItemMessage(hWnd, m_dlgItemID, CB_SETCURSEL, m_value, 0); COptItem::MemToWnd(hWnd); } - + virtual void SetValue(INT_PTR _Value) { this->m_value = _Value; COptItem::SetValue(_Value); } virtual void SetDefValue(INT_PTR _DefValue) { this->m_defValue = _DefValue; COptItem::SetDefValue(_DefValue); } - + virtual INT_PTR GetValue() { return m_value; } virtual INT_PTR GetDefValue() { return m_defValue; } - + virtual COptItem* Copy() { return new COptItem_Combobox(*this); } int m_defValue; @@ -222,19 +221,19 @@ public: COptItem_Colourpicker() {} COptItem_Colourpicker(int m_dlgItemID, char *szDBSetting, int m_defValue = 0, int lParam = 0, bool m_bReadOnly = false) : COptItem(m_dlgItemID, szDBSetting, DBVT_DWORD, lParam, m_bReadOnly), m_defValue(m_defValue), m_value(0) - {} - + {} + void DBToMem(const CString &sModule, CString *sDBSettingPrefix = NULL) { m_value = GetIntDBVal(sModule, false, sDBSettingPrefix); COptItem::DBToMem(sModule, sDBSettingPrefix); } void MemToDB(const CString &sModule, CString *sDBSettingPrefix = NULL) { SetIntDBVal(sModule, m_value, sDBSettingPrefix); COptItem::MemToDB(sModule, sDBSettingPrefix); } void WndToMem(HWND hWnd) { m_value = SendDlgItemMessage(hWnd, m_dlgItemID, CPM_GETCOLOUR, 0, 0); COptItem::WndToMem(hWnd); } void MemToWnd(HWND hWnd) { SendDlgItemMessage(hWnd, m_dlgItemID, CPM_SETCOLOUR, 0, m_value); COptItem::MemToWnd(hWnd); } - + virtual void SetValue(INT_PTR _Value) { this->m_value = _Value; COptItem::SetValue(_Value); } virtual void SetDefValue(INT_PTR _DefValue) { this->m_defValue = _DefValue; COptItem::SetDefValue(_DefValue); } - + virtual INT_PTR GetValue() { return m_value; } virtual INT_PTR GetDefValue() { return m_defValue; } - + virtual COptItem* Copy() { return new COptItem_Colourpicker(*this); } DWORD m_defValue; @@ -248,16 +247,16 @@ public: COptItem_Slider() {} COptItem_Slider(int m_dlgItemID, char *szDBSetting, int nValueSize = DBVT_BYTE, int m_defValue = 0, int lParam = 0, bool m_bReadOnly = false) : COptItem(m_dlgItemID, szDBSetting, nValueSize, lParam, m_bReadOnly), m_defValue(m_defValue), m_value(0) - {} - + {} + void DBToMem(const CString &sModule, CString *sDBSettingPrefix = NULL) { m_value = GetIntDBVal(sModule, false, sDBSettingPrefix); COptItem::DBToMem(sModule, sDBSettingPrefix); } void MemToDB(const CString &sModule, CString *sDBSettingPrefix = NULL) { SetIntDBVal(sModule, m_value, sDBSettingPrefix); COptItem::MemToDB(sModule, sDBSettingPrefix); } void WndToMem(HWND hWnd) { m_value = SendDlgItemMessage(hWnd, m_dlgItemID, TBM_GETPOS, 0, 0); COptItem::WndToMem(hWnd); } void MemToWnd(HWND hWnd) { SendDlgItemMessage(hWnd, m_dlgItemID, TBM_SETPOS, true, m_value); COptItem::MemToWnd(hWnd); } - + virtual void SetValue(INT_PTR _Value) { this->m_value = _Value; COptItem::SetValue(_Value); } virtual void SetDefValue(INT_PTR _DefValue) { this->m_defValue = _DefValue; COptItem::SetDefValue(_DefValue); } - + virtual INT_PTR GetValue() { return m_value; } virtual INT_PTR GetDefValue() { return m_defValue; } virtual COptItem* Copy() { return new COptItem_Slider(*this); } @@ -273,13 +272,13 @@ public: COptItem_IntDBSetting() {} COptItem_IntDBSetting(int m_dlgItemID, char *szDBSetting, int nValueSize = DBVT_BYTE, int bSigned = true, int m_defValue = 0, int lParam = 0, bool m_bReadOnly = false) : COptItem(m_dlgItemID, szDBSetting, nValueSize, lParam, m_bReadOnly), m_defValue(m_defValue), m_value(0), bSigned(bSigned) - {} - + {} + void DBToMem(const CString &sModule, CString *sDBSettingPrefix = NULL) { m_value = GetIntDBVal(sModule, bSigned, sDBSettingPrefix); COptItem::DBToMem(sModule, sDBSettingPrefix); } void MemToDB(const CString &sModule, CString *sDBSettingPrefix = NULL) { SetIntDBVal(sModule, m_value, sDBSettingPrefix); COptItem::MemToDB(sModule, sDBSettingPrefix); } void WndToMem(HWND hWnd) { COptItem::WndToMem(hWnd); } void MemToWnd(HWND hWnd) { COptItem::MemToWnd(hWnd); } - + virtual void SetValue(INT_PTR _Value) { this->m_value = _Value; COptItem::SetValue(_Value); } virtual void SetDefValue(INT_PTR _DefValue) { this->m_defValue = _DefValue; COptItem::SetDefValue(_DefValue); } @@ -326,13 +325,13 @@ public: void MemToDB(const CString &sModule, CString *sDBSettingPrefix = NULL) { SetStrDBVal(sModule, sValue, sDBSettingPrefix); COptItem::MemToDB(sModule, sDBSettingPrefix); } void WndToMem(HWND hWnd) { COptItem::WndToMem(hWnd); } void MemToWnd(HWND hWnd) { COptItem::MemToWnd(hWnd); } - + virtual void SetValue(INT_PTR _Value) { sValue = *(TCString*)_Value; COptItem::SetValue(_Value); } virtual void SetDefValue(INT_PTR _DefValue) { sDefValue = *(TCString*)_DefValue; COptItem::SetDefValue(_DefValue); } virtual INT_PTR GetValue() { return (INT_PTR)&sValue; } virtual INT_PTR GetDefValue() { return (INT_PTR)&sDefValue; } - + virtual COptItem* Copy() { return new COptItem_StrDBSetting(*this); } TCString sDefValue; @@ -364,8 +363,7 @@ public: CTreeItem(); CTreeItem(TCString Title, int ParentID, int ID, int Flags = 0, TCString User_Str1 = NULL) : CBaseTreeItem(Title, ID, Flags & ~TIF_ROOTITEM), ParentID(ParentID), User_Str1(User_Str1) - { - } + {} int ParentID; TCString User_Str1; @@ -414,13 +412,13 @@ public: void WndToMem(HWND hWnd); void MemToWnd(HWND hWnd); void CleanDBSettings(const CString &sModule, CString *sDBSettingPrefix = NULL); - + virtual void SetValue(INT_PTR _Value) { this->m_value = *(TreeItemArray*)_Value; COptItem::SetValue(_Value); } virtual void SetDefValue(INT_PTR _DefValue) { this->m_defValue = *(TreeItemArray*)_DefValue; COptItem::SetDefValue(_DefValue); } - + virtual INT_PTR GetValue() { return (INT_PTR)&m_value; } virtual INT_PTR GetDefValue() { return (INT_PTR)&m_defValue; } - + virtual COptItem* Copy() { return new COptItem_TreeCtrl(*this); } int IDToOrder(int ID); @@ -466,13 +464,13 @@ public: void WndToMem(HWND hWnd); void MemToWnd(HWND hWnd); void CleanDBSettings(const CString &sModule, CString *sDBSettingPrefix = NULL); - + virtual void SetValue(INT_PTR _Value) { this->m_value = *(ListItemArray*)_Value; COptItem::SetValue(_Value); } virtual void SetDefValue(INT_PTR _DefValue) { this->m_defValue = *(ListItemArray*)_DefValue; COptItem::SetDefValue(_DefValue); } - + virtual INT_PTR GetValue() { return (INT_PTR)&m_value; } virtual INT_PTR GetDefValue() { return (INT_PTR)&m_defValue; } - + virtual COptItem* Copy() { return new COptItem_ListCtrl(*this); } int GetSelectedItemID(HWND hWnd); // returns -1 if there's no selection @@ -504,21 +502,21 @@ public: COptItem* Find(int m_dlgItemID); INT_PTR GetValue(int m_dlgItemID) { return Find(m_dlgItemID)->GetValue(); } void SetValue(int m_dlgItemID, INT_PTR m_value) { Find(m_dlgItemID)->SetValue(m_value); } - + INT_PTR GetDBValue(int m_dlgItemID) { return Find(m_dlgItemID)->GetDBValue(sModule, &sDBSettingPrefix); } void SetDBValue(int m_dlgItemID, INT_PTR m_value) { Find(m_dlgItemID)->SetDBValue(sModule, m_value, &sDBSettingPrefix); } - + INT_PTR GetDBValueCopy(int m_dlgItemID) { return Find(m_dlgItemID)->GetDBValueCopy(sModule, &sDBSettingPrefix); } void SetDBValueCopy(int m_dlgItemID, INT_PTR m_value) { Find(m_dlgItemID)->SetDBValueCopy(sModule, m_value, &sDBSettingPrefix); } - + INT_PTR GetWndValue(int m_dlgItemID) { return Find(m_dlgItemID)->GetWndValue(hWnd); } void SetWndValue(int m_dlgItemID, INT_PTR m_value) { Find(m_dlgItemID)->SetWndValue(hWnd, m_value); } - + HWND GetWnd() { return hWnd; } void SetWnd(HWND _hWnd) { _ASSERT(!this->hWnd || !_hWnd); this->hWnd = _hWnd; } - + void Enable(int m_dlgItemID, bool m_bEnabled) { Find(m_dlgItemID)->Enable(m_bEnabled); } - + bool GetModified(); void SetModified(bool m_bModified); diff --git a/plugins/ClientChangeNotify/src/TMyArray.h b/plugins/ClientChangeNotify/src/TMyArray.h index 27bff9fd44..a36c261d3b 100644 --- a/plugins/ClientChangeNotify/src/TMyArray.h +++ b/plugins/ClientChangeNotify/src/TMyArray.h @@ -2,19 +2,19 @@ TMyArray.h - TMyArray template Copyright (c) 2005-2008 Chervov Dmitry - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #pragma once @@ -41,7 +41,7 @@ public: void MoveElem(int nIndex, int nMoveTo); T& SetAtGrow(int nIndex); int Find(ARG_T pElem); // returns an index of the specified item, or -1 if the array doesn't contain the item - int BinarySearch(int (*CmpFunc)(ARG_T pItem, LPARAM lParam), LPARAM lParam, int *pIndex = NULL); // returns an index of the specified item, or -1 if the array doesn't contain the item; + int BinarySearch(int(*CmpFunc)(ARG_T pItem, LPARAM lParam), LPARAM lParam, int *pIndex = NULL); // returns an index of the specified item, or -1 if the array doesn't contain the item; // also it's possible to specify pIndex so that even if the array doesn't contain the item, the function will set *pIndex to a position where the item can be inserted; // CmpFunc must return -1, 0 and 1 depending whether pItem is lesser, equal or greater than needed; // BinarySearch() requires the array to be sorted in an ascending order @@ -100,21 +100,18 @@ __forceinline int TMyArray::SetAllocNum(int nNe { _ASSERT(nNewAllocNum >= nElemNum); T*pNewData = (nNewAllocNum) ? (T*)malloc(sizeof(T) * nNewAllocNum) : NULL; - if (pData) - { - if (pNewData) - { + if (pData) { + if (pNewData) { memcpy(pNewData, pData, sizeof(T) * nElemNum); } free(pData); } pData = pNewData; - if (!pNewData) - { + if (!pNewData) { nAllocNum = 0; return -1; // not enough memory? - } else - { + } + else { nAllocNum = nNewAllocNum; return 0; // everything's ok } @@ -123,8 +120,7 @@ __forceinline int TMyArray::SetAllocNum(int nNe template __forceinline int TMyArray::AddElem(ARG_T pElem) { - if (nElemNum >= nAllocNum) - { // reallocate memory to fit new element + if (nElemNum >= nAllocNum) { // reallocate memory to fit new element SetAllocNum(nAllocNum + GrowBy); } memset(pData + nElemNum, 0, sizeof(T)); @@ -135,15 +131,13 @@ __forceinline int TMyArray::AddElem(ARG_T pElem template __forceinline int TMyArray::Add(const T *pItems, int nItems) { - if (nElemNum + nItems > nAllocNum) - { // reallocate memory to fit new items + if (nElemNum + nItems > nAllocNum) { // reallocate memory to fit new items SetAllocNum(nAllocNum + nElemNum + nItems - 1 - ((nElemNum + nItems - 1) % GrowBy) + GrowBy); } memset(pData + nElemNum, 0, sizeof(T) * nItems); int I; - for (I = 0; I < nItems; I++) - { - pData[nElemNum++] = pItems[I]; + for (I = 0; I < nItems; I++) { + pData[nElemNum++] = pItems[I]; } return nElemNum - nItems; // returns an index of the first item added } @@ -152,8 +146,7 @@ template __forceinline void TMyArray::InsertElem(ARG_T pElem, int nInsertAt) { _ASSERT(nInsertAt >= 0 && nInsertAt <= nElemNum); - if (nElemNum >= nAllocNum) - { // reallocate memory to fit new items + if (nElemNum >= nAllocNum) { // reallocate memory to fit new items SetAllocNum(nAllocNum + GrowBy); } memmove(pData + nInsertAt + 1, pData + nInsertAt, sizeof(T) * (nElemNum - nInsertAt)); @@ -166,17 +159,15 @@ template __forceinline void TMyArray::MoveElem(int nIndex, int nMoveTo) { _ASSERT(nIndex >= 0 && nIndex < nElemNum && nMoveTo >= 0 && nMoveTo < nElemNum); - if (nIndex == nMoveTo) - { + if (nIndex == nMoveTo) { return; // nothing to do } char Elem[sizeof(T)]; memcpy(Elem, pData + nIndex, sizeof(T)); - if (nIndex < nMoveTo) - { + if (nIndex < nMoveTo) { memmove(pData + nIndex, pData + nIndex + 1, sizeof(T) * (nMoveTo - nIndex)); - } else - { + } + else { memmove(pData + nMoveTo + 1, pData + nMoveTo, sizeof(T) * (nIndex - nMoveTo)); } memcpy(pData + nMoveTo, Elem, sizeof(T)); @@ -186,14 +177,11 @@ template __forceinline T& TMyArray::SetAtGrow(int nIndex) { _ASSERT(nIndex >= 0); - if (nIndex < nElemNum) - { + if (nIndex < nElemNum) { return pData[nIndex]; } - if (nIndex >= nAllocNum) - { - if (SetAllocNum(nIndex - (nIndex % GrowBy) + GrowBy)) - { // if there was an error + if (nIndex >= nAllocNum) { + if (SetAllocNum(nIndex - (nIndex % GrowBy) + GrowBy)) { // if there was an error nElemNum = 0; return *pData; } @@ -207,10 +195,8 @@ template __forceinline int TMyArray::Find(ARG_T pElem) { int I; - for (I = 0; I < nElemNum; I++) - { - if (pData[I] == pElem) - { + for (I = 0; I < nElemNum; I++) { + if (pData[I] == pElem) { return I; } } @@ -218,57 +204,47 @@ __forceinline int TMyArray::Find(ARG_T pElem) } template -__forceinline int TMyArray::BinarySearch(int (*CmpFunc)(ARG_T pItem, LPARAM lParam), LPARAM lParam, int *pIndex) +__forceinline int TMyArray::BinarySearch(int(*CmpFunc)(ARG_T pItem, LPARAM lParam), LPARAM lParam, int *pIndex) { int L, R; int CmpResult; - if (!nElemNum) - { - if (pIndex) - { + if (!nElemNum) { + if (pIndex) { *pIndex = -1; } return -1; } - for (L = 0, R = nElemNum; R - L > 1;) - { + for (L = 0, R = nElemNum; R - L > 1;) { int C = (L + R) >> 1; // rounds always to a lesser index if L + R is odd CmpResult = CmpFunc(pData[C], lParam); // usually, CmpFunc = pData[C] - lParam; i.e. CmpFunc > 0 when pData[C] is greater than necessary, < 0 when pData[C] is less, and = 0 when pData[C] is the item we search for - if (CmpResult < 0) - { + if (CmpResult < 0) { L = C; - } else if (CmpResult > 0) - { + } + else if (CmpResult > 0) { R = C; - } else - { // CmpResult == 0 - if (pIndex) - { + } + else { // CmpResult == 0 + if (pIndex) { *pIndex = C; } return C; } } - if (pIndex) - { + if (pIndex) { *pIndex = L; } CmpResult = CmpFunc(pData[L], lParam); - if (!CmpResult) - { + if (!CmpResult) { return L; } - if (CmpResult > 0) - { // we don't need to check pData[R], as pData[R] > pData[L] > lParam, i.e. there are no suitable item in the array + if (CmpResult > 0) { // we don't need to check pData[R], as pData[R] > pData[L] > lParam, i.e. there are no suitable item in the array return -1; } -// CmpResult < 0, we have to check pData[R] too - if (pIndex) - { + // CmpResult < 0, we have to check pData[R] too + if (pIndex) { *pIndex = R; } - if (R >= nElemNum) - { + if (R >= nElemNum) { return -1; } return CmpFunc(pData[R], lParam) ? -1 : R; @@ -278,21 +254,18 @@ template __forceinline void TMyArray::RemoveElem(int nIndex, int nItems) { _ASSERT(nIndex >= 0 && nIndex + nItems <= nElemNum); - if (!nItems) - { + if (!nItems) { return; } -// delete pData[nIndex]; -// ~pData[nIndex]; + // delete pData[nIndex]; + // ~pData[nIndex]; int I; - for (I = nIndex; I < nIndex + nItems; I++) - { + for (I = nIndex; I < nIndex + nItems; I++) { (pData + I)->~T(); } memmove(pData + nIndex, pData + nIndex + nItems, sizeof(T) * (nElemNum - nIndex - nItems)); nElemNum -= nItems; - if (nAllocNum - nElemNum >= FreeThreshold) - { + if (nAllocNum - nElemNum >= FreeThreshold) { SetAllocNum(nAllocNum - FreeThreshold); }/* else { @@ -304,8 +277,7 @@ template __forceinline void TMyArray::RemoveAll() { int I; - for (I = 0; I < nElemNum; I++) - { + for (I = 0; I < nElemNum; I++) { //delete pData[I]; (pData + I)->~T(); } @@ -332,8 +304,7 @@ __forceinline TMyArray& TMyArray __forceinline TMyArray& TMyArray::operator+=(const TMyArray &A) { int I; - for (I = 0; I < A.GetSize(); I++) - { + for (I = 0; I < A.GetSize(); I++) { AddElem(A[I]); } return *this; diff --git a/plugins/ClientChangeNotify/src/pcre.cpp b/plugins/ClientChangeNotify/src/pcre.cpp index d1796cfe81..0ab9eb0fe3 100644 --- a/plugins/ClientChangeNotify/src/pcre.cpp +++ b/plugins/ClientChangeNotify/src/pcre.cpp @@ -2,19 +2,19 @@ Pcre.cpp Copyright (c) 2007-2008 Chervov Dmitry - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "stdafx.h" @@ -41,13 +41,10 @@ TMyArray PcreCompileData; void FreePcreCompileData() { int I; - for (I = 0; I < PcreCompileData.GetSize(); I++) - { - if (PcreCompileData[I].pPcre) - { + for (I = 0; I < PcreCompileData.GetSize(); I++) { + if (PcreCompileData[I].pPcre) { pcre16_free(PcreCompileData[I].pPcre); - if (PcreCompileData[I].pExtra) - { + if (PcreCompileData[I].pExtra) { pcre16_free(PcreCompileData[I].pExtra); } } @@ -62,26 +59,22 @@ TCString CompileRegexp(TCString Regexp, int bAddAsUsualSubstring, int ID) sPcreCompileData s = {}; int NewID = PcreCompileData.AddElem(s); PcreCompileData[NewID].ID = ID; - if (!bAddAsUsualSubstring) - { + if (!bAddAsUsualSubstring) { const char *Err; int ErrOffs; int Flags = PCRE_CASELESS; - if (Regexp[0] == '/') - { + if (Regexp[0] == '/') { TCString OrigRegexp = Regexp; Regexp = Regexp.Right(Regexp.GetLen() - 1); wchar_t *pRegexpEnd = (wchar_t*)Regexp + Regexp.GetLen(); wchar_t *p = wcsrchr(Regexp.GetBuffer(), '/'); - if (!p) - { + if (!p) { Regexp = OrigRegexp; - } else - { + } + else { *p = 0; Flags = 0; - while (++p < pRegexpEnd) - { + while (++p < pRegexpEnd) { switch (*p) { case 'i': Flags |= PCRE_CASELESS; @@ -124,12 +117,12 @@ TCString CompileRegexp(TCString Regexp, int bAddAsUsualSubstring, int ID) if (PcreCompileData[NewID].pPcre) { PcreCompileData[NewID].pExtra = nullptr; PcreCompileData[NewID].pExtra = pcre16_study(PcreCompileData[NewID].pPcre, 0, &Err); - } + } else { // Result += LogMessage(TranslateT("Syntax error in regexp\n%s\nat offset %d: %s."), (wchar_t*)Regexp, ErrOffs, (wchar_t*)ANSI2TCHAR(Err)) + L"\n\n"; PcreCompileData[NewID].Pattern = Regexp; - } - } + } + } else PcreCompileData[NewID].Pattern = Regexp; return Result; @@ -138,35 +131,28 @@ TCString CompileRegexp(TCString Regexp, int bAddAsUsualSubstring, int ID) int PcreCheck(TCString Str, int StartingID) { // StartingID specifies the pattern from which to start checking, i.e. the check starts from the next pattern after the one that has ID == StartingID int I; - if (StartingID == -1) - { + if (StartingID == -1) { I = 0; - } else - { - for (I = 0; I < PcreCompileData.GetSize(); I++) - { - if (PcreCompileData[I].ID == StartingID) - { + } + else { + for (I = 0; I < PcreCompileData.GetSize(); I++) { + if (PcreCompileData[I].ID == StartingID) { I++; break; } } } - for (; I < PcreCompileData.GetSize(); I++) - { - if (PcreCompileData[I].pPcre) - { + for (; I < PcreCompileData.GetSize(); I++) { + if (PcreCompileData[I].pPcre) { int Res = pcre16_exec(PcreCompileData[I].pPcre, PcreCompileData[I].pExtra, Str, Str.GetLen() - 1, 0, PCRE_NOTEMPTY | PCRE_NO_UTF8_CHECK, nullptr, 0); - - if (Res >= 0) - { + + if (Res >= 0) { return PcreCompileData[I].ID; } - } else - { - if (wcsstr(Str.ToLower(), PcreCompileData[I].Pattern.ToLower())) - { + } + else { + if (wcsstr(Str.ToLower(), PcreCompileData[I].Pattern.ToLower())) { return PcreCompileData[I].ID; } } diff --git a/plugins/ClientChangeNotify/src/pcre.h b/plugins/ClientChangeNotify/src/pcre.h index 09294dabba..f230896689 100644 --- a/plugins/ClientChangeNotify/src/pcre.h +++ b/plugins/ClientChangeNotify/src/pcre.h @@ -2,19 +2,19 @@ Pcre.h Copyright (c) 2007-2008 Chervov Dmitry - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "CString.h" diff --git a/plugins/ClientChangeNotify/src/stdafx.h b/plugins/ClientChangeNotify/src/stdafx.h index 9fc0695866..c4ce64be06 100644 --- a/plugins/ClientChangeNotify/src/stdafx.h +++ b/plugins/ClientChangeNotify/src/stdafx.h @@ -2,19 +2,19 @@ ClientChangeNotify - Plugin for Miranda IM Copyright (c) 2006-2008 Chervov Dmitry - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #pragma once @@ -126,7 +126,7 @@ static __inline CString LogMessage(const char *Format, ...) char szText[8096]; mir_strcpy(szText, LOG_PREFIX); va_start(va, Format); - mir_vsnprintf(szText + _countof(LOG_PREFIX)-1, _countof(szText) - (_countof(LOG_PREFIX)-1), Format, va); + mir_vsnprintf(szText + _countof(LOG_PREFIX) - 1, _countof(szText) - (_countof(LOG_PREFIX) - 1), Format, va); va_end(va); Netlib_Log(NULL, szText); return CString(szText); diff --git a/plugins/ClientChangeNotify/src/version.h b/plugins/ClientChangeNotify/src/version.h index 1c2ba5b5d1..cfe4dc6ad9 100644 --- a/plugins/ClientChangeNotify/src/version.h +++ b/plugins/ClientChangeNotify/src/version.h @@ -1,13 +1,13 @@ -#define __MAJOR_VERSION 0 -#define __MINOR_VERSION 1 +#define __MAJOR_VERSION 0 +#define __MINOR_VERSION 1 #define __RELEASE_NUM 1 -#define __BUILD_NUM 3 +#define __BUILD_NUM 4 #include #define __PLUGIN_NAME "Client change notify" #define __FILENAME "ClientChangeNotify.dll" -#define __DESCRIPTION "Shows a notification when someone in your contact list changes his client." -#define __AUTHOR "Deathdemon" -#define __AUTHORWEB "https://miranda-ng.org/p/ClientChangeNotify/" -#define __COPYRIGHT "© 2006-2008 Chervov Dmitry" +#define __DESCRIPTION "Shows a notification when someone in your contact list changes his client." +#define __AUTHOR "Deathdemon" +#define __AUTHORWEB "https://miranda-ng.org/p/ClientChangeNotify/" +#define __COPYRIGHT "© 2006-2008 Chervov Dmitry" -- cgit v1.2.3