diff options
author | George Hazan <george.hazan@gmail.com> | 2013-08-15 14:21:16 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-08-15 14:21:16 +0000 |
commit | 21c56b9074fbfdacba112a51ae3b54edfa243e59 (patch) | |
tree | 9880c23569b1012e2ae78b43a45b661a0742d616 /protocols/MRA/src/MraSendCommand.cpp | |
parent | 7651a0799879e5af9a6831551c1c73f6e4890143 (diff) |
custom base64 & sha1 libs removed from MRA
git-svn-id: http://svn.miranda-ng.org/main/trunk@5702 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/MRA/src/MraSendCommand.cpp')
-rw-r--r-- | protocols/MRA/src/MraSendCommand.cpp | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/protocols/MRA/src/MraSendCommand.cpp b/protocols/MRA/src/MraSendCommand.cpp index 55ffd86bba..fb4a9e711a 100644 --- a/protocols/MRA/src/MraSendCommand.cpp +++ b/protocols/MRA/src/MraSendCommand.cpp @@ -80,23 +80,18 @@ DWORD CMraProto::MraMessageW(BOOL bAddToQueue, HANDLE hContact, DWORD dwAckType, // pack auth message
if (dwFlags & MESSAGE_FLAG_AUTHORIZE) {
- LPBYTE lpbAuthMsgBuff;
- size_t dwMessageConvertedBuffSize = (((((dwMessageSize*sizeof(WCHAR))+1024)+2)/3)*4);
-
- lpszMessageConverted = (LPSTR)mir_calloc(dwMessageConvertedBuffSize);
- lpbAuthMsgBuff = (LPBYTE)mir_calloc(((dwMessageSize*sizeof(WCHAR))+1024));
- if (lpszMessageConverted && lpbAuthMsgBuff) {
+ LPBYTE lpbAuthMsgBuff = (LPBYTE)mir_calloc(((dwMessageSize*sizeof(WCHAR))+1024));
+ if (lpbAuthMsgBuff) {
lpbDataCurrent = lpbAuthMsgBuff;
SetUL(&lpbDataCurrent, 2);
SetLPSW(&lpbDataCurrent, NULL, 0);//***deb possible nick here
SetLPSW(&lpbDataCurrent, lpwszMessage, dwMessageSize);
- BASE64EncodeUnSafe(lpbAuthMsgBuff, (lpbDataCurrent-lpbAuthMsgBuff), lpszMessageConverted, dwMessageConvertedBuffSize, &dwMessageConvertedSize);
- }
- else {
- mir_free(lpszMessageConverted);
- lpszMessageConverted = (LPSTR)lpwszMessage;
+ lpszMessageConverted = mir_base64_encode(lpbAuthMsgBuff, (lpbDataCurrent-lpbAuthMsgBuff));
+ dwMessageConvertedSize = strlen(lpszMessageConverted);
}
+ else lpszMessageConverted = (LPSTR)lpwszMessage;
+
mir_free(lpbAuthMsgBuff);
}
// messages with Flash
@@ -104,9 +99,8 @@ DWORD CMraProto::MraMessageW(BOOL bAddToQueue, HANDLE hContact, DWORD dwAckType, size_t dwRFTBuffSize = (((dwMessageSize*sizeof(WCHAR))*4)+8192), dwRTFDataSize;
dwFlags |= MESSAGE_FLAG_RTF;
- lpszMessageRTF = (LPSTR)mir_calloc(dwRFTBuffSize);
ptrA lpbRTFData((char*)mir_calloc(dwRFTBuffSize));
- if (lpszMessageRTF && lpbRTFData) {
+ if (lpbRTFData) {
DWORD dwBackColour = getDword("RTFBackgroundColour", MRA_DEFAULT_RTF_BACKGROUND_COLOUR);
lpbDataCurrent = (LPBYTE)lpszMessageRTF;
@@ -119,8 +113,10 @@ DWORD CMraProto::MraMessageW(BOOL bAddToQueue, HANDLE hContact, DWORD dwAckType, 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);
+ if ( compress2((LPBYTE)(LPSTR)lpbRTFData, (DWORD*)&dwRTFDataSize, (LPBYTE)lpszMessageRTF, (lpbDataCurrent-(LPBYTE)lpszMessageRTF), Z_BEST_COMPRESSION) == Z_OK) {
+ lpszMessageRTF = mir_base64_encode((LPBYTE)(char*)lpbRTFData, dwRTFDataSize);
+ dwMessageRTFSize = lstrlenA(lpszMessageRTF);
+ }
}
}
// standart message
@@ -129,9 +125,8 @@ DWORD CMraProto::MraMessageW(BOOL bAddToQueue, HANDLE hContact, DWORD dwAckType, if (dwFlags & MESSAGE_FLAG_RTF) { // add RFT part
size_t dwRFTBuffSize = (((dwMessageSize*sizeof(WCHAR))*16)+8192), dwRTFDataSize;
- lpszMessageRTF = (LPSTR)mir_calloc(dwRFTBuffSize);
ptrA lpbRTFData((char*)mir_calloc(dwRFTBuffSize));
- if (lpszMessageRTF && lpbRTFData) {
+ if (lpbRTFData) {
if ( !MraConvertToRTFW(lpwszMessage, dwMessageSize, (LPSTR)lpbRTFData, dwRFTBuffSize, &dwRTFDataSize)) {
DWORD dwBackColour = getDword("RTFBackgroundColour", MRA_DEFAULT_RTF_BACKGROUND_COLOUR);
lpbDataCurrent = (LPBYTE)lpszMessageRTF;
@@ -141,8 +136,10 @@ DWORD CMraProto::MraMessageW(BOOL bAddToQueue, HANDLE hContact, DWORD dwAckType, SetLPS(&lpbDataCurrent, (LPSTR)&dwBackColour, sizeof(DWORD));
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);
+ if ( compress2((LPBYTE)(LPSTR)lpbRTFData, (DWORD*)&dwRTFDataSize, (LPBYTE)lpszMessageRTF, (lpbDataCurrent-(LPBYTE)lpszMessageRTF), Z_BEST_COMPRESSION) == Z_OK) {
+ lpszMessageRTF = mir_base64_encode((LPBYTE)(char*)lpbRTFData, dwRTFDataSize);
+ dwMessageRTFSize = lstrlenA(lpszMessageRTF);
+ }
}
}
}
@@ -236,22 +233,23 @@ DWORD CMraProto::MraAddContactW(HANDLE hContact, DWORD dwContactFlag, DWORD dwGr SetLPS(&lpbDataCurrent, lpszPhones, dwPhonesSize);
// pack auth message
- LPBYTE lpbAuthMsgBuff, lpbAuthMessageConverted, lpbAuthDataCurrent;
+ LPBYTE lpbAuthMsgBuff, lpbAuthDataCurrent;
+ LPSTR lpszAuthMessageConverted;
size_t dwAuthMessageConvertedBuffSize = (((((dwAuthMessageSize*sizeof(WCHAR))+1024)+2)/3)*4), dwAuthMessageConvertedSize = 0;
- lpbAuthMessageConverted = (LPBYTE)mir_calloc(dwAuthMessageConvertedBuffSize);
lpbAuthMsgBuff = (LPBYTE)mir_calloc(((dwAuthMessageSize*sizeof(WCHAR))+1024));
- if (lpbAuthMessageConverted && lpbAuthMsgBuff) {
+ if (lpbAuthMsgBuff) {
lpbAuthDataCurrent = lpbAuthMsgBuff;
SetUL(&lpbAuthDataCurrent, 2);
SetLPSW(&lpbAuthDataCurrent, NULL, 0);//***deb possible nick here
SetLPSW(&lpbAuthDataCurrent, lpwszAuthMessage, dwAuthMessageSize);
- BASE64EncodeUnSafe(lpbAuthMsgBuff, (lpbAuthDataCurrent-lpbAuthMsgBuff), lpbAuthMessageConverted, dwAuthMessageConvertedBuffSize, &dwAuthMessageConvertedSize);
+ lpszAuthMessageConverted = mir_base64_encode(lpbAuthMsgBuff, (lpbAuthDataCurrent-lpbAuthMsgBuff));
+ dwAuthMessageConvertedSize = lstrlenA(lpszAuthMessageConverted);
}
- SetLPS(&lpbDataCurrent, (LPSTR)lpbAuthMessageConverted, dwAuthMessageConvertedSize);
+ SetLPS(&lpbDataCurrent, (LPSTR)lpszAuthMessageConverted, dwAuthMessageConvertedSize);
mir_free(lpbAuthMsgBuff);
- mir_free(lpbAuthMessageConverted);
+ mir_free(lpszAuthMessageConverted);
SetUL(&lpbDataCurrent, dwActions);
|