diff options
author | George Hazan <george.hazan@gmail.com> | 2014-11-27 21:08:03 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-11-27 21:08:03 +0000 |
commit | a4644874587bfc5e56aa806dad663f8710ebbb19 (patch) | |
tree | be5494ab81027c466a8dd0f509d6b82d0bfd8528 /protocols/MRA | |
parent | 737117e416225bb648f7e60034a093ed385f9b8f (diff) |
in this case there's no need to check whether parameters were really passed or not
git-svn-id: http://svn.miranda-ng.org/main/trunk@11125 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/MRA')
-rw-r--r-- | protocols/MRA/src/MraOfflineMsg.cpp | 73 | ||||
-rw-r--r-- | protocols/MRA/src/MraOfflineMsg.h | 2 | ||||
-rw-r--r-- | protocols/MRA/src/Mra_proto.cpp | 2 |
3 files changed, 30 insertions, 47 deletions
diff --git a/protocols/MRA/src/MraOfflineMsg.cpp b/protocols/MRA/src/MraOfflineMsg.cpp index 67bff4d22a..417b12d799 100644 --- a/protocols/MRA/src/MraOfflineMsg.cpp +++ b/protocols/MRA/src/MraOfflineMsg.cpp @@ -162,16 +162,16 @@ static DWORD PlainText2message(const CMStringA &szContentType, const CMStringA & return ERROR_INVALID_HANDLE;
}
-DWORD MraOfflineMessageGet(CMStringA *plpsMsg, DWORD *pdwTime, DWORD *pdwFlags, CMStringA *plpsEMail, CMStringA *plpsText, CMStringA *plpsRTFText, CMStringA *plpsMultiChatData)
+DWORD MraOfflineMessageGet(const CMStringA &plpsMsg, DWORD &pdwTime, DWORD &pdwFlags, CMStringA &plpsEMail, CMStringA &plpsText, CMStringA &plpsRTFText, CMStringA &plpsMultiChatData)
{
- if (plpsMsg == NULL || plpsMsg->IsEmpty() || plpsText == NULL)
+ if (plpsMsg.IsEmpty())
return ERROR_INVALID_HANDLE;
LPSTR lpszHeader, lpszBody, lpszContentTypeLow;
size_t dwHeaderSize, dwBodySize, dwContentTypeSize;
CMStringA szTemp;
- if ( MraOfflineMessageGetMIMEHeadAndBody(plpsMsg->GetString(), plpsMsg->GetLength(), &lpszHeader, &dwHeaderSize, &lpszBody, &dwBodySize) != NO_ERROR)
+ if (MraOfflineMessageGetMIMEHeadAndBody(plpsMsg.GetString(), plpsMsg.GetLength(), &lpszHeader, &dwHeaderSize, &lpszBody, &dwBodySize) != NO_ERROR)
return ERROR_INVALID_HANDLE;
ptrA lpszHeaderLow((LPSTR)mir_calloc(dwHeaderSize));
@@ -179,19 +179,17 @@ DWORD MraOfflineMessageGet(CMStringA *plpsMsg, DWORD *pdwTime, DWORD *pdwFlags, return ERROR_OUTOFMEMORY;
BuffToLowerCase(lpszHeaderLow, lpszHeader, dwHeaderSize);
- if (pdwTime)
if (MraOfflineMessageGetHeaderValue(lpszHeader, lpszHeaderLow, dwHeaderSize, "date", 4, szTemp) == NO_ERROR) {
INTERNET_TIME itTime;
InternetTimeGetTime(szTemp, itTime);
- *pdwTime = MraOfflineMessageConvertTime(&itTime);
+ pdwTime = MraOfflineMessageConvertTime(&itTime);
}
- else *pdwTime = 0;
+ else pdwTime = 0;
- if (pdwFlags)
if (MraOfflineMessageGetHeaderValue(lpszHeader, lpszHeaderLow, dwHeaderSize, "x-mrim-flags", 12, szTemp) == NO_ERROR)
- *pdwFlags = StrHexToUNum32(szTemp, szTemp.GetLength());
+ pdwFlags = StrHexToUNum32(szTemp, szTemp.GetLength());
else
- *pdwFlags = 0;
+ pdwFlags = 0;
DWORD dwMultichatType;
if (MraOfflineMessageGetHeaderValue(lpszHeader, lpszHeaderLow, dwHeaderSize, "x-mrim-multichat-type", 21, szTemp) == NO_ERROR)
@@ -199,20 +197,13 @@ DWORD MraOfflineMessageGet(CMStringA *plpsMsg, DWORD *pdwTime, DWORD *pdwFlags, else
dwMultichatType = 0;
- if (plpsEMail)
- if (MraOfflineMessageGetHeaderValue(lpszHeader, lpszHeaderLow, dwHeaderSize, "from", 4, *plpsEMail) != NO_ERROR)
- plpsEMail->Empty();
+ if (MraOfflineMessageGetHeaderValue(lpszHeader, lpszHeaderLow, dwHeaderSize, "from", 4, plpsEMail) != NO_ERROR)
+ plpsEMail.Empty();
- if (plpsText)
- plpsText->Empty();
+ plpsText.Empty();
+ plpsRTFText.Empty();
+ plpsMultiChatData.Empty();
- if (plpsRTFText)
- plpsRTFText->Empty();
-
- if (plpsMultiChatData)
- plpsMultiChatData->Empty();
-
- if (plpsText || plpsRTFText)
if (MraOfflineMessageGetHeaderValueLow(lpszHeaderLow, dwHeaderSize, "content-type", 12, &lpszContentTypeLow, &dwContentTypeSize) != NO_ERROR)
return ERROR_NOT_FOUND;
@@ -220,7 +211,7 @@ DWORD MraOfflineMessageGet(CMStringA *plpsMsg, DWORD *pdwTime, DWORD *pdwFlags, // Content-Type: multipart/alternative; boundary = 1217508709J3777283291217508709T31197726
LPSTR lpszBoundary = (LPSTR)MemoryFind(0, lpszContentTypeLow, dwContentTypeSize, "boundary=", 9);
if (lpszBoundary) {
- size_t dwBoundarySize = ((dwContentTypeSize-(lpszBoundary-lpszContentTypeLow))-9);
+ size_t dwBoundarySize = ((dwContentTypeSize - (lpszBoundary - lpszContentTypeLow)) - 9);
lpszBoundary = lpszHeader + (lpszBoundary + 9 - (LPSTR)lpszHeaderLow);
int i = 0;
@@ -238,42 +229,34 @@ DWORD MraOfflineMessageGet(CMStringA *plpsMsg, DWORD *pdwTime, DWORD *pdwFlags, if (MraOfflineMessageGetHeaderValueLow(lpszMIMEHeaderLow, dwMIMEHeaderSize, "content-type", 12, &lpszMIMEContentType, &dwMIMEContentTypeSize) == NO_ERROR) {
if (MemoryFind(0, lpszMIMEContentType, dwMIMEContentTypeSize, "text/plain", 10)) {
// this is simple text part: text/plain
- if (plpsText)
- return PlainText2message( CMStringA(lpszMIMEContentType, dwMIMEContentTypeSize), CMStringA(lpszMIMEBody, dwMIMEBodySize), *plpsText, pdwFlags);
+ return PlainText2message(CMStringA(lpszMIMEContentType, dwMIMEContentTypeSize), CMStringA(lpszMIMEBody, dwMIMEBodySize), plpsText, &pdwFlags);
}
- else if (MemoryFind(0, lpszMIMEContentType, dwMIMEContentTypeSize, "application/x-mrim-rtf", 22)) {
- if (plpsRTFText) {
- *plpsRTFText = CMStringA(lpszMIMEBody, dwMIMEBodySize);
- if (pdwFlags)
- (*pdwFlags) |= MESSAGE_FLAG_RTF; // set RTF flag if not exist
- return NO_ERROR;
- }
+ if (MemoryFind(0, lpszMIMEContentType, dwMIMEContentTypeSize, "application/x-mrim-rtf", 22)) {
+ plpsRTFText = CMStringA(lpszMIMEBody, dwMIMEBodySize);
+ pdwFlags |= MESSAGE_FLAG_RTF; // set RTF flag if not exist
+ return NO_ERROR;
}
- else if (MemoryFind(0, lpszMIMEContentType, dwMIMEContentTypeSize, "application/x-mrim+xml", 22)) {
- if (plpsMultiChatData) {
- *plpsMultiChatData = CMStringA(lpszMIMEBody, dwMIMEBodySize);
- if (pdwFlags)
- (*pdwFlags) |= MESSAGE_FLAG_MULTICHAT; // set MESSAGE_FLAG_MULTICHAT flag if not exist
- return NO_ERROR;
- }
+ if (MemoryFind(0, lpszMIMEContentType, dwMIMEContentTypeSize, "application/x-mrim+xml", 22)) {
+ plpsMultiChatData = CMStringA(lpszMIMEBody, dwMIMEBodySize);
+ pdwFlags |= MESSAGE_FLAG_MULTICHAT; // set MESSAGE_FLAG_MULTICHAT flag if not exist
+ return NO_ERROR;
}
- else _CrtDbgBreak();
+ _CrtDbgBreak();
}
}
i++;
}
- _ASSERTE((i>3 || i == 0));
+ _ASSERTE((i > 3 || i == 0));
}
return ERROR_NOT_FOUND;
}
-
+
if (MemoryFind(0, lpszContentTypeLow, dwContentTypeSize, "text/plain", 10))
- return PlainText2message( CMStringA(lpszContentTypeLow, dwContentTypeSize), CMStringA(lpszBody, dwBodySize), *plpsText, pdwFlags);
-
+ return PlainText2message(CMStringA(lpszContentTypeLow, dwContentTypeSize), CMStringA(lpszBody, dwBodySize), plpsText, &pdwFlags);
+
if (MemoryFind(0, lpszContentTypeLow, dwContentTypeSize, "application/x-mrim-auth-req", 27)) { // Content-Type: application/x-mrim-auth-req
- if (plpsText)
- *plpsText = CMStringA(lpszBody, dwBodySize);
+ plpsText = CMStringA(lpszBody, dwBodySize);
return NO_ERROR;
}
diff --git a/protocols/MRA/src/MraOfflineMsg.h b/protocols/MRA/src/MraOfflineMsg.h index 59104f08e4..5abb292ec3 100644 --- a/protocols/MRA/src/MraOfflineMsg.h +++ b/protocols/MRA/src/MraOfflineMsg.h @@ -3,6 +3,6 @@ #pragma once
-DWORD MraOfflineMessageGet(CMStringA *plpsMsg, DWORD *pdwTime, DWORD *pdwFlags, CMStringA *plpsEMail, CMStringA *plpsText, CMStringA *plpsRTFText, CMStringA *plpsMultiChatData);
+DWORD MraOfflineMessageGet(const CMStringA &plpsMsg, DWORD &pdwTime, DWORD &pdwFlags, CMStringA &plpsEMail, CMStringA &plpsText, CMStringA &plpsRTFText, CMStringA &plpsMultiChatData);
#endif // !defined(AFX_MRA_OFFLINEMSG_H__F58D13FF_F6F2_476C_B8F0_7B9E9357CF48__INCLUDED_)
diff --git a/protocols/MRA/src/Mra_proto.cpp b/protocols/MRA/src/Mra_proto.cpp index 80507cfe4b..1d68867ab6 100644 --- a/protocols/MRA/src/Mra_proto.cpp +++ b/protocols/MRA/src/Mra_proto.cpp @@ -530,7 +530,7 @@ bool CMraProto::CmdOfflineMessageAck(BinBuffer &buf) buf >> dwMsgUIDL >> szString;
DWORD dwTime, dwFlags;
- if (MraOfflineMessageGet(&szString, &dwTime, &dwFlags, &szEmail, &szText, &lpsRTFText, &lpsMultiChatData) == NO_ERROR) {
+ if (MraOfflineMessageGet(szString, dwTime, dwFlags, szEmail, szText, lpsRTFText, lpsMultiChatData) == NO_ERROR) {
DWORD dwTemp = MraRecvCommand_Message(dwTime, dwFlags, szEmail, szText, lpsRTFText, lpsMultiChatData);
if (dwTemp == NO_ERROR || dwTemp == ERROR_ACCESS_DENIED)
MraOfflineMessageDel(dwMsgUIDL);
|