diff options
author | George Hazan <george.hazan@gmail.com> | 2013-10-09 15:12:22 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-10-09 15:12:22 +0000 |
commit | faf22fc165caf88e561b78752aab4a1704c89086 (patch) | |
tree | eced99885a9e49e2dc093df2e25e8a3a2cc8225e /protocols | |
parent | 30eda997b099947ea38c17d547950edc4a5af8eb (diff) |
- fix for moving contact to another group;
- home made debug functions replaced with their CRT analogs
git-svn-id: http://svn.miranda-ng.org/main/trunk@6417 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/MRA/src/Mra.cpp | 45 | ||||
-rw-r--r-- | protocols/MRA/src/Mra.h | 2 | ||||
-rw-r--r-- | protocols/MRA/src/MraAvatars.cpp | 2 | ||||
-rw-r--r-- | protocols/MRA/src/MraMPop.cpp | 9 | ||||
-rw-r--r-- | protocols/MRA/src/MraMRIMProxy.cpp | 12 | ||||
-rw-r--r-- | protocols/MRA/src/MraOfflineMsg.cpp | 16 | ||||
-rw-r--r-- | protocols/MRA/src/MraProto.h | 6 | ||||
-rw-r--r-- | protocols/MRA/src/MraRTFMsg.cpp | 4 | ||||
-rw-r--r-- | protocols/MRA/src/MraSendCommand.cpp | 4 | ||||
-rw-r--r-- | protocols/MRA/src/Mra_functions.cpp | 38 | ||||
-rw-r--r-- | protocols/MRA/src/Mra_proto.cpp | 153 | ||||
-rw-r--r-- | protocols/MRA/src/Mra_svcs.cpp | 2 | ||||
-rw-r--r-- | protocols/MRA/src/Sdk/DebugFunctions.h | 103 |
13 files changed, 125 insertions, 271 deletions
diff --git a/protocols/MRA/src/Mra.cpp b/protocols/MRA/src/Mra.cpp index d77cbb639f..efaddcfd34 100644 --- a/protocols/MRA/src/Mra.cpp +++ b/protocols/MRA/src/Mra.cpp @@ -1,5 +1,7 @@ #include "Mra.h"
+LIST<CMraProto> g_Instances(1, PtrKeySortT);
+
MRA_SETTINGS masMraSettings;
int hLangpack;
@@ -19,9 +21,6 @@ PLUGININFOEX pluginInfoEx = { void IconsLoad();
-int OnModulesLoaded(WPARAM, LPARAM);
-int OnPreShutdown(WPARAM, LPARAM);
-
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID Reserved)
{
switch (dwReason) {
@@ -48,16 +47,6 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda }
///////////////////////////////////////////////////////////////////////////////
-// Protocol instances
-
-static int sttCompareProtocols(const CMraProto *p1, const CMraProto *p2)
-{
- return lstrcmp(p1->m_tszUserName, p2->m_tszUserName);
-}
-
-LIST<CMraProto> g_Instances(1, sttCompareProtocols);
-
-///////////////////////////////////////////////////////////////////////////////
static CMraProto* mraProtoInit(const char* pszProtoName, const TCHAR* tszUserName)
{
@@ -73,6 +62,20 @@ static int mraProtoUninit(CMraProto *ppro) return 0;
}
+///////////////////////////////////////////////////////////////////////////////
+
+static int OnModulesLoaded(WPARAM, LPARAM)
+{
+ masMraSettings.dwGlobalPluginRunning = TRUE;
+ return 0;
+}
+
+static int OnPreShutdown(WPARAM, LPARAM)
+{
+ masMraSettings.dwGlobalPluginRunning = FALSE;
+ return 0;
+}
+
extern "C" __declspec(dllexport) int Load(void)
{
mir_getLP(&pluginInfoEx);
@@ -117,8 +120,6 @@ extern "C" __declspec(dllexport) int Load(void) pd.fnInit = (pfnInitProto)mraProtoInit;
pd.fnUninit = (pfnUninitProto)mraProtoUninit;
CallService(MS_PROTO_REGISTERMODULE, 0, (LPARAM)&pd);
-
- DebugPrintCRLFW(_T("Load - DONE"));
return 0;
}
@@ -131,19 +132,5 @@ extern "C" __declspec(dllexport) int Unload(void) }
g_Instances.destroy();
- DebugPrintCRLFW(_T("Unload - DONE"));
- return 0;
-}
-
-
-static int OnModulesLoaded(WPARAM, LPARAM)
-{
- masMraSettings.dwGlobalPluginRunning = TRUE;
- return 0;
-}
-
-int OnPreShutdown(WPARAM, LPARAM)
-{
- masMraSettings.dwGlobalPluginRunning = FALSE;
return 0;
}
diff --git a/protocols/MRA/src/Mra.h b/protocols/MRA/src/Mra.h index 6629845429..cf8a474842 100644 --- a/protocols/MRA/src/Mra.h +++ b/protocols/MRA/src/Mra.h @@ -27,6 +27,7 @@ #pragma comment(lib,"ws2_32.lib")
#pragma comment(lib,"mswsock.lib")
+#include <crtdbg.h>
#include <malloc.h>
#include <stdio.h>
#include <time.h>
@@ -76,7 +77,6 @@ #include "resource.h"
#include "..\xstatus_MRA\src\resource.h"
-#include "Sdk/DebugFunctions.h"
#include "Sdk/MemoryFind.h"
#include "Sdk/MemoryFindByte.h"
#include "Sdk/BuffToLowerCase.h"
diff --git a/protocols/MRA/src/MraAvatars.cpp b/protocols/MRA/src/MraAvatars.cpp index f4a22c4d06..33907a5da0 100644 --- a/protocols/MRA/src/MraAvatars.cpp +++ b/protocols/MRA/src/MraAvatars.cpp @@ -310,7 +310,7 @@ void CMraProto::MraAvatarsThreadProc(LPVOID lpParameter) }
}
}
- else DebugBreak();
+ else _CrtDbgBreak();
if (bUseKeepAliveConn == FALSE || bKeepAlive == FALSE) NETLIB_CLOSEHANDLE(m_hConnection);
}
diff --git a/protocols/MRA/src/MraMPop.cpp b/protocols/MRA/src/MraMPop.cpp index d2e5506f6d..022ede41e2 100644 --- a/protocols/MRA/src/MraMPop.cpp +++ b/protocols/MRA/src/MraMPop.cpp @@ -112,15 +112,12 @@ DWORD CMraProto::MraMPopSessionQueueAddUrlAndEMail(HANDLE hMPopSessionQueue, con DWORD CMraProto::MraMPopSessionQueueStart(HANDLE hMPopSessionQueue)
{
- DWORD dwRetErrorCode;
-
if (!hMPopSessionQueue)
return ERROR_INVALID_HANDLE;
MRA_MPOP_SESSION_QUEUE *pmpsqMPopSessionQueue = (MRA_MPOP_SESSION_QUEUE*)hMPopSessionQueue;
MRA_MPOP_SESSION_QUEUE_ITEM *pmpsqi;
- dwRetErrorCode = NO_ERROR;
if (pmpsqMPopSessionQueue->bKeyValid == TRUE)
if ( FifoMTItemPop(pmpsqMPopSessionQueue, NULL, (LPVOID*)&pmpsqi) == NO_ERROR) {
CMStringA szUrl, szEmail;
@@ -129,8 +126,7 @@ DWORD CMraProto::MraMPopSessionQueueStart(HANDLE hMPopSessionQueue) szEmail.MakeLower();
szUrl.Format(MRA_MPOP_AUTH_URL, szEmail, pmpsqMPopSessionQueue->lpszMPOPKey, pmpsqi->lpszUrl);
CallService(MS_UTILS_OPENURL, TRUE, (LPARAM)szUrl.c_str());
- DebugPrint(_T("Opening URL: "));
- DebugPrintCRLFA(szUrl);
+ DebugLogA("Opening URL: %s\n", szUrl);
}
mir_free(pmpsqi);
}
@@ -153,9 +149,6 @@ DWORD MraMPopSessionQueueSetNewMPopKey(HANDLE hMPopSessionQueue, const CMStringA pmpsqMPopSessionQueue->dwMPOPKeySize = szKey.GetLength();
memmove(pmpsqMPopSessionQueue->lpszMPOPKey, szKey, szKey.GetLength());
(*(pmpsqMPopSessionQueue->lpszMPOPKey + szKey.GetLength())) = 0;
-
- DebugPrint(_T("New MPOP session key: "));
- DebugPrintCRLFA(pmpsqMPopSessionQueue->lpszMPOPKey);
return NO_ERROR;
}
diff --git a/protocols/MRA/src/MraMRIMProxy.cpp b/protocols/MRA/src/MraMRIMProxy.cpp index 0f1068c0c0..f081596605 100644 --- a/protocols/MRA/src/MraMRIMProxy.cpp +++ b/protocols/MRA/src/MraMRIMProxy.cpp @@ -148,7 +148,7 @@ DWORD CMraProto::MraMrimProxyConnect(HANDLE hMraMrimProxyData, HANDLE *phConnect case 1:
if (dwRcvBuffSizeUsed == BUFF_SIZE_RCV_MIN_FREE) { // bad packet
bContinue = FALSE;
- DebugBreak();
+ _CrtDbgBreak();
}
else {
dwBytesReceived = Netlib_Recv(nls.hReadConns[0], (LPSTR)(lpbBufferRcv+dwRcvBuffSizeUsed), (dwRcvBuffSize-dwRcvBuffSizeUsed), 0);
@@ -160,21 +160,21 @@ DWORD CMraProto::MraMrimProxyConnect(HANDLE hMraMrimProxyData, HANDLE *phConnect if (((mrim_packet_header_t*)lpbBufferRcv)->msg == MRIM_CS_PROXY_HELLO_ACK) // connect OK!
dwRetErrorCode = NO_ERROR;
else // bad/wrong
- DebugBreak();
+ _CrtDbgBreak();
bContinue = FALSE;
}
else // not all packet received, continue receiving
- DebugPrintCRLF(L"Not all packet received, continue receiving");
+ DebugLogA("Not all packet received, continue receiving\n");
}
else { // bad packet
- DebugPrintCRLF(L"Bad packet");
- DebugBreak();
+ DebugLogA("Bad packet\n");
+ _ASSERT(false);
bContinue = FALSE;
}
}
else // packet too small, continue receiving
- DebugPrintCRLF(L"Packet to small, continue receiving");
+ DebugLogA("Packet to small, continue receiving\n");
}
else { // disconnected
dwRetErrorCode = GetLastError();
diff --git a/protocols/MRA/src/MraOfflineMsg.cpp b/protocols/MRA/src/MraOfflineMsg.cpp index b94790afb9..dad1b3b693 100644 --- a/protocols/MRA/src/MraOfflineMsg.cpp +++ b/protocols/MRA/src/MraOfflineMsg.cpp @@ -112,7 +112,7 @@ static DWORD MraOfflineMessageGetNextMIMEPart(LPSTR lpszBody, size_t dwBodySize, else if ((*((WORD*)lpszMIMEPart)) == '--')
lpszMIMEPart = NULL;
else
- DebugBreak();
+ _CrtDbgBreak();
if (lpszMIMEPart == NULL)
return ERROR_NO_MORE_ITEMS;
@@ -125,7 +125,7 @@ static DWORD MraOfflineMessageGetNextMIMEPart(LPSTR lpszBody, size_t dwBodySize, else if ((*((BYTE*)(lpszTemp-3))) == (*((BYTE*)LF)))
dwMIMEPartSize -= 3;
else
- DebugBreak();
+ _CrtDbgBreak();
if (plpszMIMEPart) (*plpszMIMEPart) = lpszMIMEPart;
if (pdwMIMEPartSize) (*pdwMIMEPartSize) = dwMIMEPartSize;
@@ -162,7 +162,7 @@ static DWORD PlainText2message(const CMStringA &szContentType, const CMStringA & }
return NO_ERROR;
}
- else DebugBreak();
+ else _CrtDbgBreak();
return ERROR_INVALID_HANDLE;
}
@@ -174,13 +174,8 @@ DWORD MraOfflineMessageGet(CMStringA *plpsMsg, DWORD *pdwTime, DWORD *pdwFlags, LPSTR lpszHeader, lpszBody, lpszContentTypeLow;
size_t dwHeaderSize, dwBodySize, dwContentTypeSize;
- DWORD dwMultichatType;
CMStringA szTemp;
- #ifdef _DEBUG
- DebugPrintCRLFA(plpsMsg->GetString());
- #endif
-
if ( MraOfflineMessageGetMIMEHeadAndBody(plpsMsg->GetString(), plpsMsg->GetLength(), &lpszHeader, &dwHeaderSize, &lpszBody, &dwBodySize) != NO_ERROR)
return ERROR_INVALID_HANDLE;
@@ -202,6 +197,7 @@ DWORD MraOfflineMessageGet(CMStringA *plpsMsg, DWORD *pdwTime, DWORD *pdwFlags, else
*pdwFlags = 0;
+ DWORD dwMultichatType;
if (MraOfflineMessageGetHeaderValue(lpszHeader, lpszHeaderLow, dwHeaderSize, "x-mrim-multichat-type", 21, szTemp) == NO_ERROR)
dwMultichatType = StrHexToUNum32(szTemp, szTemp.GetLength());
else
@@ -265,13 +261,13 @@ DWORD MraOfflineMessageGet(CMStringA *plpsMsg, DWORD *pdwTime, DWORD *pdwFlags, return NO_ERROR;
}
}
- else DebugBreak();
+ else _CrtDbgBreak();
}
}
i++;
}
- DebugBreakIf((i>3 || i == 0));
+ _ASSERTE((i>3 || i == 0));
}
return ERROR_NOT_FOUND;
}
diff --git a/protocols/MRA/src/MraProto.h b/protocols/MRA/src/MraProto.h index c6f9b779e6..c7483ca40a 100644 --- a/protocols/MRA/src/MraProto.h +++ b/protocols/MRA/src/MraProto.h @@ -198,7 +198,10 @@ struct CMraProto : public PROTO<CMraProto> CRITICAL_SECTION csCriticalSectionSend;
- HANDLE AddToListByEmail(LPCTSTR plpsEMail, LPCTSTR plpsNick, LPCTSTR plpsFirstName, LPCTSTR plpsLastName, DWORD dwFlags);
+ void DebugLogA(LPCSTR szFormat, ...);
+ void DebugLogW(LPCWSTR szFormat, ...);
+
+ HANDLE AddToListByEmail(LPCTSTR plpsEMail, LPCTSTR plpsNick, LPCTSTR plpsFirstName, LPCTSTR plpsLastName, DWORD dwFlags);
DWORD MraMessage(BOOL bAddToQueue, HANDLE hContact, DWORD dwAckType, DWORD dwFlags, const CMStringA &szEmail, const CMStringW &wszMessage, LPBYTE lpbMultiChatData, size_t dwMultiChatDataSize);
DWORD MraMessageAsk(DWORD dwMsgID, DWORD dwFlags, const CMStringA &szEmail, const CMStringW &wszMessage, const CMStringW &wszMessageRTF);
@@ -347,5 +350,4 @@ struct CMraProto : public PROTO<CMraProto> DWORD MraAvatarsDeleteContactAvatarFile(HANDLE hAvatarsQueueHandle, HANDLE hContact);
void __cdecl MraAvatarsThreadProc(LPVOID lpParameter);
-
};
diff --git a/protocols/MRA/src/MraRTFMsg.cpp b/protocols/MRA/src/MraRTFMsg.cpp index bb19c55578..55e2fdf185 100644 --- a/protocols/MRA/src/MraRTFMsg.cpp +++ b/protocols/MRA/src/MraRTFMsg.cpp @@ -174,7 +174,7 @@ DWORD MraSymbolsToRTFTags(DWORD dwFlags, LPSTR lpszMessage, size_t dwMessageSize }
else {
dwRetErrorCode = ERROR_BUFFER_OVERFLOW;
- DebugBreak();
+ _CrtDbgBreak();
break;
}
}
@@ -235,7 +235,7 @@ DWORD CMraProto::MraConvertToRTFW(const CMStringW &wszMessage, CMStringA &szMess memmove(lpszMessageRTFCur, PAR, sizeof(PAR));lpszMessageRTFCur += (sizeof(PAR)-1);
memmove(lpszMessageRTFCur, CRLF, sizeof(CRLF));lpszMessageRTFCur += (sizeof(CRLF)-1);
memmove(lpszMessageRTFCur, "}", 2);lpszMessageRTFCur += 2;
- DebugPrintCRLFA(szMessageRTF);
+ DebugLogA("%s\n", szMessageRTF);
return NO_ERROR;
}
diff --git a/protocols/MRA/src/MraSendCommand.cpp b/protocols/MRA/src/MraSendCommand.cpp index e821b3548c..27519820ce 100644 --- a/protocols/MRA/src/MraSendCommand.cpp +++ b/protocols/MRA/src/MraSendCommand.cpp @@ -73,7 +73,7 @@ public: DWORD CMraProto::MraMessage(BOOL bAddToQueue, HANDLE hContact, DWORD dwAckType, DWORD dwFlags, const CMStringA &szEmail, const CMStringW &lpwszMessage, LPBYTE lpbMultiChatData, size_t dwMultiChatDataSize)
{
- Netlib_Logf(m_hNetlibUser, "Sending message: flags %08x, to '%S', message '%S'\n", dwFlags, szEmail, lpwszMessage);
+ DebugLogA("Sending message: flags %08x, to '%S', message '%S'\n", dwFlags, szEmail, lpwszMessage);
DWORD dwRet = 0;
LPSTR lpszMessageConverted = (LPSTR)lpwszMessage.GetString();
@@ -508,7 +508,7 @@ DWORD CMraProto::MraSendPacket(HANDLE m_hConnection, DWORD dwCMDNum, DWORD dwTyp pmaHeader->msg = dwType;// Тип пакета
pmaHeader->dlen = dwDataSize;// Длина данных
- Netlib_Logf(m_hNetlibUser, "Sending packet %08x\n", dwType);
+ DebugLogA("Sending packet %08x\n", dwType);
memcpy(lpbData+sizeof(mrim_packet_header_t), lpData, dwDataSize);
return Netlib_Send(m_hConnection, (LPSTR)lpbData, (dwDataSize+sizeof(mrim_packet_header_t)), 0);
diff --git a/protocols/MRA/src/Mra_functions.cpp b/protocols/MRA/src/Mra_functions.cpp index 2f2bbeb346..35c4e610c1 100644 --- a/protocols/MRA/src/Mra_functions.cpp +++ b/protocols/MRA/src/Mra_functions.cpp @@ -307,7 +307,6 @@ DWORD CMraProto::MraMoveContactToGroup(HANDLE hContact, DWORD dwGroupID, LPCTSTR break;
}
- DWORD dwContactFlags = CONTACT_FLAG_UNICODE_NAME | CONTACT_FLAG_GROUP;
if (p == NULL) {
if (m_groups.getCount() == 20)
return 0;
@@ -317,16 +316,15 @@ DWORD CMraProto::MraMoveContactToGroup(HANDLE hContact, DWORD dwGroupID, LPCTSTR if (m_groups.find((MraGroupItem*)&id) == NULL)
break;
- dwContactFlags |= (id << 24);
+ DWORD dwContactFlags = CONTACT_FLAG_UNICODE_NAME | CONTACT_FLAG_GROUP | (id << 24);
p = new MraGroupItem(id, dwContactFlags, ptszName);
m_groups.insert(p);
MraAddContact(NULL, dwContactFlags, 0, ptszName, p->m_name);
}
- else dwContactFlags |= (p->m_id << 24);
if (dwGroupID != p->m_id) {
- setDword("GroupID", p->m_id);
- MraModifyContact(hContact, 0, &dwContactFlags, &p->m_id);
+ setDword(hContact, "GroupID", p->m_id);
+ MraModifyContact(hContact, 0, 0, &p->m_id);
}
return p->m_id;
}
@@ -1463,14 +1461,6 @@ static DWORD ReplaceInBuff(LPVOID lpInBuff, size_t dwInBuffSize, size_t dwReplac {
DWORD dwRetErrorCode = NO_ERROR;
- #ifdef _DEBUG //check tables
- for (size_t i = 0;i<dwReplaceItemsCount;i++)
- {
- if (lstrlen((LPTSTR)plpInReplaceItems[i]) != (pdwInReplaceItemsCounts[i]/sizeof(TCHAR))) DebugBreak();
- if (lstrlen((LPTSTR)plpOutReplaceItems[i]) != (pdwOutReplaceItemsCounts[i]/sizeof(TCHAR))) DebugBreak();
- }
- #endif
-
LPBYTE *plpbtFounded = (LPBYTE*)mir_calloc((sizeof(LPBYTE)*dwReplaceItemsCount));
if (plpbtFounded) {
LPBYTE lpbtOutBuffCur, lpbtInBuffCur, lpbtInBuffCurPrev, lpbtOutBuffMax;
@@ -1507,12 +1497,12 @@ static DWORD ReplaceInBuff(LPVOID lpInBuff, size_t dwInBuffSize, size_t dwReplac }
else {
dwRetErrorCode = ERROR_BUFFER_OVERFLOW;
- DebugBreak();
+ _CrtDbgBreak();
break;
}
}
else {// сюда по идее никогда не попадём, на всякий случай.
- DebugBreak();
+ _CrtDbgBreak();
break;
}
}
@@ -1549,3 +1539,21 @@ CMStringW EncodeXML(const CMStringW &lptszMessage) ReplaceInBuff((void*)lptszMessage.GetString(), lptszMessage.GetLength()*sizeof(TCHAR), SIZEOF(lpszXMLTags), (LPVOID*)lpszXMLSymbols, (size_t*)dwXMLSymbolsCount, (LPVOID*)lpszXMLTags, (size_t*)dwXMLTagsCount, ret);
return ret;
}
+
+void CMraProto::DebugLogA(LPCSTR szFormat, ...)
+{
+ char buf[4096];
+ va_list args;
+ va_start(args, szFormat);
+ vsprintf_s(buf, sizeof(buf), szFormat, args);
+ CallService(MS_NETLIB_LOG, (WPARAM)m_hNetlibUser, (LPARAM)buf);
+}
+
+void CMraProto::DebugLogW(LPCWSTR szFormat, ...)
+{
+ WCHAR buf[4096];
+ va_list args;
+ va_start(args, szFormat);
+ vswprintf_s(buf, SIZEOF(buf), szFormat, args);
+ CallService(MS_NETLIB_LOGW, (WPARAM)m_hNetlibUser, (LPARAM)buf);
+}
diff --git a/protocols/MRA/src/Mra_proto.cpp b/protocols/MRA/src/Mra_proto.cpp index 82c72b335c..e57266d7a8 100644 --- a/protocols/MRA/src/Mra_proto.cpp +++ b/protocols/MRA/src/Mra_proto.cpp @@ -329,13 +329,13 @@ DWORD CMraProto::MraNetworkDispatcher() dwRcvBuffSizeUsed = dwDataCurrentBuffSizeUsed;
dwDataCurrentBuffOffset = 0;
}
- DebugPrintCRLFW(L"Not all packet received, continue receiving");
+ DebugLogW(L"Not all packet received, continue receiving\n");
break;
}
}
// bad packet
else {
- DebugPrintCRLFW(L"Bad packet");
+ DebugLogW(L"Bad packet\n");
dwDataCurrentBuffOffset = 0;
dwRcvBuffSizeUsed = 0;
break;
@@ -343,7 +343,7 @@ DWORD CMraProto::MraNetworkDispatcher() }
// packet to small, continue receiving
else {
- DebugPrintCRLFW(L"Packet to small, continue receiving");
+ DebugLogW(L"Packet to small, continue receiving\n");
memmove(lpbBufferRcv, (lpbBufferRcv+dwDataCurrentBuffOffset), dwDataCurrentBuffSizeUsed);
dwRcvBuffSizeUsed = dwDataCurrentBuffSizeUsed;
dwDataCurrentBuffOffset = 0;
@@ -360,8 +360,8 @@ DWORD CMraProto::MraNetworkDispatcher() bContinue = FALSE;
}
break;
- }// end switch
- }// end while
+ }
+ }
mir_free(lpbBufferRcv);
return dwRetErrorCode;
@@ -516,14 +516,14 @@ bool CMraProto::CmdUserInfo(BinBuffer &buf) }
}
else if (szString == "connect.xml") {
- DebugPrintA(szString);
+ DebugLogA(szString);
buf >> szStringW;
- DebugPrintCRLFW(szStringW);
+ DebugLogW(szStringW);
}
else if (szString == "micblog.show_title") {
- DebugPrintA(szString);
+ DebugLogA(szString);
buf >> szStringW;
- DebugPrintCRLFW(szStringW);
+ DebugLogW(szStringW);
}
else if (szString == "micblog.status.id") {
buf >> szString;
@@ -559,11 +559,7 @@ bool CMraProto::CmdUserInfo(BinBuffer &buf) else if (szString == "trusted_update") {
buf >> szString;
}
- else {
- #ifdef _DEBUG
- DebugBreak();
- #endif
- }
+ else _CrtDbgBreak();
}
MraUpdateEmailStatus("", "", 0, 0);
return true;
@@ -649,7 +645,7 @@ bool CMraProto::CmdFileTransfer(BinBuffer &buf) buf >> szFiles >> dwTemp;
if (dwTemp) { // LPS DESCRIPTION
buf >> dwTemp >> wszFilesW;
- DebugBreakIf(dwTemp != 1);
+ _ASSERTE(dwTemp != 1);
}
buf >> szAddresses;
}
@@ -770,7 +766,7 @@ bool CMraProto::CmdContactAck(int cmd, int seq, BinBuffer &buf) break;
case CONTACT_OPER_NO_SUCH_USER:// ## добавляемого пользователя не существует в системе
SetContactBasicInfoW(hContact, 0, SCBIF_SERVER_FLAG, 0, 0, 0, -1, 0, 0, 0, 0);
- ShowFormattedErrorMessage(_T("User does not registred"), NO_ERROR);
+ ShowFormattedErrorMessage(_T("No such user to add"), NO_ERROR);
break;
case CONTACT_OPER_INVALID_INFO:// ## некорректное имя пользователя
ShowFormattedErrorMessage(_T("Invalid user name"), NO_ERROR);
@@ -828,7 +824,7 @@ bool CMraProto::CmdAnketaInfo(int seq, BinBuffer &buf) // read headers name
for (unsigned i = 0; i < dwFieldsNum; i++) {
buf >> pmralpsFields[i];
- DebugPrintCRLFA(pmralpsFields[i]);
+ DebugLogA("%s ", pmralpsFields[i]);
}
while (!buf.eof()) {
@@ -977,10 +973,7 @@ bool CMraProto::CmdAnketaInfo(int seq, BinBuffer &buf) }
else {// for DEBUG ONLY
buf >> val;
-#ifdef _DEBUG
- DebugPrintCRLFA(fld);
- DebugPrintCRLFA(val);
-#endif
+ DebugLogA("%s = %s\n", fld, val);
}
}
}
@@ -1110,8 +1103,7 @@ bool CMraProto::CmdClist2(BinBuffer &buf) int iGroupMode = getByte("GroupMode", 100);
- DebugPrintCRLFW(L"Groups:");
- DebugPrintCRLFA(szGroupMask);
+ DebugLogA("Groups: %s\n", szGroupMask);
DWORD dwID = 0;
for (DWORD i = 0; i < dwGroupsCount; i++) { //groups handle
DWORD dwControlParam = 0, dwGroupFlags;
@@ -1141,31 +1133,24 @@ bool CMraProto::CmdClist2(BinBuffer &buf) m_groups.insert( new MraGroupItem(dwID, dwGroupFlags, wszGroupName));
Clist_CreateGroup(0, wszGroupName);
}
- #ifdef _DEBUG
- DebugPrintW(wszGroupName);
-
- char szBuff[200];
- mir_snprintf(szBuff, SIZEOF(szBuff), ": flags: %lu (", dwGroupFlags);
- DebugPrintA(szBuff);
-
- if (dwGroupFlags & CONTACT_FLAG_REMOVED) DebugPrintA("CONTACT_FLAG_REMOVED, ");
- if (dwGroupFlags & CONTACT_FLAG_GROUP) DebugPrintA("CONTACT_FLAG_GROUP, ");
- if (dwGroupFlags & CONTACT_FLAG_INVISIBLE) DebugPrintA("CONTACT_FLAG_INVISIBLE, ");
- if (dwGroupFlags & CONTACT_FLAG_VISIBLE) DebugPrintA("CONTACT_FLAG_VISIBLE, ");
- if (dwGroupFlags & CONTACT_FLAG_IGNORE) DebugPrintA("CONTACT_FLAG_IGNORE, ");
- if (dwGroupFlags & CONTACT_FLAG_SHADOW) DebugPrintA("CONTACT_FLAG_SHADOW, ");
- if (dwGroupFlags & CONTACT_FLAG_AUTHORIZED) DebugPrintA("CONTACT_FLAG_AUTHORIZED, ");
- if (dwGroupFlags & CONTACT_FLAG_MULTICHAT) DebugPrintA("CONTACT_FLAG_MULTICHAT, ");
- if (dwGroupFlags & CONTACT_FLAG_UNICODE_NAME) DebugPrintA("CONTACT_FLAG_UNICODE_NAME, ");
- if (dwGroupFlags & CONTACT_FLAG_PHONE) DebugPrintA("CONTACT_FLAG_PHONE, ");
- DebugPrintCRLFA(")");
- #endif
+
+ DebugLogW(L"'%s', flags: %lu (", wszGroupName, dwGroupFlags);
+ if (dwGroupFlags & CONTACT_FLAG_REMOVED) DebugLogA("CONTACT_FLAG_REMOVED, ");
+ if (dwGroupFlags & CONTACT_FLAG_GROUP) DebugLogA("CONTACT_FLAG_GROUP, ");
+ if (dwGroupFlags & CONTACT_FLAG_INVISIBLE) DebugLogA("CONTACT_FLAG_INVISIBLE, ");
+ if (dwGroupFlags & CONTACT_FLAG_VISIBLE) DebugLogA("CONTACT_FLAG_VISIBLE, ");
+ if (dwGroupFlags & CONTACT_FLAG_IGNORE) DebugLogA("CONTACT_FLAG_IGNORE, ");
+ if (dwGroupFlags & CONTACT_FLAG_SHADOW) DebugLogA("CONTACT_FLAG_SHADOW, ");
+ if (dwGroupFlags & CONTACT_FLAG_AUTHORIZED) DebugLogA("CONTACT_FLAG_AUTHORIZED, ");
+ if (dwGroupFlags & CONTACT_FLAG_MULTICHAT) DebugLogA("CONTACT_FLAG_MULTICHAT, ");
+ if (dwGroupFlags & CONTACT_FLAG_UNICODE_NAME) DebugLogA("CONTACT_FLAG_UNICODE_NAME, ");
+ if (dwGroupFlags & CONTACT_FLAG_PHONE) DebugLogA("CONTACT_FLAG_PHONE, ");
+ DebugLogA(")");
}
dwID++;
}
- DebugPrintCRLFA("Contacts:");
- DebugPrintCRLFA(szContactMask);
+ DebugLogA("Contacts: %s\n", szContactMask);
dwID = 20;
while (!buf.eof()) {
DWORD dwControlParam = 0;
@@ -1253,52 +1238,40 @@ bool CMraProto::CmdClist2(BinBuffer &buf) else if (j == 19 && fieldType == 's') { // ?????? ?
buf >> szString;
dwControlParam++;
- DebugBreakIf(szString.GetLength());
+ _ASSERTE(szString.GetLength());
}
else {
if (fieldType == 's') {
buf >> szString;
if (szString.GetLength()) {
- DebugPrintCRLFA(szString);
+ DebugLogA("%s ", szString);
}
}
else if (fieldType == 'u') {
char szBuff[50];
mir_snprintf(szBuff, SIZEOF(szBuff), "%lu, ", dwTemp);//;
- DebugPrintCRLFA(szBuff);
+ DebugLogA("%s ", szBuff);
}
- else DebugBreak();
+ else _CrtDbgBreak();
}
}
- #ifdef _DEBUG
- {
- char szBuff[200];
- mir_snprintf(szBuff, SIZEOF(szBuff), "ID: %lu, Group id: %lu, ", dwID, dwGroupID);
- DebugPrintA(szBuff);
- DebugPrintA(szEmail);
-
- mir_snprintf(szBuff, SIZEOF(szBuff), ": flags: %lu (", dwContactFlag);
- DebugPrintA(szBuff);
- if (dwContactFlag & CONTACT_FLAG_REMOVED) DebugPrintA("CONTACT_FLAG_REMOVED, ");
- if (dwContactFlag & CONTACT_FLAG_GROUP) DebugPrintA("CONTACT_FLAG_GROUP, ");
- if (dwContactFlag & CONTACT_FLAG_INVISIBLE) DebugPrintA("CONTACT_FLAG_INVISIBLE, ");
- if (dwContactFlag & CONTACT_FLAG_VISIBLE) DebugPrintA("CONTACT_FLAG_VISIBLE, ");
- if (dwContactFlag & CONTACT_FLAG_IGNORE) DebugPrintA("CONTACT_FLAG_IGNORE, ");
- if (dwContactFlag & CONTACT_FLAG_SHADOW) DebugPrintA("CONTACT_FLAG_SHADOW, ");
- if (dwContactFlag & CONTACT_FLAG_AUTHORIZED) DebugPrintA("CONTACT_FLAG_AUTHORIZED, ");
- if (dwContactFlag & CONTACT_FLAG_MULTICHAT) DebugPrintA("CONTACT_FLAG_MULTICHAT, ");
- if (dwContactFlag & CONTACT_FLAG_UNICODE_NAME) DebugPrintA("CONTACT_FLAG_UNICODE_NAME, ");
- if (dwContactFlag & CONTACT_FLAG_PHONE) DebugPrintA("CONTACT_FLAG_PHONE, ");
- DebugPrintA(")");
-
- mir_snprintf(szBuff, SIZEOF(szBuff), ": server flags: %lu (", dwContactSeverFlags);
- DebugPrintA(szBuff);
- if (dwContactSeverFlags & CONTACT_INTFLAG_NOT_AUTHORIZED)
- DebugPrintA("CONTACT_INTFLAG_NOT_AUTHORIZED, ");
- DebugPrintCRLFA(")");
- }
- #endif
+ DebugLogA("ID: %lu, Group id: %lu, %s: flags: %lu (", dwID, dwGroupID, szEmail, dwContactFlag);
+ if (dwContactFlag & CONTACT_FLAG_REMOVED) DebugLogA("CONTACT_FLAG_REMOVED, ");
+ if (dwContactFlag & CONTACT_FLAG_GROUP) DebugLogA("CONTACT_FLAG_GROUP, ");
+ if (dwContactFlag & CONTACT_FLAG_INVISIBLE) DebugLogA("CONTACT_FLAG_INVISIBLE, ");
+ if (dwContactFlag & CONTACT_FLAG_VISIBLE) DebugLogA("CONTACT_FLAG_VISIBLE, ");
+ if (dwContactFlag & CONTACT_FLAG_IGNORE) DebugLogA("CONTACT_FLAG_IGNORE, ");
+ if (dwContactFlag & CONTACT_FLAG_SHADOW) DebugLogA("CONTACT_FLAG_SHADOW, ");
+ if (dwContactFlag & CONTACT_FLAG_AUTHORIZED) DebugLogA("CONTACT_FLAG_AUTHORIZED, ");
+ if (dwContactFlag & CONTACT_FLAG_MULTICHAT) DebugLogA("CONTACT_FLAG_MULTICHAT, ");
+ if (dwContactFlag & CONTACT_FLAG_UNICODE_NAME) DebugLogA("CONTACT_FLAG_UNICODE_NAME, ");
+ if (dwContactFlag & CONTACT_FLAG_PHONE) DebugLogA("CONTACT_FLAG_PHONE, ");
+ DebugLogA(")");
+
+ DebugLogA(": server flags: %lu (", dwContactSeverFlags);
+ if (dwContactSeverFlags & CONTACT_INTFLAG_NOT_AUTHORIZED) DebugLogA("CONTACT_INTFLAG_NOT_AUTHORIZED, ");
+ DebugLogA(")");
// add/modify contact
if (dwGroupID != 103)//***deb filtering phone/sms contats
@@ -1311,7 +1284,7 @@ bool CMraProto::CmdClist2(BinBuffer &buf) // already in list, remove the duplicate
if (GetContactBasicInfoW(hContact, &dwTemp, NULL, NULL, NULL, NULL, NULL, NULL, NULL) == NO_ERROR && dwTemp != -1) {
dwTemp = dwTemp;
- DebugBreak();
+ _CrtDbgBreak();
}
else {
dwTemp = GetMirandaStatusFromMraStatus(dwStatus, GetMraXStatusIDFromMraUriStatus(szSpecStatusUri), &dwXStatus);
@@ -1436,7 +1409,7 @@ bool CMraProto::CmdProxy(BinBuffer &buf) MraFilesQueueStartMrimProxy(hFilesQueueHandle, dwIDRequest);
else { // empty/invalid session
MraProxyAck(PROXY_STATUS_ERROR, szEmail, dwIDRequest, dwAckType, szString, szAddresses, mguidSessionID);
- DebugBreak();
+ _CrtDbgBreak();
}
}
return true;
@@ -1473,11 +1446,11 @@ bool CMraProto::CmdProxyAck(BinBuffer &buf) case PROXY_STATUS_MIRROR:
case PROXY_STATUS_CLOSED:
default:
- DebugBreak();
+ _CrtDbgBreak();
break;
}
}
- else DebugBreak();
+ else _CrtDbgBreak();
}
return true;
}
@@ -1527,7 +1500,7 @@ bool CMraProto::MraCommandDispatcher(mrim_packet_header_t *pmaHeader) HANDLE hContact = NULL;
LPBYTE pByte;
- Netlib_Logf(m_hNetlibUser, "Received packet %x\n", pmaHeader->msg);
+ DebugLogA("Received packet %x\n", pmaHeader->msg);
BinBuffer buf((LPBYTE)pmaHeader + sizeof(mrim_packet_header_t), pmaHeader->dlen);
@@ -1600,11 +1573,11 @@ bool CMraProto::MraCommandDispatcher(mrim_packet_header_t *pmaHeader) break;
case MRIM_CS_PROXY_HELLO:
- DebugBreak();
+ _CrtDbgBreak();
break;
case MRIM_CS_PROXY_HELLO_ACK:
- DebugBreak();
+ _CrtDbgBreak();
break;
case MRIM_CS_UNKNOWN:
@@ -1613,9 +1586,7 @@ bool CMraProto::MraCommandDispatcher(mrim_packet_header_t *pmaHeader) break;
default:
- #ifdef _DEBUG
- DebugBreak();
- #endif
+ _CrtDbgBreak();
break;
}
return true;
@@ -1697,24 +1668,24 @@ DWORD CMraProto::MraRecvCommand_Message(DWORD dwTime, DWORD dwFlags, CMStringA & buf >> szString;
wszMessage = ptrW(mir_a2u_cp(szString, MRA_CODE_PAGE));
}
- else DebugBreak();
+ else _CrtDbgBreak();
}
else { // RTF text
if (dwRTFPartsCount > 2) {
buf >> szString;
- DebugBreak();
+ _CrtDbgBreak();
}
lpszMessageExt = lpsRTFString;
}
}
- else DebugBreak();
+ else _CrtDbgBreak();
}
}
}
}
- Netlib_Logf(m_hNetlibUser, "Processing message: %08X, from '%s', text '%S'\n", dwFlags, plpsFrom.c_str(), wszMessage.c_str());
+ DebugLogA("Processing message: %08X, from '%s', text '%S'\n", dwFlags, plpsFrom.c_str(), wszMessage.c_str());
// processing
if (dwFlags & (MESSAGE_FLAG_SMS | MESSAGE_SMS_DELIVERY_REPORT)) {// SMS //if (IsPhone(plpsFrom->lpszData, plpsFrom->dwSize))
@@ -1794,7 +1765,7 @@ DWORD CMraProto::MraRecvCommand_Message(DWORD dwTime, DWORD dwFlags, CMStringA & MraAddContact(hContact, (CONTACT_FLAG_VISIBLE|CONTACT_FLAG_MULTICHAT|CONTACT_FLAG_UNICODE_NAME), -1, plpsFrom, lpsMultichatName);
break;
default:
- DebugBreak();
+ _CrtDbgBreak();
break;
}
}
diff --git a/protocols/MRA/src/Mra_svcs.cpp b/protocols/MRA/src/Mra_svcs.cpp index aa7144a00c..48295be603 100644 --- a/protocols/MRA/src/Mra_svcs.cpp +++ b/protocols/MRA/src/Mra_svcs.cpp @@ -481,7 +481,7 @@ int CMraProto::MraDbSettingChanged(WPARAM wParam, LPARAM lParam) break;
}
if (wszGroup.GetLength()) {
- DWORD dwGroupID = getDword("GroupID", -1);
+ DWORD dwGroupID = getDword(hContact, "GroupID", -1);
if (dwGroupID != -1)
MraMoveContactToGroup(hContact, dwGroupID, wszGroup);
}
diff --git a/protocols/MRA/src/Sdk/DebugFunctions.h b/protocols/MRA/src/Sdk/DebugFunctions.h deleted file mode 100644 index 9ae925d448..0000000000 --- a/protocols/MRA/src/Sdk/DebugFunctions.h +++ /dev/null @@ -1,103 +0,0 @@ -/*
- * Copyright (c) 2004 Rozhuk Ivan <rozhuk.im@gmail.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- */
-
-
-
-#if !defined(AFX_DEBUG_FUNCTIONS__H__INCLUDED_)
-#define AFX_DEBUG_FUNCTIONS__H__INCLUDED_
-
-#pragma once
-
-//////////////////////////////////////////////////////////////////////////
-////////////////////////////DebugPrint////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////
-// DebugBuildPrint(Helo world);
-// Отображение текста в Debug окне во время отладки
-#ifdef _DEBUG
- #define DebugPrintA(szText) OutputDebugStringA((szText))
- #define DebugPrintW(szText) OutputDebugStringW((szText))
- #define DebugPrintCRLFA(szText) OutputDebugStringA((szText));OutputDebugStringA("\r\n")
- #define DebugPrintCRLFW(szText) OutputDebugStringW((szText));OutputDebugStringW(L"\r\n")
-#else
- #define DebugPrintA(szText)
- #define DebugPrintW(szText)
- #define DebugPrintCRLFA(szText)
- #define DebugPrintCRLFW(szText)
-#endif //_DEBUG
-
-
-#ifdef UNICODE
- #define DebugPrint DebugPrintW
- #define DebugPrintCRLF DebugPrintCRLFW
-#else
- #define DebugPrint DebugPrintA
- #define DebugPrintCRLF DebugPrintCRLFA
-#endif
-//////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////
-
-
-
-//////////////////////////////////////////////////////////////////////////
-////////////////////////////DebugBreak////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////
-// DebugBreak();
-// Точка останова, более удобная альтернатива API
-#if defined(_DEBUG)
- #if defined(_X86_)
- #define DebugBreak() _asm{int 3}
- #else
- #include <intrin.h>
- #define DebugBreak() __debugbreak()
- #endif
-#else
- #define DebugBreak()
-#endif //_DEBUG
-//////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////
-
-
-//////////////////////////////////////////////////////////////////////////
-////////////////////////////DebugBreakIf//////////////////////////////////
-//////////////////////////////////////////////////////////////////////////
-// DebugBreakIf();
-// Точка останова, более удобная альтернатива API, срабатывает при условии
-#if defined(_DEBUG)
- #define DebugBreakIf(a) if ((a)) DebugBreak();
-#else
- #define DebugBreakIf(a)
-#endif //_DEBUG
-//////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////
-
-
-
-
-#endif // !defined(AFX_DEBUG_FUNCTIONS__H__INCLUDED_)
|