summaryrefslogtreecommitdiff
path: root/protocols/MRA/src/Mra_proto.cpp
diff options
context:
space:
mode:
authorRozhuk Ivan <rozhuk.im@gmail.com>2014-03-07 21:50:21 +0000
committerRozhuk Ivan <rozhuk.im@gmail.com>2014-03-07 21:50:21 +0000
commit4b00a811ae7e3678578b04e6811265076f9404d9 (patch)
treeaec31fae331b9e4c4543433ed4bdd3fc2300fd0e /protocols/MRA/src/Mra_proto.cpp
parent5e54cbba072d17eb0f3d0fea9a14f048a3f2ab84 (diff)
MRA
+ Add: Send E-Mail to contact - Del: mail.ru blog service * Change: web authorization via https * Fix: contact services: auth request, auth grang, send post card * Fix: net error handle (after prev commit) git-svn-id: http://svn.miranda-ng.org/main/trunk@8466 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/MRA/src/Mra_proto.cpp')
-rw-r--r--protocols/MRA/src/Mra_proto.cpp97
1 files changed, 47 insertions, 50 deletions
diff --git a/protocols/MRA/src/Mra_proto.cpp b/protocols/MRA/src/Mra_proto.cpp
index 76d576dd8d..1399a0f1bf 100644
--- a/protocols/MRA/src/Mra_proto.cpp
+++ b/protocols/MRA/src/Mra_proto.cpp
@@ -271,7 +271,7 @@ DWORD CMraProto::MraNetworkDispatcher()
}
DWORD dwBytesReceived = Netlib_Recv(nls.hReadConns[0], (LPSTR)(lpbBufferRcv + dwRcvBuffSizeUsed), (dwRcvBuffSize - dwRcvBuffSizeUsed), 0);
- if ( !dwBytesReceived && dwBytesReceived == SOCKET_ERROR) { // disconnected
+ if ( !dwBytesReceived || dwBytesReceived == SOCKET_ERROR) { // disconnected
if (m_iStatus != ID_STATUS_OFFLINE) {
dwRetErrorCode = GetLastError();
ShowFormattedErrorMessage(L"Disconnected, socket read error", dwRetErrorCode);
@@ -286,54 +286,44 @@ DWORD CMraProto::MraNetworkDispatcher()
pmaHeader = (mrim_packet_header_t*)(lpbBufferRcv + dwDataCurrentBuffOffset);
// packet header received
- if (dwDataCurrentBuffSizeUsed >= sizeof(mrim_packet_header_t)) {
- // packet OK
- if (pmaHeader->magic == CS_MAGIC) {
- // full packet received, may be more than one
- if ((dwDataCurrentBuffSizeUsed - sizeof(mrim_packet_header_t)) >= pmaHeader->dlen) {
-
- bContinue = MraCommandDispatcher(pmaHeader);
-
- // move pointer to next packet in buffer
- if (dwDataCurrentBuffSizeUsed - sizeof(mrim_packet_header_t) > pmaHeader->dlen)
- dwDataCurrentBuffOffset += sizeof(mrim_packet_header_t)+pmaHeader->dlen;
- // move pointer to begin of buffer
- else {
- // динамическое уменьшение буффера приёма
- if (dwRcvBuffSize > BUFF_SIZE_RCV) {
- dwRcvBuffSize = BUFF_SIZE_RCV;
- lpbBufferRcv = (LPBYTE)mir_realloc(lpbBufferRcv, dwRcvBuffSize);
- }
- dwDataCurrentBuffOffset = 0;
- dwRcvBuffSizeUsed = 0;
- break;
- }
- }
- // not all packet received, continue receiving
- else {
- if (dwDataCurrentBuffOffset) {
- memmove(lpbBufferRcv, (lpbBufferRcv + dwDataCurrentBuffOffset), dwDataCurrentBuffSizeUsed);
- dwRcvBuffSizeUsed = dwDataCurrentBuffSizeUsed;
- dwDataCurrentBuffOffset = 0;
- }
- debugLogW(L"Not all packet received, continue receiving\n");
- break;
- }
- }
- // bad packet
- else {
- debugLogW(L"Bad packet\n");
+ if (dwDataCurrentBuffSizeUsed < sizeof(mrim_packet_header_t)) { // packet to small, continue receiving
+ debugLogW(L"Packet to small, continue receiving\n");
+ memmove(lpbBufferRcv, (lpbBufferRcv + dwDataCurrentBuffOffset), dwDataCurrentBuffSizeUsed);
+ dwRcvBuffSizeUsed = dwDataCurrentBuffSizeUsed;
+ dwDataCurrentBuffOffset = 0;
+ break;
+ }
+ if (pmaHeader->magic != CS_MAGIC) { // bad packet
+ debugLogW(L"Bad packet\n");
+ dwDataCurrentBuffOffset = 0;
+ dwRcvBuffSizeUsed = 0;
+ break;
+ }
+ // packet OK
+ if ((dwDataCurrentBuffSizeUsed - sizeof(mrim_packet_header_t)) < pmaHeader->dlen) { // not all packet received, continue receiving
+ if (dwDataCurrentBuffOffset) {
+ memmove(lpbBufferRcv, (lpbBufferRcv + dwDataCurrentBuffOffset), dwDataCurrentBuffSizeUsed);
+ dwRcvBuffSizeUsed = dwDataCurrentBuffSizeUsed;
dwDataCurrentBuffOffset = 0;
- dwRcvBuffSizeUsed = 0;
- break;
}
+ debugLogW(L"Not all packet received, continue receiving\n");
+ break;
}
- // packet to small, continue receiving
+ // full packet received, may be more than one
+ bContinue = MraCommandDispatcher(pmaHeader);
+
+ // move pointer to next packet in buffer
+ if (dwDataCurrentBuffSizeUsed - sizeof(mrim_packet_header_t) > pmaHeader->dlen)
+ dwDataCurrentBuffOffset += sizeof(mrim_packet_header_t)+pmaHeader->dlen;
+ // move pointer to begin of buffer
else {
- debugLogW(L"Packet to small, continue receiving\n");
- memmove(lpbBufferRcv, (lpbBufferRcv + dwDataCurrentBuffOffset), dwDataCurrentBuffSizeUsed);
- dwRcvBuffSizeUsed = dwDataCurrentBuffSizeUsed;
+ // динамическое уменьшение буффера приёма
+ if (dwRcvBuffSize > BUFF_SIZE_RCV) {
+ dwRcvBuffSize = BUFF_SIZE_RCV;
+ lpbBufferRcv = (LPBYTE)mir_realloc(lpbBufferRcv, dwRcvBuffSize);
+ }
dwDataCurrentBuffOffset = 0;
+ dwRcvBuffSizeUsed = 0;
break;
}
}
@@ -496,17 +486,22 @@ bool CMraProto::CmdUserInfo(BinBuffer &buf)
}
else if (szString == "micblog.show_title") {
debugLogA(szString);
- buf >> szStringW;
+ buf >> szString;
debugLogW(szStringW);
}
- else if (szString == "micblog.status.id") {
+ else if (szString == "micblog.status.xml") {
+ debugLogA(szString);
buf >> szString;
- DWORDLONG dwBlogStatusID = _atoi64(szString);
+ debugLogA(szString);
+ }
+ else if (szString == "micblog.status.id") {
+ buf >> szStringW;
+ DWORDLONG dwBlogStatusID = _ttoi64(szStringW);
mraWriteContactSettingBlob(NULL, DBSETTING_BLOGSTATUSID, &dwBlogStatusID, sizeof(DWORDLONG));
}
else if (szString == "micblog.status.time") {
- buf >> szString;
- setDword(DBSETTING_BLOGSTATUSTIME, atoi(szString));
+ buf >> szStringW;
+ setDword(DBSETTING_BLOGSTATUSTIME, _ttoi(szStringW));
}
else if (szString == "micblog.status.text") {
buf >> szStringW;
@@ -515,7 +510,9 @@ bool CMraProto::CmdUserInfo(BinBuffer &buf)
else if (szString == "HAS_MYMAIL" || szString == "mrim.status.open_search" || szString == "rb.target.cookie" ||
szString == "show_web_history_link" || szString == "friends_suggest" || szString == "timestamp" ||
szString == "trusted_update" || szString == "mrim.wp.dating") {
- buf >> szString;
+ debugLogA(szString);
+ buf >> szStringW;
+ debugLogW(szStringW);
}
else _CrtDbgBreak();
}