summaryrefslogtreecommitdiff
path: root/protocols/MRA/MraSendCommand.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-09-27 17:12:49 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-09-27 17:12:49 +0000
commit795fd3b5c0a366bd1455d4c0ae8a7d9bb474c348 (patch)
treeba6269dbf2f13a67c4fe7573f02dab93095b432c /protocols/MRA/MraSendCommand.cpp
parent6c6a48a1ea97de81ded7062eae451db4fc13261b (diff)
- mra is linked statically with zlib now;
- new simplified async acks mechanism; git-svn-id: http://svn.miranda-ng.org/main/trunk@1686 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/MRA/MraSendCommand.cpp')
-rw-r--r--protocols/MRA/MraSendCommand.cpp53
1 files changed, 23 insertions, 30 deletions
diff --git a/protocols/MRA/MraSendCommand.cpp b/protocols/MRA/MraSendCommand.cpp
index 67db1e499f..158427cbe4 100644
--- a/protocols/MRA/MraSendCommand.cpp
+++ b/protocols/MRA/MraSendCommand.cpp
@@ -101,42 +101,36 @@ DWORD CMraProto::MraMessageW(BOOL bAddToQueue, HANDLE hContact, DWORD dwAckType,
}
// messages with Flash
else if (dwFlags & MESSAGE_FLAG_FLASH) {
- if (masMraSettings.lpfnCompress2) { // only if func exist
- size_t dwRFTBuffSize = (((dwMessageSize*sizeof(WCHAR))*4)+8192), dwRTFDataSize;
- LPBYTE lpbRTFData;
-
- dwFlags |= MESSAGE_FLAG_RTF;
- lpszMessageRTF = (LPSTR)mir_calloc(dwRFTBuffSize);
- lpbRTFData = (LPBYTE)mir_calloc(dwRFTBuffSize);
- if (lpszMessageRTF && lpbRTFData) {
- DWORD dwBackColour = mraGetDword(NULL, "RTFBackgroundColour", MRA_DEFAULT_RTF_BACKGROUND_COLOUR);
- lpbDataCurrent = (LPBYTE)lpszMessageRTF;
-
- WideCharToMultiByte(MRA_CODE_PAGE, 0, lpwszMessage, dwMessageSize, (LPSTR)lpbRTFData, dwRFTBuffSize, NULL, NULL);
-
- SetUL(&lpbDataCurrent, 4);
- SetLPS(&lpbDataCurrent, (LPSTR)lpbRTFData, dwMessageSize);// сообщение что у собеседника плохая версия :)
- SetLPS(&lpbDataCurrent, (LPSTR)&dwBackColour, sizeof(DWORD));// цвет фона
- SetLPS(&lpbDataCurrent, (LPSTR)lpbRTFData, dwMessageSize);// сам мульт ANSI
- SetLPSW(&lpbDataCurrent, lpwszMessage, dwMessageSize);// сам мульт UNICODE
-
- dwRTFDataSize = dwRFTBuffSize;
- if ((PCOMPRESS2(masMraSettings.lpfnCompress2))(lpbRTFData, (DWORD*)&dwRTFDataSize, (LPBYTE)lpszMessageRTF, (lpbDataCurrent-(LPBYTE)lpszMessageRTF), Z_BEST_COMPRESSION) == Z_OK)
- BASE64EncodeUnSafe(lpbRTFData, dwRTFDataSize, lpszMessageRTF, dwRFTBuffSize, &dwMessageRTFSize);
- }
- mir_free(lpbRTFData);
+ size_t dwRFTBuffSize = (((dwMessageSize*sizeof(WCHAR))*4)+8192), dwRTFDataSize;
+
+ dwFlags |= MESSAGE_FLAG_RTF;
+ lpszMessageRTF = (LPSTR)mir_calloc(dwRFTBuffSize);
+ mir_ptr<char> lpbRTFData((char*)mir_calloc(dwRFTBuffSize));
+ if (lpszMessageRTF && lpbRTFData) {
+ DWORD dwBackColour = mraGetDword(NULL, "RTFBackgroundColour", MRA_DEFAULT_RTF_BACKGROUND_COLOUR);
+ lpbDataCurrent = (LPBYTE)lpszMessageRTF;
+
+ WideCharToMultiByte(MRA_CODE_PAGE, 0, lpwszMessage, dwMessageSize, (LPSTR)lpbRTFData, dwRFTBuffSize, NULL, NULL);
+
+ SetUL(&lpbDataCurrent, 4);
+ SetLPS(&lpbDataCurrent, (LPSTR)lpbRTFData, dwMessageSize);// сообщение что у собеседника плохая версия :)
+ SetLPS(&lpbDataCurrent, (LPSTR)&dwBackColour, sizeof(DWORD));// цвет фона
+ SetLPS(&lpbDataCurrent, (LPSTR)lpbRTFData, dwMessageSize);// сам мульт ANSI
+ SetLPSW(&lpbDataCurrent, lpwszMessage, dwMessageSize);// сам мульт UNICODE
+
+ dwRTFDataSize = dwRFTBuffSize;
+ if ( compress2((LPBYTE)(LPSTR)lpbRTFData, (DWORD*)&dwRTFDataSize, (LPBYTE)lpszMessageRTF, (lpbDataCurrent-(LPBYTE)lpszMessageRTF), Z_BEST_COMPRESSION) == Z_OK)
+ BASE64EncodeUnSafe(lpbRTFData, dwRTFDataSize, lpszMessageRTF, dwRFTBuffSize, &dwMessageRTFSize);
}
}
// standart message
else if ((dwFlags & (MESSAGE_FLAG_CONTACT | MESSAGE_FLAG_NOTIFY | MESSAGE_FLAG_SMS)) == 0) {
// Only if message is simple text message or RTF or ALARM
- if (dwFlags & MESSAGE_FLAG_RTF)// add RFT part
- if (masMraSettings.lpfnCompress2) { // обычный ртф
+ if (dwFlags & MESSAGE_FLAG_RTF) { // add RFT part
size_t dwRFTBuffSize = (((dwMessageSize*sizeof(WCHAR))*16)+8192), dwRTFDataSize;
- LPBYTE lpbRTFData;
lpszMessageRTF = (LPSTR)mir_calloc(dwRFTBuffSize);
- lpbRTFData = (LPBYTE)mir_calloc(dwRFTBuffSize);
+ mir_ptr<char> lpbRTFData((char*)mir_calloc(dwRFTBuffSize));
if (lpszMessageRTF && lpbRTFData) {
if ( !MraConvertToRTFW(lpwszMessage, dwMessageSize, (LPSTR)lpbRTFData, dwRFTBuffSize, &dwRTFDataSize)) {
DWORD dwBackColour = mraGetDword(NULL, "RTFBackgroundColour", MRA_DEFAULT_RTF_BACKGROUND_COLOUR);
@@ -147,11 +141,10 @@ DWORD CMraProto::MraMessageW(BOOL bAddToQueue, HANDLE hContact, DWORD dwAckType,
SetLPS(&lpbDataCurrent, (LPSTR)&dwBackColour, sizeof(DWORD));
dwRTFDataSize = dwRFTBuffSize;
- if ((PCOMPRESS2(masMraSettings.lpfnCompress2))(lpbRTFData, (DWORD*)&dwRTFDataSize, (LPBYTE)lpszMessageRTF, (lpbDataCurrent-(LPBYTE)lpszMessageRTF), Z_BEST_COMPRESSION) == Z_OK)
+ if ( compress2((LPBYTE)(LPSTR)lpbRTFData, (DWORD*)&dwRTFDataSize, (LPBYTE)lpszMessageRTF, (lpbDataCurrent-(LPBYTE)lpszMessageRTF), Z_BEST_COMPRESSION) == Z_OK)
BASE64EncodeUnSafe(lpbRTFData, dwRTFDataSize, lpszMessageRTF, dwRFTBuffSize, &dwMessageRTFSize);
}
}
- mir_free(lpbRTFData);
}
}