diff options
author | George Hazan <george.hazan@gmail.com> | 2013-09-06 14:51:23 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-09-06 14:51:23 +0000 |
commit | 51fd65475917b8056a5c417c960581bdb12165ff (patch) | |
tree | 79f7a4e603eb86144f72d48e1f81b9c753629c60 /protocols | |
parent | e3ebd966f8549fb271cbd076d797b52b4111b6a3 (diff) |
offline message processing fix
git-svn-id: http://svn.miranda-ng.org/main/trunk@5970 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/MRA/src/MraOfflineMsg.cpp | 405 | ||||
-rw-r--r-- | protocols/MRA/src/MraOfflineMsg.h | 2 | ||||
-rw-r--r-- | protocols/MRA/src/Mra_proto.cpp | 16 |
3 files changed, 171 insertions, 252 deletions
diff --git a/protocols/MRA/src/MraOfflineMsg.cpp b/protocols/MRA/src/MraOfflineMsg.cpp index 259d18f0ae..1c4e5c36d6 100644 --- a/protocols/MRA/src/MraOfflineMsg.cpp +++ b/protocols/MRA/src/MraOfflineMsg.cpp @@ -7,14 +7,164 @@ #define CRLF "\r\n"
#define CRLFCRLF "\r\n\r\n"
-DWORD MraOfflineMessageGetMIMEHeadAndBody(LPCSTR lpszMessage, size_t dwMessageSize, LPSTR *plpszHeader, size_t *pdwHeaderSize, LPSTR *plpszBody, size_t *pdwBodySize);
-DWORD MraOfflineMessageGetNextMIMEPart(LPSTR lpszBody, size_t dwBodySize, LPSTR lpszBoundary, size_t dwBoundarySize, LPSTR *plpszCurMIMEPos, LPSTR *plpszMIMEPart, size_t *pdwMIMEPartSize);
-DWORD MraOfflineMessageGetHeaderValue(LPSTR lpszHeader, LPSTR lpszHeaderLow, size_t dwHeaderSize, LPSTR lpszValueName, size_t dwValueNameSize, CMStringA &plpszValue);
-DWORD MraOfflineMessageGetHeaderValueLow(LPSTR lpszHeaderLow, size_t dwHeaderSize, LPSTR lpszValueName, size_t dwValueNameSize, LPSTR *plpszValue, size_t *pdwValueSize);
-DWORD MraOfflineMessageConvertTime(INTERNET_TIME *pitTime);
+static DWORD MraOfflineMessageConvertTime(INTERNET_TIME *pitTime)
+{
+ SYSTEMTIME stTime, stUniversalTime;
+ TIME_ZONE_INFORMATION tziTimeZoneMailRu = {0}, tziTimeZoneLocal;
+
+ GetTimeZoneInformation(&tziTimeZoneLocal);
+ if (GetTimeZoneInformation(&tziTimeZoneMailRu) == TIME_ZONE_ID_DAYLIGHT)
+ tziTimeZoneMailRu.DaylightBias *= 2;
+
+ tziTimeZoneMailRu.Bias = -MAILRU_SERVER_TIME_ZONE;
+ tziTimeZoneMailRu.DaylightBias = -tziTimeZoneMailRu.DaylightBias;
+ SystemTimeToTzSpecificLocalTime(&tziTimeZoneMailRu, &pitTime->stTime, &stUniversalTime);
+ SystemTimeToTzSpecificLocalTime(&tziTimeZoneLocal, &stUniversalTime, &stTime);
+
+ return((DWORD)MakeTime32FromLocalSystemTime(&stTime));
+}
+
+static DWORD MraOfflineMessageGetHeaderValueLow(LPSTR lpszHeaderLow, size_t dwHeaderSize, LPSTR lpszValueName, size_t dwValueNameSize, LPSTR *plpszValue, size_t *pdwValueSize)
+{
+ LPSTR lpszValue = (LPSTR)MemoryFind(0, lpszHeaderLow, dwHeaderSize, lpszValueName, dwValueNameSize);
+ if (lpszValue) {
+ lpszValue += dwValueNameSize;
+ LPSTR lpszValueEnd = (LPSTR)MemoryFind((lpszValue-lpszHeaderLow), lpszHeaderLow, dwHeaderSize, CRLF, (sizeof(CRLF)-1));
+ if (lpszValueEnd == NULL) lpszValueEnd = (LPSTR)MemoryFind((lpszValue-lpszHeaderLow), lpszHeaderLow, dwHeaderSize, LF, (sizeof(LF)-1));
+ if (lpszValueEnd == NULL) lpszValueEnd = (LPSTR)(lpszHeaderLow+dwHeaderSize);
+
+ lpszValue = (LPSTR)MemoryFind((lpszValue-lpszHeaderLow), lpszHeaderLow, (lpszValueEnd-lpszHeaderLow), ":", 1);
+ if (lpszValue) {
+ lpszValue++;
+ SkeepSPWSP(lpszValue, lpszValueEnd - lpszValue, plpszValue, pdwValueSize);
+ return NO_ERROR;
+ }
+ }
+ return ERROR_NOT_FOUND;
+}
+
+static DWORD MraOfflineMessageGetMIMEHeadAndBody(LPCSTR lpszMessage, size_t dwMessageSize, LPSTR *plpszHeader, size_t *pdwHeaderSize, LPSTR *plpszBody, size_t *pdwBodySize)
+{
+ if (!lpszMessage || !dwMessageSize)
+ return ERROR_NOT_FOUND;
+
+ // затычка: майл не придерживается RFC и вместо CRLFCRLF ставит LFLF в MIME частях, иногда ставит
+ LPSTR lpszBody = (LPSTR)MemoryFind(0, lpszMessage, dwMessageSize, CRLFCRLF, (sizeof(CRLFCRLF)-1));
+ if (lpszBody)
+ lpszBody += (sizeof(CRLFCRLF)-1);
+ else {
+ lpszBody = (LPSTR)MemoryFind(0, lpszMessage, dwMessageSize, LFLF, (sizeof(LFLF)-1));
+ if (lpszBody) lpszBody += (sizeof(LFLF)-1);
+ }
+
+ if (!lpszBody)
+ return ERROR_NOT_FOUND;
+
+ // нашли начало контента миме части
+ size_t dwBodySize = (dwMessageSize-(lpszBody-lpszMessage));
+ if (plpszHeader) (*plpszHeader) = (LPSTR)lpszMessage;
+ if (pdwHeaderSize) (*pdwHeaderSize) = ((lpszBody-(sizeof(LFLF)-1))-lpszMessage);
+ if (plpszBody) (*plpszBody) = lpszBody;
+ if (pdwBodySize) (*pdwBodySize) = dwBodySize;
+ return NO_ERROR;
+}
+
+static DWORD MraOfflineMessageGetHeaderValue(LPSTR lpszHeader, LPSTR lpszHeaderLow, size_t dwHeaderSize, LPSTR lpszValueName, size_t dwValueNameSize, CMStringA &plpszValue)
+{
+ LPSTR lpszValue = (LPSTR)MemoryFind(0, lpszHeaderLow, dwHeaderSize, lpszValueName, dwValueNameSize);
+ if (lpszValue) {
+ lpszValue += dwValueNameSize;
+ LPSTR lpszValueEnd = (LPSTR)MemoryFind((lpszValue-lpszHeaderLow), lpszHeaderLow, dwHeaderSize, CRLF, (sizeof(CRLF)-1));
+ if (lpszValueEnd == NULL) lpszValueEnd = (LPSTR)MemoryFind((lpszValue-lpszHeaderLow), lpszHeaderLow, dwHeaderSize, LF, (sizeof(LF)-1));
+ if (lpszValueEnd == NULL) lpszValueEnd = (LPSTR)(lpszHeaderLow+dwHeaderSize);
+
+ lpszValue = (LPSTR)MemoryFind((lpszValue-lpszHeaderLow), lpszHeaderLow, (lpszValueEnd-lpszHeaderLow), ":", 1);
+ if (lpszValue) {
+ lpszValue++;
+ plpszValue = CMStringA(lpszHeader+(lpszValue-lpszHeaderLow), (lpszValueEnd-lpszValue));
+ return NO_ERROR;
+ }
+ }
+ return ERROR_NOT_FOUND;
+}
+
+static DWORD MraOfflineMessageGetNextMIMEPart(LPSTR lpszBody, size_t dwBodySize, LPSTR lpszBoundary, size_t dwBoundarySize, LPSTR *plpszCurMIMEPos, LPSTR *plpszMIMEPart, size_t *pdwMIMEPartSize)
+{
+ if (!lpszBody || !dwBodySize)
+ return ERROR_INVALID_HANDLE;
+
+ LPSTR lpszCurMIMEPos;
+ if (plpszCurMIMEPos)
+ lpszCurMIMEPos = (*plpszCurMIMEPos);
+
+ LPSTR lpszMIMEPart = (LPSTR)MemoryFind((lpszCurMIMEPos-lpszBody), lpszBody, dwBodySize, lpszBoundary, dwBoundarySize);
+ if (lpszMIMEPart) {// первая миме часть
+ lpszMIMEPart += dwBoundarySize;
+
+ // затычка: майл не придерживается RFC и вместо CRLF ставит LF в MIME частях, иногда ставит
+ if ((*((WORD*)lpszMIMEPart)) == (*((WORD*)CRLF)))
+ lpszMIMEPart += (sizeof(CRLF)-1);
+ else if ((*((BYTE*)lpszMIMEPart)) == (*((BYTE*)LF)))
+ lpszMIMEPart += (sizeof(LF)-1);
+ else if ((*((WORD*)lpszMIMEPart)) == '--')
+ lpszMIMEPart = NULL;
+ else
+ DebugBreak();
+
+ if (lpszMIMEPart == NULL)
+ return ERROR_NO_MORE_ITEMS;
+ LPSTR lpszTemp = (LPSTR)MemoryFind((lpszMIMEPart-lpszBody), lpszBody, dwBodySize, lpszBoundary, dwBoundarySize);
+ if (lpszTemp) {// нашли конец миме части с текстом
+ size_t dwMIMEPartSize = (lpszTemp-lpszMIMEPart);// 4 = CRLF"--"Boundary / 3 = LF"--"Boundary
+ // затычка: майл не придерживается RFC и вместо CRLF ставит LF в MIME частях, иногда ставит
+ if ((*((WORD*)(lpszTemp-4))) == (*((WORD*)CRLF)))
+ dwMIMEPartSize -= 4;
+ else if ((*((BYTE*)(lpszTemp-3))) == (*((BYTE*)LF)))
+ dwMIMEPartSize -= 3;
+ else
+ DebugBreak();
+
+ if (plpszMIMEPart) (*plpszMIMEPart) = lpszMIMEPart;
+ if (pdwMIMEPartSize) (*pdwMIMEPartSize) = dwMIMEPartSize;
+ if (plpszCurMIMEPos) (*plpszCurMIMEPos) = lpszTemp;
+ return NO_ERROR;
+ }
+ }
+
+ return ERROR_NOT_FOUND;
+}
// Сообщение
-DWORD MraOfflineMessageGet(CMStringA *plpsMsg, DWORD *pdwTime, DWORD *pdwFlags, CMStringA *plpsEMail, CMStringA *plpsText, CMStringA *plpsRTFText, CMStringA *plpsMultiChatData, LPBYTE *plpbBuff)
+static DWORD PlainText2message(const CMStringA &szContentType, const CMStringA &szBody, CMStringA &plpsText, DWORD *pdwFlags)
+{
+ // Content-Type: text/plain; charset = CP-1251
+ if ( strstr(szContentType, "utf-16le")) {
+ // charset = UTF-16LE// предполагаем что оно в base64
+ unsigned dwTextSize;
+ ptrA lpszText((LPSTR)mir_base64_decode(szBody, &dwTextSize));
+ if (lpszText) {
+ plpsText = CMStringA(lpszText, dwTextSize);
+ if (pdwFlags) {
+ (*pdwFlags) |= MESSAGE_FLAG_v1p16; // set unicode flag if not exist
+ (*pdwFlags) &= ~MESSAGE_FLAG_CP1251; // reset ansi flag if exist
+ }
+ return NO_ERROR;
+ }
+ }
+ else if ( strstr(szContentType, "cp-1251")) { // charset = CP-1251
+ plpsText = szBody;
+ if (pdwFlags) {
+ (*pdwFlags) &= ~MESSAGE_FLAG_v1p16; // reset unicode flag if exist
+ (*pdwFlags) |= MESSAGE_FLAG_CP1251; // set ansi flag
+ }
+ return NO_ERROR;
+ }
+ else DebugBreak();
+
+ return ERROR_INVALID_HANDLE;
+}
+
+DWORD MraOfflineMessageGet(CMStringA *plpsMsg, DWORD *pdwTime, DWORD *pdwFlags, CMStringA *plpsEMail, CMStringA *plpsText, CMStringA *plpsRTFText, CMStringA *plpsMultiChatData)
{
DWORD dwRetErrorCode = ERROR_INVALID_HANDLE;
@@ -65,8 +215,6 @@ DWORD MraOfflineMessageGet(CMStringA *plpsMsg, DWORD *pdwTime, DWORD *pdwFlags, if (plpsMultiChatData)
plpsMultiChatData->Empty();
- if (plpbBuff) (*plpbBuff) = NULL;
-
if (plpsText || plpsRTFText)
if (MraOfflineMessageGetHeaderValueLow(lpszHeaderLow, dwHeaderSize, "content-type", 12, &lpszContentTypeLow, &dwContentTypeSize) == NO_ERROR) {
if (MemoryFind(0, lpszContentTypeLow, dwContentTypeSize, "multipart/alternative", 21)) {
@@ -89,36 +237,8 @@ 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) {
- if (MemoryFind(0, lpszMIMEContentType, dwMIMEContentTypeSize, "utf-16le", 8)) {
- // charset = UTF-16LE// предполагаем что оно в base64
- if (plpbBuff) {
- // буффер для декодирования текста можно выделять
- LPS2ANSI(szMime, lpszMIMEBody, dwMIMEBodySize);
- unsigned dwTextSize;
- LPWSTR lpwszText = (LPWSTR)mir_base64_decode(szMime, &dwTextSize);
- if (lpwszText) {
- *plpsText = CMStringW(lpwszText, dwTextSize);
- if (pdwFlags) {
- (*pdwFlags) |= MESSAGE_FLAG_v1p16; // set unocode flag if not exist
- (*pdwFlags) &= ~MESSAGE_FLAG_CP1251; // reset ansi flag if exist
- }
- *plpbBuff = (LPBYTE)lpwszText;
- dwRetErrorCode = NO_ERROR;
- }
- }
- }
- else if ( MemoryFind(0, lpszMIMEContentType, dwMIMEContentTypeSize, "cp-1251", 7)) {
- // charset = CP-1251
- *plpsText = CMStringA(lpszMIMEBody, dwMIMEBodySize);
- if (pdwFlags) {
- (*pdwFlags) &= ~MESSAGE_FLAG_v1p16; // reset unocode flag if exist
- (*pdwFlags) |= MESSAGE_FLAG_CP1251; // set ansi flag
- }
- dwRetErrorCode = NO_ERROR;
- }
- else DebugBreak();
- }
+ if (plpsText)
+ dwRetErrorCode = PlainText2message( CMStringA(lpszMIMEContentType, dwMIMEContentTypeSize), CMStringA(lpszMIMEBody, dwMIMEBodySize), *plpsText, pdwFlags);
}
else if (MemoryFind(0, lpszMIMEContentType, dwMIMEContentTypeSize, "application/x-mrim-rtf", 22)) {
if (plpsRTFText) {
@@ -149,39 +269,9 @@ DWORD MraOfflineMessageGet(CMStringA *plpsMsg, DWORD *pdwTime, DWORD *pdwFlags, else DebugBreak(); // boundary not found
}
else if (MemoryFind(0, lpszContentTypeLow, dwContentTypeSize, "text/plain", 10)) {
- // Content-Type: text/plain; charset = CP-1251
- if (MemoryFind(0, lpszContentTypeLow, dwContentTypeSize, "utf-16le", 8)) {
- // charset = UTF-16LE// предполагаем что оно в base64
- if (plpbBuff) {
- // буфер для декодирования текста можно выделять
- LPS2ANSI(szMime, lpszBody, dwBodySize);
- unsigned dwTextSize;
- LPWSTR lpwszText = (LPWSTR)mir_base64_decode(szMime, &dwTextSize);
- if (lpwszText) {
- *plpsText = CMStringW(lpwszText, dwTextSize);
- if (pdwFlags) {
- (*pdwFlags) |= MESSAGE_FLAG_v1p16; // set unocode flag if not exist
- (*pdwFlags) &= ~MESSAGE_FLAG_CP1251; // reset ansi flag if exist
- }
- (*plpbBuff) = (LPBYTE)lpwszText;
- dwRetErrorCode = NO_ERROR;
- }
- }
- }else
- if (MemoryFind(0, lpszContentTypeLow, dwContentTypeSize, "cp-1251", 7))
- {// charset = CP-1251
- *plpsText = CMStringA(lpszBody, dwBodySize);
- if (pdwFlags) {
- (*pdwFlags) &= ~MESSAGE_FLAG_v1p16; // reset unocode flag if exist
- (*pdwFlags) |= MESSAGE_FLAG_CP1251; // set ansi flag
- }
- dwRetErrorCode = NO_ERROR;
- }else {
- DebugBreak();
- }
- }else
- if (MemoryFind(0, lpszContentTypeLow, dwContentTypeSize, "application/x-mrim-auth-req", 27))
- {// Content-Type: application/x-mrim-auth-req
+ dwRetErrorCode = PlainText2message( CMStringA(lpszContentTypeLow, dwContentTypeSize), CMStringA(lpszBody, dwBodySize), *plpsText, pdwFlags);
+ }
+ else if (MemoryFind(0, lpszContentTypeLow, dwContentTypeSize, "application/x-mrim-auth-req", 27)) { // Content-Type: application/x-mrim-auth-req
if (plpsText)
*plpsText = CMStringA(lpszBody, dwBodySize);
dwRetErrorCode = NO_ERROR;
@@ -194,176 +284,5 @@ DWORD MraOfflineMessageGet(CMStringA *plpsMsg, DWORD *pdwTime, DWORD *pdwFlags, }
}
-return(dwRetErrorCode);
-}
-
-
-DWORD MraOfflineMessageGetMIMEHeadAndBody(LPCSTR lpszMessage, size_t dwMessageSize, LPSTR *plpszHeader, size_t *pdwHeaderSize, LPSTR *plpszBody, size_t *pdwBodySize)
-{
- DWORD dwRetErrorCode = ERROR_NOT_FOUND;
-
- if (lpszMessage && dwMessageSize)
- {
- LPSTR lpszBody;
- size_t dwBodySize;
-
- // затычка: майл не придерживается RFC и вместо CRLFCRLF ставит LFLF в MIME частях, иногда ставит
- lpszBody = (LPSTR)MemoryFind(0, lpszMessage, dwMessageSize, CRLFCRLF, (sizeof(CRLFCRLF)-1));
- if (lpszBody)
- {
- lpszBody += (sizeof(CRLFCRLF)-1);
- }else {
- lpszBody = (LPSTR)MemoryFind(0, lpszMessage, dwMessageSize, LFLF, (sizeof(LFLF)-1));
- if (lpszBody) lpszBody += (sizeof(LFLF)-1);
- }
-
- if (lpszBody)
- {// нашли начало контента миме части
- dwBodySize = (dwMessageSize-(lpszBody-lpszMessage));
-
- if (plpszHeader) (*plpszHeader) = (LPSTR)lpszMessage;
- if (pdwHeaderSize) (*pdwHeaderSize) = ((lpszBody-(sizeof(LFLF)-1))-lpszMessage);
- if (plpszBody) (*plpszBody) = lpszBody;
- if (pdwBodySize) (*pdwBodySize) = dwBodySize;
-
- dwRetErrorCode = NO_ERROR;
- }
- }else {
- dwRetErrorCode = ERROR_INVALID_HANDLE;
- }
-return(dwRetErrorCode);
-}
-
-
-DWORD MraOfflineMessageGetNextMIMEPart(LPSTR lpszBody, size_t dwBodySize, LPSTR lpszBoundary, size_t dwBoundarySize, LPSTR *plpszCurMIMEPos, LPSTR *plpszMIMEPart, size_t *pdwMIMEPartSize)
-{
- DWORD dwRetErrorCode = ERROR_NOT_FOUND;
-
- if (lpszBody && dwBodySize)
- {
- LPSTR lpszMIMEPart, lpszCurMIMEPos, lpszTemp;
- size_t dwMIMEPartSize;
-
- if (plpszCurMIMEPos) lpszCurMIMEPos = (*plpszCurMIMEPos);
- lpszMIMEPart = (LPSTR)MemoryFind((lpszCurMIMEPos-lpszBody), lpszBody, dwBodySize, lpszBoundary, dwBoundarySize);
- if (lpszMIMEPart)
- {// первая миме часть
- lpszMIMEPart += dwBoundarySize;
-
- // затычка: майл не придерживается RFC и вместо CRLF ставит LF в MIME частях, иногда ставит
- if ((*((WORD*)lpszMIMEPart)) == (*((WORD*)CRLF)))
- {
- lpszMIMEPart += (sizeof(CRLF)-1);
- }else
- if ((*((BYTE*)lpszMIMEPart)) == (*((BYTE*)LF)))
- {
- lpszMIMEPart += (sizeof(LF)-1);
- }else
- if ((*((WORD*)lpszMIMEPart)) == '--')
- {
- lpszMIMEPart = NULL;
- }else {
- DebugBreak();
- }
-
- if (lpszMIMEPart)
- {
- lpszTemp = (LPSTR)MemoryFind((lpszMIMEPart-lpszBody), lpszBody, dwBodySize, lpszBoundary, dwBoundarySize);
- if (lpszTemp)
- {// нашли конец миме части с текстом
- dwMIMEPartSize = (lpszTemp-lpszMIMEPart);// 4 = CRLF"--"Boundary / 3 = LF"--"Boundary
- // затычка: майл не придерживается RFC и вместо CRLF ставит LF в MIME частях, иногда ставит
- if ((*((WORD*)(lpszTemp-4))) == (*((WORD*)CRLF)))
- {
- dwMIMEPartSize-=4;
- }else
- if ((*((BYTE*)(lpszTemp-3))) == (*((BYTE*)LF)))
- {
- dwMIMEPartSize-=3;
- }else {
- DebugBreak();
- }
-
- if (plpszMIMEPart) (*plpszMIMEPart) = lpszMIMEPart;
- if (pdwMIMEPartSize) (*pdwMIMEPartSize) = dwMIMEPartSize;
- if (plpszCurMIMEPos) (*plpszCurMIMEPos) = lpszTemp;
- dwRetErrorCode = NO_ERROR;
- }
- }else {
- dwRetErrorCode = ERROR_NO_MORE_ITEMS;
- }
- }
- }else {
- dwRetErrorCode = ERROR_INVALID_HANDLE;
- }
-return(dwRetErrorCode);
-}
-
-
-DWORD MraOfflineMessageGetHeaderValue(LPSTR lpszHeader, LPSTR lpszHeaderLow, size_t dwHeaderSize, LPSTR lpszValueName, size_t dwValueNameSize, CMStringA &plpszValue)
-{
- LPSTR lpszValue = (LPSTR)MemoryFind(0, lpszHeaderLow, dwHeaderSize, lpszValueName, dwValueNameSize);
- if (lpszValue)
- {
- lpszValue += dwValueNameSize;
- LPSTR lpszValueEnd = (LPSTR)MemoryFind((lpszValue-lpszHeaderLow), lpszHeaderLow, dwHeaderSize, CRLF, (sizeof(CRLF)-1));
- if (lpszValueEnd == NULL) lpszValueEnd = (LPSTR)MemoryFind((lpszValue-lpszHeaderLow), lpszHeaderLow, dwHeaderSize, LF, (sizeof(LF)-1));
- if (lpszValueEnd == NULL) lpszValueEnd = (LPSTR)(lpszHeaderLow+dwHeaderSize);
-
- lpszValue = (LPSTR)MemoryFind((lpszValue-lpszHeaderLow), lpszHeaderLow, (lpszValueEnd-lpszHeaderLow), ":", 1);
- if (lpszValue) {
- lpszValue++;
- plpszValue = CMStringA(lpszHeader+(lpszValue-lpszHeaderLow), (lpszValueEnd-lpszValue));
- return NO_ERROR;
- }
- }
- return ERROR_NOT_FOUND;
-}
-
-
-DWORD MraOfflineMessageGetHeaderValueLow(LPSTR lpszHeaderLow, size_t dwHeaderSize, LPSTR lpszValueName, size_t dwValueNameSize, LPSTR *plpszValue, size_t *pdwValueSize)
-{
- DWORD dwRetErrorCode = ERROR_NOT_FOUND;
- LPSTR lpszValue, lpszValueEnd;
- size_t dwValueSize;
-
- lpszValue = (LPSTR)MemoryFind(0, lpszHeaderLow, dwHeaderSize, lpszValueName, dwValueNameSize);
- if (lpszValue)
- {
- lpszValue += dwValueNameSize;
- lpszValueEnd = (LPSTR)MemoryFind((lpszValue-lpszHeaderLow), lpszHeaderLow, dwHeaderSize, CRLF, (sizeof(CRLF)-1));
- if (lpszValueEnd == NULL) lpszValueEnd = (LPSTR)MemoryFind((lpszValue-lpszHeaderLow), lpszHeaderLow, dwHeaderSize, LF, (sizeof(LF)-1));
- if (lpszValueEnd == NULL) lpszValueEnd = (LPSTR)(lpszHeaderLow+dwHeaderSize);
-
- lpszValue = (LPSTR)MemoryFind((lpszValue-lpszHeaderLow), lpszHeaderLow, (lpszValueEnd-lpszHeaderLow), ":", 1);
- if (lpszValue)
- {
- lpszValue++;
- dwValueSize = (lpszValueEnd-lpszValue);
- SkeepSPWSP(lpszValue, dwValueSize, plpszValue, pdwValueSize);
- dwRetErrorCode = NO_ERROR;
- }
- }
-return(dwRetErrorCode);
-}
-
-
-DWORD MraOfflineMessageConvertTime(INTERNET_TIME *pitTime)
-{
- SYSTEMTIME stTime, stUniversalTime;
- TIME_ZONE_INFORMATION tziTimeZoneMailRu = {0}, tziTimeZoneLocal;
-
- GetTimeZoneInformation(&tziTimeZoneLocal);
- if (GetTimeZoneInformation(&tziTimeZoneMailRu) == TIME_ZONE_ID_DAYLIGHT) tziTimeZoneMailRu.DaylightBias *= 2;
- tziTimeZoneMailRu.Bias = MAILRU_SERVER_TIME_ZONE;
-
- //TzSpecificLocalTimeToSystemTime(&tziTimeZoneMailRu, &pitTime->stTime, &stUniversalTime);
- {// for win 2000 compatible
- tziTimeZoneMailRu.Bias = -tziTimeZoneMailRu.Bias;
- tziTimeZoneMailRu.DaylightBias = -tziTimeZoneMailRu.DaylightBias;
- SystemTimeToTzSpecificLocalTime(&tziTimeZoneMailRu, &pitTime->stTime, &stUniversalTime);
- }//*/
- SystemTimeToTzSpecificLocalTime(&tziTimeZoneLocal, &stUniversalTime, &stTime);
-
-return((DWORD)MakeTime32FromLocalSystemTime(&stTime));
+ return(dwRetErrorCode);
}
diff --git a/protocols/MRA/src/MraOfflineMsg.h b/protocols/MRA/src/MraOfflineMsg.h index de4173a23e..e2e7a0f50f 100644 --- a/protocols/MRA/src/MraOfflineMsg.h +++ b/protocols/MRA/src/MraOfflineMsg.h @@ -10,7 +10,7 @@ -DWORD MraOfflineMessageGet(CMStringA *plpsMsg, DWORD *pdwTime, DWORD *pdwFlags, CMStringA *plpsEMail, CMStringA *plpsText, CMStringA *plpsRTFText, CMStringA *plpsMultiChatData, LPBYTE *plpbBuff);
+DWORD MraOfflineMessageGet(CMStringA *plpsMsg, DWORD *pdwTime, DWORD *pdwFlags, CMStringA *plpsEMail, CMStringA *plpsText, CMStringA *plpsRTFText, CMStringA *plpsMultiChatData);
diff --git a/protocols/MRA/src/Mra_proto.cpp b/protocols/MRA/src/Mra_proto.cpp index 84654cab33..24594ffff9 100644 --- a/protocols/MRA/src/Mra_proto.cpp +++ b/protocols/MRA/src/Mra_proto.cpp @@ -441,7 +441,7 @@ bool CMraProto::CmdMessageAck(BinBuffer &buf) buf >> szMultiChatData; // LPS multichat_data
// подтверждаем получение, только если удалось его обработать
- if (MraRecvCommand_Message((DWORD)_time32(NULL), dwFlags, szEmail, szText, szRTFText, szMultiChatData) == NO_ERROR)
+ if ( MraRecvCommand_Message((DWORD)_time32(NULL), dwFlags, szEmail, szText, szRTFText, szMultiChatData) == NO_ERROR)
if ((dwFlags & MESSAGE_FLAG_NORECV) == 0)
MraMessageRecv(szEmail, dwMsgID);
return true;
@@ -572,13 +572,13 @@ bool CMraProto::CmdUserInfo(BinBuffer &buf) //Сообщение доставленное, пока пользователь не был подключен к сети
bool CMraProto::CmdOfflineMessageAck(BinBuffer &buf)
{
- CMStringA szEmail, lpsText, lpsRTFText, lpsMultiChatData, szString;
+ CMStringA szEmail, szText, lpsRTFText, lpsMultiChatData, szString;
DWORDLONG dwMsgUIDL;
buf >> dwMsgUIDL >> szString;
DWORD dwTime, dwFlags;
- if (MraOfflineMessageGet(&szString, &dwTime, &dwFlags, &szEmail, &lpsText, &lpsRTFText, &lpsMultiChatData, NULL) == NO_ERROR) {
- DWORD dwTemp = MraRecvCommand_Message(dwTime, dwFlags, szEmail, lpsText, lpsRTFText, lpsMultiChatData);
+ 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);
else
@@ -1483,18 +1483,18 @@ bool CMraProto::CmdBlogStatus(BinBuffer &buf) {
DWORD dwTime, dwFlags;
CMStringA szEmail, szString;
- CMStringW lpsText;
+ CMStringW wszText;
DWORDLONG dwBlogStatusID;
- buf >> dwFlags >> szEmail >> dwBlogStatusID >> dwTime >> lpsText >> szString;
+ buf >> dwFlags >> szEmail >> dwBlogStatusID >> dwTime >> wszText >> szString;
if (HANDLE hContact = MraHContactFromEmail(szEmail, FALSE, TRUE, NULL)) {
if (dwFlags & MRIM_BLOG_STATUS_MUSIC)
- mraSetStringW(hContact, DBSETTING_BLOGSTATUSMUSIC, lpsText);
+ mraSetStringW(hContact, DBSETTING_BLOGSTATUSMUSIC, wszText);
else {
setDword(hContact, DBSETTING_BLOGSTATUSTIME, dwTime);
mraWriteContactSettingBlob(hContact, DBSETTING_BLOGSTATUSID, &dwBlogStatusID, sizeof(DWORDLONG));
- mraSetStringW(hContact, DBSETTING_BLOGSTATUS, lpsText);
+ mraSetStringW(hContact, DBSETTING_BLOGSTATUS, wszText);
}
}
return true;
|